* [PATCH] mm: use a irq-safe __mod_zone_page_state in mlocked_vma_newpage()
@ 2014-05-09 15:17 Jianyu Zhan
2014-05-09 15:56 ` Christoph Lameter
0 siblings, 1 reply; 6+ messages in thread
From: Jianyu Zhan @ 2014-05-09 15:17 UTC (permalink / raw)
To: akpm, hannes, riel, mhocko, aarcange, hanpt, mgorman, oleg, cldu,
fabf, sasha.levin, zhangyanfei
Cc: linux-mm, linux-kernel, nasa4836
mlocked_vma_newpage() is only called in fault path by
page_add_new_anon_rmap(), which is called on a *new* page.
And such page is initially only visible via the pagetables, and the
pte is locked while calling page_add_new_anon_rmap(), so we could use
a irq-safe version of __mod_zone_page_state() here.
Signed-off-by: Jianyu Zhan <nasa4836@gmail.com>
---
mm/internal.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/internal.h b/mm/internal.h
index 07b6736..69079b1 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -196,7 +196,7 @@ static inline int mlocked_vma_newpage(struct vm_area_struct *vma,
return 0;
if (!TestSetPageMlocked(page)) {
- mod_zone_page_state(page_zone(page), NR_MLOCK,
+ __mod_zone_page_state(page_zone(page), NR_MLOCK,
hpage_nr_pages(page));
count_vm_event(UNEVICTABLE_PGMLOCKED);
}
--
2.0.0-rc1
--
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] 6+ messages in thread
* Re: [PATCH] mm: use a irq-safe __mod_zone_page_state in mlocked_vma_newpage()
2014-05-09 15:17 [PATCH] mm: use a irq-safe __mod_zone_page_state in mlocked_vma_newpage() Jianyu Zhan
@ 2014-05-09 15:56 ` Christoph Lameter
0 siblings, 0 replies; 6+ messages in thread
From: Christoph Lameter @ 2014-05-09 15:56 UTC (permalink / raw)
To: Jianyu Zhan
Cc: akpm, hannes, riel, mhocko, aarcange, hanpt, mgorman, oleg, cldu,
fabf, sasha.levin, zhangyanfei, linux-mm, linux-kernel
On Fri, 9 May 2014, Jianyu Zhan wrote:
> mlocked_vma_newpage() is only called in fault path by
> page_add_new_anon_rmap(), which is called on a *new* page.
> And such page is initially only visible via the pagetables, and the
> pte is locked while calling page_add_new_anon_rmap(), so we could use
> a irq-safe version of __mod_zone_page_state() here.
You are changing from the irq safe variant to __mod_zone_page_state which
is *not* irq safe. Its legit to do so since presumably irqs are disabled
anyways so you do not have to worry about irq safeness of
__mod_zone_page_state.
Please update the description. Its a bit confusing right now.
--
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] 6+ messages in thread
* Re: [PATCH] mm: use a irq-safe __mod_zone_page_state in mlocked_vma_newpage()
@ 2014-05-09 16:16 Jianyu Zhan
2014-05-09 16:34 ` Christoph Lameter
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Jianyu Zhan @ 2014-05-09 16:16 UTC (permalink / raw)
To: cl, akpm, mhocko, hannes, riel, minchan, zhangyanfei, hanpt,
sasha.levin, oleg, fabf, mgorman, aarcange, cldu, nasa4836
Cc: linux-mm, linux-kernel
>You are changing from the irq safe variant to __mod_zone_page_state which
>is *not* irq safe. Its legit to do so since presumably irqs are disabled
>anyways so you do not have to worry about irq safeness of
>__mod_zone_page_state.
>Please update the description. Its a bit confusing right now.
Hi, Christoph, I'm sorry for the misleading phrasing.
Would be this one OK? Thanks.
--------<8---------
mm: use a light-weight __mod_zone_page_state in mlocked_vma_newpage()
mlocked_vma_newpage() is only called in fault path by
page_add_new_anon_rmap(), which is called on a *new* page.
And such page is initially only visible via the pagetables, and the
pte is locked while calling page_add_new_anon_rmap(), so we need not
use an irq-safe mod_zone_page_state() here, using a light-weight version
__mod_zone_page_state() would be OK.
Signed-off-by: Jianyu Zhan <nasa4836@gmail.com>
---
mm/internal.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/internal.h b/mm/internal.h
index 07b6736..69079b1 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -196,7 +196,7 @@ static inline int mlocked_vma_newpage(struct vm_area_struct *vma,
return 0;
if (!TestSetPageMlocked(page)) {
- mod_zone_page_state(page_zone(page), NR_MLOCK,
+ __mod_zone_page_state(page_zone(page), NR_MLOCK,
hpage_nr_pages(page));
count_vm_event(UNEVICTABLE_PGMLOCKED);
}
--
2.0.0-rc1
--
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] 6+ messages in thread
* Re: [PATCH] mm: use a irq-safe __mod_zone_page_state in mlocked_vma_newpage()
2014-05-09 16:16 Jianyu Zhan
@ 2014-05-09 16:34 ` Christoph Lameter
2014-05-09 19:54 ` Andrew Morton
2014-05-12 13:57 ` Christoph Lameter
2 siblings, 0 replies; 6+ messages in thread
From: Christoph Lameter @ 2014-05-09 16:34 UTC (permalink / raw)
To: Jianyu Zhan
Cc: akpm, mhocko, hannes, riel, minchan, zhangyanfei, hanpt,
sasha.levin, oleg, fabf, mgorman, aarcange, cldu, linux-mm,
linux-kernel
On Sat, 10 May 2014, Jianyu Zhan wrote:
> Hi, Christoph, I'm sorry for the misleading phrasing.
> Would be this one OK? Thanks.
Good.
Reviewed-by: Christoph Lameter <cl@linux.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] 6+ messages in thread
* Re: [PATCH] mm: use a irq-safe __mod_zone_page_state in mlocked_vma_newpage()
2014-05-09 16:16 Jianyu Zhan
2014-05-09 16:34 ` Christoph Lameter
@ 2014-05-09 19:54 ` Andrew Morton
2014-05-12 13:57 ` Christoph Lameter
2 siblings, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2014-05-09 19:54 UTC (permalink / raw)
To: Jianyu Zhan
Cc: cl, mhocko, hannes, riel, minchan, zhangyanfei, hanpt,
sasha.levin, oleg, fabf, mgorman, aarcange, cldu, linux-mm,
linux-kernel
On Sat, 10 May 2014 00:16:48 +0800 Jianyu Zhan <nasa4836@gmail.com> wrote:
> mlocked_vma_newpage() is only called in fault path by
> page_add_new_anon_rmap(), which is called on a *new* page.
> And such page is initially only visible via the pagetables, and the
> pte is locked while calling page_add_new_anon_rmap(), so we need not
> use an irq-safe mod_zone_page_state() here, using a light-weight version
> __mod_zone_page_state() would be OK.
>
> ...
>
> --- a/mm/internal.h
> +++ b/mm/internal.h
> @@ -196,7 +196,7 @@ static inline int mlocked_vma_newpage(struct vm_area_struct *vma,
> return 0;
>
> if (!TestSetPageMlocked(page)) {
> - mod_zone_page_state(page_zone(page), NR_MLOCK,
> + __mod_zone_page_state(page_zone(page), NR_MLOCK,
> hpage_nr_pages(page));
> count_vm_event(UNEVICTABLE_PGMLOCKED);
> }
The comment over __mod_zone_page_state() says "For use when we know
that interrupts are disabled". But that is not the case here.
Please fix this up, probably by altering the __mod_zone_page_state()
documentation.
Your proposed change to (the very poorly named) mlocked_vma_newpage()
makes that function more dangerous - people might add new callsites
without knowing that they're adding races. This risk can be reduced by
a) adding documentation explaining why __mod_zone_page_state() is
used and why it is safe and
b) moving mlocked_vma_newpage() out of internal.h and placing it in
mm/rmap.c immediately before page_add_new_anon_rmap(). Or, probably
better, by removing mlocked_vma_newpage() altogether and open-coding
its logic into page_add_new_anon_rmap().
--
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] 6+ messages in thread
* Re: [PATCH] mm: use a irq-safe __mod_zone_page_state in mlocked_vma_newpage()
2014-05-09 16:16 Jianyu Zhan
2014-05-09 16:34 ` Christoph Lameter
2014-05-09 19:54 ` Andrew Morton
@ 2014-05-12 13:57 ` Christoph Lameter
2 siblings, 0 replies; 6+ messages in thread
From: Christoph Lameter @ 2014-05-12 13:57 UTC (permalink / raw)
To: Jianyu Zhan
Cc: akpm, mhocko, hannes, riel, minchan, zhangyanfei, hanpt,
sasha.levin, oleg, fabf, mgorman, aarcange, cldu, linux-mm,
linux-kernel
On Sat, 10 May 2014, Jianyu Zhan wrote:
> mlocked_vma_newpage() is only called in fault path by
> page_add_new_anon_rmap(), which is called on a *new* page.
> And such page is initially only visible via the pagetables, and the
> pte is locked while calling page_add_new_anon_rmap(), so we need not
> use an irq-safe mod_zone_page_state() here, using a light-weight version
> __mod_zone_page_state() would be OK.
This has nothing to do with the safety of statistics operations that work
on different data structures. Which leads to the conclusion that
__mod_page_state cannot be used here.
--
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] 6+ messages in thread
end of thread, other threads:[~2014-05-12 13:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-09 15:17 [PATCH] mm: use a irq-safe __mod_zone_page_state in mlocked_vma_newpage() Jianyu Zhan
2014-05-09 15:56 ` Christoph Lameter
-- strict thread matches above, loose matches on Subject: below --
2014-05-09 16:16 Jianyu Zhan
2014-05-09 16:34 ` Christoph Lameter
2014-05-09 19:54 ` Andrew Morton
2014-05-12 13:57 ` Christoph Lameter
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).