Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4092154pxb; Mon, 8 Feb 2021 07:46:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJwtTqss1FBef+0KRz0EwePhq9ZjHkQhp11mnHNRHm+gWCd+k5cDKN8l1bY5njVS5OtmlNb5 X-Received: by 2002:a17:906:2a06:: with SMTP id j6mr16849516eje.164.1612799179718; Mon, 08 Feb 2021 07:46:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612799179; cv=none; d=google.com; s=arc-20160816; b=M35a+fHLzP2GbboOi7XxWjreSOaZ+zefrPZ/8eexUfyhKKMGJV0+4yo1SS3+6F1zAe o6DvdiReVpXPmOgNW6WRmdpcjZONNJQEcdxAWPS+MrKVxI78cIRSyv0Sqkpz8nfMRsJ5 g/EO6xDZx90OHO/PqA55XsNbeOcQq+pzf512ltVqQ9Z56tBSNQFeDYSuBooTMDZCON+z thdq9Qo4ksXHxS76exgQ0DNyNDxWVxAXQTI9OaMdw5BZEnfi4DzHSyNXDrXMxpmRgwH1 LWNhfoHxeECzGUV0ZLHqtTG7mooNNJueERO09d6uUr/MJ3Oi5Z1VIo1vyfkjPazdQZJV +BnA== 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=EF+Z7Mg2S+Mx0CA4Xi6m8w0NxdKbU6ZA9zEszgUJxPU=; b=Dr8pGKPJUvsy/Eq1J76p+RGWgQSl2JMp0hQFLQ2YuTveP4BvuslQdT9Yn5y+Sepqad NpsUKGBwHJ3wFW/44FyMSIvv+jrR2+WG8qC8lZl7+l1Z75UhtfvolVJ+CEVa5KfVWpyJ 86prmXTXSjIHsUbMFLBLRP9ahnrON29RVzi5O9xZ6YgVAr/SOWSwQtKhloIltkcER0dy g9it6XeaYOWGHum1gICQYaQN7KfgVzR908ypE1GZHQeLqzLUeQQ/rA/lGUhwMDCbNiz/ gZU5PjRl20lsrUk1N0p62MfqU2NjNal1BjgfXqg1ypqW8ko3eaYORJdDDI6WJbfKmPDg rgug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RANpbjzx; 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 22si10709886ejc.181.2021.02.08.07.45.54; Mon, 08 Feb 2021 07:46:19 -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=RANpbjzx; 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 S234060AbhBHPom (ORCPT + 99 others); Mon, 8 Feb 2021 10:44:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:52070 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232782AbhBHPGa (ORCPT ); Mon, 8 Feb 2021 10:06:30 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 34E2C64E87; Mon, 8 Feb 2021 15:05:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612796700; bh=2ltP8BJMHSaEuaXTY3lwZImteGPH9IcouFFzldHk1cg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RANpbjzxnT45IZmhKZ/DF+Keu9Ciw/1B64QO8K7Gu2aoxP/11bTqNgPSwif+PyHVb /Hs5s+Qaq+TtgJRLhJ4UJdXUYyPmH02FHmjM/K56eiAd713kqWu5bNn/Rl77vFrfU7 8QjRsZ4sSntzIKwglZdyn28u6DkNp2+Il1sH+wws= 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 4.9 34/43] mm: hugetlbfs: fix cannot migrate the fallocated HugeTLB page Date: Mon, 8 Feb 2021 16:01:00 +0100 Message-Id: <20210208145807.694524853@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208145806.281758651@linuxfoundation.org> References: <20210208145806.281758651@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 | 3 +++ mm/hugetlb.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -665,8 +665,9 @@ static long hugetlbfs_fallocate(struct f mutex_unlock(&hugetlb_fault_mutex_table[hash]); + set_page_huge_active(page); /* - * page_put due to reference from alloc_huge_page() + * put_page() due to reference from alloc_huge_page() * unlock_page because locked by add_to_page_cache() */ put_page(page); --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -502,6 +502,9 @@ static inline void hugetlb_count_sub(lon { atomic_long_sub(l, &mm->hugetlb_usage); } + +void set_page_huge_active(struct page *page); + #else /* CONFIG_HUGETLB_PAGE */ struct hstate {}; #define alloc_huge_page(v, a, r) NULL --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1215,7 +1215,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]);