From patchwork Wed Dec 7 00:21:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 30554 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3127729wrr; Tue, 6 Dec 2022 16:25:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf61GK0pYom3YB+R4KkQQYjRxWF3DI5uWIR/DTNqQdPjbG7p0xgwdcCwWtf65aA0We/0tgcS X-Received: by 2002:a17:907:3907:b0:7ae:37a8:9b5c with SMTP id so7-20020a170907390700b007ae37a89b5cmr21075353ejc.241.1670372715870; Tue, 06 Dec 2022 16:25:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670372715; cv=none; d=google.com; s=arc-20160816; b=Nbm3IELzqozZA8tB29Vw2MC7kmcnwT3+OyFGBeTxf9Q8LhvmCmKUoZyw3dnkQdEdOb 60K9ME/gz4GtRJ2P5SjpNsmY3seNG+A1cJMgmsC1CONYbWunXZtRY45HWg/pGmQ6XZPu n6URZHzY9QqZb017jDHygPVyzo0VOHPus9QH7B80qOSwVyfFlgHD7m0cdaz9quNZdtw1 VqDljWZ23ngXVK7TLnPB9xuirCzMn59vK7a7ACNqHgoPmnl18Z6HGYT28tFJi2EFGAdU d2rEP+yKamNJjXkNqeMT1gLMDIuaYdGGF1SWkwqyNDyyPqVk6HhvpVyn+YD0p5tzTPWD qLAQ== 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=MoYl04wmxXLxezPOZ+70Ro47XrPK1TtSWHCWNCKBtck=; b=cybzweB0B0Sf7z24tPw2yuiZWVaxKQpnm9qwMrlvu5KGaX5GEoYkDz6z4BlqbevUVd CGAXAmkroOtGDJpVTSxkjsimARtbtN1NmhO3MY/wiuG64yk2QsYSSEgv2KvEBExRUGYO /ELgCFPY3+NJiEJ9qQhXb4g6kT7pX/OzOe50kPuTAlyoQWinsyvws/y/QQqnxoFiT+/L 65vmeFxibQahkwbgYFBgINZxqBIQW8Jm0QqUPAFEv0pGScCUIZNTFkUWW752RhLijZP8 CO1HnRgC1/0kWBydyqlgl0cOV7XNKyy6jamesL3wZseRPizP7CFGq62+K4CFtf0EyB6x ITPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gBamaz4O; 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 e22-20020a17090658d600b007c0b0f9b97esi11511867ejs.775.2022.12.06.16.24.51; Tue, 06 Dec 2022 16:25:15 -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=gBamaz4O; 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 S229684AbiLGAW1 (ORCPT + 99 others); Tue, 6 Dec 2022 19:22:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229583AbiLGAWO (ORCPT ); Tue, 6 Dec 2022 19:22:14 -0500 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AED74B99C for ; Tue, 6 Dec 2022 16:22:11 -0800 (PST) Received: by mail-pf1-x435.google.com with SMTP id n3so11817771pfq.10 for ; Tue, 06 Dec 2022 16:22:11 -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=MoYl04wmxXLxezPOZ+70Ro47XrPK1TtSWHCWNCKBtck=; b=gBamaz4OVaEVv9YnAytPCavKroW8kAh0EpjPfndUHawsWX+Te45e0LTcygfzxt8QE1 2SqiGRJcTWSCe+7cD3rFTWy6y+tYqHCvXgbJn+r4VQFX9HnuyvW8NZJ9lLFTWfnmkcmE MMe2xsoL8lhOPC+CRDfEqdjzr18ZgvwViZoUlSeR/Zo9B1Hp6uxR7DCzEGnBB8tYFU/Q 2AzyPIkz77tzkdOVaKf+MI5ugr+rsOEWFabgMLVJaRBaDHs2x7YAnjXbYL/4n9bexpZK YzC2T83N0X1QGW2u7NSK3lLFlSrooexvnhal3jwHDd5x9guBM1nkqYqdiQceIRsbYvYm D4Tw== 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=MoYl04wmxXLxezPOZ+70Ro47XrPK1TtSWHCWNCKBtck=; b=xClwhKEOE8O3pw7n59Rlc4Ryf/IdviKMZCD00TI/r6x9iIXdn+eDeb9yGQ6mho7QTM M4chWu24yy99S3otskXZoicRdGpSr/EYkJpb1SvqwMFifda+aDVaBzs6mV2YnCnMNKws 47E/VCjhpFPYmEuuD4jQBwfQ28ZxMtGijSvYo9T5upEF7VGl8xpPCW41O3NRZXV7dkmh i6bxyXIkf2FN00BSI4MvzYF9vKnS46F6WTDatDvXMSbbGe/9cU8K2NB/a0Ev/e8OcI5I hM0LOSFDTjFxbSAmV38d14S6fDlKdnFlIHav5adN+1MrSjm5PD9vzM1XLZqVRH0bNbFT gq+Q== X-Gm-Message-State: ANoB5pkohrOIrErHPRkgAORkWHDMnqgbR67Tpa/rwkEgZa9Ehnb1AKof bfdcaB+3HyzLYArikxRIjmI= X-Received: by 2002:a63:1464:0:b0:46a:f665:ed96 with SMTP id 36-20020a631464000000b0046af665ed96mr63031285pgu.486.1670372530940; Tue, 06 Dec 2022 16:22:10 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::2c6b]) by smtp.googlemail.com with ESMTPSA id i92-20020a17090a3de500b00218ec4ff0d4sm13369459pjc.6.2022.12.06.16.22.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 16:22:10 -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 1/3] madvise: Convert madvise_cold_or_pageout_pte_range() to use folios Date: Tue, 6 Dec 2022 16:21:56 -0800 Message-Id: <20221207002158.418789-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221207002158.418789-1-vishal.moola@gmail.com> References: <20221207002158.418789-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?1751512740551921534?= X-GMAIL-MSGID: =?utf-8?q?1751512740551921534?= 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..59bfc6c9c548 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_PAGE(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 00:21:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 30555 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3127732wrr; Tue, 6 Dec 2022 16:25:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf5eBWeGXgt9sBCHGhhtpOShGfrMYlRFMOhnRmGvAzQvj3ayvj5UMGU2Sy8La54rhWQX1SLZ X-Received: by 2002:a05:6402:b11:b0:46b:c86a:6411 with SMTP id bm17-20020a0564020b1100b0046bc86a6411mr24937457edb.417.1670372716424; Tue, 06 Dec 2022 16:25:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670372716; cv=none; d=google.com; s=arc-20160816; b=Dg7fCLvYMoGNsuFIDd/uQZmezAMzn570Ck8bQWSFrhpuhQebplXFZFBDyYJESlVuP6 awy3/gLTdoRJjHPovfUf/rbt1U/LQA2U+r1UyGNV/NL8f9+wvKARvCcYexZhyjKJEfBY WHD9U3rPgogwenwNVbqFc1XpCnnw8961ZVTYuCE1UkeC8a/YohSkS41oyHTklANTk8lM hACjdcf/AlQ0w57Q6Sr5tyMMlBuirtEVVwbDaSKu5wn29u6WOoIgl/u1dSpUTIiqjjcr tQVki2SOG2CidN6wf8P2nXseefXijxCt4WTbngGHJjn9vzCQ/rJrVWWjrVNGfrGYKgS7 3uDg== 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=7cFy10fUQvAp0c5CDE+pRKnURMHNPhPlaSgCKw+V2Qs=; b=YVoAGL83/iO76LiMYVUw1Po17+8cKFK+RIwjLWjL1fFf2Jp742dWjQRadUPQqZRlFD znaHkvybTVKkLmrizNb+2YtRsVZvyHT+7Kv3C4qj/h6qPl+4LD3bqwGHlaEyq4YLNwGf 4ycz0vyC6vD6A4uE8ZyJ7TFTtZgwf4iiLzGQ8JpuiRsnY3/48Xo7ZD6hzB2H32tCBLpM +Mna1cL+PmdmcXjRUlSOqoT36qKTnHd5L7QFRk6PLqz5+C06pu8HBiu3bp2VU9mo0arp YUzckyPIQ4ZQ5uKyYleCeHZJk2jOXpXjrwds/7tFwE+Y3gf6ex0pIAGowF1tmUUym0zG tiBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=YHl28cpd; 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 hs4-20020a1709073e8400b007bd71f57fddsi16109722ejc.803.2022.12.06.16.24.52; Tue, 06 Dec 2022 16:25:16 -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=YHl28cpd; 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 S229619AbiLGAWY (ORCPT + 99 others); Tue, 6 Dec 2022 19:22:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbiLGAWO (ORCPT ); Tue, 6 Dec 2022 19:22:14 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A470A4B98F for ; Tue, 6 Dec 2022 16:22:12 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id o12so16030329pjo.4 for ; Tue, 06 Dec 2022 16:22:12 -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=7cFy10fUQvAp0c5CDE+pRKnURMHNPhPlaSgCKw+V2Qs=; b=YHl28cpdsLfmOjfipvqjWtXAOa0AMP8kDcueiJ2N/YI83AXK8AqWr/PutrLcLlXgWJ 6+oMgPZlwTZh56uWh1rOpt8mEc1ZKR5Y0LX4C1FdfryzT1T1yTtNZ1my5/TzolFCJPGj 8AMBoHbKNuHITSlPhfWgrrjoRrPaAkSr07h69DbLlVEoMAbBdKq5YyTT67xyp5jauvLQ imF0VJ4E31XeS909T0Ldb2JbgeDlNv45Jjr4N6f2BuVNBMf80lbVAcHnzhMKW4/Hcy3g 3I6djJdxa4FDRbQumuumNsGYUIgLJxYdme/OkCtciK0AFWkjDy3HYydVxd6qwRzG52Av 2EwA== 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=7cFy10fUQvAp0c5CDE+pRKnURMHNPhPlaSgCKw+V2Qs=; b=AUuZPhl+s2PdBAFnqDsjh+Het+Nrddl6L5o9uxzvEh6XP+uzhZXtCSC5KkXbRUsTL/ DDONgY2ZG5RrR+niP/dcSgjr8vLWIjMpuhqcNjJdOnge9r4UOTtOzA22W4LdwMnj+osQ cB4irTZoGflVtRSscinlezTwCyNReWcZlUVLCDvR2BDPIFmLMTFnmK9/ioophRKeWUw0 VHDAVNqCer/56lKO25njgJ69/VB2F8WjuKlUu3vUj4P0y0WXu8eHS6hQ685V/hHr4w+b 4a145w1mW4m8i5ZTNJ5d3Op3+teIRe+7ZvK5bLbtGXRiS7fUoG91rrtXnXm2j0KwoFKS 6a5w== X-Gm-Message-State: ANoB5pmMVjOmMvZdmurGBsKKIaL9+HbJAfqhN0sdp1VzQMmArHr3n7Lb uudKJ31Q9ABgMPQIxm1m4Q8= X-Received: by 2002:a17:90a:5787:b0:218:8398:5846 with SMTP id g7-20020a17090a578700b0021883985846mr93924762pji.241.1670372532129; Tue, 06 Dec 2022 16:22:12 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::2c6b]) by smtp.googlemail.com with ESMTPSA id i92-20020a17090a3de500b00218ec4ff0d4sm13369459pjc.6.2022.12.06.16.22.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 16:22:11 -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 2/3] damon: Convert damon_pa_mark_accessed_or_deactivate() to use folios Date: Tue, 6 Dec 2022 16:21:57 -0800 Message-Id: <20221207002158.418789-3-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221207002158.418789-1-vishal.moola@gmail.com> References: <20221207002158.418789-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?1751512741189649158?= X-GMAIL-MSGID: =?utf-8?q?1751512741189649158?= This change replaces 2 calls to compound_head() with one. This is in preparation for the conversion of deactivate_page() to deactivate_folio(). 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 00:21:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 30556 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3130830wrr; Tue, 6 Dec 2022 16:35:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf6JLx1D/WWy7F5EO6JXjhNDgPSBh2hYbjKVG6bKlvLcveh/9CNC7PT9xH/7NvhzP+MNbFui X-Received: by 2002:a17:907:3e11:b0:7c0:7b2b:db17 with SMTP id hp17-20020a1709073e1100b007c07b2bdb17mr33350477ejc.312.1670373321325; Tue, 06 Dec 2022 16:35:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670373321; cv=none; d=google.com; s=arc-20160816; b=HO9ZnFpuZ+ZucmmUYKA/Qkl8r6D4CddGEVAmq2jUNCQwU/1fbp1ejHwWAt+9dWYxfD JbDymQbMDM7AYWVIlp26y9TBxcor5n95mnexf/CkOaAC2Z9gRdeBw0fjQzFN/p6AFSAi a2e8oOEzri+BLPu9FC42Iq06Yc94YAi1nA3GN9pD41OLk6cnFOK5a1MtB/yXha0zIrkz UYZX/jeYaRqdKXTUdc6i6r3ECvDoE60WD0d3XUWDRjKILCoAv2GGmK7rBiOYR5OfkQxp yNCBbcLtCCW2EuVilxJzgb3hLS1SI0TFUR2UpKaRFFyLqe6NGSQSO4G3pDhm+Bwl+jzo d76Q== 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=OEZ3nXZq4E7igsh2DmFsHgveY1W51E+N0X432dfJHyo=; b=YJoUXhJdCmW86Ayi8qD/IOzOAkrIrMjMq1MfdPAh8nxHM1NxAEG7n9VgeGH5FXECeC +S7r4xwpUvGQe9hgN/6aQEeu7/H3qhJgIOc0LTpf3HjxW3b9zMsGHL2NOX4Qipr74QBq CJvVexbHGW6foG9opmAzjV9lOGEuaYm1OB3fbfqoO1Pr5j55H76Igf2W26eYDQ5vbuew 9x0V30X7yZYz2Xgaunafpc3JYATUZMP8R1ww75KdmxofX4cCP/0AuVgQJPy/abdHl4OG SQpUV9raT0ohiRDLwRdgSoMP1mvP7j8d8wnG0YkDM2OfVDI8aG/m13gILgRjQZcTR/U+ TqKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=nOt7hYfh; 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 x18-20020aa7d6d2000000b004572618668asi2592940edr.461.2022.12.06.16.34.57; Tue, 06 Dec 2022 16:35:21 -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=nOt7hYfh; 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 S229627AbiLGAWW (ORCPT + 99 others); Tue, 6 Dec 2022 19:22:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229614AbiLGAWO (ORCPT ); Tue, 6 Dec 2022 19:22:14 -0500 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FA6443ADA for ; Tue, 6 Dec 2022 16:22:13 -0800 (PST) Received: by mail-pl1-x62b.google.com with SMTP id w23so15532534ply.12 for ; Tue, 06 Dec 2022 16:22:13 -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=OEZ3nXZq4E7igsh2DmFsHgveY1W51E+N0X432dfJHyo=; b=nOt7hYfhoJxkHqluSJnxpRExcW/m2quhpIhnCt2VmhwAHoWhp+foIWoMsEF6wIdkvI Rbf8GNmAIVnTLG+lIA6ThCYViUdKlHharbhvotCvy2BvDU36itd3ooK0vKMM914ZXS3K llSojtAyxUiRTUSgxDaGmOOdKjFCGPZwwkuMLrvFrsKtQhXvutBKuXRg2TdB/B72kQEw ueYt6FAFjRVdQ+xVslRGRaDThzeJGgZpIuqzVT7gWw+v991mrr4aqeEw3Ki2PlaLHaFb gcvNJY6QM6cXqabzvF8qSR/n2mJeeEOfUOMw5pNtyskDaAD4PBFedJ9w/MKFIIJs30gf /R4A== 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=OEZ3nXZq4E7igsh2DmFsHgveY1W51E+N0X432dfJHyo=; b=lolyWBtKBQXLOuS0BSVxtz4wyA9mGOcoi9NishBVq+TQvAVvHWdvT/du/KKZeXoOVz G/23e0Z1qYDeav4MVdI9IVa2jbKE3OqpEPOoygZdBLrNmrjj222MwEgXGDHh5SINPwGj vcFkJ+X+XcAJ2TTy2zJPC4ys6ltfSx3EbfZCxiC8A+RqDfgaRhKMPpycQ4CcGLcczN6C N+/RzXVjeyXqZzJfUM8KN8pfG7WIKRL3Ha3oLdARYKrDX2IEZvE5uk6kAIWRJCWUqjud MZyldXCjIBZa3JTjTIzeAyVgmZ/9e67QSWXe7EWjvPsFsD3YUtoKsqMzZ+mkjZLYzIbX eISw== X-Gm-Message-State: ANoB5pnzhsDsrdxZuR3+DydYgJ6UlslPtxe55wzlMRb+TQ/3Ja+EZutu +BKpero6LpriUXs7pDvOYmQ= X-Received: by 2002:a17:902:e411:b0:189:8796:7813 with SMTP id m17-20020a170902e41100b0018987967813mr46531581ple.110.1670372533159; Tue, 06 Dec 2022 16:22:13 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::2c6b]) by smtp.googlemail.com with ESMTPSA id i92-20020a17090a3de500b00218ec4ff0d4sm13369459pjc.6.2022.12.06.16.22.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 16:22:12 -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 3/3] swap: Convert deactivate_page() to deactivate_folio() Date: Tue, 6 Dec 2022 16:21:58 -0800 Message-Id: <20221207002158.418789-4-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221207002158.418789-1-vishal.moola@gmail.com> References: <20221207002158.418789-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?1751513376077056203?= X-GMAIL-MSGID: =?utf-8?q?1751513376077056203?= Deactivate_page() has already been converted to use folios, this change converts it to take in a folio argument instead of calling page_folio(). 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..f404790222c0 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 deactivate_folio(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..828961fc7899 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); + deactivate_folio(folio); folio_put(folio); applied += folio_nr_pages(folio); } diff --git a/mm/madvise.c b/mm/madvise.c index 59bfc6c9c548..afe957994317 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); + deactivate_folio(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); + deactivate_folio(folio); } arch_leave_lazy_mmu_mode(); diff --git a/mm/swap.c b/mm/swap.c index 955930f41d20..9982469e8da8 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 + * deactivate_folio - 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. + * deactivate_folio() moves @folio to the inactive list if @folio was on the + * active list and was not an unevictable page. This is done to accelerate + * the reclaim of @folio. */ -void deactivate_page(struct page *page) +void deactivate_folio(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;