From: Ananda Badmaev <a.badmaev@clicknet.pro>
To: linux-mm@kvack.org
Cc: Ananda Badmaev <a.badmaev@clicknet.pro>
Subject: [PATCH] zswap: add reclaim trigger and stat for debugging
Date: Wed, 2 Jun 2021 12:27:53 +0300 [thread overview]
Message-ID: <20210602092753.10566-1-a.badmaev@clicknet.pro> (raw)
- Added 'total_pages_reclaimed' stat to debugfs in zswap.
- Added ability to reclaim pages from zswap using debugfs.
- Added u64 reclaim counter to shrink_worker()
---
mm/zswap.c | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/mm/zswap.c b/mm/zswap.c
index 20763267a219..680a4e413f53 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -53,6 +53,9 @@ static atomic_t zswap_same_filled_pages = ATOMIC_INIT(0);
* certain event is occurring.
*/
+/* Total pages evicted */
+static u32 zswap_total_reclaimed;
+
/* Pool limit was hit (see zswap_max_pool_percent) */
static u64 zswap_pool_limit_hit;
/* Pages written back when pool limit was reached */
@@ -576,9 +579,11 @@ static void shrink_worker(struct work_struct *w)
{
struct zswap_pool *pool = container_of(w, typeof(*pool),
shrink_work);
+ unsigned int pages_reclaimed = 0;
- if (zpool_shrink(pool->zpool, 1, NULL))
+ if (zpool_shrink(pool->zpool, 1, &pages_reclaimed))
zswap_reject_reclaim_fail++;
+ zswap_total_reclaimed += pages_reclaimed;
zswap_pool_put(pool);
}
@@ -1397,6 +1402,24 @@ static struct frontswap_ops zswap_frontswap_ops = {
static struct dentry *zswap_debugfs_root;
+static ssize_t reclaim_pages_trigger(struct file *file, const char __user *buf,
+ size_t count, loff_t *f_pos)
+{
+ struct zswap_pool *pool;
+
+ /* reclaim pages from userspace using shrink_worker */
+ pool = zswap_pool_last_get();
+ if (pool)
+ queue_work(shrink_wq, &pool->shrink_work);
+ return count;
+}
+
+static const struct file_operations reclaim_pages_fops = {
+ .owner = THIS_MODULE,
+ .write = reclaim_pages_trigger,
+ .open = simple_open
+};
+
static int __init zswap_debugfs_init(void)
{
if (!debugfs_initialized())
@@ -1425,6 +1448,12 @@ static int __init zswap_debugfs_init(void)
debugfs_create_atomic_t("same_filled_pages", 0444,
zswap_debugfs_root, &zswap_same_filled_pages);
+ debugfs_create_u32("total_pages_reclaimed", 0444,
+ zswap_debugfs_root, &zswap_total_reclaimed);
+
+ debugfs_create_file("reclaim_pages_trigger", 0744, zswap_debugfs_root,
+ NULL, &reclaim_pages_fops);
+
return 0;
}
--
2.20.1
next reply other threads:[~2021-06-02 9:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-02 9:27 Ananda Badmaev [this message]
2021-06-09 10:48 ` [PATCH] zswap: add reclaim trigger and stat for debugging David Hildenbrand
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=20210602092753.10566-1-a.badmaev@clicknet.pro \
--to=a.badmaev@clicknet.pro \
--cc=linux-mm@kvack.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 read-only IMAP folder(s) and NNTP newsgroup(s).