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: 13067736 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 A5C4FC63705 for ; Wed, 7 Dec 2022 23:02:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 330BC8E0005; Wed, 7 Dec 2022 18:02:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 26CC78E0001; Wed, 7 Dec 2022 18:02:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 06EA18E0005; Wed, 7 Dec 2022 18:02:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E79E88E0001 for ; Wed, 7 Dec 2022 18:02:00 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9A7BCAB49E for ; Wed, 7 Dec 2022 23:02:00 +0000 (UTC) X-FDA: 80217034800.06.A42908E Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf17.hostedemail.com (Postfix) with ESMTP id 1F6EC4001A for ; Wed, 7 Dec 2022 23:01:57 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="HiV/oY75"; spf=pass (imf17.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670454118; 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=mYZlpNMA+Acznxg5e3x9zZ+EdiKxFlZgSChFwOm2lRk=; b=Fyx1RsTseqLj2hYg2/K6SEuD2FF8XLTaC3YdapAjUPnvkkrD76bnlE3bUOUffkEXO5zagU XSNJrkLr7eEOdDZBYlya8bx8kkkraC4mx+kTaiYl82OiISs16qgguo7rCELDhNAMqFl3AP oLrJGdJifBGBfRI6a8JBnknmU+rk3h0= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="HiV/oY75"; spf=pass (imf17.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670454118; a=rsa-sha256; cv=none; b=LMfTOKhx6mhUpFIod7pPW1DsD9rmTQK5TyfiPc+t3j69oGvAkEQogePLDL6m2HUn6Kp/QN Ser9g3tsNBpZvbPmlQucE2i1DTyxS9UNQECJ/IfPCw7+QOoiC3PerPBj0vPSdXagOHlbqS 1JdoVI0WWhs6W330/mQmZB6hSYZC8Zs= Received: by mail-pj1-f44.google.com with SMTP id u15-20020a17090a3fcf00b002191825cf02so3188323pjm.2 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=6q8lro7gvOPo1GiTzMWhDA3l+JZh4t0AOgEA5nWZISeAlkDqEAf2gzGfiJQV0fI6r5 XeENPcQJ2aHVEmQpSKyHAYY5yB0yotOCkhnUDlvHAnOWy6VchOeaaRS7OSMxv1cLe3qt eCMxfbTZ75BYjP/NGKVOdBEePosmsKcFvyAwZisZMN/oED9gnQ43CFI2/jAQZ4ih4QBb UQ7s9yQX98kkRNNDMXKPZoRpRuX8hHys65/7dpPE+XfkMvmL9t/iPICbd95AgoFHZFcf bKSEUhwW7dGCkIziTpZmyIv9kN7q13BqA5RIhFY8i/W0sdSxjqP4Z1DydSAutST2rCpL JYcg== X-Gm-Message-State: ANoB5pmDU21W6SFcuMi6qsZTdVHCzap7M35Id5NN9Y3aiHz7Ln3VERWB 0IhHY5gj0P2jmA4zNQhRebOV+ERRTfrDOQ== X-Google-Smtp-Source: AA0mqf4uIlwwTywDq7pnmSssjoqZm8uc2lM/w6x1j1eyco1kE6LT4+WStL0ZREb8lSZ3UNkCCMIzPA== 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-Stat-Signature: c4w3tsposrk96k1pabbq49y8w54zjmrc X-Rspam-User: X-Rspamd-Queue-Id: 1F6EC4001A X-Rspamd-Server: rspam06 X-HE-Tag: 1670454117-413357 X-HE-Meta: U2FsdGVkX1+YsYh0LXn8KIPej2yZVcrdPLvUyepKTnEkLxuGd2Z3RKA9QjTcL6s3235K15UY22BNcLAQkHF/lgLpcMvFN49HRTCZQa9hX+cyo8smnFSKPzu4ygv1P9jaUK1apvN8LflSfYD6RgHtxIyUjGCf6SMsBeCPmCNK8EBMAx89tRkik8pX1UaYocxo6oB7xyvcXmtJ77GA6pLdhwN0t3fl/r66On6/+ssJgQAU6YMYP26UnDjxZDIi031PoGD7CvAuMZ2fuh39Iqd3BsVkhnJ0R9lMpVpvdsNF/Vx8D5yB6snN6zCOgkcp4iq9pCLcddMKdQsETkRwhGsEGYVY7D0YE8I6FoXeajHbO2Ir7YuoUX4sYaTnOokt7W7xa0Znhi9GaDpW/JF9arjmecS6uDk3EY2cSGoAFAjlr7YBKp23VDMtCsavBKrUK8BZiqgeNndvLtxrNAJNK8nlRQFWcjuvvvlqvWs80uz6JCVL1vCGphLks48ekl/yvSNw8tNACoJ5OGuNjwyH9kICcWbpfrMrz19IqX6HZstazGNCMvFQvm2UdzqanwPfegYFWZCeuGxMh3DkoROTYay0oaALnb4PbDC6eEV749jmf3TPkSvK59BPj3+aIGagG6jztAVE/Nv4IAPPUXiOKnxsJHTEM/YxcJw7B0CCSEX74J4P/HdskyecdnPej/+Cd8U1k0GqVU+9+HAQuila6m8ekL792uj8cCttKsnyzOJd+0aKqiu4R0jHePdiO07j7uvYc72hRy8KMGh04GMt4xQzh0iTO0qFgGMcuq5bCkvwYbLtwhFXQ4VF2UkVdXeXWQFQoL9tFgu/UcRR2INzPOzlpj5OE6MWzMxzd6LvzPPNRDn5S6ZSskg8OvESmBSttKPHvtM9YfzFujX15bZgsb8NCC3H7gY9yIMf8mU4bP/S/IvYsEcGXPwyOadjEPT56JAjGlDKtboUC717lkdhSOB pcQn8ZCK gltDflzIjpKFByTk7TI8pMF1SsGA1hxcpOqXa5WgM25C5Siw8SfM5+3NNjQk43qexvDAozlMvHxyL5hSJOStaZbSDKHlHzo7jMOcnFU3la1UiYnqnE3T5Rs14reYznPX0IGJBtugemyLnFOmpnifvUiT5EOrlx8JAF8NSrZAXUfK39p3u081jbL6K7xE8cVkUQ0acqccHd3MtSzaeKXGwDefQ1rFZpq1Vy608eLbosdj8SzQWPUiucIa2+8cYenGJc5hAGSaYtN1Z5cifYqCggUjQqg== 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: 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: 13067737 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 4408BC63703 for ; Wed, 7 Dec 2022 23:02:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A35C08E0006; Wed, 7 Dec 2022 18:02:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E6508E0001; Wed, 7 Dec 2022 18:02:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 776B68E0006; Wed, 7 Dec 2022 18:02:02 -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 687FA8E0001 for ; Wed, 7 Dec 2022 18:02:02 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 2EE1A40766 for ; Wed, 7 Dec 2022 23:02:02 +0000 (UTC) X-FDA: 80217034884.13.8D6F71C Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by imf02.hostedemail.com (Postfix) with ESMTP id AAEA280017 for ; Wed, 7 Dec 2022 23:01:59 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=aRW3STV7; spf=pass (imf02.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670454120; 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=Ihy8jPmuCwZF2NUxckyF8mvKKJAfgGLMAeVZly3BYIQ=; b=quhlxdTSQ9XXeKTJ6/RIw4fkl6xBlbIRt0zgM6gyeC6UIKEELEl/YGx7fnntMIqghUjdJx RD8mg7w9eKsZStsO5LF/qPHvetuGNtmOW8qZyyUuxPwGDj+nUdWmrpip6BPdUa4jjOOaAQ +eTZW6WQrOZdgM4MCNI8l6MGn9GcGBI= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=aRW3STV7; spf=pass (imf02.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670454120; a=rsa-sha256; cv=none; b=K6FyaP/lxqCyIqcMREQnJiguzYTeQ3DGqpkcYANnFTKBs9SPamjedLVMkNdMWQJn1Umhk4 jfcoyf/cKEzxdZSW6DdgYLLHu+WTYw5zlY3p/JCaGiunOkyZf4zioWVK9PApWBwn7i5O3C DI1i/fJ0tgGZSk5+qSuIN5oFNZ8XsvU= Received: by mail-pl1-f177.google.com with SMTP id g10so18451200plo.11 for ; Wed, 07 Dec 2022 15:02:00 -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=lGxEJ9PmMV/HTAOZY/9WLLIzkVw541x9j7XMNTQcMT8GMXwKs9E/JXPbTyA1XnchRP N9oF7FNaCKz1YJafQaKYmOD8Pt1F6Bkn2Yb2BKdW8K2xgaiRuHAmJ+ADr6blNoj7lqjT ZS2186IfjNAjIcVbCEaA6qLsvf7KD/7iEcCdQ0RIS84IvYKN1m8BKLrPt5Wj4/kBYXm5 23AnXGzelR44KdFlh0wMSOB0bWHF9nsUu3fCXalo41PJlfqQDakdCt7yoSVC1Uw7bU4B QicAmksRZVyFWgUBpz2FSr3rUtVqXImSR3Hs1WDw8FZOUZoawTMxppW8XKfR2yIZlKVq 9/cA== X-Gm-Message-State: ANoB5pnbr2scNRNbh+WQxYri6WNoUyzwt0CgnlCjd6GikO1wqAO5SeAd SO7Ypuf+LmZ8iLDJkVaUMUxp/nWjy8UUaQ== X-Google-Smtp-Source: AA0mqf5OWOMX/v4jZwZzxW/+LnUXUxbUa7hAE7DKvC2Aq3cLs4HP8zm+Fl2Ofy4HrmxmV6JJeb1A1A== 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-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: AAEA280017 X-Stat-Signature: jwsbtqad5gigyggaakwqm7xms97ku8fb X-HE-Tag: 1670454119-732536 X-HE-Meta: U2FsdGVkX18g9Y9ZniiFr09nn9a7oX9RBVK5VyIoDG2lf/K82dTSX2YQNpfCKJ/tJwuY/IVb5FcDljYdbDKW/ZAhmofoDakHncIzi1ADYPmQMJDWdzoYWso5napuc1DHNYQpGuor+KyC9m3GZb5WrHUtXRqUaLaJ/8Tie2SYxcqecWfMb+0B8m1JdkhEjyUw8gUSmsZaZG6eZQI94BJGApdmI7EsR8+N8pkgDrJJt5PFxWdCFwOEOA6H9OD3RXDpoYUdXciHUmABl2P0iavghiRZBidHIQ7KO+neqls4nMafdH4UrnKttBcaSvoLofCNN4CIT3fg/ykBBH72hHX0M2ooFwzdpRNzKcJOhVh+//5Uoc3KAEEr7Xrgihx0pRndCAFmoz9k0bvZ3EnWO9+8gfLesuKmV5i09sDmBu2q3V3o+OMczU+FsxM5eNbVnr94Ws9CFkZiqrqCpYkXgc/JKS2j5+zQOiNJGJru6NvwXdRoTm18sScGogQdfpwvwPuxnbAbJxkIhPjz5KjxD7+v89VsNMTMI2ZqxczahgTRjpn5etcVfsPbZgBAwnj8pQ0k8luZrc9BYEqWvlCbj62TnmfcQ0r8Prnd2VTgNVT1YXx9JIR5pm3GEfbjxKCqXpWJqoTzB4iaWDy+dCuq4Xb3it4GOnXgxjYwmIPB7QRmwUp6vTjP1EsmXPAOYnCOCjFiqTiPqFVLJeaYOD8tWHiSFDmty5i8LlrvRp52ovkD4enqKkseDXdI2xL+/jH5qgE42MOTXSUnetUrF2Lm1oCxhveb03bQ3kftY6Y0SfcRvIieCqgdQCHUK6GW6XZM/E3JIzCnaXKzKDivDGwclmMF3ymDXBHUn6AXGJjL0FoWVb5jUI4OipywRi17cg2Q8XkMoM2uWn9q7pfB/6puEpvrcWMbfJHMo9VW3eBHxCeBMbISYzUIhSwwzezIPsfPfaaiqdNgzwRDk7thX3R1J6u zTWW+3/l /PUR0BJAjhTAT5mi3MnWB6/949B+Odx/ae6Y58rt/tca5Cv+UfzWLiwhzpGh3BjetCdebh3uD7mKdsTOI5LFXpV49+zUlqqidXAfqZ7zFl6DmOeuIk0OaimnJ5Wc6yDUpysn+TbRjXbvOFcPfgQ//JzEEb4nuUK18w5jtiIJ320uM0yT9ESJZCmA4PWfaH3D369ktcEIJIsfK/ieTIebFAhkq4geo5Jg3SBNXEFO9NCTHsYuyJ75x6N8s8UsHwvv935gbzl6yczuJwPQrVn97yvILzQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000924, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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: 13067738 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 AC211C4708D for ; Wed, 7 Dec 2022 23:02:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4432D8E0007; Wed, 7 Dec 2022 18:02:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A53A8E0001; Wed, 7 Dec 2022 18:02:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F8538E0007; Wed, 7 Dec 2022 18:02:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0A70A8E0001 for ; Wed, 7 Dec 2022 18:02:04 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C4179160F08 for ; Wed, 7 Dec 2022 23:02:03 +0000 (UTC) X-FDA: 80217034926.18.8EF806D Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by imf03.hostedemail.com (Postfix) with ESMTP id 2172A20021 for ; Wed, 7 Dec 2022 23:02:01 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QWjuDvsx; spf=pass (imf03.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.179 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670454122; a=rsa-sha256; cv=none; b=iDAlohD35FIFyI8jndppdocSjfyAea9b0CbHhC+oEnUZjGb/FOWtwimhOtM4Gj8RV8XBV+ gMRqYc1EDp6DHtwtFf4RKqakiXXYd5AWTU0U7LJ6Oo0VBw2TGWfrhtEAoEvDTU02G1vpZQ khFAmixQ7W+M7lfVZLSFDZV8L0cr/qs= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QWjuDvsx; spf=pass (imf03.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.179 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670454122; 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=nurryG7gVBJWg4R3e/q3KZp9RxkJsYW9MoP7t/y1faI=; b=MZmmvd+2bF7XMS/fkV6hdiRIDdZUMWGjaiQE5kxCvLyYeu605xzD5thbYF+GUaJ6nvTYTO A+1h/sC1/FbMQ0z+ux0arFJ2KZZuh4rO5FoKRg1DalPnPaeDq3GpcBT5+qvHFIffxHX4+M kL+ZO3StDJEH9rPLKnKEDPGcpLL+T7M= Received: by mail-pl1-f179.google.com with SMTP id y4so18478953plb.2 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=mr07qdN93zgYUb8AG/0uRs2OFk77TSMBhqcijCbiifA3G3u1VohdYL9TNsyqMLZQA7 pznjdhi4yWHawm6mYyqNmgILTBLEHIfHJ/AHikv7ed/LgI8zfUUe6JkedDhaJYd6QSML G/HnxiJ+mXdUbcT/ykT5JZ808m96YrhyfjpFasK83HTUuOYBwcytstCN8CpUj+/UdZpd 5JDFDCDW9ntNE4vPwBmxwdCgcbw5Ybu4HRUfxzmxoHxAjH91AQlBSXwNXPW6XZIMOiJ5 i0JZDEpTWsn2rUk/lheL5F8nWZR1PsCjHvVOTE9hk45g8B37MywpMZdpBb76dG6Oo4Ga Nbsw== X-Gm-Message-State: ANoB5plunwS+jHwmYWknjCm5Yyue/nYeAAy2oNZw72qcmrzl6oh9B4tM c8iTyVfybjd4Vz3bm9cAgYDquiJhMLFXow== X-Google-Smtp-Source: AA0mqf4LqJeISyz/cbhdlvWeu+sYEbZmsVtecPsU/yjTK5+i5Cv6K7CeBXEmtSozwv/WhsZmrZ747A== 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-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 2172A20021 X-Stat-Signature: zoshky1qskx5b6fc57fp4j4z7dmbjn97 X-HE-Tag: 1670454121-507899 X-HE-Meta: U2FsdGVkX18Yap6Y5qnsH/uDFoqxFsyZ3rlm/y0laHurNHrp8u1/7NXYKqY1bwYk970EY8AOs5uqkbxdb+8UJEihRrdnIWcO/f9jLBhJmVRapWPK8FlL/GJX9z1RCk3ujoHqQZwgE3321rkAPXkuLzLmQcaiedIz9RX4UdDPdlqW6quWOQlDgW0musPNFl3LTxYTOJY4m/VJET+4lq+lLXAOIoWYMdPDaJ9uD15YiCNshcPER/diAlQLSkXZNKOLZqk1OP+4wr9HCPPuoiEZXpTZ0TeUNU7nhhMo03yJOD7Lx7tgrOEbBhHFZbh9HYpr/fKZV9pIaMpZahhJHJf/3Q2Sqp917205r/aQJSECWWFCpFa16eBP6aspMVuZ3qvtgwyXYhJPzS3qZ54Ndlrt0svX5Za+n3Ia6GZZ+toVTPzDRlLHhKeE2CEmKa2Qx+wzjGeRoo4/rR/yQsEhu37h7G2DOqMJusTTLXg+emD2hCMXzLYSrnmDF5MElgvSm2dRcKVZlP68SzXhhqXrmgByr2ijgAs5+NcLopi+tWYOlwt6UFDCjB56iL4yT9iKJafqUsdkww5eq9+Wd1SbNXnhczSrHEjh/zOrFrAveIc0A2Is661E1lNBobyFkCHtCqhQrb8e0+siP1GBNL68IPZB3Sd4mBwh+dwZKbiPRX6mROoHny2dXRdFnZ/ZNC/pbttwW+6zqvPzcnUDqXzMNZZSqLpd+eSIluv6FUlwGYdvSmlNdUqScx7zVS26fjZPq8ZNJu1LwBpCg+UT6zF57pSopnS4CDte0sPYnh69BLDLGG4aiyTkTjpGhn0sfjYDITEzeqAChQeKd0PhERwU0ReYuPqP8FyitW04ZHKV99EKo84rbEJz2uX0gTftnyEO9O3a7+PHSXMpRPp0FEy4wco3UuYl2Ovb1eyrmWf01q+Ad20tfajfpfp/RoP1YrLo4SzwlQgWA1P1o5D3vL8zbFa H1DvbKqR QngGwaAMRfc7xkxfeTyetUnWewI9VeS/EqgK4EPwGWwDqVCiw04WiHHn/RGhU1uQ/SI4NMGSDXbv2zsP66JrSV1GLUbmKDBrXbjabrwW6KgsO7Ec4KZUA6xYJLF22apPJlrqKQHqIfFTN3/3Qo3Fbzxt9M98KRryO2shq35k4B0XwrYoOKEI8DUFeeqBGkkbK3/33Ncw5hFViL01CYFqJi0sxo4voyg+M3o60Do1f/AJ7DD297XPjHEyu3QuR333qDG8KmkdxFSAfJYX7grORyCKH9A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000633, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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;