From patchwork Thu Jan 11 15:24:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13517542 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 EA3FDC47422 for ; Thu, 11 Jan 2024 15:24:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA7EF6B0099; Thu, 11 Jan 2024 10:24:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A5A5D6B009A; Thu, 11 Jan 2024 10:24:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8AEE16B009B; Thu, 11 Jan 2024 10:24:57 -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 64CE16B0099 for ; Thu, 11 Jan 2024 10:24:57 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1C1AB1A03A9 for ; Thu, 11 Jan 2024 15:24:57 +0000 (UTC) X-FDA: 81667403034.13.5F144FC Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf12.hostedemail.com (Postfix) with ESMTP id 5272B4000F for ; Thu, 11 Jan 2024 15:24:54 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=WLvKEMaR; dmarc=none; spf=none (imf12.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=1704986695; 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=cwPZenCs5tEi8Hk4LaFtzjhgBXHRX0Dio8DzNCbpitA=; b=CE422pk/60Hj5OCEt0DX20wLVs62rwQPaE5ujNkipen5qgHrGvYJiB4xxwg2viRxpYKa7Q EJTtxU391K43unMfNkx1MtpXqqB78sXoMSlS396OqeHV9t391j04R9QccdbumAipXI/XMC bQ/lrcXHqF4neFsfy6HNd6l0ity3sPE= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=WLvKEMaR; dmarc=none; spf=none (imf12.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=1704986695; a=rsa-sha256; cv=none; b=4J+zr4nVMEDR/v0kcCBsS7fk5YqCslk6oZeM6TQGqKC3oQw1aatDZ7aJcg5h2zON9MRxdH kB27kyM9trK3uJzgOG3wczr4WOjeElp2Zlz93t/djCZYhCR7ZRaZjtcxuia9aqLphVLRB7 ss8MvyOdp9oQ1tzZGmmB0OucwmLRbek= 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=cwPZenCs5tEi8Hk4LaFtzjhgBXHRX0Dio8DzNCbpitA=; b=WLvKEMaRcwYqspQuMwl4Svoq82 xeKIGrZQRRsfMMMHvf6/3AFadgthcHgwL97RUZJaRAdfi5LruvSjkRw9Zect0ZFXF8M4ztGYFwdwf vtyLZwZVZ29gp9+SXupcdt1Z5UrUpp74WiqkObEXeyQlLoAD7DB0kfZPjl33bUjkPQmge4izvgTfy b1mg/RvGWLB0Dfhh9wlbIbxg/lgXeQFw8aAC2pej+Aaq5dx4uEPM+i+14+X333cogocV8ydnBvCc4 M8SIPWknkQtsyBZoasDv0qZey7CoqJ6chamKz5y7sI5sdlBhPqCuDSCihr7ag1R0dwXAKaVPmC72j onE9uwFg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rNwv1-00E9su-VZ; Thu, 11 Jan 2024 15:24:32 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: Kefeng Wang , linux-mm@kvack.org, david@redhat.com, linux-s390@vger.kernel.org, Matthew Wilcox Subject: [PATCH v3 08/10] mm: Convert to should_zap_page() to should_zap_folio() Date: Thu, 11 Jan 2024 15:24:27 +0000 Message-Id: <20240111152429.3374566-9-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20240111152429.3374566-1-willy@infradead.org> References: <20240111152429.3374566-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5272B4000F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 4iafubhhxji4p47i56m4ef7uhfb3zfh8 X-HE-Tag: 1704986694-266453 X-HE-Meta: U2FsdGVkX1/5UF0CGr++FbLP/drE+B/jsebS1mgEB6RKHh9j9lNdooIeTXxvmjGJSmSaIZG4Gkq9vZIFLiXoX8H5+QrG9em5Vi8/2wpAQ2j/xQS2Jl9TVs5Og6bNGDeCB7w4SEOth5kupe5YifwJ0if1tiF+7kGnit/nRhJrYwRNqY5LEYZdHHPF+TXarLddnEI2C1QWy/cfBm3Gz6Ghf+HTT7Gu5qHge73oQ2pYoz3ICXJ/xpXw6IGYKbTz5KtkNZ9w2cd5qsONr8U78K9nYWW8Q2COsJEi0LEEfqHfFUAmpFlY1t3WwQzfXLwf0xZp4BtJ+u7/UNk1SNn1Lh7TC5jpKS46exM0QJl7ZPILPrLUGQ2nx2TSaQ2NIhlKbfslDW+oKIvZY9hMaGjMk5SlaDZ49uKLkuk3313+BZK1jc8S3GUuKHC/cGi6n4wKlQwxmjbz96zybA0QzopfnVwJdTJ2svmOXIA6ZcHt9YKX2iBvZ0OS/TSruqGNelvkKhapE9Ia4UF14lanN+l35Y3IOrQpPUVESUnyWkztza3+YoKx8jCRQiAMM7IyTmAV8YhTwVtKxJ0g9hkygOjauI4KDM0PrILxgfLQqSZHBGqL0miNJtpviynHKC7DT31vEatN8gVtnQ2UKA3YbLh5K6k0gWXwTT/PHs9Br94yQraGMLrHdgEMESxUKK8FN/bcN9Mvwj6As9qsE/kTRKgHX+HUvQGI9u9ohJA4xOZ71/KHiobe2vdXTa9eoT06X842GDKFm4HUaCJeejHO3IIifyqNw6ZcCg8U4WQM+T19Yv0Id4w9Q1MjhIvanoz1ao1aTNk45YS58Mk3vPtAPUaeSm6v2cBoccL/XHtH9QdIklmdL+FexNbjC7ob4JlLRH+ggYgzGSj9IisclvD3tmsP9sKBHHEZRfptiRd2T4NhBNABt89Q4TC6f1v6PfWT9NmWz51jOGk0hXsUaxjbWpOh+mP kxvCNeV9 brEMIU4uAfk/4447Ybw3xOquAcmUPLN6CByxNQrRUYn4yFRuAtsPoLdsPu3L8DAqVGYEt605nedtP1vgdy+uhD7HoO9tta5XOAbETLzWs7Wz+6pAjTCzMHPfHCk/VCzUhyAE00+hGYoC8zh4iz9IpTeRt7O2MxmPoAF/tANaIUaCMn0h7n41/m3qPyfsH8GS3dGL7r+HyLCQ74+4w8I9DJyHvu/WAneTvbDH1crvSpLpH5prf3urx89qVSQ== 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: From: Kefeng Wang Make should_zap_page() take a folio and rename it to should_zap_folio() as preparation for converting mm counter functions to take a folio. Saves a call to compound_head() hidden inside PageAnon(). Signed-off-by: Kefeng Wang Signed-off-by: Matthew Wilcox (Oracle) --- mm/memory.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 60aa08f2ccdc..b73322ab9fd6 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1369,19 +1369,20 @@ static inline bool should_zap_cows(struct zap_details *details) return details->even_cows; } -/* Decides whether we should zap this page with the page pointer specified */ -static inline bool should_zap_page(struct zap_details *details, struct page *page) +/* Decides whether we should zap this folio with the folio pointer specified */ +static inline bool should_zap_folio(struct zap_details *details, + struct folio *folio) { - /* If we can make a decision without *page.. */ + /* If we can make a decision without *folio.. */ if (should_zap_cows(details)) return true; - /* E.g. the caller passes NULL for the case of a zero page */ - if (!page) + /* E.g. the caller passes NULL for the case of a zero folio */ + if (!folio) return true; - /* Otherwise we should only zap non-anon pages */ - return !PageAnon(page); + /* Otherwise we should only zap non-anon folios */ + return !folio_test_anon(folio); } static inline bool zap_drop_file_uffd_wp(struct zap_details *details) @@ -1447,7 +1448,10 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, unsigned int delay_rmap; page = vm_normal_page(vma, addr, ptent); - if (unlikely(!should_zap_page(details, page))) + if (page) + folio = page_folio(page); + + if (unlikely(!should_zap_folio(details, folio))) continue; ptent = ptep_get_and_clear_full(mm, addr, pte, tlb->fullmm); @@ -1460,7 +1464,6 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, continue; } - folio = page_folio(page); delay_rmap = 0; if (!folio_test_anon(folio)) { if (pte_dirty(ptent)) { @@ -1492,7 +1495,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, is_device_exclusive_entry(entry)) { page = pfn_swap_entry_to_page(entry); folio = page_folio(page); - if (unlikely(!should_zap_page(details, page))) + if (unlikely(!should_zap_folio(details, folio))) continue; /* * Both device private/exclusive mappings should only @@ -1513,10 +1516,10 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, if (unlikely(!free_swap_and_cache(entry))) print_bad_pte(vma, addr, ptent, NULL); } else if (is_migration_entry(entry)) { - page = pfn_swap_entry_to_page(entry); - if (!should_zap_page(details, page)) + folio = pfn_swap_entry_folio(entry); + if (!should_zap_folio(details, folio)) continue; - rss[mm_counter(page)]--; + rss[mm_counter(&folio->page)]--; } else if (pte_marker_entry_uffd_wp(entry)) { /* * For anon: always drop the marker; for file: only