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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 DBC3EC433E0 for ; Thu, 7 Jan 2021 02:58:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5F98622D6F for ; Thu, 7 Jan 2021 02:58:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F98622D6F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 81F2A8D0117; Wed, 6 Jan 2021 21:58:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D0728D0090; Wed, 6 Jan 2021 21:58:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E6AF8D0117; Wed, 6 Jan 2021 21:58:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0239.hostedemail.com [216.40.44.239]) by kanga.kvack.org (Postfix) with ESMTP id 596018D0090 for ; Wed, 6 Jan 2021 21:58:48 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 196E4181AEF30 for ; Thu, 7 Jan 2021 02:58:48 +0000 (UTC) X-FDA: 77677471536.08.sail82_59064a6274e6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id F132C1819E773 for ; Thu, 7 Jan 2021 02:58:47 +0000 (UTC) X-HE-Tag: sail82_59064a6274e6 X-Filterd-Recvd-Size: 6096 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Thu, 7 Jan 2021 02:58:47 +0000 (UTC) Received: by mail-pf1-f179.google.com with SMTP id t22so2973141pfl.3 for ; Wed, 06 Jan 2021 18:58:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Lbh0iTv5BrEfqhngJcXksbTE1AiUdN7XVO3JJGizBjs=; b=N7gk1rOXnoWGrYbQDh34Ue+Q1rmAmCB8IRWvvbstzfvKHrshEkONZ/NuIq9gt6Lx6q r7IgIQn8ybHd6lQU/x16WkdHhPAh05CxlAXArnwKb+A8qNpXrQvukPcwfP25DahfBJjn rx5eP0cFx+MLAhWAMNiOub7Et0XrjeMQKG4qoTVHl/s83i0PH1STbtdoEBoCbOb1pdnC yWshY/RCHTf3ZXmKWG60mEp2HflTHJaFjrHBNq8GA7CMhh2pnzORYAndYo1myHlwvTFu k27/+4fKgUyPiE901+YvrJ9S3kUWrLqEcd5Wan4ZQdEUZ/z3PHJTkkbZDX1NjUY8He1X ivjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Lbh0iTv5BrEfqhngJcXksbTE1AiUdN7XVO3JJGizBjs=; b=q/KlrDhtD5hZDEzKaGhJvDrfdu+nZ1QrSHfyuTzgwZhr5vcqSRW6RaLNaNQ7f97GmB 6XnFHmLu72v7wfkyf6Je9gbkfEMItNxVhOyqQBSJ3BzbLMdXgPfc9N7ZBz2V+1/7sNFY CVQ2ncGu+ZGxU3e7b2LrLc2KiB5FDPOnba21u3SFswCOpKsygY5IGOQHwuYro2dqm3w5 B8X2TFL5EKx3mK7/FVJ/ACyN5UkpXFn/TFkvD90peNvnb39SVzNUF5uYZeCm/MU1STeU Y4hg5p05tuKSUO4D6hc0wrpBLasBitienK2/v14JKtQv11ZEAQ1mn5SCK8ox2PqJbrWG lj3Q== X-Gm-Message-State: AOAM532p93stuJzFf27aAMkIhhi6+9pf+X6zMm9+PfaG3/7f1LqVXZKg efSyhwe9KIZmReks0j0sBf6edKuwaonENNIITOQAC32PRNHUqjV4 X-Google-Smtp-Source: ABdhPJyceDNR4Rcd3pyidd/fRRM3g/ukdzVRMqPO0DO3YGvh87zFtxB6UytQrMdvpk6EEF0Rbpn8KEUE3A03ggKWqPI= X-Received: by 2002:a63:480f:: with SMTP id v15mr7543749pga.341.1609988325955; Wed, 06 Jan 2021 18:58:45 -0800 (PST) MIME-Version: 1.0 References: <20210106084739.63318-1-songmuchun@bytedance.com> <20210106084739.63318-3-songmuchun@bytedance.com> <20210106163513.GS13207@dhcp22.suse.cz> In-Reply-To: <20210106163513.GS13207@dhcp22.suse.cz> From: Muchun Song Date: Thu, 7 Jan 2021 10:58:08 +0800 Message-ID: Subject: Re: [External] Re: [PATCH v2 2/6] mm: hugetlbfs: fix cannot migrate the fallocated HugeTLB page To: Michal Hocko Cc: Mike Kravetz , Andrew Morton , Naoya Horiguchi , Andi Kleen , Linux Memory Management List , LKML Content-Type: text/plain; charset="UTF-8" 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 Thu, Jan 7, 2021 at 12:35 AM Michal Hocko wrote: > > On Wed 06-01-21 16:47:35, Muchun Song wrote: > > Because we only can isolate a active page via isolate_huge_page() > > and hugetlbfs_fallocate() forget to mark it as active, we cannot > > isolate and migrate those pages. > > I've little bit hard time to understand this initially and had to dive > into the code to make sense of it. I would consider the following > wording easier to grasp. Feel free to reuse if you like. > " > 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. > " Thanks for your suggestion. I will reuse it. > > Now to the fix. I believe that this patch shows that the > set_page_huge_active is just too subtle. Is there any reason why we > cannot make all freshly allocated huge pages active by default? > > > 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 > > --- > > 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