From: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: Minchan Kim <minchan@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Andrea Arcangeli <aarcange@redhat.com>,
Mel Gorman <mgorman@suse.de>, Michal Hocko <mhocko@suse.cz>
Subject: Re: [PATCH] mm: do not use page_count without a page pin
Date: Mon, 11 Jun 2012 16:20:17 +0900 [thread overview]
Message-ID: <4FD59C31.6000606@jp.fujitsu.com> (raw)
In-Reply-To: <1339373872-31969-1-git-send-email-minchan@kernel.org>
(2012/06/11 9:17), Minchan Kim wrote:
> d179e84ba fixed the problem[1] in vmscan.c but same problem is here.
> Let's fix it.
>
> [1] http://comments.gmane.org/gmane.linux.kernel.mm/65844
>
> I copy and paste d179e84ba's contents for description.
>
> "It is unsafe to run page_count during the physical pfn scan because
> compound_head could trip on a dangling pointer when reading
> page->first_page if the compound page is being freed by another CPU."
>
> Cc: Andrea Arcangeli<aarcange@redhat.com>
> Cc: Mel Gorman<mgorman@suse.de>
> Cc: Michal Hocko<mhocko@suse.cz>
> Cc: KAMEZAWA Hiroyuki<kamezawa.hiroyu@jp.fujitsu.com>
> Signed-off-by: Minchan Kim<minchan@kernel.org>
> ---
> mm/page_alloc.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 266f267..019c4fe 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -5496,7 +5496,11 @@ __count_immobile_pages(struct zone *zone, struct page *page, int count)
> continue;
>
> page = pfn_to_page(check);
> - if (!page_count(page)) {
> + /*
> + * We can't use page_count withou pin a page
> + * because another CPU can free compound page.
> + */
> + if (!atomic_read(&page->_count)) {
> if (PageBuddy(page))
> iter += (1<< page_order(page)) - 1;
> continue;
Nice Catch.
Other than the comment fix already pointed out..
Hmm...BTW, it seems this __count_xxx doesn't have any code for THP/Hugepage..
so, we need more fixes for better code, I think.
Hmm, Don't we need !PageTail() check and 'skip thp' code ?
Thanks,
-Kame
--
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>
WARNING: multiple messages have this Message-ID (diff)
From: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: Minchan Kim <minchan@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Andrea Arcangeli <aarcange@redhat.com>,
Mel Gorman <mgorman@suse.de>, Michal Hocko <mhocko@suse.cz>
Subject: Re: [PATCH] mm: do not use page_count without a page pin
Date: Mon, 11 Jun 2012 16:20:17 +0900 [thread overview]
Message-ID: <4FD59C31.6000606@jp.fujitsu.com> (raw)
In-Reply-To: <1339373872-31969-1-git-send-email-minchan@kernel.org>
(2012/06/11 9:17), Minchan Kim wrote:
> d179e84ba fixed the problem[1] in vmscan.c but same problem is here.
> Let's fix it.
>
> [1] http://comments.gmane.org/gmane.linux.kernel.mm/65844
>
> I copy and paste d179e84ba's contents for description.
>
> "It is unsafe to run page_count during the physical pfn scan because
> compound_head could trip on a dangling pointer when reading
> page->first_page if the compound page is being freed by another CPU."
>
> Cc: Andrea Arcangeli<aarcange@redhat.com>
> Cc: Mel Gorman<mgorman@suse.de>
> Cc: Michal Hocko<mhocko@suse.cz>
> Cc: KAMEZAWA Hiroyuki<kamezawa.hiroyu@jp.fujitsu.com>
> Signed-off-by: Minchan Kim<minchan@kernel.org>
> ---
> mm/page_alloc.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 266f267..019c4fe 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -5496,7 +5496,11 @@ __count_immobile_pages(struct zone *zone, struct page *page, int count)
> continue;
>
> page = pfn_to_page(check);
> - if (!page_count(page)) {
> + /*
> + * We can't use page_count withou pin a page
> + * because another CPU can free compound page.
> + */
> + if (!atomic_read(&page->_count)) {
> if (PageBuddy(page))
> iter += (1<< page_order(page)) - 1;
> continue;
Nice Catch.
Other than the comment fix already pointed out..
Hmm...BTW, it seems this __count_xxx doesn't have any code for THP/Hugepage..
so, we need more fixes for better code, I think.
Hmm, Don't we need !PageTail() check and 'skip thp' code ?
Thanks,
-Kame
next prev parent reply other threads:[~2012-06-11 7:22 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-11 0:17 [PATCH] mm: do not use page_count without a page pin Minchan Kim
2012-06-11 0:17 ` Minchan Kim
2012-06-11 0:23 ` Wanpeng Li
2012-06-11 0:23 ` Wanpeng Li
2012-06-11 2:09 ` Minchan Kim
2012-06-11 2:09 ` Minchan Kim
2012-06-11 7:20 ` Kamezawa Hiroyuki [this message]
2012-06-11 7:20 ` Kamezawa Hiroyuki
2012-06-11 7:44 ` Andrea Arcangeli
2012-06-11 7:44 ` Andrea Arcangeli
2012-06-11 8:48 ` Kamezawa Hiroyuki
2012-06-11 8:48 ` Kamezawa Hiroyuki
2012-06-11 13:30 ` Minchan Kim
2012-06-11 13:30 ` Minchan Kim
2012-06-11 14:41 ` Andrea Arcangeli
2012-06-11 14:41 ` Andrea Arcangeli
2012-06-11 22:49 ` Minchan Kim
2012-06-11 22:49 ` Minchan Kim
2012-06-14 1:21 ` Andrea Arcangeli
2012-06-14 1:21 ` Andrea Arcangeli
2012-06-14 1:49 ` Minchan Kim
2012-06-14 1:49 ` Minchan Kim
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=4FD59C31.6000606@jp.fujitsu.com \
--to=kamezawa.hiroyu@jp.fujitsu.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.cz \
--cc=minchan@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.