From patchwork Tue Nov 1 17:53:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13823 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3117846wru; Tue, 1 Nov 2022 10:57:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ZC0+33viRZTHWteArfDnDpydPNWsglY/qI6sWRgU4l1mZ8hhW4m4lEykQQ3o5Kq7HaUuI X-Received: by 2002:a05:6402:2756:b0:443:4a6d:f05a with SMTP id z22-20020a056402275600b004434a6df05amr20249445edd.396.1667325479585; Tue, 01 Nov 2022 10:57:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667325479; cv=none; d=google.com; s=arc-20160816; b=YimxREpSFml0M16rvy3DW4RJq1kn6zJjEUGlInYRcqb6WdSxg6igB8+I3e6q8LzSAV mV6/5sPoKbSp25LPtx4/9GnzWtxOztljyaxyX68LCB7QFbzZT56SqVTmctgAlTqL8Oeg tmmuQ79VNzAJwY+77Ht7FPxifXNQpAH1P9tzwLiALMjnAniwt1vVYHBWoJZAJx8VNEIV /eA0sbE+Uxx6ooOk3b1c/WF36r0hUFiqwMaBR2nanLiBnYBm1wyRnGa8iFxGzu857UQ/ j9zFdxeD5Fq8MrqY4JWzGB1OyERbew3A1Kdgy/UXAVH/q31gEHYC0unMTIrOP+reiFjf QIzw== 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=FuGJz+KOe5nlhTqBhnCFZVh76KOjwWx4QzuxWRatQRw=; b=xooCsxO/cb63K9oNrdpTg6PnV7bZjSSmZxWarcRR31V6DVOjfaCj3yKH/R/Gtn4UxQ ormFMhStbZQUo4bbaU6uOaATvVVg1Suy5oY7uavLAE2qzVcrSD8epnlRZqKZnbLdEwBv A1/VfBgh1OcxWDxJxAU7Zi2lZCIhMvU1XiSii+R1wgNE5SH31RylCaLnnrh6A3kbMQXh CA+MFL+N9eWUjLL5kWBOeugTnDSQ7YLZ6qnORWaQCCVqyUN9yzrRBMQoncbr2unWZTzb TedJNXx/1mXjBO50G18BmjFWxsDKt9lY+qdcWRS7Tjz9qVyZ/44uESqC7y1EeWSd/izv rW5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GLtbpdDa; 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 rv27-20020a17090710db00b0079dc9dcbbb6si10998004ejb.337.2022.11.01.10.57.35; Tue, 01 Nov 2022 10:57:59 -0700 (PDT) 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=GLtbpdDa; 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 S230354AbiKARx7 (ORCPT + 99 others); Tue, 1 Nov 2022 13:53:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229967AbiKARxz (ORCPT ); Tue, 1 Nov 2022 13:53:55 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 156EA1CB00; Tue, 1 Nov 2022 10:53:54 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id y4so14278201plb.2; Tue, 01 Nov 2022 10:53:54 -0700 (PDT) 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=FuGJz+KOe5nlhTqBhnCFZVh76KOjwWx4QzuxWRatQRw=; b=GLtbpdDagXfzzArPWFbzC1pLfwjGTFMl3yMdbdI+UPQWP6Safe9ZomEqovW5g78jsn u1gUxCUdpMfjPpRavHZw7PboDNLvOt2PJamvnpqII7rcm63F4RGcv2RcUj96F24eSfUd hxpSBMmmWfCzqKgvA7FhwffpTioO28REYvlpGitRbXdbz3iC3bTUAOjICPQXmDpUQGHC 8XdjD6Q+zhl4iIWf96kJzS6ftU+ra0QIcIxEHG6pPH8gzHev8fLbDEvqhW+2lpB5ruE/ /L7S0GqoVyp8Jl2KJeWLQEorqRqPJXZXVhX/NX1WBf+Q2G1KhhQ7tx14rlJXnQrmV5hP JIdQ== 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=FuGJz+KOe5nlhTqBhnCFZVh76KOjwWx4QzuxWRatQRw=; b=RYRy6/TkwXdVlYnFxchu0aspS7eQ+EbvRqw2HmS0akm5Eptt9FRkqSlysPGXv1dCs+ gSihFHpo0Is00xl2Yk5N3r+6PWCeS5jJKhxzqnqMoaSJzQueDnlIGCeGescrTnB/EcIw vonswIAen8eFcOjuYCw2NJkGiCIllZ3flKX6J99/02MYTkWwHM/x6IcheHz9TcVdJLFA sOkMet4hWO8Kg7qgxtdmrkCW6vZWPLNeATyzAZHWCxfTe2+cxxZ2a4cua0H8cXJ6h1iW eRbAA5HEQS1+ba78k2YF0YaEGaZ5He3+LaJ+6x+w2iBKTVIwikyCzelDbSU5mL++7psk wtrA== X-Gm-Message-State: ACrzQf2z1WoHqJQtgWK+/UXLchZLIZJXSU9OrsMP3G/GMaxLDMoD//xW PB7ck4p7aowx2Dvjg528PP4= X-Received: by 2002:a17:902:cf02:b0:187:846:e007 with SMTP id i2-20020a170902cf0200b001870846e007mr18228062plg.70.1667325233484; Tue, 01 Nov 2022 10:53:53 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id e26-20020a056a0000da00b0056b9124d441sm6797987pfj.218.2022.11.01.10.53.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Nov 2022 10:53:53 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org, willy@infradead.org, miklos@szeredi.hu, "Vishal Moola (Oracle)" Subject: [PATCH 1/5] filemap: Convert replace_page_cache_page() to replace_page_cache_folio() Date: Tue, 1 Nov 2022 10:53:22 -0700 Message-Id: <20221101175326.13265-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221101175326.13265-1-vishal.moola@gmail.com> References: <20221101175326.13265-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?1748317481921539260?= X-GMAIL-MSGID: =?utf-8?q?1748317481921539260?= Eliminates 7 calls to compound_head(). Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Matthew Wilcox (Oracle) --- fs/fuse/dev.c | 2 +- include/linux/pagemap.h | 2 +- mm/filemap.c | 52 ++++++++++++++++++++--------------------- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index b4a6e0a1b945..26817a2db463 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -837,7 +837,7 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep) if (WARN_ON(PageMlocked(oldpage))) goto out_fallback_unlock; - replace_page_cache_page(oldpage, newpage); + replace_page_cache_folio(page_folio(oldpage), page_folio(newpage)); get_page(newpage); diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index bbccb4044222..275810697d71 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -1104,7 +1104,7 @@ int filemap_add_folio(struct address_space *mapping, struct folio *folio, void filemap_remove_folio(struct folio *folio); void delete_from_page_cache(struct page *page); void __filemap_remove_folio(struct folio *folio, void *shadow); -void replace_page_cache_page(struct page *old, struct page *new); +void replace_page_cache_folio(struct folio *old, struct folio *new); void delete_from_page_cache_batch(struct address_space *mapping, struct folio_batch *fbatch); int try_to_release_page(struct page *page, gfp_t gfp); diff --git a/mm/filemap.c b/mm/filemap.c index 08341616ae7a..c61dfaa81fee 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -785,56 +785,54 @@ int file_write_and_wait_range(struct file *file, loff_t lstart, loff_t lend) EXPORT_SYMBOL(file_write_and_wait_range); /** - * replace_page_cache_page - replace a pagecache page with a new one - * @old: page to be replaced - * @new: page to replace with - * - * This function replaces a page in the pagecache with a new one. On - * success it acquires the pagecache reference for the new page and - * drops it for the old page. Both the old and new pages must be - * locked. This function does not add the new page to the LRU, the + * replace_page_cache_folio - replace a pagecache folio with a new one + * @old: folio to be replaced + * @new: folio to replace with + * + * This function replaces a folio in the pagecache with a new one. On + * success it acquires the pagecache reference for the new folio and + * drops it for the old folio. Both the old and new folios must be + * locked. This function does not add the new folio to the LRU, the * caller must do that. * * The remove + add is atomic. This function cannot fail. */ -void replace_page_cache_page(struct page *old, struct page *new) +void replace_page_cache_folio(struct folio *old, struct folio *new) { - struct folio *fold = page_folio(old); - struct folio *fnew = page_folio(new); struct address_space *mapping = old->mapping; void (*free_folio)(struct folio *) = mapping->a_ops->free_folio; pgoff_t offset = old->index; XA_STATE(xas, &mapping->i_pages, offset); - VM_BUG_ON_PAGE(!PageLocked(old), old); - VM_BUG_ON_PAGE(!PageLocked(new), new); - VM_BUG_ON_PAGE(new->mapping, new); + VM_BUG_ON_FOLIO(!folio_test_locked(old), old); + VM_BUG_ON_FOLIO(!folio_test_locked(new), new); + VM_BUG_ON_FOLIO(new->mapping, new); - get_page(new); + folio_get(new); new->mapping = mapping; new->index = offset; - mem_cgroup_migrate(fold, fnew); + mem_cgroup_migrate(old, new); xas_lock_irq(&xas); xas_store(&xas, new); old->mapping = NULL; /* hugetlb pages do not participate in page cache accounting. */ - if (!PageHuge(old)) - __dec_lruvec_page_state(old, NR_FILE_PAGES); - if (!PageHuge(new)) - __inc_lruvec_page_state(new, NR_FILE_PAGES); - if (PageSwapBacked(old)) - __dec_lruvec_page_state(old, NR_SHMEM); - if (PageSwapBacked(new)) - __inc_lruvec_page_state(new, NR_SHMEM); + if (!folio_test_hugetlb(old)) + __lruvec_stat_sub_folio(old, NR_FILE_PAGES); + if (!folio_test_hugetlb(new)) + __lruvec_stat_add_folio(new, NR_FILE_PAGES); + if (folio_test_swapbacked(old)) + __lruvec_stat_sub_folio(old, NR_SHMEM); + if (folio_test_swapbacked(new)) + __lruvec_stat_add_folio(new, NR_SHMEM); xas_unlock_irq(&xas); if (free_folio) - free_folio(fold); - folio_put(fold); + free_folio(old); + folio_put(old); } -EXPORT_SYMBOL_GPL(replace_page_cache_page); +EXPORT_SYMBOL_GPL(replace_page_cache_folio); noinline int __filemap_add_folio(struct address_space *mapping, struct folio *folio, pgoff_t index, gfp_t gfp, void **shadowp) From patchwork Tue Nov 1 17:53:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13825 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3118098wru; Tue, 1 Nov 2022 10:58:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5zZ8UhMOYQ6wjKMOsyp1BLRUjIvjzzLCsnLWtz9TDkY+poWiuJG2ABwxEP70zOTzvNnLqJ X-Received: by 2002:a05:6402:3887:b0:458:289e:c9cc with SMTP id fd7-20020a056402388700b00458289ec9ccmr20468468edb.101.1667325514493; Tue, 01 Nov 2022 10:58:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667325514; cv=none; d=google.com; s=arc-20160816; b=g19iaMZpB/19MfpeFZuepbZNNqVJ0JXDnYoSxasFkZRZRjgCQqDaKJSwZzwCCV5yAY WhMLhwTpSeZ8VXuljyw/KzvPBASPHc42EPtWiOsthKmz3T8PEL1mAHmdP5kPR4P4R6tL 3sYGyXTeDuBsZT4ofBeI16vtTQwjCtzA6t6j8ojSNRcv4wZ66QUqUtR/R7E8fg3Pmrjn ZfmLPIiwJI47qFGo6x+I7kV0cNpLmfH1L2RejGrguJ0fL1fM3IzGrgXDewrd+egiHG2W Y5VXoP5U8ztXgxSmQrCG/p6oZIvoNR0BcWEGQwmxvoKCGZ8Ebf1nDXu+ChTF/z30Y51s S8kg== 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=gL8HvCZz9dSb2yNioMucyaNDmIRb4Dn4rkrcpThzugo=; b=oM11arTK4F3HEO43fKHqS7/7mNn4vXbE67X7QRmVvI/DZ8/Ghu3QS5sp8WnM6owdJU MKMCtfZ/N2a4jBehJfpKCiIwvPcsrQ4MiTyDzReEzmsgvwIUwH/O8o55xZjvDleZPVT7 u2PVwM6dEUcYu1g6WmabQN6hPKA06GwMD5OWh/uK1BMPP4hIPiImm8S9ZMbyh16/s+SX ZQuYR8PzarNl8u6iRT3hbt8tZdDCL19GWUfYaeX87VAA2Urfb5fI8q335LJBj2wnsW/k rDh9ruO1G0f4sUx91Trg/csUcQ/dpBtUh3wrXdDAHLRsPcs1eNmfBwMohqGEtPiU8Ggh HT2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="N/5n/6/d"; 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 z2-20020a056402274200b004542e6bd242si14264429edd.621.2022.11.01.10.58.10; Tue, 01 Nov 2022 10:58:34 -0700 (PDT) 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="N/5n/6/d"; 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 S231165AbiKARyF (ORCPT + 99 others); Tue, 1 Nov 2022 13:54:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230169AbiKARx4 (ORCPT ); Tue, 1 Nov 2022 13:53:56 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4896D1C43D; Tue, 1 Nov 2022 10:53:55 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id io19so14255135plb.8; Tue, 01 Nov 2022 10:53:55 -0700 (PDT) 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=gL8HvCZz9dSb2yNioMucyaNDmIRb4Dn4rkrcpThzugo=; b=N/5n/6/dEchQiUPQn4ILuSW0qhF4oGND1gECuxKepZ/5xh2x6iJagwhf8ZnLvpfb5n IVKFjbTElEwjtCFiWWomqbCdrTL3jxyfcNfmRkFWGrNBalcxZUeq4pL1RgDghi9aVAxj /rBag8qMIA8cBJK2PiR1fgcp3PUUBxjs3MRdhBTyQFOs+mWiigk5zpa6U5KKjwZj7AVd x9MjxtqOYf4K134z7WyeIXb9KnKVYNvTDRnTF0yd/edBvbLzTY+UgjSwpPRu6JZ38L0g 9qSW/FKlxyBMVc3RKpBMksYuJpScfFAGLcFavweU4t1PzF4PfCi2CRnmLc+anngs8yRJ bT8g== 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=gL8HvCZz9dSb2yNioMucyaNDmIRb4Dn4rkrcpThzugo=; b=WuO5gPpmYlAWJz+o3EN+WL9yzTVFsB70N8Zls5iSAOTFYuvr1VQl2+/oGB7LofX9ek EdDim3N6g8BlPq7CJESIdqCE/mOTP/D0f759DeVd+EIPVd34aT0/mY2IKVDSW0HLLHx0 bOi4AeMYHW+375nnPi8wN6yuV4+41kcKLhNluxdsr1gild5dj1HZ7hwZaQ5jt1Z+56EN VySmN0HjivC2pvjKyc/DuyAgRmD+n3Vc56J7OMiPEmeMhmT9E50Qpjnj1m/jRtgEcA5A RuuPef/1zfO484TN0EbuU86P2uLzBRXAPRwtcq67sGQZFM4lRNtOiA7F7+CHexHzC01a OrPQ== X-Gm-Message-State: ACrzQf0Su0g1I50I16eQNe4JDWWknEVAVN6m5yszd092ONHhPg7S0LgO PUI/pI79sMl1l+WC/O5oPF/niZOF03VJ0A== X-Received: by 2002:a17:90b:3b44:b0:213:34f7:facb with SMTP id ot4-20020a17090b3b4400b0021334f7facbmr38966874pjb.150.1667325234783; Tue, 01 Nov 2022 10:53:54 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id e26-20020a056a0000da00b0056b9124d441sm6797987pfj.218.2022.11.01.10.53.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Nov 2022 10:53:54 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org, willy@infradead.org, miklos@szeredi.hu, "Vishal Moola (Oracle)" Subject: [PATCH 2/5] fuse: Convert fuse_try_move_page() to use folios Date: Tue, 1 Nov 2022 10:53:23 -0700 Message-Id: <20221101175326.13265-3-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221101175326.13265-1-vishal.moola@gmail.com> References: <20221101175326.13265-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?1748317518609619289?= X-GMAIL-MSGID: =?utf-8?q?1748317518609619289?= Converts the function to try to move folios instead of pages. Also converts fuse_check_page() to fuse_get_folio() since this is its only caller. This change removes 15 calls to compound_head(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Miklos Szeredi --- fs/fuse/dev.c | 55 ++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 26817a2db463..204c332cd343 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -764,11 +764,11 @@ static int fuse_copy_do(struct fuse_copy_state *cs, void **val, unsigned *size) return ncpy; } -static int fuse_check_page(struct page *page) +static int fuse_check_folio(struct folio *folio) { - if (page_mapcount(page) || - page->mapping != NULL || - (page->flags & PAGE_FLAGS_CHECK_AT_PREP & + if (folio_mapped(folio) || + folio->mapping != NULL || + (folio->flags & PAGE_FLAGS_CHECK_AT_PREP & ~(1 << PG_locked | 1 << PG_referenced | 1 << PG_uptodate | @@ -778,7 +778,7 @@ static int fuse_check_page(struct page *page) 1 << PG_reclaim | 1 << PG_waiters | LRU_GEN_MASK | LRU_REFS_MASK))) { - dump_page(page, "fuse: trying to steal weird page"); + dump_page(&folio->page, "fuse: trying to steal weird page"); return 1; } return 0; @@ -787,11 +787,11 @@ static int fuse_check_page(struct page *page) static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep) { int err; - struct page *oldpage = *pagep; - struct page *newpage; + struct folio *oldfolio = page_folio(*pagep); + struct folio *newfolio; struct pipe_buffer *buf = cs->pipebufs; - get_page(oldpage); + folio_get(oldfolio); err = unlock_request(cs->req); if (err) goto out_put_old; @@ -814,35 +814,36 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep) if (!pipe_buf_try_steal(cs->pipe, buf)) goto out_fallback; - newpage = buf->page; + newfolio = page_folio(buf->page); - if (!PageUptodate(newpage)) - SetPageUptodate(newpage); + if (!folio_test_uptodate(newfolio)) + folio_mark_uptodate(newfolio); - ClearPageMappedToDisk(newpage); + folio_clear_mappedtodisk(newfolio); - if (fuse_check_page(newpage) != 0) + if (fuse_check_folio(newfolio) != 0) goto out_fallback_unlock; /* * This is a new and locked page, it shouldn't be mapped or * have any special flags on it */ - if (WARN_ON(page_mapped(oldpage))) + if (WARN_ON(folio_mapped(oldfolio))) goto out_fallback_unlock; - if (WARN_ON(page_has_private(oldpage))) + if (WARN_ON(folio_has_private(oldfolio))) goto out_fallback_unlock; - if (WARN_ON(PageDirty(oldpage) || PageWriteback(oldpage))) + if (WARN_ON(folio_test_dirty(oldfolio) || + folio_test_writeback(oldfolio))) goto out_fallback_unlock; - if (WARN_ON(PageMlocked(oldpage))) + if (WARN_ON(folio_test_mlocked(oldfolio))) goto out_fallback_unlock; - replace_page_cache_folio(page_folio(oldpage), page_folio(newpage)); + replace_page_cache_folio(oldfolio, newfolio); - get_page(newpage); + folio_get(newfolio); if (!(buf->flags & PIPE_BUF_FLAG_LRU)) - lru_cache_add(newpage); + folio_add_lru(newfolio); /* * Release while we have extra ref on stolen page. Otherwise @@ -855,28 +856,28 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep) if (test_bit(FR_ABORTED, &cs->req->flags)) err = -ENOENT; else - *pagep = newpage; + *pagep = &newfolio->page; spin_unlock(&cs->req->waitq.lock); if (err) { - unlock_page(newpage); - put_page(newpage); + folio_unlock(newfolio); + folio_put(newfolio); goto out_put_old; } - unlock_page(oldpage); + folio_unlock(oldfolio); /* Drop ref for ap->pages[] array */ - put_page(oldpage); + folio_put(oldfolio); cs->len = 0; err = 0; out_put_old: /* Drop ref obtained in this function */ - put_page(oldpage); + folio_put(oldfolio); return err; out_fallback_unlock: - unlock_page(newpage); + folio_unlock(newfolio); out_fallback: cs->pg = buf->page; cs->offset = buf->offset; From patchwork Tue Nov 1 17:53:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13826 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3118258wru; Tue, 1 Nov 2022 10:58:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4XT6GYql2wyRYFngg9EZYIl81p1r8wc2MMiXNYsz2+qlNFC6CGWw12ZNRA4d7sjn0BXOvh X-Received: by 2002:aa7:dd57:0:b0:453:2d35:70bb with SMTP id o23-20020aa7dd57000000b004532d3570bbmr20612669edw.26.1667325534379; Tue, 01 Nov 2022 10:58:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667325534; cv=none; d=google.com; s=arc-20160816; b=SbwqExhLDhStTCS40+5bWvgswWj694fVvKge12LqEMx8WHJsdI4rGLXZX28Af+RStV 542dVqHjVYo1LZOLkZiJ9/9sItGcl0joGOFSETwdHE/5FRJ02dyhVXygGKB+NhB7W0QB nooGyHM3AZOrdW+9ff3J+034e5dz7y/2IZwzOqEW2HLrngz3dxKWYGOw/+AeH6d4D1yp b1eHslr9HyU0iwFHpZn/Bp6UGJNscuZGIJHkM3v4o/iphgcwP5n6wrUo1nbMiki1XIjJ cYrI7v3nG7CPBIkyvrIUxfIzZRMypunUVSGJvR81+bSVCUzeeq3EhuUUUdrldftPKcHr LLBA== 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=8mi0cqN3i/1HTIqi69x1uNrDe0uDt2K2zNDb9Z1HfPw=; b=bhLn8q+km6xU4JWWu5WcEi9d/nLS52Cen61GijrNG/9J4HtKFGv9tDnHkzjevS5aGR GQ/jJbs4PxWYTqLvP78wne3I+CgP935uOs0oq5yViVYcAL0PQ5zvSj/qnPkoBdqXqTmh siFLaLE6/cXjVQ+swQi7Ta5KdBHkgLWemYVAzR4Cfo2gjkvwJgty0LvinEEBgQS3tn// 2a7WKvr1zdSr8eZ8AEespOzSHp1ONMabpjMgJVa/y0R0+RrcYbDCzDijRAAAu1SlNYNw 73eptj5GOMbScLi809xxieEjqG4bwkodvlLba2p0anB7G/MLGCkcj3AvpotkDexsk61b 3DhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RBxiYbfj; 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 nc42-20020a1709071c2a00b007ad96737de4si12923561ejc.624.2022.11.01.10.58.30; Tue, 01 Nov 2022 10:58:54 -0700 (PDT) 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=RBxiYbfj; 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 S230323AbiKARyI (ORCPT + 99 others); Tue, 1 Nov 2022 13:54:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230199AbiKARx5 (ORCPT ); Tue, 1 Nov 2022 13:53:57 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 769591CB05; Tue, 1 Nov 2022 10:53:56 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id f5-20020a17090a4a8500b002131bb59d61so1679826pjh.1; Tue, 01 Nov 2022 10:53:56 -0700 (PDT) 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=8mi0cqN3i/1HTIqi69x1uNrDe0uDt2K2zNDb9Z1HfPw=; b=RBxiYbfjpDwRWt/D6+w2v3Jo18Lh+RXCLXAOGnov4hDYGZVFU+xSvqhrVh7fhuJeq2 kN7vs3xuzmdU41BaE57uYw1KeMK7Brdl1q/LIisxF2YTer9d9gb01l5P9mg6ztt8ZlHJ FxT8H+EhTW+FcC62q64HDNZDSjsy0hsnR6EfWlTMhFK9ol8LYlk6AkNUJ1EQyw/O1AQy 6AGz2HBSGHbYmqEIG++A+uA2wSymWLBgrnpHUEAdMXxAzxaGTCmGSiKk49vZ+JGWUytd J6Qnxgq7ulgG+7lrvlSLx+XWUFiLqkZm41cvpDeTzB+Bm139Arc1de4J38auPaIICKEy Gujg== 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=8mi0cqN3i/1HTIqi69x1uNrDe0uDt2K2zNDb9Z1HfPw=; b=NySVJuze/bXrdkE6ZQXZeyL6aUn3qfGpOHRkAPmKs2cB6pfu3I+nSY4EZ51DkozgW2 ir1kkq7qs1WwaMi6bENo72mkeU1Y2zyDqmsSjAPl0cepRHV+351Nxrqk8KiLdMzaI7kx vIL+wNyJ97e3IxdaOHcteqvCi94kxxat790wd8KLfO+TwqayL1HiL+hvx/HEpwN2oHc6 Y9FNq0E27FtuZTTD3oQAnjVJAdfXaLYtXfdDk1GZyMNw57XlJvAQ40wgXKQOFsMIFQct x3rc//yta6JskRgUr3UYvyz2Bm3lVE0DULwchbKBsxf4VwOGh77V+wMGI5+uh9sHRhBX PMGw== X-Gm-Message-State: ACrzQf2mHlZpeL9ILZwFCoBT45lthadHK5klI+Tw1/0MNI6bUxtTXjs+ D/aB4LO5m6huDffIGkRLMWc= X-Received: by 2002:a17:902:ed53:b0:186:6ad3:c155 with SMTP id y19-20020a170902ed5300b001866ad3c155mr20007129plb.43.1667325235913; Tue, 01 Nov 2022 10:53:55 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id e26-20020a056a0000da00b0056b9124d441sm6797987pfj.218.2022.11.01.10.53.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Nov 2022 10:53:55 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org, willy@infradead.org, miklos@szeredi.hu, "Vishal Moola (Oracle)" Subject: [PATCH 3/5] userfualtfd: Replace lru_cache functions with folio_add functions Date: Tue, 1 Nov 2022 10:53:24 -0700 Message-Id: <20221101175326.13265-4-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221101175326.13265-1-vishal.moola@gmail.com> References: <20221101175326.13265-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?1748317539877090805?= X-GMAIL-MSGID: =?utf-8?q?1748317539877090805?= Replaces lru_cache_add() and lru_cache_add_inactive_or_unevictable() with folio_add_lru() and folio_add_lru_vma(). This is in preparation for the removal of lru_cache_add(). Signed-off-by: Vishal Moola (Oracle) --- mm/userfaultfd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index e24e8a47ce8a..2560973b00d8 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -66,6 +66,7 @@ int mfill_atomic_install_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd, bool vm_shared = dst_vma->vm_flags & VM_SHARED; bool page_in_cache = page->mapping; spinlock_t *ptl; + struct folio *folio; struct inode *inode; pgoff_t offset, max_off; @@ -113,14 +114,15 @@ int mfill_atomic_install_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd, if (!pte_none_mostly(*dst_pte)) goto out_unlock; + folio = page_folio(page); if (page_in_cache) { /* Usually, cache pages are already added to LRU */ if (newly_allocated) - lru_cache_add(page); + folio_add_lru(folio); page_add_file_rmap(page, dst_vma, false); } else { page_add_new_anon_rmap(page, dst_vma, dst_addr); - lru_cache_add_inactive_or_unevictable(page, dst_vma); + folio_add_lru_vma(folio, dst_vma); } /* From patchwork Tue Nov 1 17:53:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13828 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3118771wru; Tue, 1 Nov 2022 10:59:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5L4I9N4yu7sRoWmz+hOphWMq6Xt1hl9UCitKF/TRSJhzmfsZBQwNnTVNKQ1vXsPzXbbM5w X-Received: by 2002:a17:906:7949:b0:7ac:9917:90b9 with SMTP id l9-20020a170906794900b007ac991790b9mr19162619ejo.536.1667325594085; Tue, 01 Nov 2022 10:59:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667325594; cv=none; d=google.com; s=arc-20160816; b=ZzLE3YE60MjkBYSS1HRddjiq/9j9IvgOFY5UsZnazKkNZr9b0x0RnwieTLt278eZZB 7xk/hXYNgl57GqLfilWShf3He1FrW2QG9jeBQbvodrmVXnXGYqPIlLMEruTWqNyxGYzd esM16tdIpIt7Z+ltv4wn4UvlITjKUQpRhdvXEkgJ3WBhJl/o3SOkWAs/DuRnGeNtGUzB IlshKGpim3cHL/P2PhXAKl42D3F6SDhkHc0tTM99CqrU8L78jAoaQnOqbGRBB00VC8M0 wmvvOMs4xheHoHhHNLw9vDsdeSn4B5iUPsF4dPzvhEKKIjlCvwdYnjATvHKml/gOSQcW jKbw== 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=sd/ZTZPQkq+Y0RGPTAhY/UhYvgYWKV9wt541wP0v/Zs=; b=ktnCrMGomFTMplxikf93QfczeJQJXbQMWP1WvV5/En+rC+CeaQhXDEZIrGYEAH+D2M iEddHtQefAe92F+UO8Mf1niF7fyaXWlnz6y5A9opIY9qMJW6K5G6egA7GiQ3IScDau17 TeisbovCEp21X1S7XqIXIPrgA9rlCzwkqb5gTii/ZdUTfzKgJ/Kz5CajYU5RhcXUXi3H YOsQM11utOwQPAkZag/XHItUnS44WeCV7l2GAGyNZFtUKSkFeZdwAR8UyzhQo2l6iysj 165SLHS+E0ACTElPsh1KOHE2OOw4OJosNUexzYFqxoDTh7KSTZ9pB0gy/9XIYnWTLxrq pQeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SIGbKrtK; 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 hv12-20020a17090760cc00b0078b96068bc0si14925805ejc.79.2022.11.01.10.59.30; Tue, 01 Nov 2022 10:59:54 -0700 (PDT) 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=SIGbKrtK; 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 S229962AbiKARyT (ORCPT + 99 others); Tue, 1 Nov 2022 13:54:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230314AbiKARx6 (ORCPT ); Tue, 1 Nov 2022 13:53:58 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 819CA1C43D; Tue, 1 Nov 2022 10:53:57 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id io19so14255230plb.8; Tue, 01 Nov 2022 10:53:57 -0700 (PDT) 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=sd/ZTZPQkq+Y0RGPTAhY/UhYvgYWKV9wt541wP0v/Zs=; b=SIGbKrtKugy7nOZmvoxKWK2XYfJQbfbGIzdFN5dvzfDZL8Ani8HTrXJSEa9F4u+AxM 06FrOunrj2wfzy6hsmYucv8fjbuQhY+ivEWN9s4XkzSo8Fw/pOK90thaglhNy5U03shN RhCEpAoCI+YwQ1hxCfu+jwh01kpoiZ6GPZzP5WDlCJnzf7APFvrvSn8WpjglC+98MsYo MFE0Almyut+ZmS2LS3VcUnkb8E6ubc7zK3Mpz821N86Fy9YD8VL1yUm9anQfuvtvfkfP 4JFoMdZGZUCWXoa6IdrHlkw3mQWpRk7i88a5kAJeDpVGx5OQcdSeBPqg0yCEaI1gjDOY N9+A== 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=sd/ZTZPQkq+Y0RGPTAhY/UhYvgYWKV9wt541wP0v/Zs=; b=ldV1Z7IMlu1mc/gqhTiRPpzbtGNXSQ/PJ9+XZg0JQpU3zW1CgJgd85hN3CoFi/O1hQ lXVs1AZp5JVrRba+DFvXRA3ReC4EjS0gouz+Y+6k+WqjtcSos7f7zINUDreoS8/A/Gtb zwvPEy9SF5PFPoD04xbEhHI05JIXWZt68yZYsNFjakmFbskz7y14WNyinMwcr6+nCLbz gZuOMvqS/9wVzMvND8oohIR8lkwMrkiZRtQrQCeOivJgRJFTlyYTPemWJzwL/rJrymBI +DkhhidGACSN9vHj3kLEwpRZvHukIDJLKBBeF79jE1GcbqBs5HeZ5ecuS2tN9qYcf9SY pecA== X-Gm-Message-State: ACrzQf0HRqXXAI7e9wp3xmq7OqaUvAD3ZwT6XNaxSvAS9Fs2ETDw+wSX IQwXlsytWXOdQ0SP6a4kGSM= X-Received: by 2002:a17:902:e352:b0:187:c4c:26ff with SMTP id p18-20020a170902e35200b001870c4c26ffmr17413372plc.162.1667325237185; Tue, 01 Nov 2022 10:53:57 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id e26-20020a056a0000da00b0056b9124d441sm6797987pfj.218.2022.11.01.10.53.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Nov 2022 10:53:56 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org, willy@infradead.org, miklos@szeredi.hu, "Vishal Moola (Oracle)" Subject: [PATCH 4/5] khugepage: Replace lru_cache_add() with folio_add_lru() Date: Tue, 1 Nov 2022 10:53:25 -0700 Message-Id: <20221101175326.13265-5-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221101175326.13265-1-vishal.moola@gmail.com> References: <20221101175326.13265-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?1748317601837199763?= X-GMAIL-MSGID: =?utf-8?q?1748317601837199763?= Replaces some calls with their folio equivalents. This is in preparation for the removal of lru_cache_add(). This replaces 3 calls to compound_head() with 1. Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Matthew Wilcox (Oracle) --- mm/khugepaged.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 4734315f7940..e432d5279043 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1970,6 +1970,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, if (result == SCAN_SUCCEED) { struct page *page, *tmp; + struct folio *folio; /* * Replacing old pages with new one has succeeded, now we @@ -1997,11 +1998,13 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, index++; } - SetPageUptodate(hpage); - page_ref_add(hpage, HPAGE_PMD_NR - 1); + folio = page_folio(hpage); + folio_mark_uptodate(folio); + folio_ref_add(folio, HPAGE_PMD_NR - 1); + if (is_shmem) - set_page_dirty(hpage); - lru_cache_add(hpage); + folio_mark_dirty(folio); + folio_add_lru(folio); /* * Remove pte page tables, so we can re-fault the page as huge. From patchwork Tue Nov 1 17:53:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13827 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3118260wru; Tue, 1 Nov 2022 10:58:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7M+N93JQ0qh2l7R36YbrPpyqwR2h7a4Y5hHA99ZW38GH9Zx2rdmcqCVOekAUJQWIjbYuWR X-Received: by 2002:a17:906:6a24:b0:7ad:f2df:51b7 with SMTP id qw36-20020a1709066a2400b007adf2df51b7mr3288888ejc.54.1667325535066; Tue, 01 Nov 2022 10:58:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667325535; cv=none; d=google.com; s=arc-20160816; b=0xLdTS27cvO8xRFMYoVyRlvXZg6o8moCGG1WrtqePknF/o5xYM8u1L4hSPLwhtlRxe E8mWnpFCN3lxKrTsC733lLYwdCJd6m0VfG8WEskXcP2xXtBRH5O1uh1loud7DpRNdNHw M2OCbpfIxOVawo3h2w/Rtsz/FKGutXIuiowY5shyV9SbgAI8XGKgo+VgHfsDlNckCu4s hi5mga06dCq0FhhI6cSfmAzsMvAZi7HWqIVNvdNT7TIJn/gNDCP9aEaE9JYlq0t4IV6O edpqhRorm9gV5ldSohQ7TA0R2GMe+e0GbOb3irGVJrJ4xpYBGGZZkdjQlxI+oJx9DjNE 6LeA== 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=M2J1+cr5yCkfhmlJuiea40UIW73C1SmYJz1XZ9F//oM=; b=FK8ETyi257zUzsrcxmPRYDpFRPJ+cYGcXCTmAyUM3mkecDO9l86Y9KzBEyZ+XD/S8Q 0lPKUUtqCKvs0Jc69oERNQ0C60s3h3pH0mbgqVL2nQ7d5+/c5VbJNzMpQETYlduUjou/ UCjA895ia+TK/xFx7XJpxEvIAi5Dx3PXwGgcqjeaHoobudFxYaPqr9WnraIjvp/zqfuD hoFNQYQidX3S1GKxTQ5D4lsFF01jaYVM0dF3AUulhL61yfMDWV/LdGFAWYEtkRBDaawF rZ5Azc+7W0UocJuOU9o93JwOWeev4EZEAxE+bMVBmTS0LbMndeaWZbS3qw6OuNSqCIoT jC5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=a5nRUpRV; 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 dn19-20020a17090794d300b007824786a7easi13741970ejc.724.2022.11.01.10.58.30; Tue, 01 Nov 2022 10:58:55 -0700 (PDT) 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=a5nRUpRV; 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 S231217AbiKARyP (ORCPT + 99 others); Tue, 1 Nov 2022 13:54:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230451AbiKARx7 (ORCPT ); Tue, 1 Nov 2022 13:53:59 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D51711CB04; Tue, 1 Nov 2022 10:53:58 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id y203so3133pfb.4; Tue, 01 Nov 2022 10:53:58 -0700 (PDT) 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=M2J1+cr5yCkfhmlJuiea40UIW73C1SmYJz1XZ9F//oM=; b=a5nRUpRVccWsflu1tgAUVeXJZySVFCbti/up2zo4roQ9JkbZo/hfTJHelHBSHo5tLe tC1jaZjXp19/j7nU6I5PBFMdByE64i0asxNb/6rZb7HZt/BnmzkoLFNQr8xE+O4yNXaf cqrVi+oPQcK7NGLdteVHwS5XkTUUjXZ1UQiZE7t+qpHQdWqOSRb0WHS44woZVsj2Geoa Wa5ftzIuMBmVy8Dkdq3XIyYWOE/DlLtDUjaGU5oe7O8ZVy0BnuY36U/yEmFBBv2+hVFL dY5LBROUWb2htulwX6mqLJBYBf75f2WrHHjFLuu5Yb3twbmP/UR84r4LGdZDdoqGKA5f T83Q== 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=M2J1+cr5yCkfhmlJuiea40UIW73C1SmYJz1XZ9F//oM=; b=tQ/e9qAor0W5EYYEvn+3FGy9IrTyhEUQB/Tv2lB+Z74xBJsDagGQ6FMWzdMl6Kkpig IRvb6QBIHfFIpELeIgiaCMEmvW6jCrK05GCN/ICda+IYVWmSJQ3lb+kNYm5ut/usSIqr hqRD+iCCFKA4yDrXLPYuRUUJE2BcZAyiGCEd2KVy4EeuVMzKcIU7FC5AOeIVUpQazUyx q0ey/kbV4nPosu98trUTvZI+b7W8rzi+XPG6vDhs5AYQ1VCbq4AIq8K6wHSuSPxr4Ntr JdkikeWn2m+zN0N4QFi+JZpOckup6qCiO1ajG3XRESbfx7VH32ocaAQ5R9S+f01fOXiN lUmg== X-Gm-Message-State: ACrzQf31u7/VtrPLgy66ZOJ7FaOckRAqdPo6Kbdn6J3F12gvviqBUTwf K05imVopJmYYeFf78ypMy0MloIkFxebB3g== X-Received: by 2002:a05:6a00:891:b0:565:85a7:a6e with SMTP id q17-20020a056a00089100b0056585a70a6emr3854588pfj.21.1667325238285; Tue, 01 Nov 2022 10:53:58 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id e26-20020a056a0000da00b0056b9124d441sm6797987pfj.218.2022.11.01.10.53.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Nov 2022 10:53:57 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org, willy@infradead.org, miklos@szeredi.hu, "Vishal Moola (Oracle)" Subject: [PATCH 5/5] folio-compat: Remove lru_cache_add() Date: Tue, 1 Nov 2022 10:53:26 -0700 Message-Id: <20221101175326.13265-6-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221101175326.13265-1-vishal.moola@gmail.com> References: <20221101175326.13265-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?1748317540143827766?= X-GMAIL-MSGID: =?utf-8?q?1748317540143827766?= There are no longer any callers of lru_cache_add(), so remove it. This saves 107 bytes of kernel text. Also cleanup some comments such that they reference the new folio_add_lru() instead. Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Matthew Wilcox (Oracle) --- include/linux/swap.h | 1 - mm/folio-compat.c | 6 ------ mm/truncate.c | 2 +- mm/workingset.c | 2 +- 4 files changed, 2 insertions(+), 9 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index a18cf4b7c724..c92ccff9b962 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -388,7 +388,6 @@ void lru_note_cost(struct lruvec *lruvec, bool file, unsigned int nr_pages); void lru_note_cost_folio(struct folio *); void folio_add_lru(struct folio *); void folio_add_lru_vma(struct folio *, struct vm_area_struct *); -void lru_cache_add(struct page *); void mark_page_accessed(struct page *); void folio_mark_accessed(struct folio *); diff --git a/mm/folio-compat.c b/mm/folio-compat.c index e1e23b4947d7..efd65b7f48bb 100644 --- a/mm/folio-compat.c +++ b/mm/folio-compat.c @@ -82,12 +82,6 @@ bool redirty_page_for_writepage(struct writeback_control *wbc, } EXPORT_SYMBOL(redirty_page_for_writepage); -void lru_cache_add(struct page *page) -{ - folio_add_lru(page_folio(page)); -} -EXPORT_SYMBOL(lru_cache_add); - void lru_cache_add_inactive_or_unevictable(struct page *page, struct vm_area_struct *vma) { diff --git a/mm/truncate.c b/mm/truncate.c index c0be77e5c008..184fa17fce60 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -573,7 +573,7 @@ EXPORT_SYMBOL(invalidate_mapping_pages); * refcount. We do this because invalidate_inode_pages2() needs stronger * invalidation guarantees, and cannot afford to leave pages behind because * shrink_page_list() has a temp ref on them, or because they're transiently - * sitting in the lru_cache_add() pagevecs. + * sitting in the folio_add_lru() pagevecs. */ static int invalidate_complete_folio2(struct address_space *mapping, struct folio *folio) diff --git a/mm/workingset.c b/mm/workingset.c index ae7e984b23c6..25844171b72d 100644 --- a/mm/workingset.c +++ b/mm/workingset.c @@ -492,7 +492,7 @@ void workingset_refault(struct folio *folio, void *shadow) /* Folio was active prior to eviction */ if (workingset) { folio_set_workingset(folio); - /* XXX: Move to lru_cache_add() when it supports new vs putback */ + /* XXX: Move to folio_add_lru() when it supports new vs putback */ lru_note_cost_folio(folio); mod_lruvec_state(lruvec, WORKINGSET_RESTORE_BASE + file, nr); }