From patchwork Mon Jun 14 02:12:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 12318031 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 DC687C48BE8 for ; Mon, 14 Jun 2021 02:12:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 719BA613AB for ; Mon, 14 Jun 2021 02:12:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 719BA613AB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 132726B0072; Sun, 13 Jun 2021 22:12:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 10AD76B0073; Sun, 13 Jun 2021 22:12:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EEF226B0074; Sun, 13 Jun 2021 22:12:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0102.hostedemail.com [216.40.44.102]) by kanga.kvack.org (Postfix) with ESMTP id BC8566B0072 for ; Sun, 13 Jun 2021 22:12:32 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 60C8E8249980 for ; Mon, 14 Jun 2021 02:12:32 +0000 (UTC) X-FDA: 78250705344.03.11FFB93 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by imf08.hostedemail.com (Postfix) with ESMTP id 2DF3F801912B for ; Mon, 14 Jun 2021 02:12:24 +0000 (UTC) Received: by mail-pj1-f51.google.com with SMTP id ei4so8841977pjb.3 for ; Sun, 13 Jun 2021 19:12:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0vdMGIW3kH9wsKcFDP9ep4AZRTLAnVl6tpWr1FVt4M0=; b=Mpd1k+BpOuolkJoCsSxTQ13L6/VHwy0QbCKwaGlxzCMP/wxROPvRVQ9NNsbITJD4Lq n0e9Ew2CprYBhVPB8b6K/UENJrJ0KAiAcezsoZUrMBW1P4qdeCHuPBuJPftPRSSLBj+1 yMYEse3kXdDCDdlEHL/vpO1Rew/NoIIjbfz/dGMcEmBS0ZShaURcYgsH4eTr42Zy3VNO Z8Y+UHcPa89mL8n/INVVR4hPm0zqYDYPjvNul/AumfOcdSlVwjope/8j4mxW9g6eFaHv 9yzBs2/uTefvTtnZczQOWT697Syo8X0c3U6RUaNLM6LGd7lrOWB3behfItAyp0WCcmNc 6nDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0vdMGIW3kH9wsKcFDP9ep4AZRTLAnVl6tpWr1FVt4M0=; b=MnLTh0duwTZJyIKJMFYWKdeTr/glYQPjjwV2lfldD8o72b3ajGPcq+NhXaQHxy5W9Z T3M7Q/whkkgIZs3Esz7COyqdzQupIDZw3UKkncfVMZBFR1/p6Y5E5FmT9Ec7QOujIcT0 vMECQRNqkQjynsfZerqvOtD5MYGskFt1pVGizSmqOowTNFFKY90NTQcg7lTElmdKj69g Y6GolbOHBpEkGTF5Ddcfv7/cU/g1B0aFnOg+kDSPR32NNCMOgauIpPQQYZfh+xmeSem3 IF27k6Ot2LNj05ww0o1u/DXDkqHrJwcPVaVVeGnUZlY8CBpatkbBtlgl0hJiAMs+5L6z kdcg== X-Gm-Message-State: AOAM5316AZGQOb8rbMbzetyH0rTNpJ3QL0XCeDW6JGTbCnfVNuZRp0ts Xpc2HPkP8rgHZzua1eBtfmVSj31ChyVq X-Google-Smtp-Source: ABdhPJy9ExdxUVcz/l5+hEZ86ATtZOzE+wZeDhbCyXaRLE0w51mObupsZVVjbyjVrKMZrjT2TiDPBQ== X-Received: by 2002:a17:90a:708a:: with SMTP id g10mr21223850pjk.108.1623636751104; Sun, 13 Jun 2021 19:12:31 -0700 (PDT) Received: from localhost.localdomain (h175-177-040-153.catv02.itscom.jp. [175.177.40.153]) by smtp.gmail.com with ESMTPSA id z14sm10952986pfn.11.2021.06.13.19.12.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Jun 2021 19:12:30 -0700 (PDT) From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , David Hildenbrand , Oscar Salvador , Michal Hocko , Ding Hui , Tony Luck , "Aneesh Kumar K.V" , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v1 2/6] mm/hwpoison: remove race consideration Date: Mon, 14 Jun 2021 11:12:08 +0900 Message-Id: <20210614021212.223326-3-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614021212.223326-1-nao.horiguchi@gmail.com> References: <20210614021212.223326-1-nao.horiguchi@gmail.com> MIME-Version: 1.0 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=Mpd1k+Bp; spf=pass (imf08.hostedemail.com: domain of naohoriguchi@gmail.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=naohoriguchi@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: tz9gakztura6qb6qoqocfyws8uwk5y4d X-Rspamd-Queue-Id: 2DF3F801912B X-Rspamd-Server: rspam06 X-HE-Tag: 1623636744-972749 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: 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. Signed-off-by: Naoya Horiguchi --- mm/memory-failure.c | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git v5.13-rc5/mm/memory-failure.c v5.13-rc5_patched/mm/memory-failure.c index 280eb6d6dd15..e7910386fc9c 100644 --- v5.13-rc5/mm/memory-failure.c +++ v5.13-rc5_patched/mm/memory-failure.c @@ -1461,14 +1461,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 @@ -1730,16 +1722,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(); @@ -1956,17 +1938,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(); @@ -1975,20 +1946,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))