Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752748AbbBYCdj (ORCPT ); Tue, 24 Feb 2015 21:33:39 -0500 Received: from mail113-249.mail.alibaba.com ([205.204.113.249]:49358 "EHLO us-alimail-mta2.hst.scl.en.alidc.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751935AbbBYCdi (ORCPT ); Tue, 24 Feb 2015 21:33:38 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;FP=0|-1|-1|-1|0|-1|-1|-1;HT=r46d02010;MF=hillf.zj@alibaba-inc.com;PH=DS;RN=8;RT=8;SR=0; Reply-To: "Hillf Danton" From: "Hillf Danton" To: "'David Rientjes'" Cc: "Andrew Morton" , "'Davidlohr Bueso'" , "'Luiz Capitulino'" , "'Joonsoo Kim'" , "linux-kernel" , , "Hillf Danton" Subject: Re: [patch] mm, hugetlb: close race when setting PageTail for gigantic pages Date: Wed, 25 Feb 2015 10:32:45 +0800 Message-ID: <068c01d050a3$57c90eb0$075b2c10$@alibaba-inc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: AdBQoxyz8HByp9OvQzyn1F5KVEVOjw== Content-Language: zh-cn Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1695 Lines: 46 > Now that gigantic pages are dynamically allocatable, care must be taken > to ensure that p->first_page is valid before setting PageTail. > > If this isn't done, then it is possible to race and have compound_head() > return NULL. > > Signed-off-by: David Rientjes > --- Acked-by: Hillf Danton > mm/hugetlb.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -917,7 +917,6 @@ static void prep_compound_gigantic_page(struct page *page, unsigned long order) > __SetPageHead(page); > __ClearPageReserved(page); > for (i = 1; i < nr_pages; i++, p = mem_map_next(p, page, i)) { > - __SetPageTail(p); > /* > * For gigantic hugepages allocated through bootmem at > * boot, it's safer to be consistent with the not-gigantic > @@ -933,6 +932,9 @@ static void prep_compound_gigantic_page(struct page *page, unsigned long order) > __ClearPageReserved(p); > set_page_count(p, 0); > p->first_page = page; > + /* Make sure p->first_page is always valid for PageTail() */ > + smp_wmb(); > + __SetPageTail(p); > } > } > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/