From patchwork Fri Nov 17 16:14:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13459126 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 8E236C072A2 for ; Fri, 17 Nov 2023 16:15:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 211ED6B04F1; Fri, 17 Nov 2023 11:15:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C0446B04F3; Fri, 17 Nov 2023 11:15:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 05FB66B04F4; Fri, 17 Nov 2023 11:15:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E53CF6B04F1 for ; Fri, 17 Nov 2023 11:15:14 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A5A6EA0494 for ; Fri, 17 Nov 2023 16:15:14 +0000 (UTC) X-FDA: 81467945748.20.0F42309 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf03.hostedemail.com (Postfix) with ESMTP id D1F7120003 for ; Fri, 17 Nov 2023 16:15:12 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=eajgtCer; dmarc=none; spf=none (imf03.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=1700237712; 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=5qnFXc1Xogmh7PAIEEQ0Shj70PekKGvUt3R6/VGwhqA=; b=ywFiROYQ10QuxfQnDOKFD7Wag8U3G5CVZ+ynrqhVAzazc8SQqFmnY0kcEADNb5pfGzrRZC kpg4Kfn4NTBVPC6l6Usd2OR9VISOgPHVifpyostC4K4RO8NFNxmpcEoS2Y7abRHyJ0hF9r V6Cb0lwZpgBBJLVcWg67XjPcKlNLqaI= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=eajgtCer; dmarc=none; spf=none (imf03.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=1700237712; a=rsa-sha256; cv=none; b=8lTV+Xcoq4U926BVLmGsuHpg+of2z2dzgq0xib+m1rnZzIhFq9NCUgaQRZS8/MQEMA6Evp h2GuPCoI7zrq6oq8xBePaXAaLkdugEZBhBA3kNPyvla/aJ2hdz1qXctZvXJcgz0BA6qomH SLTRPoZb49rIWwXB1BOVIuwU3QMiz7A= 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=5qnFXc1Xogmh7PAIEEQ0Shj70PekKGvUt3R6/VGwhqA=; b=eajgtCermKMU/e17PoydSMDg9r +kz5k6bnBxxa9t7In5z9eci5kjX7tVUaXqZh+9RxzYJvhLiGT60uRDBHbuA7no6VvrrnVthyJvuLV pl8i/tVkgrMfhjjfvaaEHuvF3NDpQ24zf4m9HqFihpQ3vBLF/XeFwCdxQzgjv5m5frpWsQdT5zUDa HPb1KANQtiPQum5YxUn4dme7qift/JXUa9/FMi4K2LX/2Jm5zmMt7AY6/sLWHv3umATpyaGAr/Fl3 FWf/7zyh0qZpLFdDLd5hEQ3ul1AJfw8Rt6Ix+cMsejBKKv50kztvCiYuXE8ayVRz2nOZBekrg05Dg +MngwkxA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r41Uc-00AKZj-Na; Fri, 17 Nov 2023 16:14:54 +0000 From: "Matthew Wilcox (Oracle)" To: Naoya Horiguchi , Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 4/6] memory-failure: Use a folio in me_huge_page() Date: Fri, 17 Nov 2023 16:14:45 +0000 Message-Id: <20231117161447.2461643-5-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231117161447.2461643-1-willy@infradead.org> References: <20231117161447.2461643-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: xa5xhsk1dntzw9de9fsw4jhunxawtqie X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: D1F7120003 X-HE-Tag: 1700237712-803519 X-HE-Meta: U2FsdGVkX18gcNtJ0/7SWv+HrRM2mUZHPRlxqFjebHMwuSXxkqJRzkONBw6HsSlKJsoBr2MHFOnfEspbmAp9YRdKlrp1zr7Y03+/4AO7SQOttWYaUFjLzcSj5SnXCxawRErQvtfNxp15U9uDFLVEi4hIwZaNFvCp/r0d61jxXSxQ5BLzS3Ipe7/xaAekFCfc6PLmH1mB9Js8WbmHDCOvl/Pykdt4Z2UFlRRv3NPx55AXqUWAak7lRNCg07I0XMR0G+CL3+z4HCAsp6SFMeYodwG9T8gSoTt0PKa+1DfMJHID/16bvkAOpY0RLN3DctAn92UaufNGXOkaR8uVGY+63FoOwnCPM8HXQ5UJ7HvZF2/2p/lkYh5Ob0PnSHnbLRA5o8F5mG3x3z/HOK6P37inwBdLcnAgafsI0eh7w54iiZeR9debu3FRmCO2HCeguSgk5TgJklEgMfhDIHp2N8xtzKCOygfF3sL8b+TzYyAGaHvWWuj6biHlS5zfvRBqVTjaNxKAhYUbeptvl6aHWDXks7ILlzzPcqU6wvYGs/CLUS9JBmHIeWeDtyIO+y5CwOITUZgcYzL9kvDP75OGO3lQJyYHSgUkg5wRZLLRw/QseoSYWCkFnT5XKkY2ZktGQPIzH6X+CMtjMf10vhxzcYijV5zLpYBDkkQfbY6hWJViUntPI05JBIJj8eWL/LierCDPHONMWYbt8+nMP8BeVQUqJlIktDeVRVBitXmy9dtVHDi3BH0HO1NsQHy0hU7xyBjoiFNheYnhhvfpV45J23JEeZLfqMjYrQKXJOjdbwPsZoz402Tzi2a4AY20RdPCzHvKkCgaNi1hTl9uayilRe3XdudZQS38Oz0gQgf9uddgGT6/ET/ALbKrCG0trjDHubTbbyJjNQ3rmVdkAzg1og7TWC1sTsXytwIGVoQbNP9bks5i7BZty2eBS+xR4vm1idcg9CAQ/HyuzSXj/gk4gCq 3QHybDUX EouOcbftao2zWbRtdEU0gcdBaB37uHjV4oHdNtBCrvVdguT5OqcNymBMWyeW8JnNa1rcii9nkOf4MHAcBxjfKWoWSYMq7AhmJa/uPoyoT1adNdY6TNDqJs7Hr8Yu+vRDuuOWJfiypXiskJ4tZlAGE5Dzld5HMajlCy/2vSdMiwljeR6Uy75NijDRcxfPng78yScJKe6GpPx/DCkC/kTlC0Kb53KIaKEhjhv9u 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: This function was already explicitly calling compound_head(); unfortunately the compiler can't know that and elide the redundant calls to compound_head() buried in page_mapping(), unlock_page(), etc. Switch to using a folio, which does let us elide these calls. Signed-off-by: Matthew Wilcox (Oracle) --- mm/memory-failure.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index e73f2047ffcb..d97d247c0224 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1182,25 +1182,25 @@ static int me_swapcache_clean(struct page_state *ps, struct page *p) */ static int me_huge_page(struct page_state *ps, struct page *p) { + struct folio *folio = page_folio(p); int res; - struct page *hpage = compound_head(p); struct address_space *mapping; bool extra_pins = false; - mapping = page_mapping(hpage); + mapping = folio_mapping(folio); if (mapping) { - res = truncate_error_page(hpage, page_to_pfn(p), mapping); + res = truncate_error_page(&folio->page, page_to_pfn(p), mapping); /* The page is kept in page cache. */ extra_pins = true; - unlock_page(hpage); + folio_unlock(folio); } else { - unlock_page(hpage); + folio_unlock(folio); /* * migration entry prevents later access on error hugepage, * so we can free and dissolve it into buddy to save healthy * subpages. */ - put_page(hpage); + folio_put(folio); if (__page_handle_poison(p) >= 0) { page_ref_inc(p); res = MF_RECOVERED;