From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Hugh Dickins <hughd@google.com>, Michal Hocko <mhocko@suse.cz>,
Mel Gorman <mgorman@suse.de>,
Johannes Weiner <hannes@cmpxchg.org>,
David Rientjes <rientjes@google.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Naoya Horiguchi <nao.horiguchi@gmail.com>
Subject: Re: [PATCH v3 2/3] mm: hugetlb: introduce PageHugeActive flag
Date: Wed, 1 Apr 2015 01:40:55 +0000 [thread overview]
Message-ID: <20150401014054.GA16385@hori1.linux.bs1.fc.nec.co.jp> (raw)
In-Reply-To: <20150331140610.a146030d6a2e3abc6e4c9ba4@linux-foundation.org>
On Tue, Mar 31, 2015 at 02:06:10PM -0700, Andrew Morton wrote:
> On Tue, 31 Mar 2015 08:50:46 +0000 Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> wrote:
>
> > We are not safe from calling isolate_huge_page() on a hugepage concurrently,
> > which can make the victim hugepage in invalid state and results in BUG_ON().
> >
> > The root problem of this is that we don't have any information on struct page
> > (so easily accessible) about hugepages' activeness. Note that hugepages'
> > activeness means just being linked to hstate->hugepage_activelist, which is
> > not the same as normal pages' activeness represented by PageActive flag.
> >
> > Normal pages are isolated by isolate_lru_page() which prechecks PageLRU before
> > isolation, so let's do similarly for hugetlb with a new PageHugeActive flag.
> >
> > Set/ClearPageHugeActive should be called within hugetlb_lock. But hugetlb_cow()
> > and hugetlb_no_page() don't do this, being justified because in these function
> > SetPageHugeActive is called right after the hugepage is allocated and no other
> > thread tries to isolate it.
> >
> > ...
> >
> > +/*
> > + * Page flag to show that the hugepage is "active/in-use" (i.e. being linked to
> > + * hstate->hugepage_activelist.)
> > + *
> > + * This function can be called for tail pages, but never returns true for them.
> > + */
> > +int PageHugeActive(struct page *page)
> > +{
> > + VM_BUG_ON_PAGE(!PageHuge(page), page);
> > + return PageHead(page) && PagePrivate(&page[1]);
> > +}
>
> This is not a "page flag". It is a regular old C function which tests
> for a certain page state. Yes, it kind of pretends to act like a
> separate page flag but its use of the peculiar naming convention is
> rather misleading.
>
> I mean, if you see
>
> SetPageHugeActive(page);
>
> then you expect that to be doing set_bit(PG_hugeactive, &page->flags)
> but that isn't what it does, so the name is misleading.
>
> Agree?
Yes I agree, page_huge_active() is fine for me.
> From: Andrew Morton <akpm@linux-foundation.org>
> Subject: mm-hugetlb-introduce-pagehugeactive-flag-fix
>
> s/PageHugeActive/page_huge_active/, make it return bool
>
> Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> Cc: Hugh Dickins <hughd@google.com>
> Cc: Michal Hocko <mhocko@suse.cz>
> Cc: Mel Gorman <mgorman@suse.de>
> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Cc: David Rientjes <rientjes@google.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
>
> mm/hugetlb.c | 22 +++++++++++-----------
> 1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff -puN mm/hugetlb.c~mm-hugetlb-introduce-pagehugeactive-flag-fix mm/hugetlb.c
> --- a/mm/hugetlb.c~mm-hugetlb-introduce-pagehugeactive-flag-fix
> +++ a/mm/hugetlb.c
> @@ -925,25 +925,25 @@ struct hstate *size_to_hstate(unsigned l
> }
>
> /*
> - * Page flag to show that the hugepage is "active/in-use" (i.e. being linked to
> - * hstate->hugepage_activelist.)
> + * Test to determine whether the hugepage is "active/in-use" (i.e. being linked
> + * to hstate->hugepage_activelist.)
> *
> * This function can be called for tail pages, but never returns true for them.
> */
> -int PageHugeActive(struct page *page)
> +bool page_huge_active(struct page *page)
> {
> VM_BUG_ON_PAGE(!PageHuge(page), page);
> return PageHead(page) && PagePrivate(&page[1]);
> }
>
> /* never called for tail page */
> -void SetPageHugeActive(struct page *page)
> +void set_page_huge_active(struct page *page)
> {
> VM_BUG_ON_PAGE(!PageHeadHuge(page), page);
> SetPagePrivate(&page[1]);
> }
>
> -void ClearPageHugeActive(struct page *page)
> +void clear_page_huge_active(struct page *page)
> {
> VM_BUG_ON_PAGE(!PageHeadHuge(page), page);
> ClearPagePrivate(&page[1]);
> @@ -977,7 +977,7 @@ void free_huge_page(struct page *page)
> restore_reserve = true;
>
> spin_lock(&hugetlb_lock);
> - ClearPageHugeActive(page);
> + clear_page_huge_active(page);
> hugetlb_cgroup_uncharge_page(hstate_index(h),
> pages_per_huge_page(h), page);
> if (restore_reserve)
> @@ -2998,7 +2998,7 @@ retry_avoidcopy:
> copy_user_huge_page(new_page, old_page, address, vma,
> pages_per_huge_page(h));
> __SetPageUptodate(new_page);
> - SetPageHugeActive(new_page);
> + set_page_huge_active(new_page);
>
> mmun_start = address & huge_page_mask(h);
> mmun_end = mmun_start + huge_page_size(h);
> @@ -3111,7 +3111,7 @@ retry:
> }
> clear_huge_page(page, address, pages_per_huge_page(h));
> __SetPageUptodate(page);
> - SetPageHugeActive(page);
> + set_page_huge_active(page);
>
> if (vma->vm_flags & VM_MAYSHARE) {
> int err;
> @@ -3946,11 +3946,11 @@ bool isolate_huge_page(struct page *page
>
> VM_BUG_ON_PAGE(!PageHead(page), page);
> spin_lock(&hugetlb_lock);
> - if (!PageHugeActive(page) || !get_page_unless_zero(page)) {
> + if (!page_huge_active(page) || !get_page_unless_zero(page)) {
> ret = false;
> goto unlock;
> }
> - ClearPageHugeActive(page);
> + clear_page_huge_active(page);
> list_move_tail(&page->lru, list);
> unlock:
> spin_unlock(&hugetlb_lock);
> @@ -3961,7 +3961,7 @@ void putback_active_hugepage(struct page
> {
> VM_BUG_ON_PAGE(!PageHead(page), page);
> spin_lock(&hugetlb_lock);
> - SetPageHugeActive(page);
> + set_page_huge_active(page);
> list_move_tail(&page->lru, &(page_hstate(page))->hugepage_activelist);
> spin_unlock(&hugetlb_lock);
> put_page(page);
>
--
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:[~2015-04-01 1:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-31 8:50 [PATCH 0/3] hugetlb fixlet v3 Naoya Horiguchi
2015-03-31 8:50 ` [PATCH v3 1/3] mm: don't call __page_cache_release for hugetlb Naoya Horiguchi
2015-04-01 16:13 ` Michal Hocko
2015-03-31 8:50 ` [PATCH v3 2/3] mm: hugetlb: introduce PageHugeActive flag Naoya Horiguchi
2015-03-31 21:06 ` Andrew Morton
2015-04-01 1:40 ` Naoya Horiguchi [this message]
2015-04-01 16:30 ` Michal Hocko
2015-03-31 8:50 ` [PATCH v3 3/3] mm: hugetlb: cleanup using " Naoya Horiguchi
2015-03-31 21:08 ` Andrew Morton
2015-04-01 3:27 ` Naoya Horiguchi
2015-04-01 16:36 ` Michal Hocko
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=20150401014054.GA16385@hori1.linux.bs1.fc.nec.co.jp \
--to=n-horiguchi@ah.jp.nec.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.cz \
--cc=nao.horiguchi@gmail.com \
--cc=rientjes@google.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