linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: memcontrol: Make the walk_page_range() limit obvious
@ 2016-08-31 15:04 James Morse
  2016-08-31 15:17 ` Michal Hocko
  0 siblings, 1 reply; 3+ messages in thread
From: James Morse @ 2016-08-31 15:04 UTC (permalink / raw)
  To: cgroups
  Cc: linux-mm, Johannes Weiner, Michal Hocko, Vladimir Davydov,
	James Morse, Naoya Horiguchi

Trying to walk all of virtual memory requires architecture specific
knowledge. On x86_64, addresses must be sign extended from bit 48,
whereas on arm64 the top VA_BITS of address space have their own set
of page tables.

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.

As this call only expects to walk user address space, make it walk
0 to  'highest_vm_end'.

Signed-off-by: James Morse <james.morse@arm.com>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
---
This is in preparation for a RFC series that allows walk_page_range() to
walk kernel page tables too.

 mm/memcontrol.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 2ff0289ad061..bfd54b43beb9 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4712,7 +4712,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;
@@ -5000,7 +5001,8 @@ retry:
 	 * 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);
 }
-- 
2.8.0.rc3

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: memcontrol: Make the walk_page_range() limit obvious
  2016-08-31 15:04 [PATCH] mm: memcontrol: Make the walk_page_range() limit obvious James Morse
@ 2016-08-31 15:17 ` Michal Hocko
  2016-09-01  0:24   ` Naoya Horiguchi
  0 siblings, 1 reply; 3+ messages in thread
From: Michal Hocko @ 2016-08-31 15:17 UTC (permalink / raw)
  To: James Morse
  Cc: cgroups, linux-mm, Johannes Weiner, Vladimir Davydov,
	Naoya Horiguchi

On Wed 31-08-16 16:04:57, James Morse wrote:
> Trying to walk all of virtual memory requires architecture specific
> knowledge. On x86_64, addresses must be sign extended from bit 48,
> whereas on arm64 the top VA_BITS of address space have their own set
> of page tables.
> 
> 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.
> 
> As this call only expects to walk user address space, make it walk
> 0 to  'highest_vm_end'.
> 
> Signed-off-by: James Morse <james.morse@arm.com>
> Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> ---
> This is in preparation for a RFC series that allows walk_page_range() to
> walk kernel page tables too.

OK, so do I get it right that this is only needed with that change?
Because AFAICS walk_page_range will be bound to the last vma->vm_end
right now. If this is the case this should be mentioned in the changelog
because the above might confuse somebody to think this is a bug fix.

Other than that this seams reasonable to me.

> 
>  mm/memcontrol.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 2ff0289ad061..bfd54b43beb9 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -4712,7 +4712,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;
> @@ -5000,7 +5001,8 @@ retry:
>  	 * 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);
>  }
> -- 
> 2.8.0.rc3
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

-- 
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: memcontrol: Make the walk_page_range() limit obvious
  2016-08-31 15:17 ` Michal Hocko
@ 2016-09-01  0:24   ` Naoya Horiguchi
  0 siblings, 0 replies; 3+ messages in thread
From: Naoya Horiguchi @ 2016-09-01  0:24 UTC (permalink / raw)
  To: Michal Hocko
  Cc: James Morse, cgroups@vger.kernel.org, linux-mm@kvack.org,
	Johannes Weiner, Vladimir Davydov

On Wed, Aug 31, 2016 at 05:17:30PM +0200, Michal Hocko wrote:
> On Wed 31-08-16 16:04:57, James Morse wrote:
> > Trying to walk all of virtual memory requires architecture specific
> > knowledge. On x86_64, addresses must be sign extended from bit 48,
> > whereas on arm64 the top VA_BITS of address space have their own set
> > of page tables.
> > 
> > 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.
> > 
> > As this call only expects to walk user address space, make it walk
> > 0 to  'highest_vm_end'.
> > 
> > Signed-off-by: James Morse <james.morse@arm.com>
> > Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> > ---
> > This is in preparation for a RFC series that allows walk_page_range() to
> > walk kernel page tables too.
> 
> OK, so do I get it right that this is only needed with that change?
> Because AFAICS walk_page_range will be bound to the last vma->vm_end
> right now.

I think this is correct, find_vma() in walk_page_range() does that.

> If this is the case this should be mentioned in the changelog
> because the above might confuse somebody to think this is a bug fix.
> 
> Other than that this seams reasonable to me.

I'm fine with this change.

Acked-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-01  0:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-31 15:04 [PATCH] mm: memcontrol: Make the walk_page_range() limit obvious James Morse
2016-08-31 15:17 ` Michal Hocko
2016-09-01  0:24   ` Naoya Horiguchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).