From patchwork Tue Aug 17 05:37:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 12440537 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.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 C5908C432BE for ; Tue, 17 Aug 2021 05:37:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 428C260F5E for ; Tue, 17 Aug 2021 05:37:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 428C260F5E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.dev Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id AC0CB6B006C; Tue, 17 Aug 2021 01:37:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A6ED86B0072; Tue, 17 Aug 2021 01:37:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 95D266B0073; Tue, 17 Aug 2021 01:37:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0176.hostedemail.com [216.40.44.176]) by kanga.kvack.org (Postfix) with ESMTP id 78D1D6B006C for ; Tue, 17 Aug 2021 01:37:19 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id F110E22AC9 for ; Tue, 17 Aug 2021 05:37:18 +0000 (UTC) X-FDA: 78483464556.14.2D0F368 Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by imf20.hostedemail.com (Postfix) with ESMTP id 48786D005888 for ; Tue, 17 Aug 2021 05:37:18 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1629178636; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=qupgUTuI0E9peSKKuud5v7yCUmrTA6ykPIz7pdKMrso=; b=klN0Nyv8cnK9+E8bLBKV5zAFuwmNH3qhFivj/HoycHACDhI68c1pflaeLEVp+x3JkZnEdH JpzwaX/E5qtmwPMc07eQyiuthEfWz+BfPB+fZKu2fhTh/UatTdegVD9eHSIgMXn0NyPczE mnZAeRlii22o9RbqZflP8trpWIWYep4= From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , Tony Luck , Oscar Salvador , Muchun Song , Mike Kravetz , Michal Hocko , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v1] mm/hwpoison: Retry with shake_page() for unhandlable pages Date: Tue, 17 Aug 2021 14:37:03 +0900 Message-Id: <20210817053703.2267588-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: naoya.horiguchi@linux.dev X-Rspamd-Queue-Id: 48786D005888 Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=klN0Nyv8; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf20.hostedemail.com: domain of naoya.horiguchi@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=naoya.horiguchi@linux.dev X-Rspamd-Server: rspam04 X-Stat-Signature: 45qkw7coo6iy36uurdr5q1ard6gsshjy X-HE-Tag: 1629178638-164248 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 HWPoisonHandlable() sometimes returns false for typical user pages due to races with average memory events like transfers over LRU lists. This causes failures in hwpoison handling. There's retry code for such a case but does not work because the retry loop reaches the retry limit too quickly before the page settles down to handlable state. Let get_any_page() call shake_page() to fix it. Fixes: 25182f05ffed ("mm,hwpoison: fix race with hugetlb page allocation") Reported-by: Tony Luck Signed-off-by: Naoya Horiguchi Cc: stable@vger.kernel.org # 5.13 --- mm/memory-failure.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git v5.14-rc6/mm/memory-failure.c v5.14-rc6_patched/mm/memory-failure.c index eefd823deb67..aa6592540f17 100644 --- v5.14-rc6/mm/memory-failure.c +++ v5.14-rc6_patched/mm/memory-failure.c @@ -1146,7 +1146,7 @@ static int __get_hwpoison_page(struct page *page) * unexpected races caused by taking a page refcount. */ if (!HWPoisonHandlable(head)) - return 0; + return -EBUSY; if (PageTransHuge(head)) { /* @@ -1199,9 +1199,14 @@ static int get_any_page(struct page *p, unsigned long flags) } goto out; } else if (ret == -EBUSY) { - /* We raced with freeing huge page to buddy, retry. */ - if (pass++ < 3) + /* + * We raced with (possibly temporary) unhandlable + * page, retry. + */ + if (pass++ < 3) { + shake_page(p, 1); goto try_again; + } goto out; } }