Skip to content

Commit

Permalink
mm/memcontrol.c: make the walk_page_range() limit obvious
Browse files Browse the repository at this point in the history
mem_cgroup_count_precharge() and mem_cgroup_move_charge() both call
walk_page_range() on the range 0 to ~0UL, neither provide a pte_hole
callback, which causes the current implementation to skip non-vma
regions.  This is all fine but follow up changes would like to make
walk_page_range more generic so it is better to be explicit about which
range to traverse so let's use highest_vm_end to explicitly traverse
only user mmaped memory.

[[email protected]: rewrote changelog]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: James Morse <[email protected]>
Acked-by: Naoya Horiguchi <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Vladimir Davydov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
James Morse authored and torvalds committed Oct 8, 2016
1 parent 6fcb52a commit 0247f3f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -4681,7 +4681,8 @@ static unsigned long mem_cgroup_count_precharge(struct mm_struct *mm)
.mm = mm,
};
down_read(&mm->mmap_sem);
walk_page_range(0, ~0UL, &mem_cgroup_count_precharge_walk);
walk_page_range(0, mm->highest_vm_end,
&mem_cgroup_count_precharge_walk);
up_read(&mm->mmap_sem);

precharge = mc.precharge;
Expand Down Expand Up @@ -4969,7 +4970,8 @@ static void mem_cgroup_move_charge(void)
* When we have consumed all precharges and failed in doing
* additional charge, the page walk just aborts.
*/
walk_page_range(0, ~0UL, &mem_cgroup_move_charge_walk);
walk_page_range(0, mc.mm->highest_vm_end, &mem_cgroup_move_charge_walk);

up_read(&mc.mm->mmap_sem);
atomic_dec(&mc.from->moving_account);
}
Expand Down

0 comments on commit 0247f3f

Please sign in to comment.