From patchwork Fri Mar 1 21:47:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13579165 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 91F41C5475B for ; Fri, 1 Mar 2024 21:47:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E04706B009F; Fri, 1 Mar 2024 16:47:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D8D896B00A0; Fri, 1 Mar 2024 16:47:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BDF0D6B00A1; Fri, 1 Mar 2024 16:47:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id AB9816B009F for ; Fri, 1 Mar 2024 16:47:22 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7F2E11C0E6E for ; Fri, 1 Mar 2024 21:47:22 +0000 (UTC) X-FDA: 81849806724.23.9C1B414 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf25.hostedemail.com (Postfix) with ESMTP id E7403A001E for ; Fri, 1 Mar 2024 21:47:20 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=ld9FyidN; dmarc=none; spf=none (imf25.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=1709329641; 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=/DHmW4lsy5cWc2w+CyTR97vxYADmnbZh/vvNjDWdKlo=; b=V8gVHJLnT5oijY9zEASoB2U2hewyE3AOW7ZITuY8RNTMAE1mqCqhY1g3yUDx7d8EMVCAhX oOd0lsNO34XRZ590M6l72XMyF66hGrQVB+AW/A8uB5xGqM6QmRp6mvc9hRmwXdeH2ZJYvn Vozl+mpqszep3D65NrGbnfVkoiYSPio= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=ld9FyidN; dmarc=none; spf=none (imf25.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=1709329641; a=rsa-sha256; cv=none; b=eXb8r7a6wRoWyrMkBpCs2LR1zMbZOAWrHcDN4gRTRqEQfecKPb5F91UcIwEdu6aSGkJCdc GAiyoJHKq6pJKUtmwACQuINB3NxhEq3qHKi1NhxOSaSlYY19CvJkw5tpWakqyjn74LFdk5 eiZ+bniwPQBkOSYVoPgdMA6oXHNBybc= 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=/DHmW4lsy5cWc2w+CyTR97vxYADmnbZh/vvNjDWdKlo=; b=ld9FyidNHd6q9I4dl5lgyHFUPD 1XPOy1eBvmwS9n3uEABjERxW54V5aC1RDVmO4vZhHusKXBV/QeHis+OMsOs08fR2M3tWeL6ZOIdu2 MM03S40zP4n+bSNeJJxDnl4P9z+ubmhTywEOOrJN6oqhUBzYmWk3FHQng8XDmogEIKJtkUMv9Y4UQ KJzvyxdbSgVJp3UkbMnb3GG815mraGeVr1c0D0S6aZRD3yfxisIAXEsErggXkbjY6Tl9XWpBU9RGO vxfRWYddzhqpxYY+tWtqNnh93r+zsyo2LL4FA5+ws36JDVPDBtnWLgiJpmwJ+4H7oOGxXPrF3d2QD 4zm3FguA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgAin-0000000ByEl-32Yw; Fri, 01 Mar 2024 21:47:13 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Oscar Salvador Subject: [PATCH 3/5] memory-failure: Use hugetlb_pfn_folio Date: Fri, 1 Mar 2024 21:47:08 +0000 Message-ID: <20240301214712.2853147-4-willy@infradead.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240301214712.2853147-1-willy@infradead.org> References: <20240301214712.2853147-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: w3bnbidc6iqfiw8qje7b8aferiar7k3e X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: E7403A001E X-HE-Tag: 1709329640-768788 X-HE-Meta: U2FsdGVkX1/LlBbSjfyhTwgAjFyDo2dW91v29aP7rkYVrXY+Nr0EearOW14hdFhhDB9kMv24kFENdRBL6dur+HGPYDnY7uXGdJi2NdcUCMQHk/HvnfzWerKrpFYLcVn/TLLlkDwwsGWhlhwfgPivk5pAvBolyDS3YomiAxyIQjauLcxxbJUOTInQG1Qycokv6hXHpsvJF211+7oeOzIKor2PFXJLHHinOaOCRcw42ISS9V3CsU7V2G2G8UMWPLbjNGq6XZ5di/A7wuet18aGUoNcHrCKw6GUO4kQ4w9AmRVH5LXVre6LwZHkLHVoSgiDy3gWeHu0yqlyGc/bBuOJlzOsq34ra3AMp8x1KGCLUNiw+5dg0yhfv6cF3uqc9Kl4M90SiJmgR1xYVrpNY82koYvSXSqz+8wNk5JfVlDSEFufLe627GikqZHk9+rfNJjYz52xFipciQ0nbJnVpG/Na27VnuuR47EbbjNDGt/tdMHhvpLcj5Jqesw2EUwJRGdz9m1z/49u0SLie/kYQMEOdLtOz5SR/4YloFah0tOVwFwHSqw5DIRy85ZSnTZYQC35pfc11BP6BI8OQ0DZYd1hFUCVbJTLibW+MNlWpr9PGnfps7XMLhFYMp9EFjR5/gucNIv39ML55gP3LGBNMART1OixbqkxXD1/lOc4E5YybdMxqW1wzlFbYlpOvRImm+2h3dp86zQ8w4p7IaW+uea/rlcy5zlK4406NyGJ8s2bFzpnhhTs+JQkIeaH79k0cYpzvRnjxJ41t1daioVbHy9AmPIyehNZLcnVtjHViHXL7RpPfqp0JjMMHpaF2uu2Tk6iOBEslJl1f9QAJTKtgyYLH29zeTsN1f75JimQDSiQ1oIOgCbQsuPFe1bX0CI6JOtsKtN9mtExnsNkoS1SMfwQBQHB9bNiSIk0 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: Calling folio_test_hugetlb() is inefficient; hugetlb_pfn_folio() does less work. This is a safe use of hugetlb_pfn_folio() as __get_huge_page_for_hwpoison() holds the hugetlb_lock. Signed-off-by: Matthew Wilcox (Oracle) --- 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 9349948f1abf..e42d0cd7888d 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1987,12 +1987,12 @@ void folio_clear_hugetlb_hwpoison(struct folio *folio) int __get_huge_page_for_hwpoison(unsigned long pfn, int flags, bool *migratable_cleared) { - struct page *page = pfn_to_page(pfn); - struct folio *folio = page_folio(page); + struct folio *folio; int ret = 2; /* fallback to normal page handling */ bool count_increased = false; - if (!folio_test_hugetlb(folio)) + folio = hwpoison_pfn_folio(pfn); + if (!folio) goto out; if (flags & MF_COUNT_INCREASED) {