There are also some patch I wrote up that are based on this patchset
that I will post soonish.
I copying here what Dan mentioned with some modifications by me:
Since various parts of transcendent memory ("tmem") [1] were first posted in
2009, reviewers have suggested that various tmem features should be built
as a module and enabled by loading the module, rather than the current clunky
method of compiling as a built-in and enabling via boot parameter. Due
to certain tmem initialization steps, that was not feasible at the time.
[1] http://lwn.net/Articles/454795/
This patchset allows each of the three merged transcendent memory
backends (zcache, ramster, Xen tmem) to be used as modules by first
enabling transcendent memory frontends (cleancache, frontswap) to deal
with "lazy initialization" and, second, by adding the necessary code for
the backends to be built and loaded as modules.
The original mechanism to enable tmem backends -- namely to hardwire
them into the kernel and select/enable one with a kernel boot
parameter -- is retained but should be considered deprecated. When
backends are loaded as modules, certain knobs will now be
properly selected via module_params rather than via undocumented
kernel boot parameters. Note that module UNloading is not yet
supported as it is lower priority and will require significant
additional work.
The lazy initialization support is necessary because filesystems
and swap devices are normally mounted early in boot and these
activites normally trigger tmem calls to setup certain data structures;
if the respective cleancache/frontswap ops are not yet registered
by a back end, the tmem setup would fail for these devices and
cleancache/frontswap would never be enabled for them which limits
much of the value of tmem in many system configurations. Lazy
initialization records the necessary information in cleancache/frontswap
data structures and "replays" it after the ops are registered
to ensure that all filesystems and swap devices can benefit from
the loaded tmem backend.
[PATCH 1/8] mm: cleancache: lazy initialization to allow tmem
[PATCH 2/8] mm: frontswap: lazy initialization to allow tmem
Patches 1 and 2 are the original [2] patches to cleancache and frontswap
proposed by Erlangen University, but rebased to 3.7-rcN plus a couple
of bug fixes I found necessary to run properly + extra review comments.
[2] http://www.spinics.net/lists/linux-mm/msg31490.html
The other two:
[PATCH 3/8] frontswap: Make frontswap_init use a pointer for the
[PATCH 4/8] cleancache: Make cleancache_init use a pointer for the
do a bit of code cleanup that can be done to make it easier to
read and also remove some of the bools.
[PATCH 5/8] staging: zcache2+ramster: enable ramster to be
Enables module support for zcache2. Zsmalloc support
has not yet been merged into zcache2 but, once merged, could now
easily be selected via a module_param.
[PATCH 6/8] staging: zcache2+ramster: enable zcache2 to be
Enables module support for ramster. Ramster will now be
enabled with a module_param to zcache2.
[PATCH 7/8] xen: tmem: enable Xen tmem shim to be built/loaded as a
[PATCH 8/8] xen/tmem: Remove the subsys call.
Enables module support for the Xen tmem shim. Xen self-ballooning and
frontswap-selfshrinking are also "lazily"
initialized when the Xen tmem shim is loaded as a module, unless
explicitly disabled by module_params.
Dan Magenheimer (5):
mm: cleancache: lazy initialization to allow tmem backends to build/run as modules
mm: frontswap: lazy initialization to allow tmem backends to build/run as modules
staging: zcache2+ramster: enable ramster to be built/loaded as a module
staging: zcache2+ramster: enable zcache2 to be built/loaded as a module
xen: tmem: enable Xen tmem shim to be built/loaded as a module
Konrad Rzeszutek Wilk (3):
frontswap: Make frontswap_init use a pointer for the ops.
cleancache: Make cleancache_init use a pointer for the ops
xen/tmem: Remove the subsys call.
drivers/staging/ramster/Kconfig | 6 +-
drivers/staging/ramster/Makefile | 11 +-
drivers/staging/ramster/ramster.h | 6 +-
drivers/staging/ramster/ramster/nodemanager.c | 9 +-
drivers/staging/ramster/ramster/ramster.c | 29 +++-
drivers/staging/ramster/ramster/ramster.h | 2 +-
.../staging/ramster/ramster/ramster_nodemanager.h | 2 +
drivers/staging/ramster/tmem.c | 6 +-
drivers/staging/ramster/tmem.h | 8 +-
drivers/staging/ramster/zcache-main.c | 63 ++++++--
drivers/staging/ramster/zcache.h | 2 +-
drivers/staging/zcache/zcache-main.c | 16 +-
drivers/xen/Kconfig | 4 +-
drivers/xen/tmem.c | 50 ++++--
drivers/xen/xen-selfballoon.c | 13 +-
include/linux/cleancache.h | 2 +-
include/linux/frontswap.h | 2 +-
include/xen/tmem.h | 8 +
mm/cleancache.c | 167 +++++++++++++++++---
mm/frontswap.c | 78 +++++++--
20 files changed, 371 insertions(+), 113 deletions(-)
>From Konrad Rzeszutek Wilk <[email protected]> # This line is ignored.
Subject: [PATCH v2] enable all tmem backends to be built and loaded as modules.
Changelog since [v1: https://lkml.org/lkml/2012/10/31/403]
- Addressed various people comments (most of them in the frontswap code).
- Fixed up compile issues.
There are also some patch I wrote up that are based on this patchset
that I will post soonish.
I copying here what Dan mentioned with some modifications by me:
Since various parts of transcendent memory ("tmem") [1] were first posted in
2009, reviewers have suggested that various tmem features should be built
as a module and enabled by loading the module, rather than the current clunky
method of compiling as a built-in and enabling via boot parameter. Due
to certain tmem initialization steps, that was not feasible at the time.
[1] http://lwn.net/Articles/454795/
This patchset allows each of the three merged transcendent memory
backends (zcache, ramster, Xen tmem) to be used as modules by first
enabling transcendent memory frontends (cleancache, frontswap) to deal
with "lazy initialization" and, second, by adding the necessary code for
the backends to be built and loaded as modules.
The original mechanism to enable tmem backends -- namely to hardwire
them into the kernel and select/enable one with a kernel boot
parameter -- is retained but should be considered deprecated. When
backends are loaded as modules, certain knobs will now be
properly selected via module_params rather than via undocumented
kernel boot parameters. Note that module UNloading is not yet
supported as it is lower priority and will require significant
additional work.
The lazy initialization support is necessary because filesystems
and swap devices are normally mounted early in boot and these
activites normally trigger tmem calls to setup certain data structures;
if the respective cleancache/frontswap ops are not yet registered
by a back end, the tmem setup would fail for these devices and
cleancache/frontswap would never be enabled for them which limits
much of the value of tmem in many system configurations. Lazy
initialization records the necessary information in cleancache/frontswap
data structures and "replays" it after the ops are registered
to ensure that all filesystems and swap devices can benefit from
the loaded tmem backend.
[PATCH 1/8] mm: cleancache: lazy initialization to allow tmem
[PATCH 2/8] mm: frontswap: lazy initialization to allow tmem
Patches 1 and 2 are the original [2] patches to cleancache and frontswap
proposed by Erlangen University, but rebased to 3.7-rcN plus a couple
of bug fixes I found necessary to run properly + extra review comments.
[2] http://www.spinics.net/lists/linux-mm/msg31490.html
The other two:
[PATCH 3/8] frontswap: Make frontswap_init use a pointer for the
[PATCH 4/8] cleancache: Make cleancache_init use a pointer for the
do a bit of code cleanup that can be done to make it easier to
read and also remove some of the bools.
[PATCH 5/8] staging: zcache2+ramster: enable ramster to be
Enables module support for zcache2. Zsmalloc support
has not yet been merged into zcache2 but, once merged, could now
easily be selected via a module_param.
[PATCH 6/8] staging: zcache2+ramster: enable zcache2 to be
Enables module support for ramster. Ramster will now be
enabled with a module_param to zcache2.
[PATCH 7/8] xen: tmem: enable Xen tmem shim to be built/loaded as a
[PATCH 8/8] xen/tmem: Remove the subsys call.
Enables module support for the Xen tmem shim. Xen self-ballooning and
frontswap-selfshrinking are also "lazily"
initialized when the Xen tmem shim is loaded as a module, unless
explicitly disabled by module_params.
Dan Magenheimer (5):
mm: cleancache: lazy initialization to allow tmem backends to build/run as modules
mm: frontswap: lazy initialization to allow tmem backends to build/run as modules
staging: zcache2+ramster: enable ramster to be built/loaded as a module
staging: zcache2+ramster: enable zcache2 to be built/loaded as a module
xen: tmem: enable Xen tmem shim to be built/loaded as a module
Konrad Rzeszutek Wilk (3):
frontswap: Make frontswap_init use a pointer for the ops.
cleancache: Make cleancache_init use a pointer for the ops
xen/tmem: Remove the subsys call.
drivers/staging/ramster/Kconfig | 6 +-
drivers/staging/ramster/Makefile | 11 +-
drivers/staging/ramster/ramster.h | 6 +-
drivers/staging/ramster/ramster/nodemanager.c | 9 +-
drivers/staging/ramster/ramster/ramster.c | 29 +++-
drivers/staging/ramster/ramster/ramster.h | 2 +-
.../staging/ramster/ramster/ramster_nodemanager.h | 2 +
drivers/staging/ramster/tmem.c | 6 +-
drivers/staging/ramster/tmem.h | 8 +-
drivers/staging/ramster/zcache-main.c | 63 ++++++--
drivers/staging/ramster/zcache.h | 2 +-
drivers/staging/zcache/zcache-main.c | 16 +-
drivers/xen/Kconfig | 4 +-
drivers/xen/tmem.c | 50 ++++--
drivers/xen/xen-selfballoon.c | 13 +-
include/linux/cleancache.h | 2 +-
include/linux/frontswap.h | 2 +-
include/xen/tmem.h | 8 +
mm/cleancache.c | 167 +++++++++++++++++---
mm/frontswap.c | 78 +++++++--
20 files changed, 371 insertions(+), 113 deletions(-)
>From Konrad Rzeszutek Wilk <[email protected]> # This line is ignored.
From: Konrad Rzeszutek Wilk <[email protected]>
Subject: [PATCH] zcache2 cleanups (s/int/bool/ + debugfs move).
In-Reply-To:
Changelog since rfc: https://lkml.org/lkml/2012/11/5/549
- Added Reviewed-by from Dan.
This patchset depends on the recently posted V2 of making the
frontswap/cleancache backends be module capable:
http://mid.gmane.org/[email protected]
I think that once the V2 is OK I will combine this patchset along
with the V2 and send the whole thing to GregKH? Or perhaps just
if Greg is Ok I will do via my tree.
This is a copy of what I wrote in the RFC posting:
Looking at the zcache2 code there were a couple of things that I thought
would make sense to move out of the code. For one thing it makes it easier
to read, and for anoter - it can be cleanly compiled out. It also allows
to have a clean seperation of counters that we _need_ vs the optional ones.
Which means that in the future we could get rid of the optional ones.
It fixes some outstanding compile warnings, cleans
up some of the code, and rips out the debug counters out of zcache-main.c
and sticks them in a debug.c file.
I was hoping it would end up with less code, but sadly it ended up with
a bit more due to the empty non-debug functions - but the code is easier
to read.
drivers/staging/ramster/Kconfig | 8 +
drivers/staging/ramster/Makefile | 1 +
drivers/staging/ramster/debug.c | 66 +++++++
drivers/staging/ramster/debug.h | 229 ++++++++++++++++++++++
drivers/staging/ramster/zcache-main.c | 336 +++++++--------------------------
5 files changed, 370 insertions(+), 270 deletions(-)
Konrad Rzeszutek Wilk (11):
zcache: Provide accessory functions for counter increase
zcache: Provide accessory functions for counter decrease.
zcache: The last of the atomic reads has now an accessory function.
zcache: Fix compile warnings due to usage of debugfs_create_size_t
zcache: Make the debug code use pr_debug
zcache: Move debugfs code out of zcache-main.c file.
zcache: Use an array to initialize/use debugfs attributes.
zcache: Move the last of the debugfs counters out
zcache: Allow to compile if ZCACHE_DEBUG and !DEBUG_FS
zcache: Module license is defined twice.
zcache: Coalesce all debug under CONFIG_ZCACHE2_DEBUG
>From Konrad Rzeszutek Wilk <[email protected]> # This line is ignored.
Subject: [PATCH] zcache2 cleanups (s/int/bool/ + debugfs move).
Changelog since rfc: https://lkml.org/lkml/2012/11/5/549
- Added Reviewed-by from Dan.
This patchset depends on the recently posted V2 of making the
frontswap/cleancache backends be module capable:
http://mid.gmane.org/[email protected]
I think that once the V2 is OK I will combine this patchset along
with the V2 and send the whole thing to GregKH? Or perhaps just
if Greg is Ok I will do via my tree.
This is a copy of what I wrote in the RFC posting:
Looking at the zcache2 code there were a couple of things that I thought
would make sense to move out of the code. For one thing it makes it easier
to read, and for anoter - it can be cleanly compiled out. It also allows
to have a clean seperation of counters that we _need_ vs the optional ones.
Which means that in the future we could get rid of the optional ones.
It fixes some outstanding compile warnings, cleans
up some of the code, and rips out the debug counters out of zcache-main.c
and sticks them in a debug.c file.
I was hoping it would end up with less code, but sadly it ended up with
a bit more due to the empty non-debug functions - but the code is easier
to read.
drivers/staging/ramster/Kconfig | 8 +
drivers/staging/ramster/Makefile | 1 +
drivers/staging/ramster/debug.c | 66 +++++++
drivers/staging/ramster/debug.h | 229 ++++++++++++++++++++++
drivers/staging/ramster/zcache-main.c | 336 +++++++--------------------------
5 files changed, 370 insertions(+), 270 deletions(-)
Konrad Rzeszutek Wilk (11):
zcache: Provide accessory functions for counter increase
zcache: Provide accessory functions for counter decrease.
zcache: The last of the atomic reads has now an accessory function.
zcache: Fix compile warnings due to usage of debugfs_create_size_t
zcache: Make the debug code use pr_debug
zcache: Move debugfs code out of zcache-main.c file.
zcache: Use an array to initialize/use debugfs attributes.
zcache: Move the last of the debugfs counters out
zcache: Allow to compile if ZCACHE_DEBUG and !DEBUG_FS
zcache: Module license is defined twice.
zcache: Coalesce all debug under CONFIG_ZCACHE2_DEBUG
Reviewed-by: Dan Magenheimer <[email protected]>
Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
---
drivers/staging/ramster/Makefile | 1 +
drivers/staging/ramster/debug.c | 113 +++++++++++++++
drivers/staging/ramster/debug.h | 183 ++++++++++++++++++++++++
drivers/staging/ramster/zcache-main.c | 247 +--------------------------------
4 files changed, 304 insertions(+), 240 deletions(-)
create mode 100644 drivers/staging/ramster/debug.c
create mode 100644 drivers/staging/ramster/debug.h
diff --git a/drivers/staging/ramster/Makefile b/drivers/staging/ramster/Makefile
index fcb25cb..61f5050 100644
--- a/drivers/staging/ramster/Makefile
+++ b/drivers/staging/ramster/Makefile
@@ -4,4 +4,5 @@ zcache-y += ramster/ramster.o ramster/r2net.o
zcache-y += ramster/nodemanager.o ramster/tcp.o
zcache-y += ramster/heartbeat.o ramster/masklog.o
endif
+zcache-y-$(CONFIG_ZCACHE_DEBUG) += debug.o
obj-$(CONFIG_MODULES) += zcache.o
diff --git a/drivers/staging/ramster/debug.c b/drivers/staging/ramster/debug.c
new file mode 100644
index 0000000..0d19715
--- /dev/null
+++ b/drivers/staging/ramster/debug.c
@@ -0,0 +1,113 @@
+#include <linux/atomic.h>
+#include "debug.h"
+
+#ifdef CONFIG_DEBUG_FS
+#include <linux/debugfs.h>
+#define zdfs debugfs_create_size_t
+#define zdfs64 debugfs_create_u64
+int zcache_debugfs_init(void)
+{
+ struct dentry *root = debugfs_create_dir("zcache", NULL);
+ if (root == NULL)
+ return -ENXIO;
+
+ zdfs("obj_count", S_IRUGO, root, &zcache_obj_count);
+ zdfs("obj_count_max", S_IRUGO, root, &zcache_obj_count_max);
+ zdfs("objnode_count", S_IRUGO, root, &zcache_objnode_count);
+ zdfs("objnode_count_max", S_IRUGO, root, &zcache_objnode_count_max);
+ zdfs("flush_total", S_IRUGO, root, &zcache_flush_total);
+ zdfs("flush_found", S_IRUGO, root, &zcache_flush_found);
+ zdfs("flobj_total", S_IRUGO, root, &zcache_flobj_total);
+ zdfs("flobj_found", S_IRUGO, root, &zcache_flobj_found);
+ zdfs("failed_eph_puts", S_IRUGO, root, &zcache_failed_eph_puts);
+ zdfs("failed_pers_puts", S_IRUGO, root, &zcache_failed_pers_puts);
+ zdfs("failed_get_free_pages", S_IRUGO, root,
+ &zcache_failed_getfreepages);
+ zdfs("failed_alloc", S_IRUGO, root, &zcache_failed_alloc);
+ zdfs("put_to_flush", S_IRUGO, root, &zcache_put_to_flush);
+ zdfs("compress_poor", S_IRUGO, root, &zcache_compress_poor);
+ zdfs("mean_compress_poor", S_IRUGO, root, &zcache_mean_compress_poor);
+ zdfs("eph_ate_tail", S_IRUGO, root, &zcache_eph_ate_tail);
+ zdfs("eph_ate_tail_failed", S_IRUGO, root, &zcache_eph_ate_tail_failed);
+ zdfs("pers_ate_eph", S_IRUGO, root, &zcache_pers_ate_eph);
+ zdfs("pers_ate_eph_failed", S_IRUGO, root, &zcache_pers_ate_eph_failed);
+ zdfs("evicted_eph_zpages", S_IRUGO, root, &zcache_evicted_eph_zpages);
+ zdfs("evicted_eph_pageframes", S_IRUGO, root,
+ &zcache_evicted_eph_pageframes);
+ zdfs("eph_pageframes", S_IRUGO, root, &zcache_eph_pageframes);
+ zdfs("eph_pageframes_max", S_IRUGO, root, &zcache_eph_pageframes_max);
+ zdfs("pers_pageframes", S_IRUGO, root, &zcache_pers_pageframes);
+ zdfs("pers_pageframes_max", S_IRUGO, root, &zcache_pers_pageframes_max);
+ zdfs("eph_zpages", S_IRUGO, root, &zcache_eph_zpages);
+ zdfs("eph_zpages_max", S_IRUGO, root, &zcache_eph_zpages_max);
+ zdfs("pers_zpages", S_IRUGO, root, &zcache_pers_zpages);
+ zdfs("pers_zpages_max", S_IRUGO, root, &zcache_pers_zpages_max);
+ zdfs("last_active_file_pageframes", S_IRUGO, root,
+ &zcache_last_active_file_pageframes);
+ zdfs("last_inactive_file_pageframes", S_IRUGO, root,
+ &zcache_last_inactive_file_pageframes);
+ zdfs("last_active_anon_pageframes", S_IRUGO, root,
+ &zcache_last_active_anon_pageframes);
+ zdfs("last_inactive_anon_pageframes", S_IRUGO, root,
+ &zcache_last_inactive_anon_pageframes);
+ zdfs("eph_nonactive_puts_ignored", S_IRUGO, root,
+ &zcache_eph_nonactive_puts_ignored);
+ zdfs("pers_nonactive_puts_ignored", S_IRUGO, root,
+ &zcache_pers_nonactive_puts_ignored);
+ zdfs64("eph_zbytes", S_IRUGO, root, &zcache_eph_zbytes);
+ zdfs64("eph_zbytes_max", S_IRUGO, root, &zcache_eph_zbytes_max);
+ zdfs64("pers_zbytes", S_IRUGO, root, &zcache_pers_zbytes);
+ zdfs64("pers_zbytes_max", S_IRUGO, root, &zcache_pers_zbytes_max);
+ return 0;
+}
+#undef zdebugfs
+#undef zdfs64
+
+/* developers can call this in case of ooms, e.g. to find memory leaks */
+void zcache_dump(void)
+{
+ pr_debug("zcache: obj_count=%u\n", zcache_obj_count);
+ pr_debug("zcache: obj_count_max=%u\n", zcache_obj_count_max);
+ pr_debug("zcache: objnode_count=%u\n", zcache_objnode_count);
+ pr_debug("zcache: objnode_count_max=%u\n", zcache_objnode_count_max);
+ pr_debug("zcache: flush_total=%u\n", zcache_flush_total);
+ pr_debug("zcache: flush_found=%u\n", zcache_flush_found);
+ pr_debug("zcache: flobj_total=%u\n", zcache_flobj_total);
+ pr_debug("zcache: flobj_found=%u\n", zcache_flobj_found);
+ pr_debug("zcache: failed_eph_puts=%u\n", zcache_failed_eph_puts);
+ pr_debug("zcache: failed_pers_puts=%u\n", zcache_failed_pers_puts);
+ pr_debug("zcache: failed_get_free_pages=%u\n",
+ zcache_failed_getfreepages);
+ pr_debug("zcache: failed_alloc=%u\n", zcache_failed_alloc);
+ pr_debug("zcache: put_to_flush=%u\n", zcache_put_to_flush);
+ pr_debug("zcache: compress_poor=%u\n", zcache_compress_poor);
+ pr_debug("zcache: mean_compress_poor=%u\n",
+ zcache_mean_compress_poor);
+ pr_debug("zcache: eph_ate_tail=%u\n", zcache_eph_ate_tail);
+ pr_debug("zcache: eph_ate_tail_failed=%u\n",
+ zcache_eph_ate_tail_failed);
+ pr_debug("zcache: pers_ate_eph=%u\n", zcache_pers_ate_eph);
+ pr_debug("zcache: pers_ate_eph_failed=%u\n",
+ zcache_pers_ate_eph_failed);
+ pr_debug("zcache: evicted_eph_zpages=%u\n", zcache_evicted_eph_zpages);
+ pr_debug("zcache: evicted_eph_pageframes=%u\n",
+ zcache_evicted_eph_pageframes);
+ pr_debug("zcache: eph_pageframes=%u\n", zcache_eph_pageframes);
+ pr_debug("zcache: eph_pageframes_max=%u\n", zcache_eph_pageframes_max);
+ pr_debug("zcache: pers_pageframes=%u\n", zcache_pers_pageframes);
+ pr_debug("zcache: pers_pageframes_max=%u\n",
+ zcache_pers_pageframes_max);
+ pr_debug("zcache: eph_zpages=%u\n", zcache_eph_zpages);
+ pr_debug("zcache: eph_zpages_max=%u\n", zcache_eph_zpages_max);
+ pr_debug("zcache: pers_zpages=%u\n", zcache_pers_zpages);
+ pr_debug("zcache: pers_zpages_max=%u\n", zcache_pers_zpages_max);
+ pr_debug("zcache: eph_zbytes=%llu\n",
+ (unsigned long long)zcache_eph_zbytes);
+ pr_debug("zcache: eph_zbytes_max=%llu\n",
+ (unsigned long long)zcache_eph_zbytes_max);
+ pr_debug("zcache: pers_zbytes=%llu\n",
+ (unsigned long long)zcache_pers_zbytes);
+ pr_debug("zcache: pers_zbytes_max=%llu\n",
+ (unsigned long long)zcache_pers_zbytes_max);
+}
+#endif
diff --git a/drivers/staging/ramster/debug.h b/drivers/staging/ramster/debug.h
new file mode 100644
index 0000000..496735b
--- /dev/null
+++ b/drivers/staging/ramster/debug.h
@@ -0,0 +1,183 @@
+#ifdef CONFIG_ZCACHE_DEBUG
+
+/* we try to keep these statistics SMP-consistent */
+static ssize_t zcache_obj_count;
+static atomic_t zcache_obj_atomic = ATOMIC_INIT(0);
+static ssize_t zcache_obj_count_max;
+static inline void inc_zcache_obj_count(void)
+{
+ zcache_obj_count = atomic_inc_return(&zcache_obj_atomic);
+ if (zcache_obj_count > zcache_obj_count_max)
+ zcache_obj_count_max = zcache_obj_count;
+}
+static inline void dec_zcache_obj_count(void)
+{
+ zcache_obj_count = atomic_dec_return(&zcache_obj_atomic);
+ BUG_ON(zcache_obj_count < 0);
+};
+static ssize_t zcache_objnode_count;
+static atomic_t zcache_objnode_atomic = ATOMIC_INIT(0);
+static ssize_t zcache_objnode_count_max;
+static inline void inc_zcache_objnode_count(void)
+{
+ zcache_objnode_count = atomic_inc_return(&zcache_objnode_atomic);
+ if (zcache_objnode_count > zcache_objnode_count_max)
+ zcache_objnode_count_max = zcache_objnode_count;
+};
+static inline void dec_zcache_objnode_count(void)
+{
+ zcache_objnode_count = atomic_dec_return(&zcache_objnode_atomic);
+ BUG_ON(zcache_objnode_count < 0);
+};
+static u64 zcache_eph_zbytes;
+static atomic_long_t zcache_eph_zbytes_atomic = ATOMIC_INIT(0);
+static u64 zcache_eph_zbytes_max;
+static inline void inc_zcache_eph_zbytes(unsigned clen)
+{
+ zcache_eph_zbytes = atomic_long_add_return(clen, &zcache_eph_zbytes_atomic);
+ if (zcache_eph_zbytes > zcache_eph_zbytes_max)
+ zcache_eph_zbytes_max = zcache_eph_zbytes;
+};
+static inline void dec_zcache_eph_zbytes(unsigned zsize)
+{
+ zcache_eph_zbytes = atomic_long_sub_return(zsize, &zcache_eph_zbytes_atomic);
+};
+extern u64 zcache_pers_zbytes;
+static atomic_long_t zcache_pers_zbytes_atomic = ATOMIC_INIT(0);
+static u64 zcache_pers_zbytes_max;
+static inline void inc_zcache_pers_zbytes(unsigned clen)
+{
+ zcache_pers_zbytes = atomic_long_add_return(clen, &zcache_pers_zbytes_atomic);
+ if (zcache_pers_zbytes > zcache_pers_zbytes_max)
+ zcache_pers_zbytes_max = zcache_pers_zbytes;
+}
+static inline void dec_zcache_pers_zbytes(unsigned zsize)
+{
+ zcache_pers_zbytes = atomic_long_sub_return(zsize, &zcache_pers_zbytes_atomic);
+}
+extern ssize_t zcache_eph_pageframes;
+static atomic_t zcache_eph_pageframes_atomic = ATOMIC_INIT(0);
+static ssize_t zcache_eph_pageframes_max;
+static inline void inc_zcache_eph_pageframes(void)
+{
+ zcache_eph_pageframes = atomic_inc_return(&zcache_eph_pageframes_atomic);
+ if (zcache_eph_pageframes > zcache_eph_pageframes_max)
+ zcache_eph_pageframes_max = zcache_eph_pageframes;
+};
+static inline void dec_zcache_eph_pageframes(void)
+{
+ zcache_eph_pageframes = atomic_dec_return(&zcache_eph_pageframes_atomic);
+};
+extern ssize_t zcache_pers_pageframes;
+static atomic_t zcache_pers_pageframes_atomic = ATOMIC_INIT(0);
+static ssize_t zcache_pers_pageframes_max;
+static inline void inc_zcache_pers_pageframes(void)
+{
+ zcache_pers_pageframes = atomic_inc_return(&zcache_pers_pageframes_atomic);
+ if (zcache_pers_pageframes > zcache_pers_pageframes_max)
+ zcache_pers_pageframes_max = zcache_pers_pageframes;
+}
+static inline void dec_zcache_pers_pageframes(void)
+{
+ zcache_pers_pageframes = atomic_dec_return(&zcache_pers_pageframes_atomic);
+}
+static ssize_t zcache_pageframes_alloced;
+static atomic_t zcache_pageframes_alloced_atomic = ATOMIC_INIT(0);
+static inline void inc_zcache_pageframes_alloced(void)
+{
+ zcache_pageframes_alloced = atomic_inc_return(&zcache_pageframes_alloced_atomic);
+};
+static ssize_t zcache_pageframes_freed;
+static atomic_t zcache_pageframes_freed_atomic = ATOMIC_INIT(0);
+static inline void inc_zcache_pageframes_freed(void)
+{
+ zcache_pageframes_freed = atomic_inc_return(&zcache_pageframes_freed_atomic);
+}
+static ssize_t zcache_eph_zpages;
+static atomic_t zcache_eph_zpages_atomic = ATOMIC_INIT(0);
+static ssize_t zcache_eph_zpages_max;
+static inline void inc_zcache_eph_zpages(void)
+{
+ zcache_eph_zpages = atomic_inc_return(&zcache_eph_zpages_atomic);
+ if (zcache_eph_zpages > zcache_eph_zpages_max)
+ zcache_eph_zpages_max = zcache_eph_zpages;
+}
+static inline void dec_zcache_eph_zpages(unsigned zpages)
+{
+ zcache_eph_zpages = atomic_sub_return(zpages, &zcache_eph_zpages_atomic);
+}
+extern ssize_t zcache_pers_zpages;
+static atomic_t zcache_pers_zpages_atomic = ATOMIC_INIT(0);
+static ssize_t zcache_pers_zpages_max;
+static inline void inc_zcache_pers_zpages(void)
+{
+ zcache_pers_zpages = atomic_inc_return(&zcache_pers_zpages_atomic);
+ if (zcache_pers_zpages > zcache_pers_zpages_max)
+ zcache_pers_zpages_max = zcache_pers_zpages;
+}
+static inline void dec_zcache_pers_zpages(unsigned zpages)
+{
+ zcache_pers_zpages = atomic_sub_return(zpages, &zcache_pers_zpages_atomic);
+}
+
+static inline unsigned long curr_pageframes_count(void)
+{
+ return zcache_pageframes_alloced -
+ atomic_read(&zcache_pageframes_freed_atomic) -
+ atomic_read(&zcache_eph_pageframes_atomic) -
+ atomic_read(&zcache_pers_pageframes_atomic);
+};
+/* but for the rest of these, counting races are ok */
+extern ssize_t zcache_flush_total;
+extern ssize_t zcache_flush_found;
+extern ssize_t zcache_flobj_total;
+extern ssize_t zcache_flobj_found;
+extern ssize_t zcache_failed_eph_puts;
+extern ssize_t zcache_failed_pers_puts;
+extern ssize_t zcache_failed_getfreepages;
+extern ssize_t zcache_failed_alloc;
+extern ssize_t zcache_put_to_flush;
+extern ssize_t zcache_compress_poor;
+extern ssize_t zcache_mean_compress_poor;
+extern ssize_t zcache_eph_ate_tail;
+extern ssize_t zcache_eph_ate_tail_failed;
+extern ssize_t zcache_pers_ate_eph;
+extern ssize_t zcache_pers_ate_eph_failed;
+extern ssize_t zcache_evicted_eph_zpages;
+extern ssize_t zcache_evicted_eph_pageframes;
+extern ssize_t zcache_last_active_file_pageframes;
+extern ssize_t zcache_last_inactive_file_pageframes;
+extern ssize_t zcache_last_active_anon_pageframes;
+extern ssize_t zcache_last_inactive_anon_pageframes;
+extern ssize_t zcache_eph_nonactive_puts_ignored;
+extern ssize_t zcache_pers_nonactive_puts_ignored;
+
+int zcache_debugfs_init(void);
+#else
+static inline void inc_zcache_obj_count(void) { };
+static inline void dec_zcache_obj_count(void) { };
+static inline void inc_zcache_objnode_count(void) { };
+static inline void dec_zcache_objnode_count(void) { };
+static inline void inc_zcache_eph_zbytes(unsigned clen) { };
+static inline void dec_zcache_eph_zbytes(unsigned zsize) { };
+static inline void inc_zcache_pers_zbytes(unsigned clen) { };
+static inline void dec_zcache_pers_zbytes(unsigned zsize) { };
+static inline void inc_zcache_eph_pageframes(void) { };
+static inline void dec_zcache_eph_pageframes(void) { };
+static inline void inc_zcache_pers_pageframes(void) { };
+static inline void dec_zcache_pers_pageframes(void) { };
+static inline void inc_zcache_pageframes_alloced(void) { };
+static inline void inc_zcache_pageframes_freed(void) { };
+static inline void inc_zcache_eph_zpages(void) { };
+static inline void dec_zcache_eph_zpages(unsigned zpages) { };
+static inline void inc_zcache_pers_zpages(void) { };
+static inline void dec_zcache_pers_zpages(unsigned zpages) { };
+static inline unsigned long curr_pageframes_count(void)
+{
+ return 0;
+};
+static inline int zcache_debugfs_init(void)
+{
+ return 0;
+};
+#endif
diff --git a/drivers/staging/ramster/zcache-main.c b/drivers/staging/ramster/zcache-main.c
index a43c3b0..52c29de 100644
--- a/drivers/staging/ramster/zcache-main.c
+++ b/drivers/staging/ramster/zcache-main.c
@@ -29,6 +29,7 @@
#include "zcache.h"
#include "zbud.h"
#include "ramster.h"
+#include "debug.h"
#ifdef CONFIG_RAMSTER
static bool ramster_enabled __read_mostly;
static bool disable_frontswap_selfshrink __read_mostly;
@@ -133,135 +134,13 @@ static struct kmem_cache *zcache_obj_cache;
static DEFINE_PER_CPU(struct zcache_preload, zcache_preloads) = { 0, };
-/* we try to keep these statistics SMP-consistent */
-static ssize_t zcache_obj_count;
-static atomic_t zcache_obj_atomic = ATOMIC_INIT(0);
-static ssize_t zcache_obj_count_max;
-static inline void inc_zcache_obj_count(void)
-{
- zcache_obj_count = atomic_inc_return(&zcache_obj_atomic);
- if (zcache_obj_count > zcache_obj_count_max)
- zcache_obj_count_max = zcache_obj_count;
-}
-static ssize_t zcache_objnode_count;
-static inline void dec_zcache_obj_count(void)
-{
- zcache_obj_count = atomic_dec_return(&zcache_obj_atomic);
- BUG_ON(zcache_obj_count < 0);
-};
-static atomic_t zcache_objnode_atomic = ATOMIC_INIT(0);
-static ssize_t zcache_objnode_count_max;
-static inline void inc_zcache_objnode_count(void)
-{
- zcache_objnode_count = atomic_inc_return(&zcache_objnode_atomic);
- if (zcache_objnode_count > zcache_objnode_count_max)
- zcache_objnode_count_max = zcache_objnode_count;
-};
-static inline void dec_zcache_objnode_count(void)
-{
- zcache_objnode_count = atomic_dec_return(&zcache_objnode_atomic);
- BUG_ON(zcache_objnode_count < 0);
-};
-static u64 zcache_eph_zbytes;
-static atomic_long_t zcache_eph_zbytes_atomic = ATOMIC_INIT(0);
-static u64 zcache_eph_zbytes_max;
-static inline void inc_zcache_eph_zbytes(unsigned clen)
-{
- zcache_eph_zbytes = atomic_long_add_return(clen, &zcache_eph_zbytes_atomic);
- if (zcache_eph_zbytes > zcache_eph_zbytes_max)
- zcache_eph_zbytes_max = zcache_eph_zbytes;
-};
-static inline void dec_zcache_eph_zbytes(unsigned zsize)
-{
- zcache_eph_zbytes = atomic_long_sub_return(zsize, &zcache_eph_zbytes_atomic);
-};
-static u64 zcache_pers_zbytes;
-static atomic_long_t zcache_pers_zbytes_atomic = ATOMIC_INIT(0);
-static u64 zcache_pers_zbytes_max;
-static inline void inc_zcache_pers_zbytes(unsigned clen)
-{
- zcache_pers_zbytes = atomic_long_add_return(clen, &zcache_pers_zbytes_atomic);
- if (zcache_pers_zbytes > zcache_pers_zbytes_max)
- zcache_pers_zbytes_max = zcache_pers_zbytes;
-}
-static ssize_t zcache_eph_pageframes;
-static inline void dec_zcache_pers_zbytes(unsigned zsize)
-{
- zcache_pers_zbytes = atomic_long_sub_return(zsize, &zcache_pers_zbytes_atomic);
-}
-static atomic_t zcache_eph_pageframes_atomic = ATOMIC_INIT(0);
-static ssize_t zcache_eph_pageframes_max;
-static inline void inc_zcache_eph_pageframes(void)
-{
- zcache_eph_pageframes = atomic_inc_return(&zcache_eph_pageframes_atomic);
- if (zcache_eph_pageframes > zcache_eph_pageframes_max)
- zcache_eph_pageframes_max = zcache_eph_pageframes;
-};
-static ssize_t zcache_pers_pageframes;
-static inline void dec_zcache_eph_pageframes(void)
-{
- zcache_eph_pageframes = atomic_dec_return(&zcache_eph_pageframes_atomic);
-};
-static atomic_t zcache_pers_pageframes_atomic = ATOMIC_INIT(0);
-static ssize_t zcache_pers_pageframes_max;
-static inline void inc_zcache_pers_pageframes(void)
-{
- zcache_pers_pageframes = atomic_inc_return(&zcache_pers_pageframes_atomic);
- if (zcache_pers_pageframes > zcache_pers_pageframes_max)
- zcache_pers_pageframes_max = zcache_pers_pageframes;
-}
-static ssize_t zcache_pageframes_alloced;
-static inline void dec_zcache_pers_pageframes(void)
-{
- zcache_pers_pageframes = atomic_dec_return(&zcache_pers_pageframes_atomic);
-}
-static atomic_t zcache_pageframes_alloced_atomic = ATOMIC_INIT(0);
-static ssize_t zcache_pageframes_freed;
-static atomic_t zcache_pageframes_freed_atomic = ATOMIC_INIT(0);
-static ssize_t zcache_eph_zpages;
-static inline void inc_zcache_pageframes_alloced(void)
-{
- zcache_pageframes_alloced = atomic_inc_return(&zcache_pageframes_alloced_atomic);
-};
-static inline void inc_zcache_pageframes_freed(void)
-{
- zcache_pageframes_freed = atomic_inc_return(&zcache_pageframes_freed_atomic);
-}
-static ssize_t zcache_eph_zpages;
-static atomic_t zcache_eph_zpages_atomic = ATOMIC_INIT(0);
-static ssize_t zcache_eph_zpages_max;
-static inline void inc_zcache_eph_zpages(void)
-{
- zcache_eph_zpages = atomic_inc_return(&zcache_eph_zpages_atomic);
- if (zcache_eph_zpages > zcache_eph_zpages_max)
- zcache_eph_zpages_max = zcache_eph_zpages;
-}
-static ssize_t zcache_pers_zpages;
-static inline void dec_zcache_eph_zpages(unsigned zpages)
-{
- zcache_eph_zpages = atomic_sub_return(zpages, &zcache_eph_zpages_atomic);
-}
-static atomic_t zcache_pers_zpages_atomic = ATOMIC_INIT(0);
-static ssize_t zcache_pers_zpages_max;
-static inline void inc_zcache_pers_zpages(void)
-{
- zcache_pers_zpages = atomic_inc_return(&zcache_pers_zpages_atomic);
- if (zcache_pers_zpages > zcache_pers_zpages_max)
- zcache_pers_zpages_max = zcache_pers_zpages;
-}
-static inline void dec_zcache_pers_zpages(unsigned zpages)
-{
- zcache_pers_zpages = atomic_sub_return(zpages, &zcache_pers_zpages_atomic);
-}
+/* Used by debug.c */
+ssize_t zcache_pers_zpages;
+u64 zcache_pers_zbytes;
+ssize_t zcache_eph_pageframes;
+ssize_t zcache_pers_pageframes;
-static inline unsigned long curr_pageframes_count(void)
-{
- return zcache_pageframes_alloced -
- atomic_read(&zcache_pageframes_freed_atomic) -
- atomic_read(&zcache_eph_pageframes_atomic) -
- atomic_read(&zcache_pers_pageframes_atomic);
-};
-/* but for the rest of these, counting races are ok */
+/* Used by this code. */
static ssize_t zcache_flush_total;
static ssize_t zcache_flush_found;
static ssize_t zcache_flobj_total;
@@ -285,118 +164,6 @@ static ssize_t zcache_last_active_anon_pageframes;
static ssize_t zcache_last_inactive_anon_pageframes;
static ssize_t zcache_eph_nonactive_puts_ignored;
static ssize_t zcache_pers_nonactive_puts_ignored;
-
-#ifdef CONFIG_DEBUG_FS
-#include <linux/debugfs.h>
-#define zdfs debugfs_create_size_t
-#define zdfs64 debugfs_create_u64
-static int zcache_debugfs_init(void)
-{
- struct dentry *root = debugfs_create_dir("zcache", NULL);
- if (root == NULL)
- return -ENXIO;
-
- zdfs("obj_count", S_IRUGO, root, &zcache_obj_count);
- zdfs("obj_count_max", S_IRUGO, root, &zcache_obj_count_max);
- zdfs("objnode_count", S_IRUGO, root, &zcache_objnode_count);
- zdfs("objnode_count_max", S_IRUGO, root, &zcache_objnode_count_max);
- zdfs("flush_total", S_IRUGO, root, &zcache_flush_total);
- zdfs("flush_found", S_IRUGO, root, &zcache_flush_found);
- zdfs("flobj_total", S_IRUGO, root, &zcache_flobj_total);
- zdfs("flobj_found", S_IRUGO, root, &zcache_flobj_found);
- zdfs("failed_eph_puts", S_IRUGO, root, &zcache_failed_eph_puts);
- zdfs("failed_pers_puts", S_IRUGO, root, &zcache_failed_pers_puts);
- zdfs("failed_get_free_pages", S_IRUGO, root,
- &zcache_failed_getfreepages);
- zdfs("failed_alloc", S_IRUGO, root, &zcache_failed_alloc);
- zdfs("put_to_flush", S_IRUGO, root, &zcache_put_to_flush);
- zdfs("compress_poor", S_IRUGO, root, &zcache_compress_poor);
- zdfs("mean_compress_poor", S_IRUGO, root, &zcache_mean_compress_poor);
- zdfs("eph_ate_tail", S_IRUGO, root, &zcache_eph_ate_tail);
- zdfs("eph_ate_tail_failed", S_IRUGO, root, &zcache_eph_ate_tail_failed);
- zdfs("pers_ate_eph", S_IRUGO, root, &zcache_pers_ate_eph);
- zdfs("pers_ate_eph_failed", S_IRUGO, root, &zcache_pers_ate_eph_failed);
- zdfs("evicted_eph_zpages", S_IRUGO, root, &zcache_evicted_eph_zpages);
- zdfs("evicted_eph_pageframes", S_IRUGO, root,
- &zcache_evicted_eph_pageframes);
- zdfs("eph_pageframes", S_IRUGO, root, &zcache_eph_pageframes);
- zdfs("eph_pageframes_max", S_IRUGO, root, &zcache_eph_pageframes_max);
- zdfs("pers_pageframes", S_IRUGO, root, &zcache_pers_pageframes);
- zdfs("pers_pageframes_max", S_IRUGO, root, &zcache_pers_pageframes_max);
- zdfs("eph_zpages", S_IRUGO, root, &zcache_eph_zpages);
- zdfs("eph_zpages_max", S_IRUGO, root, &zcache_eph_zpages_max);
- zdfs("pers_zpages", S_IRUGO, root, &zcache_pers_zpages);
- zdfs("pers_zpages_max", S_IRUGO, root, &zcache_pers_zpages_max);
- zdfs("last_active_file_pageframes", S_IRUGO, root,
- &zcache_last_active_file_pageframes);
- zdfs("last_inactive_file_pageframes", S_IRUGO, root,
- &zcache_last_inactive_file_pageframes);
- zdfs("last_active_anon_pageframes", S_IRUGO, root,
- &zcache_last_active_anon_pageframes);
- zdfs("last_inactive_anon_pageframes", S_IRUGO, root,
- &zcache_last_inactive_anon_pageframes);
- zdfs("eph_nonactive_puts_ignored", S_IRUGO, root,
- &zcache_eph_nonactive_puts_ignored);
- zdfs("pers_nonactive_puts_ignored", S_IRUGO, root,
- &zcache_pers_nonactive_puts_ignored);
- zdfs64("eph_zbytes", S_IRUGO, root, &zcache_eph_zbytes);
- zdfs64("eph_zbytes_max", S_IRUGO, root, &zcache_eph_zbytes_max);
- zdfs64("pers_zbytes", S_IRUGO, root, &zcache_pers_zbytes);
- zdfs64("pers_zbytes_max", S_IRUGO, root, &zcache_pers_zbytes_max);
- return 0;
-}
-#undef zdebugfs
-#undef zdfs64
-#endif
-
-/* developers can call this in case of ooms, e.g. to find memory leaks */
-void zcache_dump(void)
-{
- pr_debug("zcache: obj_count=%u\n", zcache_obj_count);
- pr_debug("zcache: obj_count_max=%u\n", zcache_obj_count_max);
- pr_debug("zcache: objnode_count=%u\n", zcache_objnode_count);
- pr_debug("zcache: objnode_count_max=%u\n", zcache_objnode_count_max);
- pr_debug("zcache: flush_total=%u\n", zcache_flush_total);
- pr_debug("zcache: flush_found=%u\n", zcache_flush_found);
- pr_debug("zcache: flobj_total=%u\n", zcache_flobj_total);
- pr_debug("zcache: flobj_found=%u\n", zcache_flobj_found);
- pr_debug("zcache: failed_eph_puts=%u\n", zcache_failed_eph_puts);
- pr_debug("zcache: failed_pers_puts=%u\n", zcache_failed_pers_puts);
- pr_debug("zcache: failed_get_free_pages=%u\n",
- zcache_failed_getfreepages);
- pr_debug("zcache: failed_alloc=%u\n", zcache_failed_alloc);
- pr_debug("zcache: put_to_flush=%u\n", zcache_put_to_flush);
- pr_debug("zcache: compress_poor=%u\n", zcache_compress_poor);
- pr_debug("zcache: mean_compress_poor=%u\n",
- zcache_mean_compress_poor);
- pr_debug("zcache: eph_ate_tail=%u\n", zcache_eph_ate_tail);
- pr_debug("zcache: eph_ate_tail_failed=%u\n",
- zcache_eph_ate_tail_failed);
- pr_debug("zcache: pers_ate_eph=%u\n", zcache_pers_ate_eph);
- pr_debug("zcache: pers_ate_eph_failed=%u\n",
- zcache_pers_ate_eph_failed);
- pr_debug("zcache: evicted_eph_zpages=%u\n", zcache_evicted_eph_zpages);
- pr_debug("zcache: evicted_eph_pageframes=%u\n",
- zcache_evicted_eph_pageframes);
- pr_debug("zcache: eph_pageframes=%u\n", zcache_eph_pageframes);
- pr_debug("zcache: eph_pageframes_max=%u\n", zcache_eph_pageframes_max);
- pr_debug("zcache: pers_pageframes=%u\n", zcache_pers_pageframes);
- pr_debug("zcache: pers_pageframes_max=%u\n",
- zcache_pers_pageframes_max);
- pr_debug("zcache: eph_zpages=%u\n", zcache_eph_zpages);
- pr_debug("zcache: eph_zpages_max=%u\n", zcache_eph_zpages_max);
- pr_debug("zcache: pers_zpages=%u\n", zcache_pers_zpages);
- pr_debug("zcache: pers_zpages_max=%u\n", zcache_pers_zpages_max);
- pr_debug("zcache: eph_zbytes=%llu\n",
- (unsigned long long)zcache_eph_zbytes);
- pr_debug("zcache: eph_zbytes_max=%llu\n",
- (unsigned long long)zcache_eph_zbytes_max);
- pr_debug("zcache: pers_zbytes=%llu\n",
- (unsigned long long)zcache_pers_zbytes);
- pr_debug("zcache: pers_zbytes_max=%llu\n",
- (unsigned long long)zcache_pers_zbytes_max);
-}
-
/*
* zcache core code starts here
*/
--
1.7.7.6
is defined.
Reviewed-by: Dan Magenheimer <[email protected]>
Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
---
drivers/staging/ramster/debug.h | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/ramster/debug.h b/drivers/staging/ramster/debug.h
index 35af06d..b412b90 100644
--- a/drivers/staging/ramster/debug.h
+++ b/drivers/staging/ramster/debug.h
@@ -174,7 +174,6 @@ static inline void inc_zcache_evicted_eph_pageframes(void) { zcache_evicted_eph_
static inline void inc_zcache_eph_nonactive_puts_ignored(void) { zcache_eph_nonactive_puts_ignored ++; };
static inline void inc_zcache_pers_nonactive_puts_ignored(void) { zcache_pers_nonactive_puts_ignored ++; };
-int zcache_debugfs_init(void);
#else
static inline void inc_zcache_obj_count(void) { };
static inline void dec_zcache_obj_count(void) { };
@@ -198,10 +197,6 @@ static inline unsigned long curr_pageframes_count(void)
{
return 0;
};
-static inline int zcache_debugfs_init(void)
-{
- return 0;
-};
static inline void inc_zcache_flush_total(void) { };
static inline void inc_zcache_flush_found(void) { };
static inline void inc_zcache_flobj_total(void) { };
@@ -223,3 +218,12 @@ static inline void inc_zcache_evicted_eph_pageframes(void) { };
static inline void inc_zcache_eph_nonactive_puts_ignored(void) { };
static inline void inc_zcache_pers_nonactive_puts_ignored(void) { };
#endif
+
+#ifdef CONFIG_DEBUG_FS
+int zcache_debugfs_init(void);
+#else
+static inline int zcache_debugfs_init(void)
+{
+ return 0;
+};
+#endif
--
1.7.7.6
The other (same license) is at the end of the file.
Reviewed-by: Dan Magenheimer <[email protected]>
Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
---
drivers/staging/ramster/zcache-main.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/ramster/zcache-main.c b/drivers/staging/ramster/zcache-main.c
index 457e41c..a1a9799 100644
--- a/drivers/staging/ramster/zcache-main.c
+++ b/drivers/staging/ramster/zcache-main.c
@@ -68,8 +68,6 @@ static char *namestr __read_mostly = "zcache";
#define ZCACHE_GFP_MASK \
(__GFP_FS | __GFP_NORETRY | __GFP_NOWARN | __GFP_NOMEMALLOC)
-MODULE_LICENSE("GPL");
-
/* crypto API for zcache */
#ifdef CONFIG_ZCACHE2_MODULE
static char *zcache_comp_name = "lzo";
--
1.7.7.6
and also define this extra attribute in the Kconfig entry.
Reviewed-by: Dan Magenheimer <[email protected]>
Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
---
drivers/staging/ramster/Kconfig | 8 ++++++++
drivers/staging/ramster/Makefile | 2 +-
drivers/staging/ramster/debug.h | 2 +-
drivers/staging/ramster/zcache-main.c | 6 +++---
4 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/ramster/Kconfig b/drivers/staging/ramster/Kconfig
index 9ce2590..24c8704 100644
--- a/drivers/staging/ramster/Kconfig
+++ b/drivers/staging/ramster/Kconfig
@@ -15,6 +15,14 @@ config ZCACHE2
again in the future. Until then, zcache2 is a single-node
version of ramster.
+config ZCACHE2_DEBUG
+ bool "Enable debug statistics"
+ depends on DEBUG_FS && ZCACHE2
+ default n
+ help
+ This is used to provide an debugfs directory with counters of
+ how zcache2 is doing. You probably want to set this to 'N'.
+
config RAMSTER
tristate "Cross-machine RAM capacity sharing, aka peer-to-peer tmem"
depends on CONFIGFS_FS && SYSFS && !HIGHMEM && ZCACHE2
diff --git a/drivers/staging/ramster/Makefile b/drivers/staging/ramster/Makefile
index 61f5050..d341a23 100644
--- a/drivers/staging/ramster/Makefile
+++ b/drivers/staging/ramster/Makefile
@@ -4,5 +4,5 @@ zcache-y += ramster/ramster.o ramster/r2net.o
zcache-y += ramster/nodemanager.o ramster/tcp.o
zcache-y += ramster/heartbeat.o ramster/masklog.o
endif
-zcache-y-$(CONFIG_ZCACHE_DEBUG) += debug.o
+zcache-y-$(CONFIG_ZCACHE2_DEBUG) += debug.o
obj-$(CONFIG_MODULES) += zcache.o
diff --git a/drivers/staging/ramster/debug.h b/drivers/staging/ramster/debug.h
index b412b90..cf375d7 100644
--- a/drivers/staging/ramster/debug.h
+++ b/drivers/staging/ramster/debug.h
@@ -1,4 +1,4 @@
-#ifdef CONFIG_ZCACHE_DEBUG
+#ifdef CONFIG_ZCACHE2_DEBUG
/* we try to keep these statistics SMP-consistent */
static ssize_t zcache_obj_count;
diff --git a/drivers/staging/ramster/zcache-main.c b/drivers/staging/ramster/zcache-main.c
index a1a9799..6add13d 100644
--- a/drivers/staging/ramster/zcache-main.c
+++ b/drivers/staging/ramster/zcache-main.c
@@ -308,7 +308,7 @@ static void zcache_free_page(struct page *page)
max_pageframes = curr_pageframes;
if (curr_pageframes < min_pageframes)
min_pageframes = curr_pageframes;
-#ifdef ZCACHE_DEBUG
+#ifdef CONFIG_ZCACHE2_DEBUG
if (curr_pageframes > 2L || curr_pageframes < -2L) {
/* pr_info here */
}
@@ -1603,7 +1603,7 @@ static int zcache_init(void)
old_ops = zcache_cleancache_register_ops();
pr_info("%s: cleancache enabled using kernel transcendent "
"memory and compression buddies\n", namestr);
-#ifdef ZCACHE_DEBUG
+#ifdef CONFIG_ZCACHE2_DEBUG
pr_info("%s: cleancache: ignorenonactive = %d\n",
namestr, !disable_cleancache_ignore_nonactive);
#endif
@@ -1618,7 +1618,7 @@ static int zcache_init(void)
frontswap_tmem_exclusive_gets(true);
pr_info("%s: frontswap enabled using kernel transcendent "
"memory and compression buddies\n", namestr);
-#ifdef ZCACHE_DEBUG
+#ifdef CONFIG_ZCACHE2_DEBUG
pr_info("%s: frontswap: excl gets = %d active only = %d\n",
namestr, frontswap_has_exclusive_gets,
!disable_frontswap_ignore_nonactive);
--
1.7.7.6
It makes it neater and also allows us to piggyback on that
in the zcache_dump function.
Reviewed-by: Dan Magenheimer <[email protected]>
Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
---
drivers/staging/ramster/debug.c | 141 +++++++++++++--------------------------
1 files changed, 47 insertions(+), 94 deletions(-)
diff --git a/drivers/staging/ramster/debug.c b/drivers/staging/ramster/debug.c
index 0d19715..3a252a5 100644
--- a/drivers/staging/ramster/debug.c
+++ b/drivers/staging/ramster/debug.c
@@ -3,111 +3,64 @@
#ifdef CONFIG_DEBUG_FS
#include <linux/debugfs.h>
-#define zdfs debugfs_create_size_t
-#define zdfs64 debugfs_create_u64
+
+#define ATTR(x) { .name = #x, .val = &zcache_##x, }
+static struct debug_entry {
+ const char *name;
+ ssize_t *val;
+} attrs[] = {
+ ATTR(obj_count), ATTR(obj_count_max),
+ ATTR(objnode_count), ATTR(objnode_count_max),
+ ATTR(flush_total), ATTR(flush_found),
+ ATTR(flobj_total), ATTR(flobj_found),
+ ATTR(failed_eph_puts), ATTR(failed_pers_puts),
+ ATTR(failed_getfreepages), ATTR(failed_alloc),
+ ATTR(put_to_flush),
+ ATTR(compress_poor), ATTR(mean_compress_poor),
+ ATTR(eph_ate_tail), ATTR(eph_ate_tail_failed),
+ ATTR(pers_ate_eph), ATTR(pers_ate_eph_failed),
+ ATTR(evicted_eph_zpages), ATTR(evicted_eph_pageframes),
+ ATTR(eph_pageframes), ATTR(eph_pageframes_max),
+ ATTR(eph_zpages), ATTR(eph_zpages_max),
+ ATTR(pers_zpages), ATTR(pers_zpages_max),
+ ATTR(last_active_file_pageframes),
+ ATTR(last_inactive_file_pageframes),
+ ATTR(last_active_anon_pageframes),
+ ATTR(last_inactive_anon_pageframes),
+ ATTR(eph_nonactive_puts_ignored),
+ ATTR(pers_nonactive_puts_ignored),
+};
+#undef ATTR
int zcache_debugfs_init(void)
{
+ unsigned int i;
struct dentry *root = debugfs_create_dir("zcache", NULL);
if (root == NULL)
return -ENXIO;
- zdfs("obj_count", S_IRUGO, root, &zcache_obj_count);
- zdfs("obj_count_max", S_IRUGO, root, &zcache_obj_count_max);
- zdfs("objnode_count", S_IRUGO, root, &zcache_objnode_count);
- zdfs("objnode_count_max", S_IRUGO, root, &zcache_objnode_count_max);
- zdfs("flush_total", S_IRUGO, root, &zcache_flush_total);
- zdfs("flush_found", S_IRUGO, root, &zcache_flush_found);
- zdfs("flobj_total", S_IRUGO, root, &zcache_flobj_total);
- zdfs("flobj_found", S_IRUGO, root, &zcache_flobj_found);
- zdfs("failed_eph_puts", S_IRUGO, root, &zcache_failed_eph_puts);
- zdfs("failed_pers_puts", S_IRUGO, root, &zcache_failed_pers_puts);
- zdfs("failed_get_free_pages", S_IRUGO, root,
- &zcache_failed_getfreepages);
- zdfs("failed_alloc", S_IRUGO, root, &zcache_failed_alloc);
- zdfs("put_to_flush", S_IRUGO, root, &zcache_put_to_flush);
- zdfs("compress_poor", S_IRUGO, root, &zcache_compress_poor);
- zdfs("mean_compress_poor", S_IRUGO, root, &zcache_mean_compress_poor);
- zdfs("eph_ate_tail", S_IRUGO, root, &zcache_eph_ate_tail);
- zdfs("eph_ate_tail_failed", S_IRUGO, root, &zcache_eph_ate_tail_failed);
- zdfs("pers_ate_eph", S_IRUGO, root, &zcache_pers_ate_eph);
- zdfs("pers_ate_eph_failed", S_IRUGO, root, &zcache_pers_ate_eph_failed);
- zdfs("evicted_eph_zpages", S_IRUGO, root, &zcache_evicted_eph_zpages);
- zdfs("evicted_eph_pageframes", S_IRUGO, root,
- &zcache_evicted_eph_pageframes);
- zdfs("eph_pageframes", S_IRUGO, root, &zcache_eph_pageframes);
- zdfs("eph_pageframes_max", S_IRUGO, root, &zcache_eph_pageframes_max);
- zdfs("pers_pageframes", S_IRUGO, root, &zcache_pers_pageframes);
- zdfs("pers_pageframes_max", S_IRUGO, root, &zcache_pers_pageframes_max);
- zdfs("eph_zpages", S_IRUGO, root, &zcache_eph_zpages);
- zdfs("eph_zpages_max", S_IRUGO, root, &zcache_eph_zpages_max);
- zdfs("pers_zpages", S_IRUGO, root, &zcache_pers_zpages);
- zdfs("pers_zpages_max", S_IRUGO, root, &zcache_pers_zpages_max);
- zdfs("last_active_file_pageframes", S_IRUGO, root,
- &zcache_last_active_file_pageframes);
- zdfs("last_inactive_file_pageframes", S_IRUGO, root,
- &zcache_last_inactive_file_pageframes);
- zdfs("last_active_anon_pageframes", S_IRUGO, root,
- &zcache_last_active_anon_pageframes);
- zdfs("last_inactive_anon_pageframes", S_IRUGO, root,
- &zcache_last_inactive_anon_pageframes);
- zdfs("eph_nonactive_puts_ignored", S_IRUGO, root,
- &zcache_eph_nonactive_puts_ignored);
- zdfs("pers_nonactive_puts_ignored", S_IRUGO, root,
- &zcache_pers_nonactive_puts_ignored);
- zdfs64("eph_zbytes", S_IRUGO, root, &zcache_eph_zbytes);
- zdfs64("eph_zbytes_max", S_IRUGO, root, &zcache_eph_zbytes_max);
- zdfs64("pers_zbytes", S_IRUGO, root, &zcache_pers_zbytes);
- zdfs64("pers_zbytes_max", S_IRUGO, root, &zcache_pers_zbytes_max);
+ for (i = 0; i < ARRAY_SIZE(attrs); i++)
+ if (!debugfs_create_size_t(attrs[i].name, S_IRUGO, root, attrs[i].val))
+ goto out;
+
+ debugfs_create_u64("eph_zbytes", S_IRUGO, root, &zcache_eph_zbytes);
+ debugfs_create_u64("eph_zbytes_max", S_IRUGO, root, &zcache_eph_zbytes_max);
+ debugfs_create_u64("pers_zbytes", S_IRUGO, root, &zcache_pers_zbytes);
+ debugfs_create_u64("pers_zbytes_max", S_IRUGO, root, &zcache_pers_zbytes_max);
return 0;
+out:
+ return -ENODEV;
}
-#undef zdebugfs
-#undef zdfs64
/* developers can call this in case of ooms, e.g. to find memory leaks */
void zcache_dump(void)
{
- pr_debug("zcache: obj_count=%u\n", zcache_obj_count);
- pr_debug("zcache: obj_count_max=%u\n", zcache_obj_count_max);
- pr_debug("zcache: objnode_count=%u\n", zcache_objnode_count);
- pr_debug("zcache: objnode_count_max=%u\n", zcache_objnode_count_max);
- pr_debug("zcache: flush_total=%u\n", zcache_flush_total);
- pr_debug("zcache: flush_found=%u\n", zcache_flush_found);
- pr_debug("zcache: flobj_total=%u\n", zcache_flobj_total);
- pr_debug("zcache: flobj_found=%u\n", zcache_flobj_found);
- pr_debug("zcache: failed_eph_puts=%u\n", zcache_failed_eph_puts);
- pr_debug("zcache: failed_pers_puts=%u\n", zcache_failed_pers_puts);
- pr_debug("zcache: failed_get_free_pages=%u\n",
- zcache_failed_getfreepages);
- pr_debug("zcache: failed_alloc=%u\n", zcache_failed_alloc);
- pr_debug("zcache: put_to_flush=%u\n", zcache_put_to_flush);
- pr_debug("zcache: compress_poor=%u\n", zcache_compress_poor);
- pr_debug("zcache: mean_compress_poor=%u\n",
- zcache_mean_compress_poor);
- pr_debug("zcache: eph_ate_tail=%u\n", zcache_eph_ate_tail);
- pr_debug("zcache: eph_ate_tail_failed=%u\n",
- zcache_eph_ate_tail_failed);
- pr_debug("zcache: pers_ate_eph=%u\n", zcache_pers_ate_eph);
- pr_debug("zcache: pers_ate_eph_failed=%u\n",
- zcache_pers_ate_eph_failed);
- pr_debug("zcache: evicted_eph_zpages=%u\n", zcache_evicted_eph_zpages);
- pr_debug("zcache: evicted_eph_pageframes=%u\n",
- zcache_evicted_eph_pageframes);
- pr_debug("zcache: eph_pageframes=%u\n", zcache_eph_pageframes);
- pr_debug("zcache: eph_pageframes_max=%u\n", zcache_eph_pageframes_max);
- pr_debug("zcache: pers_pageframes=%u\n", zcache_pers_pageframes);
- pr_debug("zcache: pers_pageframes_max=%u\n",
- zcache_pers_pageframes_max);
- pr_debug("zcache: eph_zpages=%u\n", zcache_eph_zpages);
- pr_debug("zcache: eph_zpages_max=%u\n", zcache_eph_zpages_max);
- pr_debug("zcache: pers_zpages=%u\n", zcache_pers_zpages);
- pr_debug("zcache: pers_zpages_max=%u\n", zcache_pers_zpages_max);
- pr_debug("zcache: eph_zbytes=%llu\n",
- (unsigned long long)zcache_eph_zbytes);
- pr_debug("zcache: eph_zbytes_max=%llu\n",
- (unsigned long long)zcache_eph_zbytes_max);
- pr_debug("zcache: pers_zbytes=%llu\n",
- (unsigned long long)zcache_pers_zbytes);
- pr_debug("zcache: pers_zbytes_max=%llu\n",
- (unsigned long long)zcache_pers_zbytes_max);
+ unsigned int i;
+ for (i = 0; i < ARRAY_SIZE(attrs); i++)
+ pr_debug("zcache: %s=%u\n", attrs[i].name, *attrs[i].val);
+
+ pr_debug("zcache: eph_zbytes=%llu\n", (unsigned long long)zcache_eph_zbytes);
+ pr_debug("zcache: eph_zbytes_max=%llu\n", (unsigned long long)zcache_eph_zbytes_max);
+ pr_debug("zcache: pers_zbytes=%llu\n", (unsigned long long)zcache_pers_zbytes);
+ pr_debug("zcache: pers_zbytes_max=%llu\n", (unsigned long long)zcache_pers_zbytes_max);
}
#endif
--
1.7.7.6
We now have in zcache-main only the counters that are
are not debugfs related.
Reviewed-by: Dan Magenheimer <[email protected]>
Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
---
drivers/staging/ramster/debug.h | 80 +++++++++++++++++++++++++--------
drivers/staging/ramster/zcache-main.c | 71 +++++++++++------------------
2 files changed, 87 insertions(+), 64 deletions(-)
diff --git a/drivers/staging/ramster/debug.h b/drivers/staging/ramster/debug.h
index 496735b..35af06d 100644
--- a/drivers/staging/ramster/debug.h
+++ b/drivers/staging/ramster/debug.h
@@ -128,29 +128,51 @@ static inline unsigned long curr_pageframes_count(void)
atomic_read(&zcache_pers_pageframes_atomic);
};
/* but for the rest of these, counting races are ok */
-extern ssize_t zcache_flush_total;
-extern ssize_t zcache_flush_found;
-extern ssize_t zcache_flobj_total;
-extern ssize_t zcache_flobj_found;
-extern ssize_t zcache_failed_eph_puts;
-extern ssize_t zcache_failed_pers_puts;
-extern ssize_t zcache_failed_getfreepages;
-extern ssize_t zcache_failed_alloc;
-extern ssize_t zcache_put_to_flush;
-extern ssize_t zcache_compress_poor;
-extern ssize_t zcache_mean_compress_poor;
-extern ssize_t zcache_eph_ate_tail;
-extern ssize_t zcache_eph_ate_tail_failed;
-extern ssize_t zcache_pers_ate_eph;
-extern ssize_t zcache_pers_ate_eph_failed;
-extern ssize_t zcache_evicted_eph_zpages;
-extern ssize_t zcache_evicted_eph_pageframes;
+static ssize_t zcache_flush_total;
+static ssize_t zcache_flush_found;
+static ssize_t zcache_flobj_total;
+static ssize_t zcache_flobj_found;
+static ssize_t zcache_failed_eph_puts;
+static ssize_t zcache_failed_pers_puts;
+static ssize_t zcache_failed_getfreepages;
+static ssize_t zcache_failed_alloc;
+static ssize_t zcache_put_to_flush;
+static ssize_t zcache_compress_poor;
+static ssize_t zcache_mean_compress_poor;
+static ssize_t zcache_eph_ate_tail;
+static ssize_t zcache_eph_ate_tail_failed;
+static ssize_t zcache_pers_ate_eph;
+static ssize_t zcache_pers_ate_eph_failed;
+static ssize_t zcache_evicted_eph_zpages;
+static ssize_t zcache_evicted_eph_pageframes;
+
extern ssize_t zcache_last_active_file_pageframes;
extern ssize_t zcache_last_inactive_file_pageframes;
extern ssize_t zcache_last_active_anon_pageframes;
extern ssize_t zcache_last_inactive_anon_pageframes;
-extern ssize_t zcache_eph_nonactive_puts_ignored;
-extern ssize_t zcache_pers_nonactive_puts_ignored;
+static ssize_t zcache_eph_nonactive_puts_ignored;
+static ssize_t zcache_pers_nonactive_puts_ignored;
+
+static inline void inc_zcache_flush_total(void) { zcache_flush_total ++; };
+static inline void inc_zcache_flush_found(void) { zcache_flush_found ++; };
+static inline void inc_zcache_flobj_total(void) { zcache_flobj_total ++; };
+static inline void inc_zcache_flobj_found(void) { zcache_flobj_found ++; };
+static inline void inc_zcache_failed_eph_puts(void) { zcache_failed_eph_puts ++; };
+static inline void inc_zcache_failed_pers_puts(void) { zcache_failed_pers_puts ++; };
+static inline void inc_zcache_failed_getfreepages(void) { zcache_failed_getfreepages ++; };
+static inline void inc_zcache_failed_alloc(void) { zcache_failed_alloc ++; };
+static inline void inc_zcache_put_to_flush(void) { zcache_put_to_flush ++; };
+static inline void inc_zcache_compress_poor(void) { zcache_compress_poor ++; };
+static inline void inc_zcache_mean_compress_poor(void) { zcache_mean_compress_poor ++; };
+static inline void inc_zcache_eph_ate_tail(void) { zcache_eph_ate_tail ++; };
+static inline void inc_zcache_eph_ate_tail_failed(void) { zcache_eph_ate_tail_failed ++; };
+static inline void inc_zcache_pers_ate_eph(void) { zcache_pers_ate_eph ++; };
+static inline void inc_zcache_pers_ate_eph_failed(void) { zcache_pers_ate_eph_failed ++; };
+static inline void inc_zcache_evicted_eph_zpages(void) { zcache_evicted_eph_zpages ++; };
+static inline void inc_zcache_evicted_eph_pageframes(void) { zcache_evicted_eph_pageframes ++; };
+
+static inline void inc_zcache_eph_nonactive_puts_ignored(void) { zcache_eph_nonactive_puts_ignored ++; };
+static inline void inc_zcache_pers_nonactive_puts_ignored(void) { zcache_pers_nonactive_puts_ignored ++; };
int zcache_debugfs_init(void);
#else
@@ -180,4 +202,24 @@ static inline int zcache_debugfs_init(void)
{
return 0;
};
+static inline void inc_zcache_flush_total(void) { };
+static inline void inc_zcache_flush_found(void) { };
+static inline void inc_zcache_flobj_total(void) { };
+static inline void inc_zcache_flobj_found(void) { };
+static inline void inc_zcache_failed_eph_puts(void) { };
+static inline void inc_zcache_failed_pers_puts(void) { };
+static inline void inc_zcache_failed_getfreepages(void) { };
+static inline void inc_zcache_failed_alloc(void) { };
+static inline void inc_zcache_put_to_flush(void) { };
+static inline void inc_zcache_compress_poor(void) { };
+static inline void inc_zcache_mean_compress_poor(void) { };
+static inline void inc_zcache_eph_ate_tail(void) { };
+static inline void inc_zcache_eph_ate_tail_failed(void) { };
+static inline void inc_zcache_pers_ate_eph(void) { };
+static inline void inc_zcache_pers_ate_eph_failed(void) { };
+static inline void inc_zcache_evicted_eph_zpages(void) { };
+static inline void inc_zcache_evicted_eph_pageframes(void) { };
+
+static inline void inc_zcache_eph_nonactive_puts_ignored(void) { };
+static inline void inc_zcache_pers_nonactive_puts_ignored(void) { };
#endif
diff --git a/drivers/staging/ramster/zcache-main.c b/drivers/staging/ramster/zcache-main.c
index 52c29de..457e41c 100644
--- a/drivers/staging/ramster/zcache-main.c
+++ b/drivers/staging/ramster/zcache-main.c
@@ -141,29 +141,10 @@ ssize_t zcache_eph_pageframes;
ssize_t zcache_pers_pageframes;
/* Used by this code. */
-static ssize_t zcache_flush_total;
-static ssize_t zcache_flush_found;
-static ssize_t zcache_flobj_total;
-static ssize_t zcache_flobj_found;
-static ssize_t zcache_failed_eph_puts;
-static ssize_t zcache_failed_pers_puts;
-static ssize_t zcache_failed_getfreepages;
-static ssize_t zcache_failed_alloc;
-static ssize_t zcache_put_to_flush;
-static ssize_t zcache_compress_poor;
-static ssize_t zcache_mean_compress_poor;
-static ssize_t zcache_eph_ate_tail;
-static ssize_t zcache_eph_ate_tail_failed;
-static ssize_t zcache_pers_ate_eph;
-static ssize_t zcache_pers_ate_eph_failed;
-static ssize_t zcache_evicted_eph_zpages;
-static ssize_t zcache_evicted_eph_pageframes;
-static ssize_t zcache_last_active_file_pageframes;
-static ssize_t zcache_last_inactive_file_pageframes;
-static ssize_t zcache_last_active_anon_pageframes;
-static ssize_t zcache_last_inactive_anon_pageframes;
-static ssize_t zcache_eph_nonactive_puts_ignored;
-static ssize_t zcache_pers_nonactive_puts_ignored;
+ssize_t zcache_last_active_file_pageframes;
+ssize_t zcache_last_inactive_file_pageframes;
+ssize_t zcache_last_active_anon_pageframes;
+ssize_t zcache_last_inactive_anon_pageframes;
/*
* zcache core code starts here
*/
@@ -356,7 +337,7 @@ static void *zcache_pampd_eph_create(char *data, size_t size, bool raw,
if (!raw) {
zcache_compress(page, &cdata, &clen);
if (clen > zbud_max_buddy_size()) {
- zcache_compress_poor++;
+ inc_zcache_compress_poor();
goto out;
}
} else {
@@ -373,14 +354,14 @@ static void *zcache_pampd_eph_create(char *data, size_t size, bool raw,
if (newpage != NULL)
goto create_in_new_page;
- zcache_failed_getfreepages++;
+ inc_zcache_failed_getfreepages();
/* can't allocate a page, evict an ephemeral page via LRU */
newpage = zcache_evict_eph_pageframe();
if (newpage == NULL) {
- zcache_eph_ate_tail_failed++;
+ inc_zcache_eph_ate_tail_failed();
goto out;
}
- zcache_eph_ate_tail++;
+ inc_zcache_eph_ate_tail();
create_in_new_page:
pampd = (void *)zbud_create_prep(th, true, cdata, clen, newpage);
@@ -415,7 +396,7 @@ static void *zcache_pampd_pers_create(char *data, size_t size, bool raw,
zcache_compress(page, &cdata, &clen);
/* reject if compression is too poor */
if (clen > zbud_max_zsize) {
- zcache_compress_poor++;
+ inc_zcache_compress_poor();
goto out;
}
/* reject if mean compression is too poor */
@@ -426,7 +407,7 @@ static void *zcache_pampd_pers_create(char *data, size_t size, bool raw,
zbud_mean_zsize = div_u64(total_zsize,
curr_pers_zpages);
if (zbud_mean_zsize > zbud_max_mean_zsize) {
- zcache_mean_compress_poor++;
+ inc_zcache_mean_compress_poor();
goto out;
}
}
@@ -447,14 +428,14 @@ create_pampd:
* (global_page_state(NR_LRU_BASE + LRU_ACTIVE_FILE) +
* global_page_state(NR_LRU_BASE + LRU_INACTIVE_FILE)))
*/
- zcache_failed_getfreepages++;
+ inc_zcache_failed_getfreepages();
/* can't allocate a page, evict an ephemeral page via LRU */
newpage = zcache_evict_eph_pageframe();
if (newpage == NULL) {
- zcache_pers_ate_eph_failed++;
+ inc_zcache_pers_ate_eph_failed();
goto out;
}
- zcache_pers_ate_eph++;
+ inc_zcache_pers_ate_eph();
create_in_new_page:
pampd = (void *)zbud_create_prep(th, false, cdata, clen, newpage);
@@ -494,7 +475,7 @@ void *zcache_pampd_create(char *data, unsigned int size, bool raw,
objnode = kmem_cache_alloc(zcache_objnode_cache,
ZCACHE_GFP_MASK);
if (unlikely(objnode == NULL)) {
- zcache_failed_alloc++;
+ inc_zcache_failed_alloc();
goto out;
}
kp->objnodes[i] = objnode;
@@ -505,7 +486,7 @@ void *zcache_pampd_create(char *data, unsigned int size, bool raw,
kp->obj = obj;
}
if (unlikely(kp->obj == NULL)) {
- zcache_failed_alloc++;
+ inc_zcache_failed_alloc();
goto out;
}
/*
@@ -783,9 +764,9 @@ static struct page *zcache_evict_eph_pageframe(void)
goto out;
dec_zcache_eph_zbytes(zsize);
dec_zcache_eph_zpages(zpages);
- zcache_evicted_eph_zpages++;
+ inc_zcache_evicted_eph_zpages();
dec_zcache_eph_pageframes();
- zcache_evicted_eph_pageframes++;
+ inc_zcache_evicted_eph_pageframes();
out:
return page;
}
@@ -978,9 +959,9 @@ int zcache_put_page(int cli_id, int pool_id, struct tmem_oid *oidp,
if (pampd == NULL) {
ret = -ENOMEM;
if (ephemeral)
- zcache_failed_eph_puts++;
+ inc_zcache_failed_eph_puts();
else
- zcache_failed_pers_puts++;
+ inc_zcache_failed_pers_puts();
} else {
if (ramster_enabled)
ramster_do_preload_flnode(pool);
@@ -990,7 +971,7 @@ int zcache_put_page(int cli_id, int pool_id, struct tmem_oid *oidp,
}
zcache_put_pool(pool);
} else {
- zcache_put_to_flush++;
+ inc_zcache_put_to_flush();
if (ramster_enabled)
ramster_do_preload_flnode(pool);
if (atomic_read(&pool->obj_count) > 0)
@@ -1040,7 +1021,7 @@ int zcache_flush_page(int cli_id, int pool_id,
unsigned long flags;
local_irq_save(flags);
- zcache_flush_total++;
+ inc_zcache_flush_total();
pool = zcache_get_pool_by_id(cli_id, pool_id);
if (ramster_enabled)
ramster_do_preload_flnode(pool);
@@ -1050,7 +1031,7 @@ int zcache_flush_page(int cli_id, int pool_id,
zcache_put_pool(pool);
}
if (ret >= 0)
- zcache_flush_found++;
+ inc_zcache_flush_found();
local_irq_restore(flags);
return ret;
}
@@ -1063,7 +1044,7 @@ int zcache_flush_object(int cli_id, int pool_id,
unsigned long flags;
local_irq_save(flags);
- zcache_flobj_total++;
+ inc_zcache_flobj_total();
pool = zcache_get_pool_by_id(cli_id, pool_id);
if (ramster_enabled)
ramster_do_preload_flnode(pool);
@@ -1073,7 +1054,7 @@ int zcache_flush_object(int cli_id, int pool_id,
zcache_put_pool(pool);
}
if (ret >= 0)
- zcache_flobj_found++;
+ inc_zcache_flobj_found();
local_irq_restore(flags);
return ret;
}
@@ -1239,7 +1220,7 @@ static void zcache_cleancache_put_page(int pool_id,
struct tmem_oid oid = *(struct tmem_oid *)&key;
if (!disable_cleancache_ignore_nonactive && !PageWasActive(page)) {
- zcache_eph_nonactive_puts_ignored++;
+ inc_zcache_eph_nonactive_puts_ignored();
return;
}
if (likely(ind == index))
@@ -1368,7 +1349,7 @@ static int zcache_frontswap_put_page(unsigned type, pgoff_t offset,
BUG_ON(!PageLocked(page));
if (!disable_frontswap_ignore_nonactive && !PageWasActive(page)) {
- zcache_pers_nonactive_puts_ignored++;
+ inc_zcache_pers_nonactive_puts_ignored();
ret = -ERANGE;
goto out;
}
--
1.7.7.6
This is the first step in moving the debugfs code out of the
main file in-to another file. And will also allow the code to
run without CONFIG_DEBUG_FS set.
Reviewed-by: Dan Magenheimer <[email protected]>
Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
---
drivers/staging/ramster/zcache-main.c | 103 ++++++++++++++++++++++-----------
1 files changed, 68 insertions(+), 35 deletions(-)
diff --git a/drivers/staging/ramster/zcache-main.c b/drivers/staging/ramster/zcache-main.c
index b5c811e..24adcbd 100644
--- a/drivers/staging/ramster/zcache-main.c
+++ b/drivers/staging/ramster/zcache-main.c
@@ -137,32 +137,88 @@ static DEFINE_PER_CPU(struct zcache_preload, zcache_preloads) = { 0, };
static long zcache_obj_count;
static atomic_t zcache_obj_atomic = ATOMIC_INIT(0);
static long zcache_obj_count_max;
+static inline void inc_zcache_obj_count(void)
+{
+ zcache_obj_count = atomic_inc_return(&zcache_obj_atomic);
+ if (zcache_obj_count > zcache_obj_count_max)
+ zcache_obj_count_max = zcache_obj_count;
+}
+
static long zcache_objnode_count;
static atomic_t zcache_objnode_atomic = ATOMIC_INIT(0);
static long zcache_objnode_count_max;
+static inline void inc_zcache_objnode_count(void)
+{
+ zcache_objnode_count = atomic_inc_return(&zcache_objnode_atomic);
+ if (zcache_objnode_count > zcache_objnode_count_max)
+ zcache_objnode_count_max = zcache_objnode_count;
+};
static u64 zcache_eph_zbytes;
static atomic_long_t zcache_eph_zbytes_atomic = ATOMIC_INIT(0);
static u64 zcache_eph_zbytes_max;
+static inline void inc_zcache_eph_zbytes(unsigned clen)
+{
+ zcache_eph_zbytes = atomic_long_add_return(clen, &zcache_eph_zbytes_atomic);
+ if (zcache_eph_zbytes > zcache_eph_zbytes_max)
+ zcache_eph_zbytes_max = zcache_eph_zbytes;
+};
static u64 zcache_pers_zbytes;
static atomic_long_t zcache_pers_zbytes_atomic = ATOMIC_INIT(0);
static u64 zcache_pers_zbytes_max;
+static inline void inc_zcache_pers_zbytes(unsigned clen)
+{
+ zcache_pers_zbytes = atomic_long_add_return(clen, &zcache_pers_zbytes_atomic);
+ if (zcache_pers_zbytes > zcache_pers_zbytes_max)
+ zcache_pers_zbytes_max = zcache_pers_zbytes;
+}
static long zcache_eph_pageframes;
static atomic_t zcache_eph_pageframes_atomic = ATOMIC_INIT(0);
static long zcache_eph_pageframes_max;
+static inline void inc_zcache_eph_pageframes(void)
+{
+ zcache_eph_pageframes = atomic_inc_return(&zcache_eph_pageframes_atomic);
+ if (zcache_eph_pageframes > zcache_eph_pageframes_max)
+ zcache_eph_pageframes_max = zcache_eph_pageframes;
+};
static long zcache_pers_pageframes;
static atomic_t zcache_pers_pageframes_atomic = ATOMIC_INIT(0);
static long zcache_pers_pageframes_max;
+static inline void inc_zcache_pers_pageframes(void)
+{
+ zcache_pers_pageframes = atomic_inc_return(&zcache_pers_pageframes_atomic);
+ if (zcache_pers_pageframes > zcache_pers_pageframes_max)
+ zcache_pers_pageframes_max = zcache_pers_pageframes;
+}
static long zcache_pageframes_alloced;
static atomic_t zcache_pageframes_alloced_atomic = ATOMIC_INIT(0);
+static inline void inc_zcache_pageframes_alloced(void)
+{
+ zcache_pageframes_alloced = atomic_inc_return(&zcache_pageframes_alloced_atomic);
+};
static long zcache_pageframes_freed;
static atomic_t zcache_pageframes_freed_atomic = ATOMIC_INIT(0);
+static inline void inc_zcache_pageframes_freed(void)
+{
+ zcache_pageframes_freed = atomic_inc_return(&zcache_pageframes_freed_atomic);
+}
static long zcache_eph_zpages;
static atomic_t zcache_eph_zpages_atomic = ATOMIC_INIT(0);
static long zcache_eph_zpages_max;
+static inline void inc_zcache_eph_zpages(void)
+{
+ zcache_eph_zpages = atomic_inc_return(&zcache_eph_zpages_atomic);
+ if (zcache_eph_zpages > zcache_eph_zpages_max)
+ zcache_eph_zpages_max = zcache_eph_zpages;
+}
static long zcache_pers_zpages;
static atomic_t zcache_pers_zpages_atomic = ATOMIC_INIT(0);
static long zcache_pers_zpages_max;
-
+static inline void inc_zcache_pers_zpages(void)
+{
+ zcache_pers_zpages = atomic_inc_return(&zcache_pers_zpages_atomic);
+ if (zcache_pers_zpages > zcache_pers_zpages_max)
+ zcache_pers_zpages_max = zcache_pers_zpages;
+}
/* but for the rest of these, counting races are ok */
static unsigned long zcache_flush_total;
static unsigned long zcache_flush_found;
@@ -400,9 +456,7 @@ static struct tmem_objnode *zcache_objnode_alloc(struct tmem_pool *pool)
}
}
BUG_ON(objnode == NULL);
- zcache_objnode_count = atomic_inc_return(&zcache_objnode_atomic);
- if (zcache_objnode_count > zcache_objnode_count_max)
- zcache_objnode_count_max = zcache_objnode_count;
+ inc_zcache_objnode_count();
return objnode;
}
@@ -424,9 +478,7 @@ static struct tmem_obj *zcache_obj_alloc(struct tmem_pool *pool)
obj = kp->obj;
BUG_ON(obj == NULL);
kp->obj = NULL;
- zcache_obj_count = atomic_inc_return(&zcache_obj_atomic);
- if (zcache_obj_count > zcache_obj_count_max)
- zcache_obj_count_max = zcache_obj_count;
+ inc_zcache_obj_count();
return obj;
}
@@ -450,16 +502,14 @@ static struct page *zcache_alloc_page(void)
struct page *page = alloc_page(ZCACHE_GFP_MASK);
if (page != NULL)
- zcache_pageframes_alloced =
- atomic_inc_return(&zcache_pageframes_alloced_atomic);
+ inc_zcache_pageframes_alloced();
return page;
}
#ifdef FRONTSWAP_HAS_UNUSE
static void zcache_unacct_page(void)
{
- zcache_pageframes_freed =
- atomic_inc_return(&zcache_pageframes_freed_atomic);
+ inc_zcache_pageframes_freed();
}
#endif
@@ -471,8 +521,7 @@ static void zcache_free_page(struct page *page)
if (page == NULL)
BUG();
__free_page(page);
- zcache_pageframes_freed =
- atomic_inc_return(&zcache_pageframes_freed_atomic);
+ inc_zcache_pageframes_freed();
curr_pageframes = zcache_pageframes_alloced -
atomic_read(&zcache_pageframes_freed_atomic) -
atomic_read(&zcache_eph_pageframes_atomic) -
@@ -537,19 +586,11 @@ static void *zcache_pampd_eph_create(char *data, size_t size, bool raw,
create_in_new_page:
pampd = (void *)zbud_create_prep(th, true, cdata, clen, newpage);
BUG_ON(pampd == NULL);
- zcache_eph_pageframes =
- atomic_inc_return(&zcache_eph_pageframes_atomic);
- if (zcache_eph_pageframes > zcache_eph_pageframes_max)
- zcache_eph_pageframes_max = zcache_eph_pageframes;
+ inc_zcache_eph_pageframes();
got_pampd:
- zcache_eph_zbytes =
- atomic_long_add_return(clen, &zcache_eph_zbytes_atomic);
- if (zcache_eph_zbytes > zcache_eph_zbytes_max)
- zcache_eph_zbytes_max = zcache_eph_zbytes;
- zcache_eph_zpages = atomic_inc_return(&zcache_eph_zpages_atomic);
- if (zcache_eph_zpages > zcache_eph_zpages_max)
- zcache_eph_zpages_max = zcache_eph_zpages;
+ inc_zcache_eph_zbytes(clen);
+ inc_zcache_eph_zpages();
if (ramster_enabled && raw)
ramster_count_foreign_pages(true, 1);
out:
@@ -619,19 +660,11 @@ create_pampd:
create_in_new_page:
pampd = (void *)zbud_create_prep(th, false, cdata, clen, newpage);
BUG_ON(pampd == NULL);
- zcache_pers_pageframes =
- atomic_inc_return(&zcache_pers_pageframes_atomic);
- if (zcache_pers_pageframes > zcache_pers_pageframes_max)
- zcache_pers_pageframes_max = zcache_pers_pageframes;
+ inc_zcache_pers_pageframes();
got_pampd:
- zcache_pers_zpages = atomic_inc_return(&zcache_pers_zpages_atomic);
- if (zcache_pers_zpages > zcache_pers_zpages_max)
- zcache_pers_zpages_max = zcache_pers_zpages;
- zcache_pers_zbytes =
- atomic_long_add_return(clen, &zcache_pers_zbytes_atomic);
- if (zcache_pers_zbytes > zcache_pers_zbytes_max)
- zcache_pers_zbytes_max = zcache_pers_zbytes;
+ inc_zcache_pers_zpages();
+ inc_zcache_pers_zbytes(clen);
if (ramster_enabled && raw)
ramster_count_foreign_pages(false, 1);
out:
--
1.7.7.6
as if you are debugging this driver you would be using 'debug'
on the command line anyhow - and this would dump the debug
data on the proper loglevel.
While at it also remove the unconditional #define ZCACHE_DEBUG.
Reviewed-by: Dan Magenheimer <[email protected]>
Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
---
drivers/staging/ramster/zcache-main.c | 69 ++++++++++++++++-----------------
1 files changed, 33 insertions(+), 36 deletions(-)
diff --git a/drivers/staging/ramster/zcache-main.c b/drivers/staging/ramster/zcache-main.c
index 6988f5c..a43c3b0 100644
--- a/drivers/staging/ramster/zcache-main.c
+++ b/drivers/staging/ramster/zcache-main.c
@@ -349,56 +349,53 @@ static int zcache_debugfs_init(void)
#undef zdfs64
#endif
-#define ZCACHE_DEBUG
-#ifdef ZCACHE_DEBUG
/* developers can call this in case of ooms, e.g. to find memory leaks */
void zcache_dump(void)
{
- pr_info("zcache: obj_count=%u\n", zcache_obj_count);
- pr_info("zcache: obj_count_max=%u\n", zcache_obj_count_max);
- pr_info("zcache: objnode_count=%u\n", zcache_objnode_count);
- pr_info("zcache: objnode_count_max=%u\n", zcache_objnode_count_max);
- pr_info("zcache: flush_total=%u\n", zcache_flush_total);
- pr_info("zcache: flush_found=%u\n", zcache_flush_found);
- pr_info("zcache: flobj_total=%u\n", zcache_flobj_total);
- pr_info("zcache: flobj_found=%u\n", zcache_flobj_found);
- pr_info("zcache: failed_eph_puts=%u\n", zcache_failed_eph_puts);
- pr_info("zcache: failed_pers_puts=%u\n", zcache_failed_pers_puts);
- pr_info("zcache: failed_get_free_pages=%u\n",
+ pr_debug("zcache: obj_count=%u\n", zcache_obj_count);
+ pr_debug("zcache: obj_count_max=%u\n", zcache_obj_count_max);
+ pr_debug("zcache: objnode_count=%u\n", zcache_objnode_count);
+ pr_debug("zcache: objnode_count_max=%u\n", zcache_objnode_count_max);
+ pr_debug("zcache: flush_total=%u\n", zcache_flush_total);
+ pr_debug("zcache: flush_found=%u\n", zcache_flush_found);
+ pr_debug("zcache: flobj_total=%u\n", zcache_flobj_total);
+ pr_debug("zcache: flobj_found=%u\n", zcache_flobj_found);
+ pr_debug("zcache: failed_eph_puts=%u\n", zcache_failed_eph_puts);
+ pr_debug("zcache: failed_pers_puts=%u\n", zcache_failed_pers_puts);
+ pr_debug("zcache: failed_get_free_pages=%u\n",
zcache_failed_getfreepages);
- pr_info("zcache: failed_alloc=%u\n", zcache_failed_alloc);
- pr_info("zcache: put_to_flush=%u\n", zcache_put_to_flush);
- pr_info("zcache: compress_poor=%u\n", zcache_compress_poor);
- pr_info("zcache: mean_compress_poor=%u\n",
+ pr_debug("zcache: failed_alloc=%u\n", zcache_failed_alloc);
+ pr_debug("zcache: put_to_flush=%u\n", zcache_put_to_flush);
+ pr_debug("zcache: compress_poor=%u\n", zcache_compress_poor);
+ pr_debug("zcache: mean_compress_poor=%u\n",
zcache_mean_compress_poor);
- pr_info("zcache: eph_ate_tail=%u\n", zcache_eph_ate_tail);
- pr_info("zcache: eph_ate_tail_failed=%u\n",
+ pr_debug("zcache: eph_ate_tail=%u\n", zcache_eph_ate_tail);
+ pr_debug("zcache: eph_ate_tail_failed=%u\n",
zcache_eph_ate_tail_failed);
- pr_info("zcache: pers_ate_eph=%u\n", zcache_pers_ate_eph);
- pr_info("zcache: pers_ate_eph_failed=%u\n",
+ pr_debug("zcache: pers_ate_eph=%u\n", zcache_pers_ate_eph);
+ pr_debug("zcache: pers_ate_eph_failed=%u\n",
zcache_pers_ate_eph_failed);
- pr_info("zcache: evicted_eph_zpages=%u\n", zcache_evicted_eph_zpages);
- pr_info("zcache: evicted_eph_pageframes=%u\n",
+ pr_debug("zcache: evicted_eph_zpages=%u\n", zcache_evicted_eph_zpages);
+ pr_debug("zcache: evicted_eph_pageframes=%u\n",
zcache_evicted_eph_pageframes);
- pr_info("zcache: eph_pageframes=%u\n", zcache_eph_pageframes);
- pr_info("zcache: eph_pageframes_max=%u\n", zcache_eph_pageframes_max);
- pr_info("zcache: pers_pageframes=%u\n", zcache_pers_pageframes);
- pr_info("zcache: pers_pageframes_max=%u\n",
+ pr_debug("zcache: eph_pageframes=%u\n", zcache_eph_pageframes);
+ pr_debug("zcache: eph_pageframes_max=%u\n", zcache_eph_pageframes_max);
+ pr_debug("zcache: pers_pageframes=%u\n", zcache_pers_pageframes);
+ pr_debug("zcache: pers_pageframes_max=%u\n",
zcache_pers_pageframes_max);
- pr_info("zcache: eph_zpages=%u\n", zcache_eph_zpages);
- pr_info("zcache: eph_zpages_max=%u\n", zcache_eph_zpages_max);
- pr_info("zcache: pers_zpages=%u\n", zcache_pers_zpages);
- pr_info("zcache: pers_zpages_max=%u\n", zcache_pers_zpages_max);
- pr_info("zcache: eph_zbytes=%llu\n",
+ pr_debug("zcache: eph_zpages=%u\n", zcache_eph_zpages);
+ pr_debug("zcache: eph_zpages_max=%u\n", zcache_eph_zpages_max);
+ pr_debug("zcache: pers_zpages=%u\n", zcache_pers_zpages);
+ pr_debug("zcache: pers_zpages_max=%u\n", zcache_pers_zpages_max);
+ pr_debug("zcache: eph_zbytes=%llu\n",
(unsigned long long)zcache_eph_zbytes);
- pr_info("zcache: eph_zbytes_max=%llu\n",
+ pr_debug("zcache: eph_zbytes_max=%llu\n",
(unsigned long long)zcache_eph_zbytes_max);
- pr_info("zcache: pers_zbytes=%llu\n",
+ pr_debug("zcache: pers_zbytes=%llu\n",
(unsigned long long)zcache_pers_zbytes);
- pr_info("zcache: pers_zbytes_max=%llu\n",
+ pr_debug("zcache: pers_zbytes_max=%llu\n",
(unsigned long long)zcache_pers_zbytes_max);
}
-#endif
/*
* zcache core code starts here
--
1.7.7.6
When we compile we get tons of:
include/linux/debugfs.h:80:16: note: expected ‘size_t *’ but argument is
of type ‘long int *’
drivers/staging/ramster/zcache-main.c:279:2: warning: passing argument 4
of ‘debugfs_create_size_t’ from incompatible pointer type [enabled by d
efault]
which is b/c we end up using 'unsigned' or 'unsigned long' instead
of 'ssize_t'. So lets fix this up and use the proper type.
Reviewed-by: Dan Magenheimer <[email protected]>
Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
---
drivers/staging/ramster/zcache-main.c | 135 +++++++++++++++++----------------
1 files changed, 68 insertions(+), 67 deletions(-)
diff --git a/drivers/staging/ramster/zcache-main.c b/drivers/staging/ramster/zcache-main.c
index 9e6b6d3..6988f5c 100644
--- a/drivers/staging/ramster/zcache-main.c
+++ b/drivers/staging/ramster/zcache-main.c
@@ -134,23 +134,23 @@ static struct kmem_cache *zcache_obj_cache;
static DEFINE_PER_CPU(struct zcache_preload, zcache_preloads) = { 0, };
/* we try to keep these statistics SMP-consistent */
-static long zcache_obj_count;
+static ssize_t zcache_obj_count;
static atomic_t zcache_obj_atomic = ATOMIC_INIT(0);
-static long zcache_obj_count_max;
+static ssize_t zcache_obj_count_max;
static inline void inc_zcache_obj_count(void)
{
zcache_obj_count = atomic_inc_return(&zcache_obj_atomic);
if (zcache_obj_count > zcache_obj_count_max)
zcache_obj_count_max = zcache_obj_count;
}
-static long zcache_objnode_count;
+static ssize_t zcache_objnode_count;
static inline void dec_zcache_obj_count(void)
{
zcache_obj_count = atomic_dec_return(&zcache_obj_atomic);
BUG_ON(zcache_obj_count < 0);
};
static atomic_t zcache_objnode_atomic = ATOMIC_INIT(0);
-static long zcache_objnode_count_max;
+static ssize_t zcache_objnode_count_max;
static inline void inc_zcache_objnode_count(void)
{
zcache_objnode_count = atomic_inc_return(&zcache_objnode_atomic);
@@ -184,64 +184,65 @@ static inline void inc_zcache_pers_zbytes(unsigned clen)
if (zcache_pers_zbytes > zcache_pers_zbytes_max)
zcache_pers_zbytes_max = zcache_pers_zbytes;
}
-static long zcache_eph_pageframes;
+static ssize_t zcache_eph_pageframes;
static inline void dec_zcache_pers_zbytes(unsigned zsize)
{
zcache_pers_zbytes = atomic_long_sub_return(zsize, &zcache_pers_zbytes_atomic);
}
static atomic_t zcache_eph_pageframes_atomic = ATOMIC_INIT(0);
-static long zcache_eph_pageframes_max;
+static ssize_t zcache_eph_pageframes_max;
static inline void inc_zcache_eph_pageframes(void)
{
zcache_eph_pageframes = atomic_inc_return(&zcache_eph_pageframes_atomic);
if (zcache_eph_pageframes > zcache_eph_pageframes_max)
zcache_eph_pageframes_max = zcache_eph_pageframes;
};
-static long zcache_pers_pageframes;
+static ssize_t zcache_pers_pageframes;
static inline void dec_zcache_eph_pageframes(void)
{
zcache_eph_pageframes = atomic_dec_return(&zcache_eph_pageframes_atomic);
};
static atomic_t zcache_pers_pageframes_atomic = ATOMIC_INIT(0);
-static long zcache_pers_pageframes_max;
+static ssize_t zcache_pers_pageframes_max;
static inline void inc_zcache_pers_pageframes(void)
{
zcache_pers_pageframes = atomic_inc_return(&zcache_pers_pageframes_atomic);
if (zcache_pers_pageframes > zcache_pers_pageframes_max)
zcache_pers_pageframes_max = zcache_pers_pageframes;
}
-static long zcache_pageframes_alloced;
+static ssize_t zcache_pageframes_alloced;
static inline void dec_zcache_pers_pageframes(void)
{
zcache_pers_pageframes = atomic_dec_return(&zcache_pers_pageframes_atomic);
}
static atomic_t zcache_pageframes_alloced_atomic = ATOMIC_INIT(0);
+static ssize_t zcache_pageframes_freed;
+static atomic_t zcache_pageframes_freed_atomic = ATOMIC_INIT(0);
+static ssize_t zcache_eph_zpages;
static inline void inc_zcache_pageframes_alloced(void)
{
zcache_pageframes_alloced = atomic_inc_return(&zcache_pageframes_alloced_atomic);
};
-static long zcache_pageframes_freed;
-static atomic_t zcache_pageframes_freed_atomic = ATOMIC_INIT(0);
static inline void inc_zcache_pageframes_freed(void)
{
zcache_pageframes_freed = atomic_inc_return(&zcache_pageframes_freed_atomic);
}
-static long zcache_eph_zpages;
+static ssize_t zcache_eph_zpages;
static atomic_t zcache_eph_zpages_atomic = ATOMIC_INIT(0);
-static long zcache_eph_zpages_max;
+static ssize_t zcache_eph_zpages_max;
static inline void inc_zcache_eph_zpages(void)
{
zcache_eph_zpages = atomic_inc_return(&zcache_eph_zpages_atomic);
if (zcache_eph_zpages > zcache_eph_zpages_max)
zcache_eph_zpages_max = zcache_eph_zpages;
}
-static long zcache_pers_zpages;
+static ssize_t zcache_pers_zpages;
static inline void dec_zcache_eph_zpages(unsigned zpages)
{
zcache_eph_zpages = atomic_sub_return(zpages, &zcache_eph_zpages_atomic);
}
static atomic_t zcache_pers_zpages_atomic = ATOMIC_INIT(0);
-static long zcache_pers_zpages_max;
+static ssize_t zcache_pers_zpages_max;
static inline void inc_zcache_pers_zpages(void)
{
zcache_pers_zpages = atomic_inc_return(&zcache_pers_zpages_atomic);
@@ -261,29 +262,29 @@ static inline unsigned long curr_pageframes_count(void)
atomic_read(&zcache_pers_pageframes_atomic);
};
/* but for the rest of these, counting races are ok */
-static unsigned long zcache_flush_total;
-static unsigned long zcache_flush_found;
-static unsigned long zcache_flobj_total;
-static unsigned long zcache_flobj_found;
-static unsigned long zcache_failed_eph_puts;
-static unsigned long zcache_failed_pers_puts;
-static unsigned long zcache_failed_getfreepages;
-static unsigned long zcache_failed_alloc;
-static unsigned long zcache_put_to_flush;
-static unsigned long zcache_compress_poor;
-static unsigned long zcache_mean_compress_poor;
-static unsigned long zcache_eph_ate_tail;
-static unsigned long zcache_eph_ate_tail_failed;
-static unsigned long zcache_pers_ate_eph;
-static unsigned long zcache_pers_ate_eph_failed;
-static unsigned long zcache_evicted_eph_zpages;
-static unsigned long zcache_evicted_eph_pageframes;
-static unsigned long zcache_last_active_file_pageframes;
-static unsigned long zcache_last_inactive_file_pageframes;
-static unsigned long zcache_last_active_anon_pageframes;
-static unsigned long zcache_last_inactive_anon_pageframes;
-static unsigned long zcache_eph_nonactive_puts_ignored;
-static unsigned long zcache_pers_nonactive_puts_ignored;
+static ssize_t zcache_flush_total;
+static ssize_t zcache_flush_found;
+static ssize_t zcache_flobj_total;
+static ssize_t zcache_flobj_found;
+static ssize_t zcache_failed_eph_puts;
+static ssize_t zcache_failed_pers_puts;
+static ssize_t zcache_failed_getfreepages;
+static ssize_t zcache_failed_alloc;
+static ssize_t zcache_put_to_flush;
+static ssize_t zcache_compress_poor;
+static ssize_t zcache_mean_compress_poor;
+static ssize_t zcache_eph_ate_tail;
+static ssize_t zcache_eph_ate_tail_failed;
+static ssize_t zcache_pers_ate_eph;
+static ssize_t zcache_pers_ate_eph_failed;
+static ssize_t zcache_evicted_eph_zpages;
+static ssize_t zcache_evicted_eph_pageframes;
+static ssize_t zcache_last_active_file_pageframes;
+static ssize_t zcache_last_inactive_file_pageframes;
+static ssize_t zcache_last_active_anon_pageframes;
+static ssize_t zcache_last_inactive_anon_pageframes;
+static ssize_t zcache_eph_nonactive_puts_ignored;
+static ssize_t zcache_pers_nonactive_puts_ignored;
#ifdef CONFIG_DEBUG_FS
#include <linux/debugfs.h>
@@ -353,41 +354,41 @@ static int zcache_debugfs_init(void)
/* developers can call this in case of ooms, e.g. to find memory leaks */
void zcache_dump(void)
{
- pr_info("zcache: obj_count=%lu\n", zcache_obj_count);
- pr_info("zcache: obj_count_max=%lu\n", zcache_obj_count_max);
- pr_info("zcache: objnode_count=%lu\n", zcache_objnode_count);
- pr_info("zcache: objnode_count_max=%lu\n", zcache_objnode_count_max);
- pr_info("zcache: flush_total=%lu\n", zcache_flush_total);
- pr_info("zcache: flush_found=%lu\n", zcache_flush_found);
- pr_info("zcache: flobj_total=%lu\n", zcache_flobj_total);
- pr_info("zcache: flobj_found=%lu\n", zcache_flobj_found);
- pr_info("zcache: failed_eph_puts=%lu\n", zcache_failed_eph_puts);
- pr_info("zcache: failed_pers_puts=%lu\n", zcache_failed_pers_puts);
- pr_info("zcache: failed_get_free_pages=%lu\n",
+ pr_info("zcache: obj_count=%u\n", zcache_obj_count);
+ pr_info("zcache: obj_count_max=%u\n", zcache_obj_count_max);
+ pr_info("zcache: objnode_count=%u\n", zcache_objnode_count);
+ pr_info("zcache: objnode_count_max=%u\n", zcache_objnode_count_max);
+ pr_info("zcache: flush_total=%u\n", zcache_flush_total);
+ pr_info("zcache: flush_found=%u\n", zcache_flush_found);
+ pr_info("zcache: flobj_total=%u\n", zcache_flobj_total);
+ pr_info("zcache: flobj_found=%u\n", zcache_flobj_found);
+ pr_info("zcache: failed_eph_puts=%u\n", zcache_failed_eph_puts);
+ pr_info("zcache: failed_pers_puts=%u\n", zcache_failed_pers_puts);
+ pr_info("zcache: failed_get_free_pages=%u\n",
zcache_failed_getfreepages);
- pr_info("zcache: failed_alloc=%lu\n", zcache_failed_alloc);
- pr_info("zcache: put_to_flush=%lu\n", zcache_put_to_flush);
- pr_info("zcache: compress_poor=%lu\n", zcache_compress_poor);
- pr_info("zcache: mean_compress_poor=%lu\n",
+ pr_info("zcache: failed_alloc=%u\n", zcache_failed_alloc);
+ pr_info("zcache: put_to_flush=%u\n", zcache_put_to_flush);
+ pr_info("zcache: compress_poor=%u\n", zcache_compress_poor);
+ pr_info("zcache: mean_compress_poor=%u\n",
zcache_mean_compress_poor);
- pr_info("zcache: eph_ate_tail=%lu\n", zcache_eph_ate_tail);
- pr_info("zcache: eph_ate_tail_failed=%lu\n",
+ pr_info("zcache: eph_ate_tail=%u\n", zcache_eph_ate_tail);
+ pr_info("zcache: eph_ate_tail_failed=%u\n",
zcache_eph_ate_tail_failed);
- pr_info("zcache: pers_ate_eph=%lu\n", zcache_pers_ate_eph);
- pr_info("zcache: pers_ate_eph_failed=%lu\n",
+ pr_info("zcache: pers_ate_eph=%u\n", zcache_pers_ate_eph);
+ pr_info("zcache: pers_ate_eph_failed=%u\n",
zcache_pers_ate_eph_failed);
- pr_info("zcache: evicted_eph_zpages=%lu\n", zcache_evicted_eph_zpages);
- pr_info("zcache: evicted_eph_pageframes=%lu\n",
+ pr_info("zcache: evicted_eph_zpages=%u\n", zcache_evicted_eph_zpages);
+ pr_info("zcache: evicted_eph_pageframes=%u\n",
zcache_evicted_eph_pageframes);
- pr_info("zcache: eph_pageframes=%lu\n", zcache_eph_pageframes);
- pr_info("zcache: eph_pageframes_max=%lu\n", zcache_eph_pageframes_max);
- pr_info("zcache: pers_pageframes=%lu\n", zcache_pers_pageframes);
- pr_info("zcache: pers_pageframes_max=%lu\n",
+ pr_info("zcache: eph_pageframes=%u\n", zcache_eph_pageframes);
+ pr_info("zcache: eph_pageframes_max=%u\n", zcache_eph_pageframes_max);
+ pr_info("zcache: pers_pageframes=%u\n", zcache_pers_pageframes);
+ pr_info("zcache: pers_pageframes_max=%u\n",
zcache_pers_pageframes_max);
- pr_info("zcache: eph_zpages=%lu\n", zcache_eph_zpages);
- pr_info("zcache: eph_zpages_max=%lu\n", zcache_eph_zpages_max);
- pr_info("zcache: pers_zpages=%lu\n", zcache_pers_zpages);
- pr_info("zcache: pers_zpages_max=%lu\n", zcache_pers_zpages_max);
+ pr_info("zcache: eph_zpages=%u\n", zcache_eph_zpages);
+ pr_info("zcache: eph_zpages_max=%u\n", zcache_eph_zpages_max);
+ pr_info("zcache: pers_zpages=%u\n", zcache_pers_zpages);
+ pr_info("zcache: pers_zpages_max=%u\n", zcache_pers_zpages_max);
pr_info("zcache: eph_zbytes=%llu\n",
(unsigned long long)zcache_eph_zbytes);
pr_info("zcache: eph_zbytes_max=%llu\n",
--
1.7.7.6
This way we can have all wrapped with these functions and
can disable/enable this with CONFIG_DEBUG_FS eventually.
Reviewed-by: Dan Magenheimer <[email protected]>
Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
---
drivers/staging/ramster/zcache-main.c | 88 +++++++++++++++++++--------------
1 files changed, 51 insertions(+), 37 deletions(-)
diff --git a/drivers/staging/ramster/zcache-main.c b/drivers/staging/ramster/zcache-main.c
index 24adcbd..99dc045 100644
--- a/drivers/staging/ramster/zcache-main.c
+++ b/drivers/staging/ramster/zcache-main.c
@@ -143,8 +143,12 @@ static inline void inc_zcache_obj_count(void)
if (zcache_obj_count > zcache_obj_count_max)
zcache_obj_count_max = zcache_obj_count;
}
-
static long zcache_objnode_count;
+static inline void dec_zcache_obj_count(void)
+{
+ zcache_obj_count = atomic_dec_return(&zcache_obj_atomic);
+ BUG_ON(zcache_obj_count < 0);
+};
static atomic_t zcache_objnode_atomic = ATOMIC_INIT(0);
static long zcache_objnode_count_max;
static inline void inc_zcache_objnode_count(void)
@@ -153,6 +157,11 @@ static inline void inc_zcache_objnode_count(void)
if (zcache_objnode_count > zcache_objnode_count_max)
zcache_objnode_count_max = zcache_objnode_count;
};
+static inline void dec_zcache_objnode_count(void)
+{
+ zcache_objnode_count = atomic_dec_return(&zcache_objnode_atomic);
+ BUG_ON(zcache_objnode_count < 0);
+};
static u64 zcache_eph_zbytes;
static atomic_long_t zcache_eph_zbytes_atomic = ATOMIC_INIT(0);
static u64 zcache_eph_zbytes_max;
@@ -162,6 +171,10 @@ static inline void inc_zcache_eph_zbytes(unsigned clen)
if (zcache_eph_zbytes > zcache_eph_zbytes_max)
zcache_eph_zbytes_max = zcache_eph_zbytes;
};
+static inline void dec_zcache_eph_zbytes(unsigned zsize)
+{
+ zcache_eph_zbytes = atomic_long_sub_return(zsize, &zcache_eph_zbytes_atomic);
+};
static u64 zcache_pers_zbytes;
static atomic_long_t zcache_pers_zbytes_atomic = ATOMIC_INIT(0);
static u64 zcache_pers_zbytes_max;
@@ -172,6 +185,10 @@ static inline void inc_zcache_pers_zbytes(unsigned clen)
zcache_pers_zbytes_max = zcache_pers_zbytes;
}
static long zcache_eph_pageframes;
+static inline void dec_zcache_pers_zbytes(unsigned zsize)
+{
+ zcache_pers_zbytes = atomic_long_sub_return(zsize, &zcache_pers_zbytes_atomic);
+}
static atomic_t zcache_eph_pageframes_atomic = ATOMIC_INIT(0);
static long zcache_eph_pageframes_max;
static inline void inc_zcache_eph_pageframes(void)
@@ -181,6 +198,10 @@ static inline void inc_zcache_eph_pageframes(void)
zcache_eph_pageframes_max = zcache_eph_pageframes;
};
static long zcache_pers_pageframes;
+static inline void dec_zcache_eph_pageframes(void)
+{
+ zcache_eph_pageframes = atomic_dec_return(&zcache_eph_pageframes_atomic);
+};
static atomic_t zcache_pers_pageframes_atomic = ATOMIC_INIT(0);
static long zcache_pers_pageframes_max;
static inline void inc_zcache_pers_pageframes(void)
@@ -190,6 +211,10 @@ static inline void inc_zcache_pers_pageframes(void)
zcache_pers_pageframes_max = zcache_pers_pageframes;
}
static long zcache_pageframes_alloced;
+static inline void dec_zcache_pers_pageframes(void)
+{
+ zcache_pers_pageframes = atomic_dec_return(&zcache_pers_pageframes_atomic);
+}
static atomic_t zcache_pageframes_alloced_atomic = ATOMIC_INIT(0);
static inline void inc_zcache_pageframes_alloced(void)
{
@@ -211,6 +236,10 @@ static inline void inc_zcache_eph_zpages(void)
zcache_eph_zpages_max = zcache_eph_zpages;
}
static long zcache_pers_zpages;
+static inline void dec_zcache_eph_zpages(unsigned zpages)
+{
+ zcache_eph_zpages = atomic_sub_return(zpages, &zcache_eph_zpages_atomic);
+}
static atomic_t zcache_pers_zpages_atomic = ATOMIC_INIT(0);
static long zcache_pers_zpages_max;
static inline void inc_zcache_pers_zpages(void)
@@ -219,6 +248,10 @@ static inline void inc_zcache_pers_zpages(void)
if (zcache_pers_zpages > zcache_pers_zpages_max)
zcache_pers_zpages_max = zcache_pers_zpages;
}
+static inline void dec_zcache_pers_zpages(unsigned zpages)
+{
+ zcache_pers_zpages = atomic_sub_return(zpages, &zcache_pers_zpages_atomic);
+}
/* but for the rest of these, counting races are ok */
static unsigned long zcache_flush_total;
static unsigned long zcache_flush_found;
@@ -463,9 +496,7 @@ static struct tmem_objnode *zcache_objnode_alloc(struct tmem_pool *pool)
static void zcache_objnode_free(struct tmem_objnode *objnode,
struct tmem_pool *pool)
{
- zcache_objnode_count =
- atomic_dec_return(&zcache_objnode_atomic);
- BUG_ON(zcache_objnode_count < 0);
+ dec_zcache_objnode_count();
kmem_cache_free(zcache_objnode_cache, objnode);
}
@@ -484,9 +515,7 @@ static struct tmem_obj *zcache_obj_alloc(struct tmem_pool *pool)
static void zcache_obj_free(struct tmem_obj *obj, struct tmem_pool *pool)
{
- zcache_obj_count =
- atomic_dec_return(&zcache_obj_atomic);
- BUG_ON(zcache_obj_count < 0);
+ dec_zcache_obj_count();
kmem_cache_free(zcache_obj_cache, obj);
}
@@ -813,20 +842,14 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw,
&zsize, &zpages);
if (eph) {
if (page)
- zcache_eph_pageframes =
- atomic_dec_return(&zcache_eph_pageframes_atomic);
- zcache_eph_zpages =
- atomic_sub_return(zpages, &zcache_eph_zpages_atomic);
- zcache_eph_zbytes =
- atomic_long_sub_return(zsize, &zcache_eph_zbytes_atomic);
+ dec_zcache_eph_pageframes();
+ dec_zcache_eph_zpages(zpages);
+ dec_zcache_eph_zbytes(zsize);
} else {
if (page)
- zcache_pers_pageframes =
- atomic_dec_return(&zcache_pers_pageframes_atomic);
- zcache_pers_zpages =
- atomic_sub_return(zpages, &zcache_pers_zpages_atomic);
- zcache_pers_zbytes =
- atomic_long_sub_return(zsize, &zcache_pers_zbytes_atomic);
+ dec_zcache_pers_pageframes();
+ dec_zcache_pers_zpages(zpages);
+ dec_zcache_pers_zbytes(zsize);
}
if (!is_local_client(pool->client))
ramster_count_foreign_pages(eph, -1);
@@ -856,23 +879,17 @@ static void zcache_pampd_free(void *pampd, struct tmem_pool *pool,
page = zbud_free_and_delist((struct zbudref *)pampd,
true, &zsize, &zpages);
if (page)
- zcache_eph_pageframes =
- atomic_dec_return(&zcache_eph_pageframes_atomic);
- zcache_eph_zpages =
- atomic_sub_return(zpages, &zcache_eph_zpages_atomic);
- zcache_eph_zbytes =
- atomic_long_sub_return(zsize, &zcache_eph_zbytes_atomic);
+ dec_zcache_eph_pageframes();
+ dec_zcache_eph_zpages(zpages);
+ dec_zcache_eph_zbytes(zsize);
/* FIXME CONFIG_RAMSTER... check acct parameter? */
} else {
page = zbud_free_and_delist((struct zbudref *)pampd,
false, &zsize, &zpages);
if (page)
- zcache_pers_pageframes =
- atomic_dec_return(&zcache_pers_pageframes_atomic);
- zcache_pers_zpages =
- atomic_sub_return(zpages, &zcache_pers_zpages_atomic);
- zcache_pers_zbytes =
- atomic_long_sub_return(zsize, &zcache_pers_zbytes_atomic);
+ dec_zcache_pers_pageframes();
+ dec_zcache_pers_zpages(zpages);
+ dec_zcache_pers_zbytes(zsize);
}
if (!is_local_client(pool->client))
ramster_count_foreign_pages(is_ephemeral(pool), -1);
@@ -994,13 +1011,10 @@ static struct page *zcache_evict_eph_pageframe(void)
page = zbud_evict_pageframe_lru(&zsize, &zpages);
if (page == NULL)
goto out;
- zcache_eph_zbytes = atomic_long_sub_return(zsize,
- &zcache_eph_zbytes_atomic);
- zcache_eph_zpages = atomic_sub_return(zpages,
- &zcache_eph_zpages_atomic);
+ dec_zcache_eph_zbytes(zsize);
+ dec_zcache_eph_zpages(zpages);
zcache_evicted_eph_zpages++;
- zcache_eph_pageframes =
- atomic_dec_return(&zcache_eph_pageframes_atomic);
+ dec_zcache_eph_pageframes();
zcache_evicted_eph_pageframes++;
out:
return page;
--
1.7.7.6
And now we can move the code to its own file.
Reviewed-by: Dan Magenheimer <[email protected]>
Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
---
drivers/staging/ramster/zcache-main.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/ramster/zcache-main.c b/drivers/staging/ramster/zcache-main.c
index 99dc045..9e6b6d3 100644
--- a/drivers/staging/ramster/zcache-main.c
+++ b/drivers/staging/ramster/zcache-main.c
@@ -252,6 +252,14 @@ static inline void dec_zcache_pers_zpages(unsigned zpages)
{
zcache_pers_zpages = atomic_sub_return(zpages, &zcache_pers_zpages_atomic);
}
+
+static inline unsigned long curr_pageframes_count(void)
+{
+ return zcache_pageframes_alloced -
+ atomic_read(&zcache_pageframes_freed_atomic) -
+ atomic_read(&zcache_eph_pageframes_atomic) -
+ atomic_read(&zcache_pers_pageframes_atomic);
+};
/* but for the rest of these, counting races are ok */
static unsigned long zcache_flush_total;
static unsigned long zcache_flush_found;
@@ -551,10 +559,7 @@ static void zcache_free_page(struct page *page)
BUG();
__free_page(page);
inc_zcache_pageframes_freed();
- curr_pageframes = zcache_pageframes_alloced -
- atomic_read(&zcache_pageframes_freed_atomic) -
- atomic_read(&zcache_eph_pageframes_atomic) -
- atomic_read(&zcache_pers_pageframes_atomic);
+ curr_pageframes = curr_pageframes_count();
if (curr_pageframes > max_pageframes)
max_pageframes = curr_pageframes;
if (curr_pageframes < min_pageframes)
--
1.7.7.6
Um, that is what I get from doing this while traveling.
This is the writeup:
From: Konrad Rzeszutek Wilk <[email protected]>
Subject: [PATCH] zcache2 cleanups (s/int/bool/ + debugfs move).
In-Reply-To:
Changelog since rfc: https://lkml.org/lkml/2012/11/5/549
- Added Reviewed-by from Dan.
This patchset depends on the recently posted V2 of making the
frontswap/cleancache backends be module capable:
http://mid.gmane.org/[email protected]
I think that once the V2 is OK I will combine this patchset along
with the V2 and send the whole thing to GregKH? Or perhaps just
if Greg is Ok I will do via my tree.
This is a copy of what I wrote in the RFC posting:
Looking at the zcache2 code there were a couple of things that I thought
would make sense to move out of the code. For one thing it makes it easier
to read, and for anoter - it can be cleanly compiled out. It also allows
to have a clean seperation of counters that we _need_ vs the optional ones.
Which means that in the future we could get rid of the optional ones.
It fixes some outstanding compile warnings, cleans
up some of the code, and rips out the debug counters out of zcache-main.c
and sticks them in a debug.c file.
I was hoping it would end up with less code, but sadly it ended up with
a bit more due to the empty non-debug functions - but the code is easier
to read.
drivers/staging/ramster/Kconfig | 8 +
drivers/staging/ramster/Makefile | 1 +
drivers/staging/ramster/debug.c | 66 +++++++
drivers/staging/ramster/debug.h | 229 ++++++++++++++++++++++
drivers/staging/ramster/zcache-main.c | 336 +++++++--------------------------
5 files changed, 370 insertions(+), 270 deletions(-)
Konrad Rzeszutek Wilk (11):
zcache: Provide accessory functions for counter increase
zcache: Provide accessory functions for counter decrease.
zcache: The last of the atomic reads has now an accessory function.
zcache: Fix compile warnings due to usage of debugfs_create_size_t
zcache: Make the debug code use pr_debug
zcache: Move debugfs code out of zcache-main.c file.
zcache: Use an array to initialize/use debugfs attributes.
zcache: Move the last of the debugfs counters out
zcache: Allow to compile if ZCACHE_DEBUG and !DEBUG_FS
zcache: Module license is defined twice.
zcache: Coalesce all debug under CONFIG_ZCACHE2_DEBUG