Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4179221pxb; Mon, 8 Feb 2021 09:44:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxyCC+BkOSdfCC9sQnNTT9JQDuLcp6M362ZTgNvYsMT1Cfm8UkK1DxFb9+/AzG3rAtLaIdL X-Received: by 2002:a17:906:9705:: with SMTP id k5mr18485696ejx.325.1612806256429; Mon, 08 Feb 2021 09:44:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612806256; cv=none; d=google.com; s=arc-20160816; b=mA9NOfWT7+b7oRb3QNaoFDBQAJviqHT4TS3Y4LtiStBgoQi9nrXlLKJEZoO/gF5NR8 qhe5Xn0DBNxCJZcCwcnkGsclYeMwNABda68FfyVLAAkFwpwziim7nVloHIy4V2Gw5ZDS LkAbDj5x8uLxYPtdTsnpKr3uYMkAC8BfdTMePD054HvB9UrZKHc5yCZHWOJ7Vs9Q+w3E 1o8p5/1OC6hv5L32otesjKHW180CeSYXX+XEeA2n2f5EKRQeW8eHdlidH7D19SFitJ00 g/47EmeLC5jhAVwtzjflASjd154NO32vhl70/K4FAcaJP2AhZ4TG750tY3HXVUgoz5RX /5NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MeI1E+cn077oTvYIaLChVP6s/dCueMGB89x3U2bpbm4=; b=y/QiNpOX5sifFd+V42IWFq9K41l5KNHOm7nM7vqjGP7/Odg97rKe6OMEqlX/oB2UG2 NjSg5buzPujR0byBejHeZkrG1Bf0tExqSQwAXvmA9QHJ79cUkAYtRhd6oI+fZ8+ZWLkp uzZo5sLjW+kFpvxwiC5z68g1CXgfSSNQb8UbKUZYPO/WXM0ufpHAy1kWupNsrYVxi4pb Iv2Y/Fo3EnMzrubr5L9bmIiIPh078bTtIcA4Xxqse8kb2xHWwZVHcyhlkt3QkMmky3Iq RHpP//nOq3DEJkwbQIxCz5RuEM+iXahn0zbDVoVtfbIDNbS+5BQVi+lC/HqUGVHC5uZ2 Jjtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EK2R5cPo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j23si12684790eje.347.2021.02.08.09.43.52; Mon, 08 Feb 2021 09:44:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EK2R5cPo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233264AbhBHRkx (ORCPT + 99 others); Mon, 8 Feb 2021 12:40:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:32772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232353AbhBHPSV (ORCPT ); Mon, 8 Feb 2021 10:18:21 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 783FA64EC3; Mon, 8 Feb 2021 15:12:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612797144; bh=7x1RtK3j6ej2txRsFyn5vOqqlVJ+xupbVIGHvKDOdVo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EK2R5cPoVZUDuXMJudPF+OTkX5LwqqUpdpOzYgW6n/B3w7aybZRonkUHm0GYD4fSB xI1QwgCgmbaiUS4OCBZ0eMUDmiEmxRrvJaSV8Wuc56z0Me6UENall6gCrgyN3b0ROe 250ixFh793em9E7iFp73GTgJ09BqqIN0RYdc0v0I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Muchun Song , Michal Hocko , Mike Kravetz , Oscar Salvador , David Hildenbrand , Yang Shi , Andrew Morton , Linus Torvalds Subject: [PATCH 5.4 48/65] mm: hugetlbfs: fix cannot migrate the fallocated HugeTLB page Date: Mon, 8 Feb 2021 16:01:20 +0100 Message-Id: <20210208145812.074719342@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208145810.230485165@linuxfoundation.org> References: <20210208145810.230485165@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Muchun Song commit 585fc0d2871c9318c949fbf45b1f081edd489e96 upstream. 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. Link: https://lkml.kernel.org/r/20210115124942.46403-3-songmuchun@bytedance.com Fixes: 70c3547e36f5 (hugetlbfs: add hugetlbfs_fallocate()) Signed-off-by: Muchun Song Acked-by: Michal Hocko Reviewed-by: Mike Kravetz Reviewed-by: Oscar Salvador Cc: David Hildenbrand Cc: Yang Shi Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- fs/hugetlbfs/inode.c | 3 ++- include/linux/hugetlb.h | 2 ++ mm/hugetlb.c | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -675,9 +675,10 @@ static long hugetlbfs_fallocate(struct f 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); --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -590,6 +590,8 @@ static inline void huge_ptep_modify_prot } #endif +void set_page_huge_active(struct page *page); + #else /* CONFIG_HUGETLB_PAGE */ struct hstate {}; --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1222,7 +1222,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]);