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: 13027299 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 0F4D5C43219 for ; Tue, 1 Nov 2022 17:53:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 86A436B0073; Tue, 1 Nov 2022 13:53:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F2A76B0074; Tue, 1 Nov 2022 13:53:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61EE06B0075; Tue, 1 Nov 2022 13:53:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 4F6236B0073 for ; Tue, 1 Nov 2022 13:53:55 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 28EC1160A55 for ; Tue, 1 Nov 2022 17:53:55 +0000 (UTC) X-FDA: 80085621630.28.5AF0F4C Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by imf21.hostedemail.com (Postfix) with ESMTP id C42C01C0019 for ; Tue, 1 Nov 2022 17:53:54 +0000 (UTC) Received: by mail-pl1-f169.google.com with SMTP id j12so14266774plj.5 for ; 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=GyzyDdRLZGDR3xLhrZgV6hUvWa4pLH5r7OywRc1gx1j/7sZ0GDO7XFBf8IhbHReD0o j9cgZzqfPZQ3vjd/IWXpkCxXFvNjfD+FgJZLa51lVq1YaA8THWRQ7xaXg39MrtbLH1bb ZY4Gw1kS/jWCjcoai7Cg5H9lNJgSzSuDAPudzL/T1bzVPzaQr0441W7eHfxEFeuuBzba xvk9GCcuVEhOh7jvPAgrXYJP64M5TBJGI/8ygaZh5cJojU4G/mXjyvysD4foqq2L/fZw o/h3ZWd7y2dycl0MA0eieFskf9hDayKgIoezgW4P49nmOaz1Ieft66TN0sfh/MEuWrv4 ohcg== X-Gm-Message-State: ACrzQf07J2i5Oc+ovLUion9XPllQa5M1R7JtADcvM2gYzLmeJL/FAgW3 oh3OyJbNjkpb7Mt+gBoeLnHZIavaGZGRrA== X-Google-Smtp-Source: AMsMyM4Lo9FQUAx4PCChA3A3lYDxPoKT3ikIU8naaS8JY51piB8RrefMXEBKCh8ZFG34NdjISTQlXQ== 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667325234; 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=FuGJz+KOe5nlhTqBhnCFZVh76KOjwWx4QzuxWRatQRw=; b=YB3lyKpRnCW3kFDGd8VnxdOB/0EUQ1WOEvP/PElNow8P/6xkv/o8h6LjvZ9s0wxFWNcNmQ Z5tDCq6n7iAQhtYg54yxnR/N0j170btusuhsud8VGseCSIxZLwJ6feIWo7OkI+dAtBZXGS 860ptKRcvLpljK1ymMQ761g1Nhwrg1I= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=GLtbpdDa; spf=pass (imf21.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.169 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=1667325234; a=rsa-sha256; cv=none; b=p0zBtcdO16GQyO+9zRZBua9X3rCB2FBjZWHBk3fKCAgo9wG1c35fnK/3bYcSG91D3wmwoA 1fEd/D4oMkN/0VtAbM+HpMFUwatTOw7epKwNoXT8Ey9DUjsdWMYLRGenNnfdifiD/6iYlG NwRjOtwUvLibyFieN60gCwQ70Rmn2QY= Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=GLtbpdDa; spf=pass (imf21.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.169 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: ucsp4fsy74c34z65ny4bw5wepqgrc9fe X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: C42C01C0019 X-HE-Tag: 1667325234-627247 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: 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: 13027298 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 4EC43C4321E for ; Tue, 1 Nov 2022 17:53:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC0E56B0074; Tue, 1 Nov 2022 13:53:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D4B926B0075; Tue, 1 Nov 2022 13:53:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B9CBA6B0078; Tue, 1 Nov 2022 13:53:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A673D6B0074 for ; Tue, 1 Nov 2022 13:53:56 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 67AA91C674D for ; Tue, 1 Nov 2022 17:53:56 +0000 (UTC) X-FDA: 80085621672.18.FBE6560 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf18.hostedemail.com (Postfix) with ESMTP id F07A51C001A for ; Tue, 1 Nov 2022 17:53:55 +0000 (UTC) Received: by mail-pj1-f44.google.com with SMTP id m14-20020a17090a3f8e00b00212dab39bcdso19590650pjc.0 for ; 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=WZOBbLJH8OdmM7YYXl8Hr2N06+nw7uGUDeyhlWWGz1gZ42zt4hn/356dx3lV1cmdBP 2xamGgc/hiDO4bH+0xn08wiqJtdzyAPIWXRsqvoWL4l53hRqfBHTUo2EG32SOwU2qifv gVScHl9S5nn1CmOr0pxauNmqpUQTdf37rfbC51zMTCk40g/tCh9OTkRq+er7Tc2CknTe FVuhxhFUmx4BkIolgqJhxLeRw3ETGo1kWSrSVcdbYk44buGdS2hT/XEFTo7LiJzobvm1 m0KwOc8takGUDUOTOodmKPYIPTwat49KEYHeNGVH6cPzuAhr5fX1ELMwHDXBuRXj9Asu 9L1Q== X-Gm-Message-State: ACrzQf2afVvI3cn/9f6DFptTd/XMiAX5AFvgb/B8ROacJEUJFVs15cZn 3onyD/IAECpAbqilyU8a9gZq0eC9rjku+g== X-Google-Smtp-Source: AMsMyM6C1f+mV994BjbsV8kHe2UGkzBklv03r5VTJO+o24yiXYT9etxuz+hC6lPxfT1+bQnnM3TC4A== 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667325236; 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=gL8HvCZz9dSb2yNioMucyaNDmIRb4Dn4rkrcpThzugo=; b=Yyo5HZ1DFml6KDVOhIwq8Csv8C0kLqm7HCS8fK/fJeu3JEvv0aD/y+OOOYJGRWcFv4ylWw sgRJzUTOPLa1r9eyGIUo7H08Z9ZHBYJYLAB+5AwjTLBrhs1HbvtDqMv0MtcRfHlt+8Jmqo 2NCknxv5qwXlIyDXY3GOCV86yYdx5ak= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="N/5n/6/d"; spf=pass (imf18.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=1667325236; a=rsa-sha256; cv=none; b=KGbd5fbcR+zugE4XRXuNNUXwQmbrnepec0II6XfDU8Pom0b6fl7xF7ZiAubrpyChnMH3kI TmB+jdIzSFlevY1e2Naat8Sr6GSJ+0CNZHI2qtGPdjUZMx/zUUYfJz18Vkzmajt+URbW3H Bg2jVnfapo0k6Eznnrwj23Rs8JEd/XI= X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: F07A51C001A Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="N/5n/6/d"; spf=pass (imf18.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 X-Stat-Signature: ogupoeandphbjpc81ctcfrkscrmkq81t X-HE-Tag: 1667325235-9015 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: 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: 13027300 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 B0C61C43217 for ; Tue, 1 Nov 2022 17:53:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BED9B6B0075; Tue, 1 Nov 2022 13:53:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B755D6B0078; Tue, 1 Nov 2022 13:53:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9EF8F6B007B; Tue, 1 Nov 2022 13:53:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 908916B0075 for ; Tue, 1 Nov 2022 13:53:57 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 6F0EA1C6769 for ; Tue, 1 Nov 2022 17:53:57 +0000 (UTC) X-FDA: 80085621714.04.50A5C60 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by imf20.hostedemail.com (Postfix) with ESMTP id 224851C0017 for ; Tue, 1 Nov 2022 17:53:56 +0000 (UTC) Received: by mail-pj1-f52.google.com with SMTP id gw22so994399pjb.3 for ; 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=ILZFTr6471wrqEEEQQ1r8w0TFpueHujpEUCktE3NBHszbxsqSkh52Rsg9ATSfBoyyL ahjLoLbjpfpRJEZ2rQNcgqK8hdYrgxAFgazYHr3gFMlnUJ1B7lowBtaccBlMiMhuo/VX jd/1L+hfifdrjVmuMlIio/FM4/gbX08QwHdWj8Bh7cWSA58ThvBhYwmocbqi832IvNhR Pync92+XAHh7eTzxIeScVZTpc/NBIDhcWOOsPyWkPQx9lgwS3XYl463YIquAEEiNHK9F XvFhLys3R0Z5IkonNBe+mv3hsnsaoyHLsW7B4KMG4Lmu7pIcrzVvWTtVvMSTrrwDaIQ3 Td6w== X-Gm-Message-State: ACrzQf1NV0c+STYXm3fzeXYSOnytIy5/9pI6ZustZ+pXI3I8nD4WTgYT cnG4uqKQF0H0L7tV2QhIMM3CPgADVQ3wDQ== X-Google-Smtp-Source: AMsMyM7/EQi6vdSoH4+shOGY8XE1Z+NZy/JCQ0R8kX0/zqHOOQtYC7myzSBOz691gq6Q7sVSEU8Gxg== 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667325237; a=rsa-sha256; cv=none; b=3pdzRGFxCyH3rEP0nBZXudl/GxiwU+nz3tXEywQbYIOTmD/6/WMZXbINgNxEwe+BkJuebc tyhPgh0m7slyHv4nKjsDbkhPfs2qdCgtg/BQlEMxIJJ22L4Zv+PBdMqLTIT4O7uDzIg8xk BPs+M5VDm5tSxaxDBkXDUPmuTlfJ1KA= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=RBxiYbfj; spf=pass (imf20.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.52 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=1667325237; 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=8mi0cqN3i/1HTIqi69x1uNrDe0uDt2K2zNDb9Z1HfPw=; b=GsB6cOD/GqEYDshYRNPUbN7BLj0zDOxFyHmyrr/oV1iV2231QKpYeHCBmzkqDr744LsSVM XMKLJV/WnaHcSseooqjac/dDRl0XjZAEI/wxJuRx8gSppKOs0CvZ9vDUTGf74vSJfBBkDq zKTBWl/AbXV/51rnlAFhw5Dh5S+OB/4= X-Stat-Signature: payfsyawsj8kkbp8gapbw4wozyqge8sx X-Rspamd-Server: rspam09 X-Rspam-User: X-Rspamd-Queue-Id: 224851C0017 Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=RBxiYbfj; spf=pass (imf20.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.52 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1667325236-424969 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: 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: 13027301 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 23648C433FE for ; Tue, 1 Nov 2022 17:54:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0F0946B0078; Tue, 1 Nov 2022 13:53:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0A1416B007B; Tue, 1 Nov 2022 13:53:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E0EB66B007D; Tue, 1 Nov 2022 13:53:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id D09806B0078 for ; Tue, 1 Nov 2022 13:53:58 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B29F04022A for ; Tue, 1 Nov 2022 17:53:58 +0000 (UTC) X-FDA: 80085621756.20.55F6A24 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by imf26.hostedemail.com (Postfix) with ESMTP id 67258140005 for ; Tue, 1 Nov 2022 17:53:58 +0000 (UTC) Received: by mail-pl1-f174.google.com with SMTP id c24so14255203pls.9 for ; 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=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=38jtyG7DG3MUXj/nwESP2xLA6BRLw+vWaxbXUVdtvvEiBaCBZ7LK9kV+Yu9Lgk6n/1 L+Lb0nZaksQIXuk9InA4jbKvTmfqW3txIU75WnbYx4KoSD07MIpz9TGrbCiiDDieYAU2 1bR4P8SCpE8ReM+a0RgXxQPSkvMzPDLvuKescbjdcZTUvPCMfUKpbjWh8J3OkJUzogB0 T93+izFRoZOZycZQVh90Z+4NIFhEaZz45Vh5HEYrz1XXww6tW7j7+q8iEBoc72RYR3Bd 5HFINWQx2pf1q3IwSi8KyIihReXA1dwruKTUPB5Oz56BgbqFsiXI4Ip1jaWl2nf2Uccm y53w== X-Gm-Message-State: ACrzQf2rArKJVEoi7lK8+NMgxrbEHG8iMs1vSsYrisKHoPkWqdOwQL0e IzAZ2EDe1M7xVrvQP4RNMo2/pjSOdym9Ww== X-Google-Smtp-Source: AMsMyM6JC1O/v8aLCpaRP/DQaK1pXWU0tYXi0PNefL+TH1DnYBlJkFbjclImohZF7Wr316yRxNvZDw== 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667325238; a=rsa-sha256; cv=none; b=j1uP/oDsdrLcnoGsd9OWKIXBZwIQGrvPLlAyJx6N4aMk0liro3FFTWAim3EVkF/nvwoneF AXePw+sTWh38rKFsQPJf3FUjGMhoAGpY6x18T5m26VdMX2w/Luaormj1HK6ZHH1cNAyvyx TcRYvun0H6MkIViNUTA/kNLBHgozT10= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=SIGbKrtK; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.174 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667325238; 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=sd/ZTZPQkq+Y0RGPTAhY/UhYvgYWKV9wt541wP0v/Zs=; b=57wR0pIWkZZC1+nbmaaAV+OEHS/z0ocrotCJsya1m+eFsZzfiyE8gxpa/vG1ToT/ZOppRn aQVjIFuoenuJjJ0QQKcfO5QR0gj2IjYSLUWmqmiYisFII0rUy+0cYIPEwo+2KAssqYHaIs /ny255fqoM5zuwuX7rBqZ6lXkVWY6oY= X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 67258140005 X-Rspam-User: Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=SIGbKrtK; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.174 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com X-Stat-Signature: n31rqh8jmmfcouwgz8eamh4yxurrtkd7 X-HE-Tag: 1667325238-298636 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: 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: 13027302 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 68395C4332F for ; Tue, 1 Nov 2022 17:54:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 623AE6B007B; Tue, 1 Nov 2022 13:54:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 534C46B007D; Tue, 1 Nov 2022 13:54:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 35F3E6B007E; Tue, 1 Nov 2022 13:54:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 25EB46B007B for ; Tue, 1 Nov 2022 13:54:00 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E3C74160618 for ; Tue, 1 Nov 2022 17:53:59 +0000 (UTC) X-FDA: 80085621798.11.F4480B8 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by imf27.hostedemail.com (Postfix) with ESMTP id 7F6474001D for ; Tue, 1 Nov 2022 17:53:59 +0000 (UTC) Received: by mail-pf1-f174.google.com with SMTP id b185so14136736pfb.9 for ; Tue, 01 Nov 2022 10:53:59 -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=nrn4TTtLyelTK+koaXEKGETpC8CVGW8dt17FK2JEDF98Kdq8tb1eeDsV1xSqbZHOlg xPAn3S9vTdidHHEPgqpjIN2DazZE5hFwzestFpqfS6UJjYe7khWfnTz9OYZ5nZfrSOw8 wxy39i6cuNPtFVjWM/1uwlzjYbyj1wGtInkvBPbr0zn35tm/YfonUqTOF0yiM6yhCzMd ihUL7Y3VpIarEhn1VNEjhPVEzgl1QZWpctXlhG5mtoQNFTDCQgkrzOCyE11OixsLiTOa Vm8b7TDySPyvd4kPyP16c1Mbqql3o80relpcSf78yzpeKacknpnsChe9A3/jYmsEm8D0 AshA== X-Gm-Message-State: ACrzQf2XxHr/78STrymBnDgHoQ2xvGGxN8vTW065sKhf2fGNzFedL8wP LDInNTb5ExKKrO65dOHfhTC6z+GzSpO4pg== X-Google-Smtp-Source: AMsMyM51zCtXYMyAw9bd3/mTakXsP6meG/nQMZjuLadCOHRAo9SG1oiCI9WwArgVlu9PEj5R5eiZHg== 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 ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=a5nRUpRV; spf=pass (imf27.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.174 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=1667325239; a=rsa-sha256; cv=none; b=RwPlwqdhTlVceBPkjiNlF8Zjk0g0iSbJVbVZPEifEdVEXVii4v8Lap0Ln52q7FW73IDqkH k2NYu55WfQBOmAzJRv7Upp698dJL7SReDbGqwhXM3zJcScVfgOtpzapgPOvSGL5EQjYdsD Dzs5IcFyyuixJdqdYrFOJgzogtbu8qU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667325239; 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=M2J1+cr5yCkfhmlJuiea40UIW73C1SmYJz1XZ9F//oM=; b=nHy5AqUlAhJrJSYGLYJ5r/w87ZLyEkQ9v7b7TvLrHvJnFZjnPxqIY11yN8WGH+RZ3q/DRW OT/2rip4TSnDwcGz7jlNb9Uy14nJDgVlHsNwLB398ZjNfHMeuRsDQNDvJe24CsWc4ynjpI Yaz9hhueB+6Mvxav3xJw94F46mXisV4= X-Stat-Signature: mrw6ymgn1rbbufgbqnx7nqa5n41hectg X-Rspamd-Queue-Id: 7F6474001D X-Rspam-User: Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=a5nRUpRV; spf=pass (imf27.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam01 X-HE-Tag: 1667325239-275178 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: 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); }