From patchwork Fri May 26 07:55:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13256582 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 A3BD4C7EE2D for ; Fri, 26 May 2023 07:56:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B8466B0075; Fri, 26 May 2023 03:56:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 741986B007B; Fri, 26 May 2023 03:56:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 593B5900002; Fri, 26 May 2023 03:56:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 415986B0078 for ; Fri, 26 May 2023 03:56:08 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 20544120117 for ; Fri, 26 May 2023 07:56:08 +0000 (UTC) X-FDA: 80831648016.03.DECA166 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf28.hostedemail.com (Postfix) with ESMTP id 6D2ACC0003 for ; Fri, 26 May 2023 07:56:05 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=LdiDWYPf; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=none (imf28.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685087766; h=from:from:sender: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=5oQ2gGbUsqL42uQDz21dyQWBbUA0px4CnOLURAD/lus=; b=E6BYNYk6r0jb2wlu76FayJqzMd9/LOIeY4GLolUAmDEWFsvyjW1Fz5l3l+zQxJAcHbSAvx mft3jAzKyFPoRBys7i4mDsN8i0DY/IQhKPlcBv53mtj7eiCoilVGu7jPC6j5JQ5kMn4CGq OaTtiQcdyerlTsGoCwiSwXmDeHgYFow= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=LdiDWYPf; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=none (imf28.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685087766; a=rsa-sha256; cv=none; b=Yol0EL6dJxQeJvnzShc6A3FVooymheh5fkkESXaXM1ex4Erd1fWiVtJU6i2ZdyqL+N/wBI lYzWg6bJf6PHS6ysW4rVYk5qMMkFT7ARS166lb9o/X9VO4erUbpm8GX7oAOeyI8keyALS7 kCxf80I8hsDyoQRefrDjgm+dQ8+r4Tc= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=5oQ2gGbUsqL42uQDz21dyQWBbUA0px4CnOLURAD/lus=; b=LdiDWYPfbsR2VwE3muTukBHf1n 2WKuZw7xVn16RN6k6Wo9ylU0o5DsPwzzrnruYbzYdoYyEpJt744EXDXhFgaq3aPLQM0XtiDj2f8FP 2plHBSw0sndtNX7DTHqerD4102mCieETYl1G0dRVa+cHO3vzNpp7xWDo8hVulJyMeNAOkZv4L98nW 6TmrmiHMZRz3tMGsyF1olHjbXr53o35bSOXIQ23JnCL7T/TEVq47iBber3uY3gk1HYKtkAuea4Vam CYKjwRSPO0HEhImDxfLN6W/tI67qgSTWbDSI9uMVp9MT7NiJOiaImnK7AjLb+fCQHpyGYE6dCefwT r8p56qVA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1q2SIj-001WZg-2T; Fri, 26 May 2023 07:55:53 +0000 From: Luis Chamberlain To: hughd@google.com, akpm@linux-foundation.org, willy@infradead.org, brauner@kernel.org, djwong@kernel.org Cc: p.raghav@samsung.com, da.gomez@samsung.com, rohan.puri@samsung.com, rpuri.linux@gmail.com, a.manzanares@samsung.com, dave@stgolabs.net, yosryahmed@google.com, keescook@chromium.org, hare@suse.de, kbusch@kernel.org, mcgrof@kernel.org, patches@lists.linux.dev, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC v2 1/8] page_flags: add is_folio_hwpoison() Date: Fri, 26 May 2023 00:55:45 -0700 Message-Id: <20230526075552.363524-2-mcgrof@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230526075552.363524-1-mcgrof@kernel.org> References: <20230526075552.363524-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 6D2ACC0003 X-Stat-Signature: fnpy3jaihr43466hz1ctfwkdcqkgioks X-HE-Tag: 1685087765-479923 X-HE-Meta: U2FsdGVkX1+nUZoP0JpVaO3mZF/1sccPy9ssgJCjhLHx+IHAkRgk9ALi2fmoCk/DTDd5RPd4BOlQRMmGEsNYSOPuuHr5SyV6du5rYwAS+t6aHESpUkzl6c80cCuQziNqgj04z3A4GqvT/3G8swoAZ7TC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VoGf8M3fn/chqC3XqMzSNEaNno3vqQeCgZo5Lutgc761eDcMWM5KE9qy4i6BCQkT6wLjWhb8fbnGAlFRtnjeIb6ZamG+KXb+S+W+ZR2oySyDo3hfW2xq/cpHDWTBdRQljtSic/OmmybbbHR7tkAuqv0gsXgFhC+lrtZn8nxwQEruZa9tUYblfrIQKdh6ME3D1/z+MvRrrRZUgL3nBgJdTlhYxVr6S0m7hPghf+o9ANUYpvle4fU5Dn3hoW/eMeR2AaHIDXmu+oRrEXLxwFc+RmROmSIOaFF011/I= 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: Provide a helper similar to is_page_hwpoison() for folios which tests the first head and if the folio is large any page in the folio is tested for the poison flag. Signed-off-by: Luis Chamberlain --- include/linux/page-flags.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 1c68d67b832f..4d5f395edf03 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -883,6 +883,13 @@ static inline bool is_page_hwpoison(struct page *page) return PageHuge(page) && PageHWPoison(compound_head(page)); } +static inline bool is_folio_hwpoison(struct folio *folio) +{ + if (folio_test_hwpoison(folio)) + return true; + return folio_test_large(folio) && folio_test_has_hwpoisoned(folio); +} + /* * For pages that are never mapped to userspace (and aren't PageSlab), * page_type may be used. Because it is initialised to -1, we invert the