Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1988753pxb; Fri, 5 Mar 2021 04:54:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJyOWml7NPejI376/7f9QmyDy3zI54cWoQZ/jnluc8/Y2VMy9DZkRIiMkza9StFthMIyvqag X-Received: by 2002:a17:907:2bdd:: with SMTP id gv29mr1996442ejc.259.1614948869549; Fri, 05 Mar 2021 04:54:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614948869; cv=none; d=google.com; s=arc-20160816; b=Nk2TeU67NIgnTr66pKWfCWFVcvSLX1lHA+qi94dNzPUYnIAqqQPW/Ekxd4+/0jB63J 58o5uxNi71cc9wG7Dp1SeMFz4cw83RthJbxONG5wobs7qVF51YLGsaesNLTxiGONMwL8 h+Ce4nM76PtOmjTpEYOVuou/EcqnbtCM9YA4JL/CkVSXYSxem27ai1PzzCR+yDk7h/8C Hyos8SRSafDDylueRLx7v3t2tB4Spv86iDjx08KJh5NSRKvyL/ky2ZE4icTCsXep0RkW /bSlF7JtsekEkk6P5guCv0pUV0rlrBHi368k6T6Ucuu1suoh1nwtDBCrJrc+Zqqk7gDb LrNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=JYg8YweLZdbUf9BN7yPIkniCjV+jX92R/nckK3AvHhc=; b=B/Q0JtoGR4KIcK6+A/I0dPsAGgSR0seL0PmyBpOMbAdskT3OKuvJonkaooPdfQvSOh icvyjf3+T+unZmgN6M/XDE9SZ7kNDk99cvqIng7/dBZWpdxads9EoRqPV18HarwNFzW0 kWlqG9ESF1ToIPT8OV4eIQk6CzQq32/xPynXhr82QgL2QrvIT8N4LkWI3cbqCgvlUf4Y mko850jaqZLwZCgizBvfIyniY6xUOOGP1rMqmzpYlZnUWAPka7Hj3jn9v5nSKm7YHucN X0Taj43PC5+jaK6ZQQJY5Ze5PBlFq4rMepklC0n40yuullrVUljJUR8kz6ZGvE2guuLl f4DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tFPJRWdH; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f4si1274094ejf.359.2021.03.05.04.54.06; Fri, 05 Mar 2021 04:54:29 -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=@gmail.com header.s=20161025 header.b=tFPJRWdH; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229813AbhCEMw5 (ORCPT + 99 others); Fri, 5 Mar 2021 07:52:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229978AbhCEMwv (ORCPT ); Fri, 5 Mar 2021 07:52:51 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BE6EC061574 for ; Fri, 5 Mar 2021 04:52:51 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id i14so1803756pjz.4 for ; Fri, 05 Mar 2021 04:52:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=JYg8YweLZdbUf9BN7yPIkniCjV+jX92R/nckK3AvHhc=; b=tFPJRWdH2tWcIqtx7mrEbL3daOlr0XKJcsYshWPLJ0jG2WXB/dVzEYt6L5J1do7uDn eY07dalaGhpJNWbPSgmmUagLf9LfvE8azvtlXDjXjD3C8W2lZtzfIs4fabFMzyMsn1zt NrKPGV4S4T8Bc72Zpa/QtDkVtpOyYLsRuNNjKQght6NGDhZ6iiiqcplI2o5NIY0nQkGU 92u5DCL6aDEIrxV/OnrX8PItWFpzMCw9965b2yHplUUuTz7/t7pty7W0+nXqOnhRCNeX 0jL+J8AgUeRAsYhBPBN64PF43LCt6AUtewA2HKqNCZLUubJAdX05Hqn55T4GKz0AufWx 795Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=JYg8YweLZdbUf9BN7yPIkniCjV+jX92R/nckK3AvHhc=; b=C7KS5vg4YnpL2ec0ngwhz0qA9crEmz6yuEk+vkKw/xgRur5odKb/DYu5sFa3FSTpeW Kk9I/Jti1a7pt9H5L5j+TK9HvPcouHTcMaRlrrj9v7nVteQShwzzzLDywFYbaQPyAOnO de9IB1fqIwP9E1RctCaYOMM6vNFE1NeieMtIZKWGp49CogB/eQH16Rv5kx2gBxpmWk4e fXE2kNSucf3t8SqVGBknsE+eApZzgZuEGPnFamr2t7uvTH8Ob4cPecgD4vP4otS/bjlR NbaNyYVdsBG95Ah0RwjRz26gKBpf/VajfACbJnUOQq6seicEE594y6mTG2ZiBUDO6V+u klVQ== X-Gm-Message-State: AOAM533lMmUdWJtqROEJSV0fJG1k4OjNR2ca16YKhsZ5Ma5Vdn4YWbrx 8nwcVtaaVjqLPG+tlIMfLA== X-Received: by 2002:a17:90a:71c3:: with SMTP id m3mr10214603pjs.186.1614948770657; Fri, 05 Mar 2021 04:52:50 -0800 (PST) Received: from u2004 (h175-177-040-153.catv02.itscom.jp. [175.177.40.153]) by smtp.gmail.com with ESMTPSA id ms21sm2524497pjb.5.2021.03.05.04.52.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Mar 2021 04:52:50 -0800 (PST) Date: Fri, 5 Mar 2021 21:52:46 +0900 From: Naoya Horiguchi To: Oscar Salvador Cc: linux-mm@kvack.org, Andrew Morton , Michal Hocko , Tony Luck , "Aneesh Kumar K.V" , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v2] mm, hwpoison: do not lock page again when me_huge_page() successfully recovers Message-ID: <20210305125246.GA975517@u2004> References: <20210304064437.962442-1-nao.horiguchi@gmail.com> <20210305072652.GA18868@linux> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-2022-jp Content-Disposition: inline In-Reply-To: <20210305072652.GA18868@linux> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Oscar, On Fri, Mar 05, 2021 at 08:26:58AM +0100, Oscar Salvador wrote: > On Thu, Mar 04, 2021 at 03:44:37PM +0900, Naoya Horiguchi wrote: > > From: Naoya Horiguchi > > Hi Naoya, > > good catch! > > > Currently me_huge_page() temporary unlocks page to perform some actions > > then locks it again later. My testcase (which calls hard-offline on some > > tail page in a hugetlb, then accesses the address of the hugetlb range) > > showed that page allocation code detects the page lock on buddy page and > > printed out "BUG: Bad page state" message. PG_hwpoison does not prevent > > it because PG_hwpoison flag is set on any subpage of the hugetlb page > > but the 2nd page lock is on the head page. > > I am having difficulties to parse "PG_hwpoison does not prevent it because > PG_hwpoison flag is set on any subpage of the hugetlb page". > > What do you mean by that? What was in my mind is that check_new_page_bad() does not consider a page with __PG_HWPOISON as bad page, so this flag works as kind of filter, but this filtering doesn't work in my case because the "bad page" is not the actual hwpoisoned page. Thank for nice comment, I've updated the patch below with this description. > > > > > This patch suggests to drop the 2nd page lock to fix the issue. > > > > Fixes: commit 78bb920344b8 ("mm: hwpoison: dissolve in-use hugepage in unrecoverable memory error") > > Cc: stable@vger.kernel.org > > Signed-off-by: Naoya Horiguchi > > The fix looks fine to me: > > Reviewed-by: Oscar Salvador Thank you! Have a nice weekend. - Naoya --- From eaaaab05750c13fe9b637190410289a3168b097e Mon Sep 17 00:00:00 2001 From: Naoya Horiguchi Date: Fri, 5 Mar 2021 21:44:47 +0900 Subject: [PATCH v2] mm, hwpoison: do not lock page again when me_huge_page() successfully recovers Currently me_huge_page() temporary unlocks page to perform some actions then locks it again later. My testcase (which calls hard-offline on some tail page in a hugetlb, then accesses the address of the hugetlb range) showed that page allocation code detects this page lock on buddy page and printed out "BUG: Bad page state" message. check_new_page_bad() does not consider a page with __PG_HWPOISON as bad page, so this flag works as kind of filter, but this filtering doesn't work in this case because the "bad page" is not the actual hwpoisoned page. This patch suggests to drop the 2nd page lock to fix the issue. Fixes: commit 78bb920344b8 ("mm: hwpoison: dissolve in-use hugepage in unrecoverable memory error") Cc: stable@vger.kernel.org Signed-off-by: Naoya Horiguchi Reviewed-by: Oscar Salvador --- mm/memory-failure.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index e9481632fcd1..d8aba15295c5 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -830,7 +830,6 @@ static int me_huge_page(struct page *p, unsigned long pfn) page_ref_inc(p); res = MF_RECOVERED; } - lock_page(hpage); } return res; @@ -1286,7 +1285,8 @@ static int memory_failure_hugetlb(unsigned long pfn, int flags) res = identify_page_state(pfn, p, page_flags); out: - unlock_page(head); + if (PageLocked(head)) + unlock_page(head); return res; } -- 2.25.1