From patchwork Mon Dec 18 13:58:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13497024 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92F3DC35274 for ; Mon, 18 Dec 2023 13:58:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EBEE58D0007; Mon, 18 Dec 2023 08:58:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E6F1C8D0001; Mon, 18 Dec 2023 08:58:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CC25B8D0007; Mon, 18 Dec 2023 08:58:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B70428D0001 for ; Mon, 18 Dec 2023 08:58:51 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3ECBC1A1309 for ; Mon, 18 Dec 2023 13:58:51 +0000 (UTC) X-FDA: 81580094862.21.D458CC9 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf27.hostedemail.com (Postfix) with ESMTP id 97DE64001F for ; Mon, 18 Dec 2023 13:58:49 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=lj7R6Q+G; dmarc=none; spf=none (imf27.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702907929; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=y48/RgxA4nfcI2a4m0fGd6f8VrRcn5zgGTlb3Ss4JS8=; b=IVWztKBI6UlviplnEFls8vdXdv2xkAbdKa4sje0QFAgJ6ZFWhUKqjOG/6OmVTCC4aggAJG fHXLgODu8063/4/S7S4gmzoybUMXtXhgESNQnIT61EVzS4hhbkdKUkGJThdpWSvWtcYRa9 iCHZzuHXeQVx38vTlaQBFd5s8pfKJ1g= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=lj7R6Q+G; dmarc=none; spf=none (imf27.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702907929; a=rsa-sha256; cv=none; b=dzWOuNYbiWEX5HF6+2/XtZFRw2hX3ju3BxwITa8xqVIKbVXIU95bt2viyxabyfQ8zafoft Pe9zPWrivKh0UKjZpdPt5tFIbPitG9KFwqkRpSzuxv5rGjAO/3KtdI+htk1Egyy5LScznK eDM/6jrWP0VTi8c1se35LD0yT2bDZ+g= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=y48/RgxA4nfcI2a4m0fGd6f8VrRcn5zgGTlb3Ss4JS8=; b=lj7R6Q+Gh/P4ky+VC2j7LwEvYI wDbJ31fFiEvtIKehx+Q6fCRtVx9Z++4gkzRKJNSo1F2cq18NcCB1CkOozGh3OHZTyY7tXcLk9Npmc FG/YsObFXeN7Pz+XWQsxJeqBxw5I4hk/JDGeGE0648cOzSgdhSFg8d9Lys1jJb54FZrDZwcvXVN/G WQpV9A1AxcCpex4F3gBh1Zvc5msenhmhJ3HZgDWFe8o9WK4+CLC0fqlW/lzpW0KrOzVJY3/un/xig ovMvr1DEO8Ok8I7wB9Xb3PJ0H7k9GFqGPOM8YGmYMyapM/CEbMu/Rv1zjGQi8DUz5i5ioDbZ9DzkB sr7ivZRA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rFE8l-00DtCO-F4; Mon, 18 Dec 2023 13:58:39 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Naoya Horiguchi , Dan Williams , stable@vger.kernel.org Subject: [PATCH 2/3] mm/memory-failure: Check the mapcount of the precise page Date: Mon, 18 Dec 2023 13:58:36 +0000 Message-Id: <20231218135837.3310403-3-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231218135837.3310403-1-willy@infradead.org> References: <20231218135837.3310403-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 97DE64001F X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: bccthr1awhdhnnhmfugcxomucbhh6c5b X-HE-Tag: 1702907929-794399 X-HE-Meta: U2FsdGVkX185H84hoarlhzObFLiLOEIfDLKHDQNpsRPJ6Wpw8jR6TC3Q/ivUu3EHV4zCZJitiYzZ0p7kCSNwYzx2GA8b/iOkXQwjVLmvey3RK3sOZL0ddOiPe9R3Gbz+s7Ht+/dNIH93Y3YC2vHViNeOhrCdtsQnNq9xXk1OsTCUOMdTvKK6BlhlS+a6YYPYkwo8TTfU0aL0omHDuJS/dEjTDYdHmPcf6wZIiELeyBifpsGERUI/bsbxa6tM5Mt0Skjc9iPjVtCIdbknTpWw3Ce6ReB0wWMo60i/ikmcrzBMu+GRwKUOT7iHedrK6+k3j3tomF8VR2iGfX3NBjs5RZqDnWXRlfoK1xwRdJFvDpM3qIpctaPj19Z9qqnm522n8pvSkbAOd/LHfb1wiXYDuh2I6HNbHCvvP3+e82pHO4cMgsaMgWfM9f8riaJZ2lUoRl+74kYOXytacnTvlrNFOaxNZsjW4fNmZ0ly4GrVB8kStCnnm5MuPKr8pLqCd/DSZCUDqRURmT4zQRBMAB4uWDnYn469LFN5BzVP9dN+e/CsXVmbvZSlGfYFGhYzakknREksQzzMDn7M7u6SocunXvIUxC+8mHfjBO9CW1uwatkZUYnFUp4lAfe4EF3UMWEL/FbISm81z3hQExRm2iezlwWRFMRWXNV6Mx6FI6IEpczvBar1s2b986r8fUJ2l6spETP4fU+2vQD32O2KXHcHzzujIFs2fpbf3Fem2IexYrczeuWi4GGVWP/0e/lFjHNe1WCGwRS4RR+ZjVKkbqawF/MOYDukeqENFIlH+89hx9cWHQA06TnBJ0iXZony0QPWxolHuSFkhTDPodAOGXD3GWiK+yUdyJjixqYShX1avQUUA7WNKfI6N2sTAG0hPaqYKP2rGeVfbbIHhihRNA1agJWkrYB+Rss7Gy+RABdl0769yPnkPiqdqif0rZDg+1HBw+TWPO72GcmMlwUusb5 3AUqKJJW tH4Nj550S281xeeYogNWe3rjYQXB/f4yeY1gyOx8bjOSPDtZwhqGBakYc14HjSCsYAZcX+O+MWsvzKSWeBVoaqfzYCJGvApH6UYSYfw+rctnsQyd20WO70ag8RktVZ2iYE3Znpc0aC3aLgRmWHBXGXNFrsyohRz4d7zMUowzAV9AgEpb6Tep7S4mpr66J5AWRVP9vGSMPYPGsuonE6wYViT6ewirjzFbCFmcaMUswVZnWnkk= 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: List-Subscribe: List-Unsubscribe: A process may map only some of the pages in a folio, and might be missed if it maps the poisoned page but not the head page. Or it might be unnecessarily hit if it maps the head page, but not the poisoned page. Fixes: 7af446a841a2 ("HWPOISON, hugetlb: enable error handling path for hugepage") Cc: stable@vger.kernel.org Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 6953bda11e6e..82e15baabb48 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1570,7 +1570,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, * This check implies we don't kill processes if their pages * are in the swap cache early. Those are always late kills. */ - if (!page_mapped(hpage)) + if (!page_mapped(p)) return true; if (PageSwapCache(p)) { @@ -1621,10 +1621,10 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, try_to_unmap(folio, ttu); } - unmap_success = !page_mapped(hpage); + unmap_success = !page_mapped(p); if (!unmap_success) pr_err("%#lx: failed to unmap page (mapcount=%d)\n", - pfn, page_mapcount(hpage)); + pfn, page_mapcount(p)); /* * try_to_unmap() might put mlocked page in lru cache, so call