Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7524988rwp; Tue, 18 Jul 2023 17:20:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlGzZsjdYkI/37Fzr/91w1TRqHTm0BYjIlyP1t9pyIqTR56LnsSBIAlyLuPtlHWQxJbyxcS9 X-Received: by 2002:a17:90b:3449:b0:263:f630:228f with SMTP id lj9-20020a17090b344900b00263f630228fmr16064304pjb.23.1689726008119; Tue, 18 Jul 2023 17:20:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689726008; cv=none; d=google.com; s=arc-20160816; b=wUu0SVZPn9mllTsqrQWOK/ZRdI6MPNPQgVXYqq/512HFhekl7tgSFIcLCuLTljiL1f wUl3MvjAfSc6A54tQsYK0K3rtxSBIM8pb78jvd9sYU4QZDSjqD3flYh00/bWuj9JD3bS G+UJpUTOTiIydhqoh3EiRvbaVt9wSisasoBrLBkhIkRqcg3f09tNg7lOgiT1nQ9JHDKS 94ZTFStCHKdmF1NZ16+uYx3xF5wtl/1ZjK9WopAlvDWRNN7R2iq8aOUkJuGcGfgUxzkn /g+eQASCf/NyQmnSNULl5smK4tCai1jmsoh0p4y2eaeeoTohUEKtMHe4QRr85GNAhvHf C2CA== 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:dkim-signature:date; bh=MpJgs9wRGslX7B0v5r1djRNwrOTPSth9rMMf+bQv7bw=; fh=zg2j5kVBvfZ6enSJwXyTaWRSsngNH4bQvVjbUnBIcaQ=; b=m3RFUQ8oN7pOqFANqKgXzAbj9o0GJIyaeeLU4H3vBWynJfRcVbv6wqzyef6o7SHmu8 TmWLuRsQsNPc5dVPxlnTKHjwzBnEbBAuEEEv0eTMk4MQfvSz86PBC5xn+ZVsOYt0kGzH TyZmPg+WF9a+TS3J8GjINk/q2hBW4Q/hEa66O2+KoKYqJxAMYEqwEWQZZiUmfDklW6LN wol/X4KIYy4KfjwaPB+Ubiv1X7lEayqC0yAsTCwwU3LYzV4GbXkVkRauZDASFbkyEEB5 VIFRDE1/AKcuFgCzwKpGqtJ9eJsfMwFP0Z4mIuvn/n3LyGltyc3GCZ//Q5YD3JwzsftO q9rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=WYnZ4pp9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m7-20020a17090a2c0700b00263d559dbf1si297866pjd.55.2023.07.18.17.19.55; Tue, 18 Jul 2023 17:20:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=WYnZ4pp9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229437AbjGSABf (ORCPT + 99 others); Tue, 18 Jul 2023 20:01:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbjGSABd (ORCPT ); Tue, 18 Jul 2023 20:01:33 -0400 Received: from out-42.mta1.migadu.com (out-42.mta1.migadu.com [IPv6:2001:41d0:203:375::2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F52B1719 for ; Tue, 18 Jul 2023 17:01:01 -0700 (PDT) Date: Wed, 19 Jul 2023 08:59:46 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1689724794; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=MpJgs9wRGslX7B0v5r1djRNwrOTPSth9rMMf+bQv7bw=; b=WYnZ4pp9slmQ2hwQev8HbcppJxGxief9n5Va5HFZ1X1tR64d3tufyCKwlA6RML4tADBRvB B+f+tEGKcFEZzN1utrRUo0hvMhShxz/vE/k9e9lpGORIXNVD/djPI8y3fYbzt2ltu3RiOL +k/JLqwpVnJErwKnw/et3BFkM+7iBgA= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Naoya Horiguchi To: Sidhartha Kumar Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, willy@infradead.org, linmiaohe@huawei.com, naoya.horiguchi@nec.com, stable@vger.kernel.org Subject: Re: [PATCH] mm/memory-failure: fix hardware poison check in unpoison_memory() Message-ID: <20230718235946.GA1106729@ik1-406-35019.vs.sakura.ne.jp> References: <20230717181812.167757-1-sidhartha.kumar@oracle.com> <20230718001409.GA751192@ik1-406-35019.vs.sakura.ne.jp> <20230718003956.GA762147@ik1-406-35019.vs.sakura.ne.jp> <6736667f-6456-34b5-1d1f-47219e499001@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <6736667f-6456-34b5-1d1f-47219e499001@oracle.com> X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 18, 2023 at 07:30:23AM -0700, Sidhartha Kumar wrote: > On 7/17/23 5:39 PM, Naoya Horiguchi wrote: > > On Tue, Jul 18, 2023 at 09:14:09AM +0900, Naoya Horiguchi wrote: > > > On Mon, Jul 17, 2023 at 11:18:12AM -0700, Sidhartha Kumar wrote: > > > > It was pointed out[1] that using folio_test_hwpoison() is wrong > > > > as we need to check the indiviual page that has poison. > > > > folio_test_hwpoison() only checks the head page so go back to using > > > > PageHWPoison(). > > > > > > > > Reported-by: Matthew Wilcox (Oracle) > > > > Fixes: a6fddef49eef ("mm/memory-failure: convert unpoison_memory() to folios") > > > > Cc: stable@vger.kernel.org #v6.4 > > > > Signed-off-by: Sidhartha Kumar > > > > > > > > [1]: https://lore.kernel.org/lkml/ZLIbZygG7LqSI9xe@casper.infradead.org/ > > > > --- > > > > mm/memory-failure.c | 2 +- > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > > > > index 02b1d8f104d51..a114c8c3039cd 100644 > > > > --- a/mm/memory-failure.c > > > > +++ b/mm/memory-failure.c > > > > @@ -2523,7 +2523,7 @@ int unpoison_memory(unsigned long pfn) > > > > goto unlock_mutex; > > > > } > > > > - if (!folio_test_hwpoison(folio)) { > > > > + if (!PageHWPoison(p)) { > > > > > > > > > I don't think this works for hwpoisoned hugetlb pages that have PageHWPoison > > > set on the head page, rather than on the raw subpage. In the case of > > > hwpoisoned thps, PageHWPoison is set on the raw subpage, not on the head > > > pages. (I believe this is not detected because no one considers the > > > scenario of unpoisoning hwpoisoned thps, which is a rare case). Perhaps the > > > function is_page_hwpoison() would be useful for this purpose? > > > > Sorry, I was wrong. Checking PageHWPoison() is fine because the users of > > unpoison should know where the PageHWPoison is set via /proc/kpageflags. > > So this patch is OK to me after comments from other reviewers are resolved. > > > > Hi Naoya, > > While taking a closer at the patch, later in unpoison_memory() there is > also: > > - ret = TestClearPageHWPoison(page) ? 0 : -EBUSY; > + ret = folio_test_clear_hwpoison(folio) ? 0 : -EBUSY; > > I thought this folio conversion would be safe because page is the result of > a compound_head() call but I'm wondering if the same issue exists here and > we should be calling TestClearPageHWPoison() on the specific subpage by > doing TestClearPageHWPoison(p). In this case (get_hwpoison_page returns 0), the target of unpoison_memory was buddy page or free huge page, so there seems not any realistic problem. But putting back to TestClearPageHWPoison() looks consistent, so I'm fine with it. Thanks, Naoya Horiguchi