From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B0DAC433F5 for ; Wed, 27 Oct 2021 01:04:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CA13F60F9B for ; Wed, 27 Oct 2021 01:04:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CA13F60F9B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 17BCA940008; Tue, 26 Oct 2021 21:04:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 12BC5940007; Tue, 26 Oct 2021 21:04:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE81E940008; Tue, 26 Oct 2021 21:04:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0198.hostedemail.com [216.40.44.198]) by kanga.kvack.org (Postfix) with ESMTP id DED7A940007 for ; Tue, 26 Oct 2021 21:04:27 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9824D3A2CB for ; Wed, 27 Oct 2021 01:04:27 +0000 (UTC) X-FDA: 78740421774.30.A433C59 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by imf08.hostedemail.com (Postfix) with ESMTP id 48362300024C for ; Wed, 27 Oct 2021 01:04:20 +0000 (UTC) Received: by mail-ed1-f45.google.com with SMTP id r4so3666485edi.5 for ; Tue, 26 Oct 2021 18:04:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rDz/i6IyMh6CO7idWG+/4e+s/eK8ViVHThqmRp1kNZQ=; b=mNkUJb2Y99kLVttKo3d4dZoUgtl+5Bt0KuxH3ZXJ5Ynr10kVpkyfEU6mLZyxXYWXpv cuAaslsqOiCV8D5FZLWgY90IBoBAGKsTu1RQY64Q6bzq2HGA1qPNIEJsdawZePOl6SlK KVpx8DdcBaW2hM/DiQfGAs+87oE3Pg0bGs+8cAjZUs1/94/WlTpduAl0FXASThH8rr+R GBeJ07LbdDMbMc66i/KzYEUsiEcpNUzUqkjZA3mErsoPvw5LOQy+3t36la12qlH2Ifmr wpQz1HyYADWgEEsMNwIfBiwh/OkN1ZxkBZIkoV/N+SCKHwTaivvd45DqWwut1tb9aZGx tg1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rDz/i6IyMh6CO7idWG+/4e+s/eK8ViVHThqmRp1kNZQ=; b=zx1Z+NvMEQTsAB3wHeafgOSn0DVSGU/5C7LGfAv4WCHp7xG0IGwTWBymn3x0z3uNTE zPxf5SF2PaallsESn1PxmCglf4RD/xLuwz8m+ysf/BPQ/dU28kTbIuSvLdjfSI4zjBkH Hm5mVg7HX2iOQzejJrxhO+ktB3L141+UPbtNTfGQiZMjMVCYHEcCQQBF8IB6a4LVOYqM UEyhizkrnYhodZ1ouWdinzkkJ/qLyHaVCf5cbdvZcDlYUyHyUagVe0tQek7mBjetjKJr SMtprh9NuFU3Tmkjp4jWbsP9nPQm0sojS+NMaMLzRQ9sEwrPPaneZPv1ZnSlQ7hH0S5j Cflw== X-Gm-Message-State: AOAM532PuWMhnwPQX28JceAm3iY/HnwRa60wuIwgg9iczglXxlK5ZnIb 2oEvBTLu3QgT4Ixtn5I7p/eR2djXXBKmPy2tK0g= X-Google-Smtp-Source: ABdhPJwWMdtrUfTPamyfGICTc6BTJiO46PSUDvMyp5nAXWPvA1mvU1PY3Jf8sMoaPVusDJen1ABaQcfY69f9jdTVw4w= X-Received: by 2002:a17:907:3f83:: with SMTP id hr3mr34783494ejc.555.1635296665941; Tue, 26 Oct 2021 18:04:25 -0700 (PDT) MIME-Version: 1.0 References: <20211025230503.2650970-1-naoya.horiguchi@linux.dev> <20211025230503.2650970-3-naoya.horiguchi@linux.dev> In-Reply-To: <20211025230503.2650970-3-naoya.horiguchi@linux.dev> From: Yang Shi Date: Tue, 26 Oct 2021 18:04:13 -0700 Message-ID: Subject: Re: [PATCH v2 2/4] mm/hwpoison: remove race consideration To: Naoya Horiguchi Cc: Linux MM , Andrew Morton , David Hildenbrand , Oscar Salvador , Michal Hocko , Ding Hui , Tony Luck , "Aneesh Kumar K.V" , Miaohe Lin , Peter Xu , Naoya Horiguchi , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 48362300024C X-Stat-Signature: mfcgjfpcj1nie9kx6718t86iba8bfph9 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=mNkUJb2Y; spf=pass (imf08.hostedemail.com: domain of shy828301@gmail.com designates 209.85.208.45 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1635296660-657236 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Oct 25, 2021 at 4:06 PM Naoya Horiguchi wrote: > > From: Naoya Horiguchi > > Now memory_failure() and unpoison_memory() are protected by mf_mutex, > so no need to explicitly check races between them. So remove them. It seems this patch could be folded into patch #1. Some "unlock_mutex" were added by patch #1 then they were removed by this patch immediately, it seems a bit of a waste and this patch is actually the by-product of patch #1. > > Signed-off-by: Naoya Horiguchi > --- > mm/memory-failure.c | 37 ------------------------------------- > 1 file changed, 37 deletions(-) > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index 97297edfbd8e..a47b741ca04b 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -1507,14 +1507,6 @@ static int memory_failure_hugetlb(unsigned long pfn, int flags) > lock_page(head); > page_flags = head->flags; > > - if (!PageHWPoison(head)) { > - pr_err("Memory failure: %#lx: just unpoisoned\n", pfn); > - num_poisoned_pages_dec(); > - unlock_page(head); > - put_page(head); > - return 0; > - } > - > /* > * TODO: hwpoison for pud-sized hugetlb doesn't work right now, so > * simply disable it. In order to make it work properly, we need > @@ -1789,16 +1781,6 @@ int memory_failure(unsigned long pfn, int flags) > */ > page_flags = p->flags; > > - /* > - * unpoison always clear PG_hwpoison inside page lock > - */ > - if (!PageHWPoison(p)) { > - pr_err("Memory failure: %#lx: just unpoisoned\n", pfn); > - num_poisoned_pages_dec(); > - unlock_page(p); > - put_page(p); > - goto unlock_mutex; > - } > if (hwpoison_filter(p)) { > if (TestClearPageHWPoison(p)) > num_poisoned_pages_dec(); > @@ -2016,17 +1998,6 @@ int unpoison_memory(unsigned long pfn) > goto unlock_mutex; > } > > - /* > - * unpoison_memory() can encounter thp only when the thp is being > - * worked by memory_failure() and the page lock is not held yet. > - * In such case, we yield to memory_failure() and make unpoison fail. > - */ > - if (!PageHuge(page) && PageTransHuge(page)) { > - unpoison_pr_info("Unpoison: Memory failure is now running on %#lx\n", > - pfn, &unpoison_rs); > - goto unlock_mutex; > - } > - > if (!get_hwpoison_page(p, flags)) { > if (TestClearPageHWPoison(p)) > num_poisoned_pages_dec(); > @@ -2035,20 +2006,12 @@ int unpoison_memory(unsigned long pfn) > goto unlock_mutex; > } > > - lock_page(page); > - /* > - * This test is racy because PG_hwpoison is set outside of page lock. > - * That's acceptable because that won't trigger kernel panic. Instead, > - * the PG_hwpoison page will be caught and isolated on the entrance to > - * the free buddy page pool. > - */ > if (TestClearPageHWPoison(page)) { > unpoison_pr_info("Unpoison: Software-unpoisoned page %#lx\n", > pfn, &unpoison_rs); > num_poisoned_pages_dec(); > freeit = 1; > } > - unlock_page(page); > > put_page(page); > if (freeit && !(pfn == my_zero_pfn(0) && page_count(p) == 1)) > -- > 2.25.1 >