From: Christoph Hellwig <hch@lst.de>
To: Andrew Morton <akpm@linux-foundation.org>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Hugh Dickins <hughd@google.com>,
Seth Jennings <sjenning@redhat.com>,
Dan Streetman <ddstreet@ieee.org>,
Vitaly Wool <vitaly.wool@konsulko.com>,
Matthew Wilcox <willy@infradead.org>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-mm@kvack.org
Subject: [PATCH 04/13] frontswap: remove frontswap_shrink
Date: Fri, 24 Dec 2021 07:22:37 +0100 [thread overview]
Message-ID: <20211224062246.1258487-5-hch@lst.de> (raw)
In-Reply-To: <20211224062246.1258487-1-hch@lst.de>
frontswap_shrink is never called, so remove it.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
Documentation/vm/frontswap.rst | 13 ------
include/linux/frontswap.h | 1 -
mm/frontswap.c | 83 ----------------------------------
3 files changed, 97 deletions(-)
diff --git a/Documentation/vm/frontswap.rst b/Documentation/vm/frontswap.rst
index 2ab660651d04e..feecc5e244778 100644
--- a/Documentation/vm/frontswap.rst
+++ b/Documentation/vm/frontswap.rst
@@ -255,19 +255,6 @@ the old data and ensure that it is no longer accessible. Since the
swap subsystem then writes the new data to the read swap device,
this is the correct course of action to ensure coherency.
-* What is frontswap_shrink for?
-
-When the (non-frontswap) swap subsystem swaps out a page to a real
-swap device, that page is only taking up low-value pre-allocated disk
-space. But if frontswap has placed a page in transcendent memory, that
-page may be taking up valuable real estate. The frontswap_shrink
-routine allows code outside of the swap subsystem to force pages out
-of the memory managed by frontswap and back into kernel-addressable memory.
-For example, in RAMster, a "suction driver" thread will attempt
-to "repatriate" pages sent to a remote machine back to the local machine;
-this is driven using the frontswap_shrink mechanism when memory pressure
-subsides.
-
* Why does the frontswap patch create the new include file swapfile.h?
The frontswap code depends on some swap-subsystem-internal data
diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
index 83a56392cc7f6..d268d7bb65134 100644
--- a/include/linux/frontswap.h
+++ b/include/linux/frontswap.h
@@ -24,7 +24,6 @@ struct frontswap_ops {
};
extern void frontswap_register_ops(struct frontswap_ops *ops);
-extern void frontswap_shrink(unsigned long);
extern unsigned long frontswap_curr_pages(void);
extern bool __frontswap_test(struct swap_info_struct *, pgoff_t);
diff --git a/mm/frontswap.c b/mm/frontswap.c
index dba7f087ee862..a77ebba6101bd 100644
--- a/mm/frontswap.c
+++ b/mm/frontswap.c
@@ -341,89 +341,6 @@ static unsigned long __frontswap_curr_pages(void)
return totalpages;
}
-static int __frontswap_unuse_pages(unsigned long total, unsigned long *unused,
- int *swapid)
-{
- int ret = -EINVAL;
- struct swap_info_struct *si = NULL;
- int si_frontswap_pages;
- unsigned long total_pages_to_unuse = total;
- unsigned long pages = 0, pages_to_unuse = 0;
-
- assert_spin_locked(&swap_lock);
- plist_for_each_entry(si, &swap_active_head, list) {
- si_frontswap_pages = atomic_read(&si->frontswap_pages);
- if (total_pages_to_unuse < si_frontswap_pages) {
- pages = pages_to_unuse = total_pages_to_unuse;
- } else {
- pages = si_frontswap_pages;
- pages_to_unuse = 0; /* unuse all */
- }
- /* ensure there is enough RAM to fetch pages from frontswap */
- if (security_vm_enough_memory_mm(current->mm, pages)) {
- ret = -ENOMEM;
- continue;
- }
- vm_unacct_memory(pages);
- *unused = pages_to_unuse;
- *swapid = si->type;
- ret = 0;
- break;
- }
-
- return ret;
-}
-
-/*
- * Used to check if it's necessary and feasible to unuse pages.
- * Return 1 when nothing to do, 0 when need to shrink pages,
- * error code when there is an error.
- */
-static int __frontswap_shrink(unsigned long target_pages,
- unsigned long *pages_to_unuse,
- int *type)
-{
- unsigned long total_pages = 0, total_pages_to_unuse;
-
- assert_spin_locked(&swap_lock);
-
- total_pages = __frontswap_curr_pages();
- if (total_pages <= target_pages) {
- /* Nothing to do */
- *pages_to_unuse = 0;
- return 1;
- }
- total_pages_to_unuse = total_pages - target_pages;
- return __frontswap_unuse_pages(total_pages_to_unuse, pages_to_unuse, type);
-}
-
-/*
- * Frontswap, like a true swap device, may unnecessarily retain pages
- * under certain circumstances; "shrink" frontswap is essentially a
- * "partial swapoff" and works by calling try_to_unuse to attempt to
- * unuse enough frontswap pages to attempt to -- subject to memory
- * constraints -- reduce the number of pages in frontswap to the
- * number given in the parameter target_pages.
- */
-void frontswap_shrink(unsigned long target_pages)
-{
- unsigned long pages_to_unuse = 0;
- int type, ret;
-
- /*
- * we don't want to hold swap_lock while doing a very
- * lengthy try_to_unuse, but swap_list may change
- * so restart scan from swap_active_head each time
- */
- spin_lock(&swap_lock);
- ret = __frontswap_shrink(target_pages, &pages_to_unuse, &type);
- spin_unlock(&swap_lock);
- if (ret == 0)
- try_to_unuse(type, true, pages_to_unuse);
- return;
-}
-EXPORT_SYMBOL(frontswap_shrink);
-
/*
* Count and return the number of frontswap pages across all
* swap devices. This is exported so that backend drivers can
--
2.30.2
next prev parent reply other threads:[~2021-12-24 6:23 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-24 6:22 remove Xen tmem leftovers Christoph Hellwig
2021-12-24 6:22 ` [PATCH 01/13] mm: remove cleancache Christoph Hellwig
2021-12-24 7:01 ` Juergen Gross
2021-12-24 7:02 ` Christoph Hellwig
2021-12-25 10:35 ` Geert Uytterhoeven
2021-12-24 6:22 ` [PATCH 02/13] frontswap: remove frontswap_writethrough Christoph Hellwig
2021-12-24 6:22 ` [PATCH 03/13] frontswap: remove frontswap_tmem_exclusive_gets Christoph Hellwig
2021-12-24 6:22 ` Christoph Hellwig [this message]
2021-12-24 6:22 ` [PATCH 05/13] frontswap: remove frontswap_curr_pages Christoph Hellwig
2021-12-24 6:22 ` [PATCH 06/13] frontswap: simplify frontswap_init Christoph Hellwig
2021-12-24 6:22 ` [PATCH 07/13] frontswap: remove the frontswap exports Christoph Hellwig
2021-12-24 6:22 ` [PATCH 08/13] mm: simplify try_to_unuse Christoph Hellwig
2021-12-24 6:22 ` [PATCH 09/13] frontswap: remove frontswap_test Christoph Hellwig
2021-12-24 6:22 ` [PATCH 10/13] frontswap: simplify frontswap_register_ops Christoph Hellwig
2021-12-24 6:22 ` [PATCH 11/13] mm: mark swap_lock and swap_active_head static Christoph Hellwig
2021-12-24 6:22 ` [PATCH 12/13] frontswap: remove support for multiple ops Christoph Hellwig
2021-12-24 6:22 ` [PATCH 13/13] mm: hide the FRONTSWAP Kconfig symbol Christoph Hellwig
2022-01-04 14:31 ` remove Xen tmem leftovers David Hildenbrand
2022-01-04 14:46 ` Christoph Hellwig
2022-01-05 6:08 ` Juergen Gross
2022-01-05 8:46 ` David Hildenbrand
2022-01-05 19:36 ` Konrad Rzeszutek Wilk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211224062246.1258487-5-hch@lst.de \
--to=hch@lst.de \
--cc=akpm@linux-foundation.org \
--cc=ddstreet@ieee.org \
--cc=hughd@google.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sjenning@redhat.com \
--cc=vitaly.wool@konsulko.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).