From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout05.his.huawei.com (canpmsgout05.his.huawei.com [113.46.200.220]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 543FD1A08AF for ; Wed, 27 May 2026 03:35:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.220 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779852959; cv=none; b=fU4F5oTVSF0xCsGgzvVETalR17Vr6aZf5b1N4b+iVVPIyIogyYBFwYqYdIeDzB9iNPEavvmUTSJfLgHSlGtT736JHxF+3uNGjuF0oCDiZyKQlOoviEACjP3IcX1qEv45X1ZwQHJAkgSMdxRSkQ8ndcWC4fcathgueZrnDU+G0C8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779852959; c=relaxed/simple; bh=JXA1GK0rWCZrQXuOPBXfSmjJWzDWYKHYIejTDXFgFq0=; h=Subject:To:CC:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=o7DpHu7BVWs/v4fy2MvzBYyEEBrY+0Q/Js+MmqikZWwWfAmEGXbCGwvFyfLvtqjeFu2GABgdC1LuCR3y6vlXqTfIb08kgaLN9vEGdtbMKIaiBvNfpNDUOkDsbnysTFgj66PvnLkuX5HsLTCvlCgwVPPmP/RNl3/kapwpvH5enuU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=ABWrFTgX; arc=none smtp.client-ip=113.46.200.220 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="ABWrFTgX" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=Q/dvUtKgd/9QJ8D28aOAJEXGFBb6PbtKyMzWlL26Lhw=; b=ABWrFTgXCg+vtvUGJPbUrbQW8jHQMNLeqhTy3Fuhept1IXlZr8cHqTp3UJZ8CyCD0Suk73hww Aj4Raoylx5GctYIkH9XYgQGix2ZwNvKcYxykQAe54RPbgr4MHpcUsHnSqOiqQm4HJx8EALANZ9X VJcvLkHHk4O4FsCJp6BEjmc= Received: from mail.maildlp.com (unknown [172.19.163.0]) by canpmsgout05.his.huawei.com (SkyGuard) with ESMTPS id 4gQFS84z2Qz12Ljl; Wed, 27 May 2026 11:27:52 +0800 (CST) Received: from dggemv705-chm.china.huawei.com (unknown [10.3.19.32]) by mail.maildlp.com (Postfix) with ESMTPS id 8F9F040571; Wed, 27 May 2026 11:35:52 +0800 (CST) Received: from kwepemq500010.china.huawei.com (7.202.194.235) by dggemv705-chm.china.huawei.com (10.3.19.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 27 May 2026 11:35:44 +0800 Received: from [10.173.124.160] (10.173.124.160) by kwepemq500010.china.huawei.com (7.202.194.235) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 27 May 2026 11:35:43 +0800 Subject: Re: [PATCH resend] mm/memory-failure: fix hugetlb_lock AA deadlock in get_huge_page_for_hwpoison To: Andrew Morton , Wupeng Ma CC: , , , , , , , , , , , References: <20260522010305.4099834-1-mawupeng1@huawei.com> <20260522205041.a85237b104d74533c13745e4@linux-foundation.org> From: Miaohe Lin Message-ID: Date: Wed, 27 May 2026 11:35:43 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20260522205041.a85237b104d74533c13745e4@linux-foundation.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: kwepems500002.china.huawei.com (7.221.188.17) To kwepemq500010.china.huawei.com (7.202.194.235) On 2026/5/23 11:50, Andrew Morton wrote: > On Fri, 22 May 2026 09:03:05 +0800 Wupeng Ma wrote: > >> Two concurrent madvise(MADV_HWPOISON) calls on the same hugetlb page >> can trigger a recursive spinlock self-deadlock (AA deadlock) on >> hugetlb_lock when racing with a concurrent unmap: > > Well we don't want that. > >> Fixes: 405ce051236c ("mm/hwpoison: fix race between hugetlb free/demotion and memory_failure_hugetlb()") > > So I'll add cc:stable here. > > AI review didn't like the unlocked page_folio(): > > https://sashiko.dev/#/patchset/20260522010305.4099834-1-mawupeng1@huawei.com > > So I'll add a followup patch which addresses that (and which addresses > Miaohe's naming nit). > > Please let's check this - perhaps the locking alteration isn't needed. > > > From: Andrew Morton > Subject: mm-memory-failure-fix-hugetlb_lock-aa-deadlock-in-get_huge_page_for_hwpoison-fix > Date: Fri May 22 08:44:25 PM PDT 2026 > > - address possible race identified by Sashiko > > - s/out/out_unlock/, per Miaohe > > Link: https://sashiko.dev/#/patchset/20260522010305.4099834-1-mawupeng1@huawei.com > Link: https://lore.kernel.org/f39f405e-4b4b-8f79-70fe-a2b5b62114eb@huawei.com > Cc: David Hildenbrand > Cc: Kefeng Wang > Cc: Liam Howlett > Cc: Lorenzo Stoakes > Cc: Miaohe Lin > Cc: Michal Hocko > Cc: Mike Rapoport > Cc: Muchun Song > Cc: Naoya Horiguchi > Cc: Oscar Salvador (SUSE) > Cc: Suren Baghdasaryan > Cc: Vlastimil Babka > Cc: Wupeng Ma > Signed-off-by: Andrew Morton > --- > > mm/memory-failure.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > --- a/mm/memory-failure.c~mm-memory-failure-fix-hugetlb_lock-aa-deadlock-in-get_huge_page_for_hwpoison-fix > +++ a/mm/memory-failure.c > @@ -1970,14 +1970,15 @@ static int get_huge_page_for_hwpoison(un > bool *migratable_cleared) > { > struct page *page = pfn_to_page(pfn); > - struct folio *folio = page_folio(page); > + struct folio *folio; > bool count_increased = false; > int ret, rc; > > spin_lock_irq(&hugetlb_lock); > + folio = page_folio(page); This fix works to me. The folio could become stale without holding hugetlb_lock due to race, e.g. hugetlb demotion, dissolve and ... Thanks Andrew. .