From: SeongJae Park <sj38.park@gmail.com>
To: akpm@linux-foundation.org
Cc: lauraa@codeaurora.org, minchan@kernel.org,
sergey.senozhatsky@gmail.com, linux-mm@kvack.org,
SeongJae Park <sj38.park@gmail.com>
Subject: [RFC v1 5/6] gcma: export statistical data on debugfs
Date: Wed, 12 Nov 2014 00:00:09 +0900 [thread overview]
Message-ID: <1415718010-18663-6-git-send-email-sj38.park@gmail.com> (raw)
In-Reply-To: <1415718010-18663-1-git-send-email-sj38.park@gmail.com>
Export saved / loaded / evicted / reclaimed pages from gcma's frontswap
backend on debugfs to let users know how gcma is working internally.
Signed-off-by: SeongJae Park <sj38.park@gmail.com>
---
mm/gcma.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/mm/gcma.c b/mm/gcma.c
index 9c07128..65395ec 100644
--- a/mm/gcma.c
+++ b/mm/gcma.c
@@ -57,6 +57,12 @@ static spinlock_t slru_lock; /* protect slru_list */
static struct frontswap_tree *gcma_swap_trees[MAX_SWAPFILES];
static struct kmem_cache *swap_slot_entry_cache;
+/* For statistics */
+static atomic_t gcma_stored_pages = ATOMIC_INIT(0);
+static atomic_t gcma_loaded_pages = ATOMIC_INIT(0);
+static atomic_t gcma_evicted_pages = ATOMIC_INIT(0);
+static atomic_t gcma_reclaimed_pages = ATOMIC_INIT(0);
+
static unsigned long evict_frontswap_pages(unsigned long nr_pages);
static struct frontswap_tree *swap_tree(struct page *page)
@@ -380,6 +386,7 @@ static unsigned long evict_frontswap_pages(unsigned long nr_pages)
spin_unlock(&tree->lock);
}
+ atomic_add(evicted, &gcma_evicted_pages);
return evicted;
}
@@ -480,6 +487,7 @@ int gcma_frontswap_store(unsigned type, pgoff_t offset,
spin_unlock(&slru_lock);
spin_unlock(&tree->lock);
+ atomic_inc(&gcma_stored_pages);
return ret;
}
@@ -521,6 +529,7 @@ int gcma_frontswap_load(unsigned type, pgoff_t offset,
spin_unlock(&slru_lock);
spin_unlock(&tree->lock);
+ atomic_inc(&gcma_loaded_pages);
return 0;
}
@@ -659,6 +668,7 @@ retry:
if (atomic_inc_not_zero(&entry->refcount)) {
clear_gpage_flag(page, GF_SWAP_LRU);
set_gpage_flag(page, GF_RECLAIMING);
+ atomic_inc(&gcma_reclaimed_pages);
list_move(&page->lru, &free_pages);
spin_unlock(&slru_lock);
continue;
@@ -679,6 +689,7 @@ retry:
set_gpage_flag(page, GF_ISOLATED);
} else {
set_gpage_flag(page, GF_RECLAIMING);
+ atomic_inc(&gcma_reclaimed_pages);
}
spin_unlock(&gcma->lock);
spin_unlock(&slru_lock);
@@ -727,6 +738,40 @@ void gcma_free_contig(struct gcma *gcma,
spin_unlock(&gcma->lock);
}
+#ifdef CONFIG_DEBUG_FS
+#include <linux/debugfs.h>
+
+static struct dentry *gcma_debugfs_root;
+
+static int __init gcma_debugfs_init(void)
+{
+ if (!debugfs_initialized())
+ return -ENODEV;
+
+ gcma_debugfs_root = debugfs_create_dir("gcma", NULL);
+ if (!gcma_debugfs_root)
+ return -ENOMEM;
+
+ debugfs_create_atomic_t("stored_pages", S_IRUGO,
+ gcma_debugfs_root, &gcma_stored_pages);
+ debugfs_create_atomic_t("loaded_pages", S_IRUGO,
+ gcma_debugfs_root, &gcma_loaded_pages);
+ debugfs_create_atomic_t("evicted_pages", S_IRUGO,
+ gcma_debugfs_root, &gcma_evicted_pages);
+ debugfs_create_atomic_t("reclaimed_pages", S_IRUGO,
+ gcma_debugfs_root, &gcma_reclaimed_pages);
+
+ pr_info("gcma debufs init\n");
+ return 0;
+}
+#else
+static int __init gcma_debugfs_init(void)
+{
+ return 0;
+}
+#endif
+
+
static int __init init_gcma(void)
{
pr_info("loading gcma\n");
@@ -743,6 +788,7 @@ static int __init init_gcma(void)
frontswap_writethrough(true);
frontswap_register_ops(&gcma_frontswap_ops);
+ gcma_debugfs_init();
return 0;
}
--
1.9.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2014-11-11 14:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-11 15:00 [RFC v1 0/6] introduce gcma SeongJae Park
2014-11-11 15:00 ` [RFC v1 1/6] gcma: introduce contiguous memory allocator SeongJae Park
2014-11-11 15:00 ` [RFC v1 2/6] gcma: utilize reserved memory as swap cache SeongJae Park
2014-11-11 15:00 ` [RFC v1 3/6] gcma: evict frontswap pages in LRU order when memory is full SeongJae Park
2014-11-11 15:00 ` [RFC v1 4/6] gcma: discard swap cache pages to meet successful GCMA allocation SeongJae Park
2014-11-11 15:00 ` SeongJae Park [this message]
2014-11-11 15:00 ` [RFC v1 6/6] gcma: integrate gcma under cma interface SeongJae Park
2014-11-11 18:57 ` [RFC v1 0/6] introduce gcma Christoph Lameter
2014-11-12 7:02 ` SeongJae Park
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=1415718010-18663-6-git-send-email-sj38.park@gmail.com \
--to=sj38.park@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=lauraa@codeaurora.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=sergey.senozhatsky@gmail.com \
/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