From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D90F7C433DB for ; Tue, 12 Jan 2021 09:45:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5CBB1230FA for ; Tue, 12 Jan 2021 09:45:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5CBB1230FA Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D922C8D0085; Tue, 12 Jan 2021 04:45:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D69B38D0051; Tue, 12 Jan 2021 04:45:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C59778D0085; Tue, 12 Jan 2021 04:45:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0158.hostedemail.com [216.40.44.158]) by kanga.kvack.org (Postfix) with ESMTP id AEF488D0051 for ; Tue, 12 Jan 2021 04:45:51 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7D187181AEF07 for ; Tue, 12 Jan 2021 09:45:51 +0000 (UTC) X-FDA: 77696641302.09.prose39_2f02e9227514 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 60191180AD80F for ; Tue, 12 Jan 2021 09:45:51 +0000 (UTC) X-HE-Tag: prose39_2f02e9227514 X-Filterd-Recvd-Size: 3929 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Tue, 12 Jan 2021 09:45:50 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1610444749; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=dA3k4t4NuRzP2rImbNYwbp5ThBFOnm8mec1oBsfxQUQ=; b=BUaJWqP9XW/TSzwKi8DEekpPSmcyhrX/viSiS/h2epyh/76Bogh/dVC18jHfq//hUYmGuk e3OFgU9dA4MOaGd5JZE8V1pLDxMq2PikOzCKeTZ2Wd9v9gpLZQD/es06UmOjMFaIiJRpaT hvN+7+NocU82RowqSurESFkl8SrepjA= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id C232BAD19; Tue, 12 Jan 2021 09:45:49 +0000 (UTC) Date: Tue, 12 Jan 2021 10:45:49 +0100 From: Michal Hocko To: Muchun Song Cc: mike.kravetz@oracle.com, akpm@linux-foundation.org, n-horiguchi@ah.jp.nec.com, ak@linux.intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v3 2/6] mm: hugetlbfs: fix cannot migrate the fallocated HugeTLB page Message-ID: <20210112094549.GJ22493@dhcp22.suse.cz> References: <20210110124017.86750-1-songmuchun@bytedance.com> <20210110124017.86750-3-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210110124017.86750-3-songmuchun@bytedance.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sun 10-01-21 20:40:13, Muchun Song wrote: > If a new hugetlb page is allocated during fallocate it will not be > marked as active (set_page_huge_active) which will result in a later > isolate_huge_page failure when the page migration code would like to > move that page. Such a failure would be unexpected and wrong. > > Only export set_page_huge_active, just leave clear_page_huge_active > as static. Because there are no external users. > > Fixes: 70c3547e36f5 (hugetlbfs: add hugetlbfs_fallocate()) > Signed-off-by: Muchun Song > Cc: stable@vger.kernel.org Acked-by: Michal Hocko Thanks! > --- > fs/hugetlbfs/inode.c | 3 ++- > include/linux/hugetlb.h | 2 ++ > mm/hugetlb.c | 2 +- > 3 files changed, 5 insertions(+), 2 deletions(-) > > diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c > index b5c109703daa..21c20fd5f9ee 100644 > --- a/fs/hugetlbfs/inode.c > +++ b/fs/hugetlbfs/inode.c > @@ -735,9 +735,10 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset, > > mutex_unlock(&hugetlb_fault_mutex_table[hash]); > > + set_page_huge_active(page); > /* > * unlock_page because locked by add_to_page_cache() > - * page_put due to reference from alloc_huge_page() > + * put_page() due to reference from alloc_huge_page() > */ > unlock_page(page); > put_page(page); > diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h > index ebca2ef02212..b5807f23caf8 100644 > --- a/include/linux/hugetlb.h > +++ b/include/linux/hugetlb.h > @@ -770,6 +770,8 @@ static inline void huge_ptep_modify_prot_commit(struct vm_area_struct *vma, > } > #endif > > +void set_page_huge_active(struct page *page); > + > #else /* CONFIG_HUGETLB_PAGE */ > struct hstate {}; > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index 1f3bf1710b66..4741d60f8955 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -1348,7 +1348,7 @@ bool page_huge_active(struct page *page) > } > > /* never called for tail page */ > -static void set_page_huge_active(struct page *page) > +void set_page_huge_active(struct page *page) > { > VM_BUG_ON_PAGE(!PageHeadHuge(page), page); > SetPagePrivate(&page[1]); > -- > 2.11.0 -- Michal Hocko SUSE Labs