From patchwork Sun Jan 17 20:44:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 365438 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 41A96C433E0 for ; Sun, 17 Jan 2021 20:45:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 08ACF21D7A for ; Sun, 17 Jan 2021 20:45:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730321AbhAQUp1 (ORCPT ); Sun, 17 Jan 2021 15:45:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:48992 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730308AbhAQUpW (ORCPT ); Sun, 17 Jan 2021 15:45:22 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0340822227; Sun, 17 Jan 2021 20:44:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1610916278; bh=yP4E4ifK8PzoGEMj7rUZzk18qMC2lm278idp/cCXn/E=; h=Date:From:To:Subject:From; b=PCwAkq7PaC8UpcR4WLTGy3D/PEjxdyzeHXr2fQupVrpBnWR80K2H0l6tlsOVBdhi9 UvIFEvbhNNtavPyDQ1Fch22GdRoyZCP58RYSLBho4/ZH4EDWg5lxO63Rkegu7uy0p2 3GvRu/EslOc0Bc88YTXRCVC/q3aq/CwMRs9sFJ9A= Date: Sun, 17 Jan 2021 12:44:36 -0800 From: akpm@linux-foundation.org To: ak@linux.intel.com, mhocko@suse.com, mike.kravetz@oracle.com, mm-commits@vger.kernel.org, n-horiguchi@ah.jp.nec.com, songmuchun@bytedance.com, stable@vger.kernel.org Subject: [to-be-updated] mm-hugetlb-fix-a-race-between-isolating-and-freeing-page.patch removed from -mm tree Message-ID: <20210117204436.awIpnPC-N%akpm@linux-foundation.org> User-Agent: s-nail v14.8.16 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch titled Subject: mm: hugetlb: fix a race between isolating and freeing page has been removed from the -mm tree. Its filename was mm-hugetlb-fix-a-race-between-isolating-and-freeing-page.patch This patch was dropped because an updated version will be merged ------------------------------------------------------ From: Muchun Song Subject: mm: hugetlb: fix a race between isolating and freeing page There is a race between isolate_huge_page() and __free_huge_page(). CPU0: CPU1: if (PageHuge(page)) put_page(page) __free_huge_page(page) spin_lock(&hugetlb_lock) update_and_free_page(page) set_compound_page_dtor(page, NULL_COMPOUND_DTOR) spin_unlock(&hugetlb_lock) isolate_huge_page(page) // trigger BUG_ON VM_BUG_ON_PAGE(!PageHead(page), page) spin_lock(&hugetlb_lock) page_huge_active(page) // trigger BUG_ON VM_BUG_ON_PAGE(!PageHuge(page), page) spin_unlock(&hugetlb_lock) When we isolate a HugeTLB page on CPU0. Meanwhile, we free it to the buddy allocator on CPU1. Then, we can trigger a BUG_ON on CPU0. Because it is already freed to the buddy allocator. Link: https://lkml.kernel.org/r/20210110124017.86750-6-songmuchun@bytedance.com Fixes: c8721bbbdd36 ("mm: memory-hotplug: enable memory hotplug to handle hugepage") Signed-off-by: Muchun Song Reviewed-by: Mike Kravetz Acked-by: Michal Hocko Cc: Andi Kleen Cc: Naoya Horiguchi Cc: Signed-off-by: Andrew Morton --- mm/hugetlb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/mm/hugetlb.c~mm-hugetlb-fix-a-race-between-isolating-and-freeing-page +++ a/mm/hugetlb.c @@ -5581,9 +5581,9 @@ bool isolate_huge_page(struct page *page { bool ret = true; - VM_BUG_ON_PAGE(!PageHead(page), page); spin_lock(&hugetlb_lock); - if (!page_huge_active(page) || !get_page_unless_zero(page)) { + if (!PageHeadHuge(page) || !page_huge_active(page) || + !get_page_unless_zero(page)) { ret = false; goto unlock; }