Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2896330pxb; Tue, 24 Aug 2021 10:05:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqoOP5g/Vjc+Atn8slVjAYZ82ohcab1Fvdzb0lyQodFgH0uoTQFJqlMKZW5DDVEW2dehJv X-Received: by 2002:a92:d351:: with SMTP id a17mr18923319ilh.167.1629824733527; Tue, 24 Aug 2021 10:05:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629824733; cv=none; d=google.com; s=arc-20160816; b=P9KD3LM5McXpLeAiHvKeHmY87pvnaZKrmcltFwN84wM/bWEPBH1NCboB+y0uv/o6jP 09gYW06/sdOtv64AN/XyVC14rTI7iUg22kZqZHgfxLSw6NxfuO9op2pVeo2z5AmBOfHD LcnpJKGbSBtXtm2d7OnOoHkS5/kuhXa9mhgxpQMH0dx2rLmPUq+mjedXLzIkVGhnCSvf kH/3bfcug2P/4Et32S/1mE9rjd0oNvExFxa3DoLii6V6nZZMKnrWZ55fFJvaIxHrwLrZ 2re6pJYGSxwtYDrL9Y0Khj1i2sFd+Nv6nBz/wREh+M3yppYzYxGUzlNyjKHMdtBwuyaS TL2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yTGfCxSEmR1jYChxdAb6a0/L+CB7ic6oxzwUG43SjXM=; b=FSmCXTkm1JEq9LVimHFzcH/FcIraeRjG7jq35q7jZOzHxHC+QB7cTF9gY64QnkybY1 CTFEDjyWdhKtMZAHgm2R8Qqf1NhhEN0Noi8mgobYe5RoS83zeUxoyVVFB0/gMuC7xokQ 6Tu6a6TcuS/AOUdQBxxsQQkAg15+6LIZGNL5M6dATmKRYBtY6SqUftc77WrJakMAV4zx pSKCiXsZxsn+1AHhYiOHnFn0A0hnhyGIlPQ15saF+CnmrjO2ksnSaxlsTpTrzoQKUHZP rn/kVEyA1dqzgGiU4i616+pr48rbzQeDt6m9ansrgOmMMu5xFDhsQcZcJweXpGku3pFI 2tJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jT8vQL3I; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t39si20696844jal.96.2021.08.24.10.05.18; Tue, 24 Aug 2021 10:05:33 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=jT8vQL3I; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238570AbhHXRFP (ORCPT + 99 others); Tue, 24 Aug 2021 13:05:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:39258 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234877AbhHXRCO (ORCPT ); Tue, 24 Aug 2021 13:02:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B648D61882; Tue, 24 Aug 2021 16:58:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629824289; bh=XeeMr38iQ0i4olwwCt11F3iC7LgHZ7gcMd/4yzKy7/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jT8vQL3IQV4IgKJdD7CRt67FGu6rcCnsD0Pq19s74aKLzUPYYkDzk7Z83sYLHzEAU HGC7f2gGvNtHVXFBXSuG6s8U/mgrWe2g02eKSvPHxkrncL45ttj3ac+kYTEbXw0gBI x2qvHCyWXlHBxRryPRgNLdKgkjjZwMqJZAK80G369E2CbIpekKspcpmb5c02GdqnLl 5ISI0jrBDqxLK+a9yfhIkrz7/oBpaBEne1y9omI3MD7i6kk8A0nVAPaVveQzRYdmfc zaVtr4qsGduR5KfG+2Ij7TfGLD+tmILQkvQurCjMULIT9xAneiFmGJLAHmq+wfzPDX J2k3SYcqEeuWw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Naoya Horiguchi , Tony Luck , Yang Shi , Oscar Salvador , Muchun Song , Mike Kravetz , Michal Hocko , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.13 122/127] mm/hwpoison: retry with shake_page() for unhandlable pages Date: Tue, 24 Aug 2021 12:56:02 -0400 Message-Id: <20210824165607.709387-123-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210824165607.709387-1-sashal@kernel.org> References: <20210824165607.709387-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.13.13-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.13.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.13.13-rc1 X-KernelTest-Deadline: 2021-08-26T16:55+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Naoya Horiguchi [ Upstream commit fcc00621d88b274b5dffd8daeea71d0e4c28b84e ] 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. [naoya.horiguchi@nec.com: get_any_page(): return -EIO when retry limit reached] Link: https://lkml.kernel.org/r/20210819001958.2365157-1-naoya.horiguchi@linux.dev Link: https://lkml.kernel.org/r/20210817053703.2267588-1-naoya.horiguchi@linux.dev Fixes: 25182f05ffed ("mm,hwpoison: fix race with hugetlb page allocation") Signed-off-by: Naoya Horiguchi Reported-by: Tony Luck Reviewed-by: Yang Shi Cc: Oscar Salvador Cc: Muchun Song Cc: Mike Kravetz Cc: Michal Hocko Cc: [5.13+] Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- mm/memory-failure.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 18e83150194a..624763fdecc5 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -990,7 +990,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)) { /* @@ -1043,9 +1043,15 @@ try_again: } 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; + } + ret = -EIO; goto out; } } -- 2.30.2