From patchwork Wed Dec 7 23:01:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 31086 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp447411wrr; Wed, 7 Dec 2022 15:03:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf6tTQWwpWRAIJ3D+nqo//GKZTltbE23h957J9jOxQHImFKMR/T2yN9cPRClJUM0EeLBL4JV X-Received: by 2002:a63:5958:0:b0:478:5a63:b45b with SMTP id j24-20020a635958000000b004785a63b45bmr28593351pgm.410.1670454200981; Wed, 07 Dec 2022 15:03:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670454200; cv=none; d=google.com; s=arc-20160816; b=Nz1h7bYpA60WwPfrlGLnnRu5gWvZ9pUQ8HIAEHrD+V501Uibdy0TOLAsYsqjf0kSxa apW03iAKKTuJF5OO+fEFwm8p0eii+8fUlVGjZlFkml+Ra+6ZPlLZLf0DkWDloYfa5T6S OVRoEcP/KaBTZYQGNPPAX+HD8dSA2LEymIFgTOgnxDR3J6Ea4GUerX6yTzvZCemDH8Qj ITkbWSPtB0upJyiiD/yCnu1TNFlROY9cHiQ6yRirBhMCJ32DTHe5x/dDxwUs3ii0Rabi HeaID3AUmsqc52Q3LS/LjHAQLfFZ67z31NEEXGhAsD51+0PJ2LHQx+ffb/UmzK1BsmAt 4s+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mYZlpNMA+Acznxg5e3x9zZ+EdiKxFlZgSChFwOm2lRk=; b=ceWaL46QTCk8AntTlJ41tHTCEXzffIZa87G2q7zVneZO28keV0aoioc4R5wPAi4sbO K6Z4jkjHWnSJFd6mC3HNTCk3lgBvbj07YfwlyRzqW+pXZM+vgV8XKD42EMUqkcdFLto4 RUb3+ALi+xZVG4RRNhsRuFFPoU7mJ8l7Rp6V4V5Ic3fMlxLREPkfabyP6eAjPrb+TZbt mXBWHIJ0Kd2TfVEdVWubUn+d45UB5+yE6cGfWFvjdJ36C2VF5ptWCQkkdjuYwuwExLLE 5AkUvIL2nbZgPjDzOqViLgDIPr2avm2NfQAvZAQ5pTgU4EuG+zQ5CTDWPGxD3QU9uJ1C pniQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="HiV/oY75"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c2-20020a17090abf0200b0020a97a92a2fsi2420443pjs.135.2022.12.07.15.03.06; Wed, 07 Dec 2022 15:03:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="HiV/oY75"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229964AbiLGXCJ (ORCPT + 99 others); Wed, 7 Dec 2022 18:02:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229930AbiLGXB7 (ORCPT ); Wed, 7 Dec 2022 18:01:59 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1942554740 for ; Wed, 7 Dec 2022 15:01:58 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id d7so2178944pll.9 for ; Wed, 07 Dec 2022 15:01:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mYZlpNMA+Acznxg5e3x9zZ+EdiKxFlZgSChFwOm2lRk=; b=HiV/oY75y2SgvXSPgyC4fy1/yI+dEmaKpwJP9rcT9dvAgK7E9TPad3a0idSitkerjT Rrx0RTHSsmtv3oYd5pfyIkV0y4GmO+Ls1xkjiaFCRuEDjWgdtfBwXFaxlF5rV4ac7dhC CTZ+IdatW3dUUDP49usWcGXfNyH1/cFNk/xhDASziYsASDFEEJQN1T4Qz8o2+HDwFMZQ n4bL6G0h7Mv4SDokh1Hd/WE4OycJFvigMqFcBjH3A6gGRp/2gfMSNyIay1/n3CcbXFu0 JYMWAnXquC8dwcR+vBFJiWJXrY4ZOi92H5zeUQj/dJopHjbdAk622Ttf2+x+Y1B265qB 6RrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mYZlpNMA+Acznxg5e3x9zZ+EdiKxFlZgSChFwOm2lRk=; b=fYRbSVZ6eZusaQOj0otat2WkNEnoI4mZ98tbl4w+ifufEGoI7eiJDu8oIdg1RAbBIK lsC3x0SksYmAWkoc3tEaEtjS3sKh0VAD9d5w+2xL9ZHlk7mSFhaTifIG8g73AxoL2TJR XciWVtYFuqVDveJ4RTCvd90o1fAp+++BiNocCSdAKQVqK7lPK0QT407ESkmTuXBdPwJ7 K12+CK0HUrqnHZ9VDqfjyaJ1HZeUmPeOaRmYK1sFo880b75p4yt6Akoqma+5PSctdJOY CQmpbFjG5EC2IptoKYkAg9Oop16HRb0gugNYrcP9FJw4n6tPR0s8w5o7z2prmxnMtadq ZTEQ== X-Gm-Message-State: ANoB5pkGnfaDrHzrGYGNg1pI0qxYlCkYMx7X8L94oKzFa21ZfkSOr6Wt nEPhucTg2ufLX5phi7ncu0g= X-Received: by 2002:a17:90b:1913:b0:219:396c:9e30 with SMTP id mp19-20020a17090b191300b00219396c9e30mr1056216pjb.20.1670454117492; Wed, 07 Dec 2022 15:01:57 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::2c6b]) by smtp.googlemail.com with ESMTPSA id pc16-20020a17090b3b9000b00212cf2fe8c3sm5411033pjb.1.2022.12.07.15.01.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 15:01:57 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: damon@lists.linux.dev, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, sj@kernel.org, "Vishal Moola (Oracle)" Subject: [PATCH v2 1/3] madvise: Convert madvise_cold_or_pageout_pte_range() to use folios Date: Wed, 7 Dec 2022 15:01:50 -0800 Message-Id: <20221207230152.22938-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221207230152.22938-1-vishal.moola@gmail.com> References: <20221207230152.22938-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751598184528892743?= X-GMAIL-MSGID: =?utf-8?q?1751598184528892743?= This change removes a number of calls to compound_head(), and saves 1319 bytes of kernel text. Signed-off-by: Vishal Moola (Oracle) --- mm/madvise.c | 88 +++++++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/mm/madvise.c b/mm/madvise.c index 2baa93ca2310..b323672c969d 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -332,8 +332,9 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, struct vm_area_struct *vma = walk->vma; pte_t *orig_pte, *pte, ptent; spinlock_t *ptl; + struct folio *folio = NULL; struct page *page = NULL; - LIST_HEAD(page_list); + LIST_HEAD(folio_list); if (fatal_signal_pending(current)) return -EINTR; @@ -358,23 +359,23 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, goto huge_unlock; } - page = pmd_page(orig_pmd); + folio = pfn_folio(pmd_pfn(orig_pmd)); - /* Do not interfere with other mappings of this page */ - if (page_mapcount(page) != 1) + /* Do not interfere with other mappings of this folio */ + if (folio_mapcount(folio) != 1) goto huge_unlock; if (next - addr != HPAGE_PMD_SIZE) { int err; - get_page(page); + folio_get(folio); spin_unlock(ptl); - lock_page(page); - err = split_huge_page(page); - unlock_page(page); - put_page(page); + folio_lock(folio); + err = split_folio(folio); + folio_unlock(folio); + folio_put(folio); if (!err) - goto regular_page; + goto regular_folio; return 0; } @@ -386,25 +387,25 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, tlb_remove_pmd_tlb_entry(tlb, pmd, addr); } - ClearPageReferenced(page); - test_and_clear_page_young(page); + folio_clear_referenced(folio); + folio_test_clear_young(folio); if (pageout) { - if (!isolate_lru_page(page)) { - if (PageUnevictable(page)) - putback_lru_page(page); + if (!folio_isolate_lru(folio)) { + if (folio_test_unevictable(folio)) + folio_putback_lru(folio); else - list_add(&page->lru, &page_list); + list_add(&folio->lru, &folio_list); } } else - deactivate_page(page); + deactivate_page(&folio->page); huge_unlock: spin_unlock(ptl); if (pageout) - reclaim_pages(&page_list); + reclaim_pages(&folio_list); return 0; } -regular_page: +regular_folio: if (pmd_trans_unstable(pmd)) return 0; #endif @@ -424,28 +425,29 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, page = vm_normal_page(vma, addr, ptent); if (!page || is_zone_device_page(page)) continue; + folio = page_folio(page); /* * Creating a THP page is expensive so split it only if we * are sure it's worth. Split it if we are only owner. */ - if (PageTransCompound(page)) { - if (page_mapcount(page) != 1) + if (folio_test_large(folio)) { + if (folio_mapcount(folio) != 1) break; - get_page(page); - if (!trylock_page(page)) { - put_page(page); + folio_get(folio); + if (!folio_trylock(folio)) { + folio_put(folio); break; } pte_unmap_unlock(orig_pte, ptl); - if (split_huge_page(page)) { - unlock_page(page); - put_page(page); + if (split_folio(folio)) { + folio_unlock(folio); + folio_put(folio); orig_pte = pte_offset_map_lock(mm, pmd, addr, &ptl); break; } - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); orig_pte = pte = pte_offset_map_lock(mm, pmd, addr, &ptl); pte--; addr -= PAGE_SIZE; @@ -453,13 +455,13 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, } /* - * Do not interfere with other mappings of this page and - * non-LRU page. + * Do not interfere with other mappings of this folio and + * non-LRU folio. */ - if (!PageLRU(page) || page_mapcount(page) != 1) + if (!folio_test_lru(folio)) continue; - VM_BUG_ON_PAGE(PageTransCompound(page), page); + VM_BUG_ON_FOLIO(folio_test_large(folio), folio); if (pte_young(ptent)) { ptent = ptep_get_and_clear_full(mm, addr, pte, @@ -470,28 +472,28 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, } /* - * We are deactivating a page for accelerating reclaiming. - * VM couldn't reclaim the page unless we clear PG_young. + * We are deactivating a folio for accelerating reclaiming. + * VM couldn't reclaim the folio unless we clear PG_young. * As a side effect, it makes confuse idle-page tracking * because they will miss recent referenced history. */ - ClearPageReferenced(page); - test_and_clear_page_young(page); + folio_clear_referenced(folio); + folio_test_clear_young(folio); if (pageout) { - if (!isolate_lru_page(page)) { - if (PageUnevictable(page)) - putback_lru_page(page); + if (!folio_isolate_lru(folio)) { + if (folio_test_unevictable(folio)) + folio_putback_lru(folio); else - list_add(&page->lru, &page_list); + list_add(&folio->lru, &folio_list); } } else - deactivate_page(page); + deactivate_page(&folio->page); } arch_leave_lazy_mmu_mode(); pte_unmap_unlock(orig_pte, ptl); if (pageout) - reclaim_pages(&page_list); + reclaim_pages(&folio_list); cond_resched(); return 0; From patchwork Wed Dec 7 23:01:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 31087 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp447523wrr; Wed, 7 Dec 2022 15:03:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf4E4dVAJNN/SNQMZJ0iKKhaEaJ/pEOgJRAIMOle+xaeyBhzFNGOcWalqCH8UM0wIW/bx1rz X-Received: by 2002:a63:4b1d:0:b0:476:837c:e0a with SMTP id y29-20020a634b1d000000b00476837c0e0amr67324322pga.411.1670454210809; Wed, 07 Dec 2022 15:03:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670454210; cv=none; d=google.com; s=arc-20160816; b=nx82w8sDTRLk9T9idm2FdcbH24GQZZH1jGNiW2KBKXIXghN2Azrs1AFcw0aQZ9enaL WllVsl5ouGdNTT+urhp3fwpWKFGKIymqICXFHFVtU9BMd/yD6k+9/HlBCCByFKdBji/g tZUYwiUJwK49lGFuzaIQFh31r13bHyKd+cgQvc7umeYQlHZDgibu8wEvatlq5un0F194 lRfkS4Nb+uVFHFMICK1eLjv9fSrabSUsYtxH6Z78cZ4A0Qn2qoJ08hAxD7UT2+W6kxKk Y3PGu6EW2EOcxE74kwMjXYvmYgjVYT54dnKjQL+Y8CVWiSZGzilwcX0LsOQolfkCVbwi 2UbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ihy8jPmuCwZF2NUxckyF8mvKKJAfgGLMAeVZly3BYIQ=; b=CQKGa9Dx6xrWHxBIBQdNiNUXMB2MojtyT4Ga2mKO2bU8ZuTa1NvP/0LeLm9PKmEiM8 hYv9gcYhDM8Bf5LemiypLXZ8z0uQJkR7oBgmpWgHZw4Kq/N08iiow0pxKpmw4q/ok7ZL BipD0Wx42HkuM4PF7jkmB3pbeXDKuEs4imYSSVxqmPYtj6KFHSIepfO+mB6ZbOyXpOF9 AKIsnvBYyi8Dp4QcXoyUWCvr3uE8QpdLJDq7SVqx3nOynGw14Cip77GGqrTTyOY/Dr0o DCi+rG2PO+LrADrhLJ8yi6HaCjZEYmJYDcSLtynxbpZ4KgDwak1rDr6/Wr3Xxmp7xL2z lTKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aRW3STV7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n14-20020a170902e54e00b001769e08c554si21594759plf.545.2022.12.07.15.03.07; Wed, 07 Dec 2022 15:03:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aRW3STV7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229954AbiLGXCM (ORCPT + 99 others); Wed, 7 Dec 2022 18:02:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229949AbiLGXCC (ORCPT ); Wed, 7 Dec 2022 18:02:02 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C666D7BC3F for ; Wed, 7 Dec 2022 15:01:59 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id k88-20020a17090a4ce100b00219d0b857bcso3191821pjh.1 for ; Wed, 07 Dec 2022 15:01:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ihy8jPmuCwZF2NUxckyF8mvKKJAfgGLMAeVZly3BYIQ=; b=aRW3STV7RblLr2UZyt0OTfxbCMJqzXcDNCvfPBFSL8j4JPwCmtZkBnAWT2aBKleJxM S3/S1x1bm1MpdH3mCRtHaNVJoA9agm3kV/DY2R4ALu1LaFoVxFx25litGpXvg0Pvv3gh uoVb7nRNI9Qsr8wEjAMXHbfKT2kJbq0+RJAy9yhPqI+XBxbk4puqiVriF0clbfnRW70s BoqZQTnhKW+xtH8CD1pB7fQKPmCtUiJwD+YIRriTaJAr7X6qPNEhR1gMWRbwuwhYFKuc 8gjib0AzihFb9ybVk0MTROBvleagUuf+5ZDDM3BziLgRNQJLYQgKz7T7B91ISD3U5F+A JrAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ihy8jPmuCwZF2NUxckyF8mvKKJAfgGLMAeVZly3BYIQ=; b=slKiGllHB9p9VdxnEVLoIuCJStdUXqqMJ2fc/hKTnsPmtN+dPm+nRxP9eaONc6XThW z8ZErqB7JRA8JPMnFT/5H869QxewsqlMCqDlRHpWEi0Bv7eu+9OuUmYufvv9q8o82pI0 doL841qnCNcY3RG1tKffA1cQz1EKmCoMOguf6jbIA77C7xfif9uByUa93zuk92KhMnIU zFXU5tZ67Q/psBJOw/2AexDQbewAnjk9lTdDOXVfDks2GUbVLJ2ZyA/ybQ3/TL5v6qLV 1Om3v0tBYLQrs06tCu4Y3WUEowK4PHeEhRiANAC4jMDzDcjtT/vf10n7QT5/b4xl3B0Q 3zkw== X-Gm-Message-State: ANoB5plMuiuDrFSUAwt93B+kLdRPac70tUjjyVpW2iQ2dFH3Pew6Hoqr 4mZQqAYt+w0qymijOsnpeno= X-Received: by 2002:a05:6a20:a028:b0:9d:efbe:52b2 with SMTP id p40-20020a056a20a02800b0009defbe52b2mr2023625pzj.34.1670454119220; Wed, 07 Dec 2022 15:01:59 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::2c6b]) by smtp.googlemail.com with ESMTPSA id pc16-20020a17090b3b9000b00212cf2fe8c3sm5411033pjb.1.2022.12.07.15.01.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 15:01:58 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: damon@lists.linux.dev, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, sj@kernel.org, "Vishal Moola (Oracle)" Subject: [PATCH v2 2/3] mm/damon: Convert damon_pa_mark_accessed_or_deactivate() to use folios Date: Wed, 7 Dec 2022 15:01:51 -0800 Message-Id: <20221207230152.22938-3-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221207230152.22938-1-vishal.moola@gmail.com> References: <20221207230152.22938-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751598194679466468?= X-GMAIL-MSGID: =?utf-8?q?1751598194679466468?= This change replaces 2 calls to compound_head() with one. This is in preparation for the conversion of deactivate_page() to folio_deactivate(). Signed-off-by: Vishal Moola (Oracle) --- mm/damon/paddr.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index e1a4315c4be6..73548bc82297 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -238,15 +238,18 @@ static inline unsigned long damon_pa_mark_accessed_or_deactivate( for (addr = r->ar.start; addr < r->ar.end; addr += PAGE_SIZE) { struct page *page = damon_get_page(PHYS_PFN(addr)); + struct folio *folio; if (!page) continue; + folio = page_folio(page); + if (mark_accessed) - mark_page_accessed(page); + folio_mark_accessed(folio); else - deactivate_page(page); - put_page(page); - applied++; + deactivate_page(&folio->page); + folio_put(folio); + applied += folio_nr_pages(folio); } return applied * PAGE_SIZE; } From patchwork Wed Dec 7 23:01:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 31088 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp447893wrr; Wed, 7 Dec 2022 15:04:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf68YcwwIQTLK3YWezEexu5lhYYgC7vsWgVLoLs+awO0DrAm99j+BC2jsUJ+8LTixHejhKhx X-Received: by 2002:aa7:93cd:0:b0:577:29c9:a7b with SMTP id y13-20020aa793cd000000b0057729c90a7bmr11698966pff.61.1670454252403; Wed, 07 Dec 2022 15:04:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670454252; cv=none; d=google.com; s=arc-20160816; b=ehUJhIRv2gbx6PnH/SHTFEo8JD9wkk/K+fzs34EbD+ZiSu7Bcfntdqc5TtunVaGPXA MZ/E3sxWWj5akCAsG0yYvzUbTwpV95P/FRU8+rsIEYqvgd75nMU179M+ggTlFEevMmZC gyqc1srtVIs6/BUG8B81fRnqqnVB3xFH+qTLUIczXvR/rXRfqD/fJuMd4JKX6lTcoqPa VTymI+XNVu2VeF+1LwyYW9g8UWXoIj4FIZbdLkkOyd5bL0FzM8C3PbigKM17xZhGPRW5 DD5+mv2PLV1z3oFEFNnM7y0lqxSnNA/ejAm/hu/lwosf/TVzEvNmUwo2irZ50yqqzJv5 HiXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nurryG7gVBJWg4R3e/q3KZp9RxkJsYW9MoP7t/y1faI=; b=nIIEhB2cjTLV9v7+gzMIKqu1MwjGEYlYO7cAb3MPEqSBR3JNz9iGeVgaUQ5xGB91bN CLMnI4/VLwyIPhMnfaOrhJcYbFSV6w7/S9+JYE0Y39VI8eNVW1crMSFOTRYf9rrzdhIu CVeAtyC8wOkE8mRm5cTgn/+ohwH7zF8JY8HCWWHkSnJ1sxLNPSi03KdF0u7jeGasCRy4 Nx7uxUEpgkIQbWPsNyrmFgafSQ9CCfN2dXYAoiBlnwfAH/EQG2GS2Bw3rSCF3Tp6FDJX ovgW3SaRQd8JHpLbzIVFaIBNy1w1HsHSERqcXKsS0q41G2qwFHERs4GyhJQbN6RysXH+ sf8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=QWjuDvsx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pv16-20020a17090b3c9000b00219b9479155si2535819pjb.187.2022.12.07.15.03.47; Wed, 07 Dec 2022 15:04:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=QWjuDvsx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230009AbiLGXCR (ORCPT + 99 others); Wed, 7 Dec 2022 18:02:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229944AbiLGXCD (ORCPT ); Wed, 7 Dec 2022 18:02:03 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DAD27E40E for ; Wed, 7 Dec 2022 15:02:01 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id v13-20020a17090a6b0d00b00219c3be9830so3184381pjj.4 for ; Wed, 07 Dec 2022 15:02:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nurryG7gVBJWg4R3e/q3KZp9RxkJsYW9MoP7t/y1faI=; b=QWjuDvsx7JlXe9jXENwXVfaXVWdDN8pp2PRVifSfiC5uewfqCcXo7a7QY5NClKN4jo XIYubaBMmt41X0S6tkEosOyXPlmKpSnefXHj4lrdnAshM3ZqoRsqR/RWso9mHzpVH2EP iyucwJCvCzBxNiS0DZOrs2OZQscCfv+Vqs9jHd/QNNIevSm+PEY54R+KQI0Exh/tMikx qtdFlLWc4RdRRyygzeNnWWu9/2rHRjBFNCd+iV5E2Thc6eAcGtYHsG3IJk4RraRP8FB6 kttIG2u/RDgKJ/UB3+uT0UUAbXapXVCFd+u44YZpTHrUfNzXtdq4Pif7xxDj1ewuJ6pR jg4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nurryG7gVBJWg4R3e/q3KZp9RxkJsYW9MoP7t/y1faI=; b=hjfYk8vkwlGFXrFCohuanLGHbN1cyIHMpUcrXeFKYULoTAr9JfWg2mTzjeZny0QbdZ sRty4W3NuQj4TZNYXErXj6lbpq2/5DoLCrCBYPFNd4i9cwervVWjDA/DXnXMK9ey6eIZ Bo1I93isYQlUeu91w+ln+WULPLDAfNt+rfS1+x+qBo1slUp1tJomFgEkUubTt4xJk0Ah 4oUYeSjy0pWlNA9UQLxYxu8gMSj2TrV1N7FUSEziSDD0L7UIwIOLdZJPs/OuPbS7RMM6 rZH9mi4NKhTiC5AVHgDN/9ZXkJUJuAxZ7UxfiR4DJ2xx80xVnskApIpXhol7Jmxvw5S8 H5bA== X-Gm-Message-State: ANoB5pmUl9Vtm8Hk2jccMN4qpNcmlPUG3E/nz+T9HDQPvlhi9ZkSdZYo AQsJgPtApci3W3kugyuBTTFQAf1l1kZfVw== X-Received: by 2002:a17:90b:1913:b0:219:396c:9e30 with SMTP id mp19-20020a17090b191300b00219396c9e30mr1056306pjb.20.1670454120814; Wed, 07 Dec 2022 15:02:00 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::2c6b]) by smtp.googlemail.com with ESMTPSA id pc16-20020a17090b3b9000b00212cf2fe8c3sm5411033pjb.1.2022.12.07.15.01.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 15:02:00 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: damon@lists.linux.dev, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, sj@kernel.org, "Vishal Moola (Oracle)" Subject: [PATCH v2 3/3] mm/swap: Convert deactivate_page() to folio_deactivate() Date: Wed, 7 Dec 2022 15:01:52 -0800 Message-Id: <20221207230152.22938-4-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221207230152.22938-1-vishal.moola@gmail.com> References: <20221207230152.22938-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751598238213543696?= X-GMAIL-MSGID: =?utf-8?q?1751598238213543696?= Deactivate_page() has already been converted to use folios, this change converts it to take in a folio argument instead of calling page_folio(). It also renames the function folio_deactivate() to be more consistent with other folio functions. Signed-off-by: Vishal Moola (Oracle) --- include/linux/swap.h | 2 +- mm/damon/paddr.c | 2 +- mm/madvise.c | 4 ++-- mm/swap.c | 14 ++++++-------- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index a18cf4b7c724..94aa709ed933 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -409,7 +409,7 @@ extern void lru_add_drain(void); extern void lru_add_drain_cpu(int cpu); extern void lru_add_drain_cpu_zone(struct zone *zone); extern void lru_add_drain_all(void); -extern void deactivate_page(struct page *page); +extern void folio_deactivate(struct folio *folio); extern void mark_page_lazyfree(struct page *page); extern void swap_setup(void); diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 73548bc82297..6b36de1396a4 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -247,7 +247,7 @@ static inline unsigned long damon_pa_mark_accessed_or_deactivate( if (mark_accessed) folio_mark_accessed(folio); else - deactivate_page(&folio->page); + folio_deactivate(folio); folio_put(folio); applied += folio_nr_pages(folio); } diff --git a/mm/madvise.c b/mm/madvise.c index b323672c969d..9667d052b52f 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -397,7 +397,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, list_add(&folio->lru, &folio_list); } } else - deactivate_page(&folio->page); + folio_deactivate(folio); huge_unlock: spin_unlock(ptl); if (pageout) @@ -487,7 +487,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, list_add(&folio->lru, &folio_list); } } else - deactivate_page(&folio->page); + folio_deactivate(folio); } arch_leave_lazy_mmu_mode(); diff --git a/mm/swap.c b/mm/swap.c index 955930f41d20..9cc8215acdbb 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -720,17 +720,15 @@ void deactivate_file_folio(struct folio *folio) } /* - * deactivate_page - deactivate a page - * @page: page to deactivate + * folio_deactivate - deactivate a folio + * @folio: folio to deactivate * - * deactivate_page() moves @page to the inactive list if @page was on the active - * list and was not an unevictable page. This is done to accelerate the reclaim - * of @page. + * folio_deactivate() moves @folio to the inactive list if @folio was on the + * active list and was not unevictable. This is done to accelerate the + * reclaim of @folio. */ -void deactivate_page(struct page *page) +void folio_deactivate(struct folio *folio) { - struct folio *folio = page_folio(page); - if (folio_test_lru(folio) && !folio_test_unevictable(folio) && (folio_test_active(folio) || lru_gen_enabled())) { struct folio_batch *fbatch;