From patchwork Thu Jan 14 10:35:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12019191 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 152F7C433E6 for ; Thu, 14 Jan 2021 10:38:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4A86523A50 for ; Thu, 14 Jan 2021 10:38:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4A86523A50 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 AA4298D00D0; Thu, 14 Jan 2021 05:38:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A79E78D008E; Thu, 14 Jan 2021 05:38:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9696F8D00D0; Thu, 14 Jan 2021 05:38:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0160.hostedemail.com [216.40.44.160]) by kanga.kvack.org (Postfix) with ESMTP id 7CEA58D008E for ; Thu, 14 Jan 2021 05:38:36 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 3360E181AC9CB for ; Thu, 14 Jan 2021 10:38:36 +0000 (UTC) X-FDA: 77704031832.12.fork42_020b67627526 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 06CE718027F8D for ; Thu, 14 Jan 2021 10:38:36 +0000 (UTC) X-HE-Tag: fork42_020b67627526 X-Filterd-Recvd-Size: 5406 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Thu, 14 Jan 2021 10:38:35 +0000 (UTC) Received: by mail-pf1-f179.google.com with SMTP id x126so3089631pfc.7 for ; Thu, 14 Jan 2021 02:38:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=en8qVXfeyVDqIIP8px6ejCNcDJPI30a78TjFLPR7Emo=; b=Bb7SJUlOhKJC1ZzQyZRdMOsjlGvbnabYiGk73Uj/BFVF0fB4N9cHrQZRz2Ef0yCHtz E0ImuUx5/qPYjt+BO6+mt+i77HasP85vbfStHl0AMkjYZqvfQSCxTA3TCeXYPLtQ4PdS wXUz0Vic6sDxivwltEBJrz0GNebiJ66Ifr5RSYWWTDZRSXY1mLyQS2MVg9LAIwfSmSIB ybUqD2JIN8GSVmVAYNSBQysheqB+R0Jvdgx6W74b6s7lDL0K76LNty3kEJEGvFMEPns6 PWIZ0FhmKAbsQgfRtHki3p7AhVx6ukdkvuhjAEY2WIARmoHDLMLmhZAA8T6SGZVfeqmz JyqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=en8qVXfeyVDqIIP8px6ejCNcDJPI30a78TjFLPR7Emo=; b=L2k22u+88Hp6DYfbfmbk7130vlsFHlL1O3nsH60GKuf4ae90i6IKhsj6XBuz/fWYUC HI8wGnKhhdN51TWYiC1Ck9AzZJc+WA5wLgbHTYQe07ADTMSrh0bl3Uki2jjo8qavB9eq R5lFxq2nonbdPMYzikDlvtIhhEB0TG9gNrajLLZ+xauMV7WePmoG8NLTv9UgR6YCyBse Um5DHDSOtQ6qKwtTftCtojwotyWVy4nMmYjaJflZASwPf36ufgyUqpgvQtz3PTV781HT 6py6aOBEbNYgCbTRRLJebJ11/pZf0zAb0AM+uJQespmO+j/+X517idKpxtrX7yJZCwvV cb4g== X-Gm-Message-State: AOAM5337cxC18SdsEdqwrP7njNschPBhpJt1s4cZ9ffkQ4h0IIAVU+oH axwIusFilOLtpp1XFn0F+ilW7w== X-Google-Smtp-Source: ABdhPJzYhufPXUdWQ/iuHCLrwoMhWfXjHdW3SAj4YRCzZdLGSVm2HIBKmnA9RKGGOzKXrViUuR2j/w== X-Received: by 2002:a63:7904:: with SMTP id u4mr6863861pgc.41.1610620714482; Thu, 14 Jan 2021 02:38:34 -0800 (PST) Received: from localhost.localdomain ([139.177.225.247]) by smtp.gmail.com with ESMTPSA id l12sm4970112pjq.7.2021.01.14.02.38.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jan 2021 02:38:33 -0800 (PST) From: Muchun Song To: mike.kravetz@oracle.com, akpm@linux-foundation.org Cc: n-horiguchi@ah.jp.nec.com, ak@linux.intel.com, mhocko@suse.cz, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Muchun Song , Michal Hocko , Oscar Salvador , stable@vger.kernel.org Subject: [PATCH v5 2/5] mm: hugetlbfs: fix cannot migrate the fallocated HugeTLB page Date: Thu, 14 Jan 2021 18:35:12 +0800 Message-Id: <20210114103515.12955-3-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20210114103515.12955-1-songmuchun@bytedance.com> References: <20210114103515.12955-1-songmuchun@bytedance.com> MIME-Version: 1.0 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: 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 Acked-by: Michal Hocko Reviewed-by: Mike Kravetz Reviewed-by: Oscar Salvador Cc: stable@vger.kernel.org --- 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]);