Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4185305pxb; Mon, 8 Feb 2021 09:53:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdOBFxs8bbPFOmWkit8j2zWOd7qO1+PYVAXZvoGRYuYOxvhsmNDNr4ublL3tT6s+5HiqqN X-Received: by 2002:a50:aade:: with SMTP id r30mr495084edc.15.1612806832094; Mon, 08 Feb 2021 09:53:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612806832; cv=none; d=google.com; s=arc-20160816; b=qNnm7b8z+0vX+jbgf0wZrFgRV5Kj0g0a2/LPbYYVgilncC3dYo5ds0ZJ9CFRHyBuZ0 vlnpiJSazfxHs3hWetqIekSUt/BxgXjbvAKocR7mKgzRM7V6I2tbM1qaDLR1N3j/rTHr QWZj9NddWmhPmS4KOukrDvGZF5gownV5m/aSrGQCE1hNjzIevWsf2QO3PWA0n9EfU52L mcUUL86g2IRQG4+BeY8b3iXoGR3Rx0yXs8rzWw4Qr7wBHVIOd5sHBDiv+nN7vi3mBXUT s/8Qm1T3maMGTg1Yn/sbIchfxH56zOE3t3l5NZTdwwRRN0ggdDtwB36DHMTyuNcBfi2B p+FA== 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=mq3LwJOA8VhQDrlNw0EYh5pDFSfNVZ0Mz6MEhKF9tnw=; b=DTP4gtjnfpxAzcrAmzXUi90R3BTe2L5Nel29hZpzlo6gaCBakKMeLBc3tAQdJSFy0N Ik4uPpCKeyblKRqwfrMgewsYOu8G0aK1abc+vYkYbOJKWU/ni+9AVdCK32hNtODylQIs pMmLLkNTRGWu3Dd5FAxihY3c9iw+drcbh4fkJTKLJfqpH3UzLKc4csYk3HCOA5xCHWKo gOxc3ZyCPn2MZHjpxvh7t31PMNZLNgM5ARTpr01wkSMj0umgwisGOWnO5ZwygmYQKwc4 9tUzHxyC0kJaDvaNath5rpSaXPx59Szd7VD2n24uRk7N+nPnD/Sk6YQQex2UG9kHnnlh NIfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="CNw2lFB/"; 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 a24si9126319edm.608.2021.02.08.09.53.28; Mon, 08 Feb 2021 09:53:52 -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="CNw2lFB/"; 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 S233618AbhBHRwA (ORCPT + 99 others); Mon, 8 Feb 2021 12:52:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:37878 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233955AbhBHPcF (ORCPT ); Mon, 8 Feb 2021 10:32:05 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E78D064F38; Mon, 8 Feb 2021 15:17:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612797470; bh=tZH2xiQ/QmLOR9b6IIEglTWN46YHukGUgqV/5Jbi6gA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CNw2lFB/e7jxzC8WFC9/dXd4c/oTbfaWEN/2Ao72vlayjJpaohYSUMgqTYozW5Rwj q7w11OefkQPB97CneS6D/h+1WrTqREbaikx5PNXDKsoqLFLD71Xk8QW75ZRCz7Hema kkJrC1FKgRRMINphEYNzVD15Ao6LrJNqdBbICrJg= 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.10 098/120] mm: hugetlbfs: fix cannot migrate the fallocated HugeTLB page Date: Mon, 8 Feb 2021 16:01:25 +0100 Message-Id: <20210208145822.286842726@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208145818.395353822@linuxfoundation.org> References: <20210208145818.395353822@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 @@ -735,9 +735,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 @@ -770,6 +770,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 @@ -1349,7 +1349,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]);