From: Andrew Morton <akpm@linux-foundation.org>
To: Jianyu Zhan <nasa4836@gmail.com>
Cc: cl@linux.com, mhocko@suse.cz, hannes@cmpxchg.org,
riel@redhat.com, minchan@kernel.org, zhangyanfei@cn.fujitsu.com,
hanpt@linux.vnet.ibm.com, sasha.levin@oracle.com,
oleg@redhat.com, fabf@skynet.be, mgorman@suse.de,
aarcange@redhat.com, cldu@marvell.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: use a irq-safe __mod_zone_page_state in mlocked_vma_newpage()
Date: Fri, 9 May 2014 12:54:26 -0700 [thread overview]
Message-ID: <20140509125426.e585b751a81bfcc96b6b8b88@linux-foundation.org> (raw)
In-Reply-To: <1399652208-18987-1-git-send-email-nasa4836@gmail.com>
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>
next prev parent reply other threads:[~2014-05-09 19:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-09 16:16 [PATCH] mm: use a irq-safe __mod_zone_page_state in mlocked_vma_newpage() Jianyu Zhan
2014-05-09 16:34 ` Christoph Lameter
2014-05-09 19:54 ` Andrew Morton [this message]
2014-05-12 13:57 ` Christoph Lameter
-- strict thread matches above, loose matches on Subject: below --
2014-05-09 15:17 Jianyu Zhan
2014-05-09 15:56 ` Christoph Lameter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140509125426.e585b751a81bfcc96b6b8b88@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=aarcange@redhat.com \
--cc=cl@linux.com \
--cc=cldu@marvell.com \
--cc=fabf@skynet.be \
--cc=hannes@cmpxchg.org \
--cc=hanpt@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.cz \
--cc=minchan@kernel.org \
--cc=nasa4836@gmail.com \
--cc=oleg@redhat.com \
--cc=riel@redhat.com \
--cc=sasha.levin@oracle.com \
--cc=zhangyanfei@cn.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).