mm/zsmalloc: add statistics support
PATCH v2 1/1 mm/zsmalloc: add statistics support
Keeping fragmentation of zsmalloc in a low level is our target. But now we still need to add the debug code in zsmalloc to get the quantitative data.
This patch adds a new configuration CONFIG_ZSMALLOC_STAT to enable the statistics collection for developers. Currently only the objects statatitics in each class are collected. User can get the information via debugfs.
cat /sys/kernel/debug/zsmalloc/pool-1/...
For example:
After I copied "jdk-8u25-linux-x64.tar.gz" to zram with ext4 filesystem:
class size obj_allocated obj_used pages_used
0 32 0 0 0
1 48 256 12 3
2 64 64 14 1
3 80 51 7 1
4 96 128 5 3
5 112 73 5 2
6 128 32 4 1
7 144 0 0 0
8 160 0 0 0
9 176 0 0 0
10 192 0 0 0
11 208 0 0 0
12 224 0 0 0
13 240 0 0 0
14 256 16 1 1
15 272 15 9 1
16 288 0 0 0
17 304 0 0 0
18 320 0 0 0
19 336 0 0 0
20 352 0 0 0
21 368 0 0 0
22 384 0 0 0
23 400 0 0 0
24 416 0 0 0
25 432 0 0 0
26 448 0 0 0
27 464 0 0 0
28 480 0 0 0
29 496 33 1 4
30 512 0 0 0
31 528 0 0 0
32 544 0 0 0
33 560 0 0 0
34 576 0 0 0
35 592 0 0 0
36 608 0 0 0
37 624 0 0 0
38 640 0 0 0
40 672 0 0 0
42 704 0 0 0
43 720 17 1 3
44 736 0 0 0
46 768 0 0 0
49 816 0 0 0
51 848 0 0 0
52 864 14 1 3
54 896 0 0 0
57 944 13 1 3
58 960 0 0 0
62 1024 4 1 1
66 1088 15 2 4
67 1104 0 0 0
71 1168 0 0 0
74 1216 0 0 0
76 1248 0 0 0
83 1360 3 1 1
91 1488 11 1 4
94 1536 0 0 0
100 1632 5 1 2
107 1744 0 0 0
111 1808 9 1 4
126 2048 4 4 2
144 2336 7 3 4
151 2448 0 0 0
168 2720 15 15 10
190 3072 28 27 21
202 3264 0 0 0
254 4096 36209 36209 36209Total 37022 36326 36288
We can calculate the overall fragentation by the last line:
Total 37022 36326 36288
(37022 - 36326) / 37022 = 1.87%Also by analysing objects alocated in every class we know why we got so low fragmentation:
Most of the allocated objects is in <class 254>. And there is only 1 page in class 254 zspage. So, No fragmentation will be introduced by allocating objs in class 254.
To let users know which zsmalloc pool he is using, an API get_zs_pool_index() is exported. User can call it to get the zs pool index after zs pool is populated.
And you can collect other zsmalloc statistics as you need and analyse them.
---
V1 -> V2:
create and use zs_size_stat to store the zs stat - Minchan use pool->index to associate zs pool and block device - Minchan export get_zs_pool_index() to zsmalloc user - Minchan Fix race for zs pool index increasement - Minchan patch description change - Minchan
propagate error to user when zs_stat_init() is failed - Minchan
--- include/linux/zsmalloc.h | 9 ++ mm/Kconfig | 10 ++ mm/zsmalloc.c | 246 +++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 261 insertions(+), 4 deletions(-)
include/linux/zsmalloc.h +9 -0
@@ -48,4 +48,13 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle);unsigned long zs_get_total_pages (struct zs_pool *pool); +#ifdef CONFIG_ZSMALLOC_STAT +int get_zs_pool_index (struct zs_pool *pool); +#else +static inline int get_zs_pool_index (struct zs_pool *pool) +{ +return -1 ; +} +#endif +#endif
mm/Kconfig +10 -0
@@ -601,6 +601,16 @@ config PGTABLE_MAPPING You can check speed with zsmalloc benchmark: https://github.com/spartacus06/zsmapbench +config ZSMALLOC_STAT + bool "Export zsmalloc statistics" + depends on ZSMALLOC + select DEBUG_FS + help + This option enables code in the zsmalloc to collect various + statistics about whats happening in zsmalloc and exports that + information to userspace via debugfs. + If unsure, say N. + config GENERIC_EARLY_IOREMAP bool
mm/zsmalloc.c +242 -4
326 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Andrew Morton
maintainerQuoted 7 lines · On Fri, 19 Dec 2014 20:55:19 +0800 Ganesh Mahendran…
Keeping fragmentation of zsmalloc in a low level is our target. But now we still need to add the debug code in zsmalloc to get the quantitative data.
This patch adds a new configuration
CONFIG_ZSMALLOC_STATto enable the statistics collection for developers. Currently only the objects statatitics in each class are collected. User can get the information via debugfs.cat /sys/kernel/debug/zsmalloc/pool-1/...
Is everyone OK with this now?
include/linux/zsmalloc.h void zs_unmap_object(struct zs_pool *pool, unsigned long handle); · line 52
Quoted 8 lines
include/linux/zsmalloc.h +2
-0@@ -48,4 +48,13 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle);unsigned long zs_get_total_pages (struct zs_pool *pool); +#ifdef CONFIG_ZSMALLOC_STAT +int get_zs_pool_index (struct zs_pool *pool);
The name is inconsistent with the rest of zsmalloc and with preferred kernel naming conventions. Should be "zs_get_pool_index".
Quoted 12 lines
include/linux/zsmalloc.h +7
-0+#else +static inline int get_zs_pool_index (struct zs_pool *pool) +{ +return -1 ; +} +#endif +#endif mm/Kconfig +0
-0
mm/Kconfig
Quoted 7 lines
mm/Kconfig +4
-0+static int zs_stats_size_show(struct seq_file *s, void *v) +{ + int i; + struct zs_pool *pool = (struct zs_pool *)s->private;
The typecast is unneeded and undesirable (it defeats typechecking).
Quoted 34 lines
mm/Kconfig +34
-0+ struct size_class *class; + int objs_per_zspage; + unsigned long obj_allocated, obj_used, pages_used; + unsigned long total_objs = 0, total_used_objs = 0, total_pages = 0; + + seq_printf(s, " %5s %5s %13s %10s %10s\n", "class", "size", + "obj_allocated", "obj_used", "pages_used"); + + for (i = 0; i < zs_size_classes; i++) { + class = pool->size_class[i]; + + if (class->index != i) + continue; + + spin_lock(&class->lock); + obj_allocated = zs_stat_get(class, OBJ_ALLOCATED); + obj_used = zs_stat_get(class, OBJ_USED); + spin_unlock(&class->lock); + + objs_per_zspage = get_maxobj_per_zspage(class->size, + class->pages_per_zspage); + pages_used = obj_allocated / objs_per_zspage * + class->pages_per_zspage; + + seq_printf(s, " %5u %5u %10lu %10lu %10lu\n", i, + class->size, obj_allocated, obj_used, pages_used); + + total_objs += obj_allocated; + total_used_objs += obj_used; + total_pages += pages_used; + } + + seq_puts(s, "\n"); + seq_printf(s, " %5s %5s %10lu %10lu %10lu\n", "Total", "",
mm/Kconfig
Quoted 10 lines
mm/Kconfig +7
-0+ total_objs, total_used_objs, total_pages); + + return 0; +} +static int zs_pool_stat_create(struct zs_pool *pool) +{ + char name[10];
This is not good. If the kernel creates and then destroys a pool 10000 times, zs_pool_index==10000 and we overrun the buffer. Could use kasprintf() in here to fix this.
zs_pool_index isn't a very good name - it doesn't index anything. zs_pool_id would be better.
mm/Kconfig
Quoted 12 lines
mm/Kconfig +12
-0+ struct dentry *entry; + + if (!zs_stat_root) + return -ENODEV; + + pool->index = atomic_inc_return(&zs_pool_index); + snprintf(name, sizeof(name), "pool-%d", pool->index); + entry = debugfs_create_dir(name, zs_stat_root); + if (!entry) { + pr_warn("pool %d, debugfs dir <%s> creation failed\n", + pool->index, name); + return -ENOMEM;
Sigh. The debugfs interface does suck. Doesn't matter much.
Quoted 16 lines
mm/Kconfig +13
-0+ } + pool->stat_dentry = entry; + + entry = debugfs_create_file("obj_in_classes", S_IFREG | S_IRUGO, + pool->stat_dentry, pool, &zs_stat_size_ops); + if (!entry) { + pr_warn("pool %d, debugfs file entry <%s> creation failed\n", + pool->index, "obj_in_classes"); + return -ENOMEM; + } + + return 0; +}
Minchan Kim
maintainerQuoted 11 lines · Andrew Morton
Quoted 7 lines · On Fri, 19 Dec 2014 20:55:19 +0800 Ganesh Mahendran…
Keeping fragmentation of zsmalloc in a low level is our target. But now we still need to add the debug code in zsmalloc to get the quantitative data.
This patch adds a new configuration
CONFIG_ZSMALLOC_STATto enable the statistics collection for developers. Currently only the objects statatitics in each class are collected. User can get the information via debugfs.cat /sys/kernel/debug/zsmalloc/pool-1/...Is everyone OK with this now?
Hmm, how about passing straightforward name from the user(ex, zram) when it creates zsmalloc? (ex, ex, zs_create_pool(gfp, zram0)).
Then, we should fix debugfs_create_dir can return errno to propagate the error to end user who can know it was failed ENOMEM or EEXIST.
Quoted 116 lines
include/linux/zsmalloc.h void zs_unmap_object(struct zs_pool *pool, unsigned long handle); · line 52
Quoted 9 lines
include/linux/zsmalloc.h +2
-0@@ -48,4 +48,13 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle);unsigned long zs_get_total_pages (struct zs_pool *pool); +#ifdef CONFIG_ZSMALLOC_STAT +int get_zs_pool_index (struct zs_pool *pool);The name is inconsistent with the rest of zsmalloc and with preferred kernel naming conventions. Should be "
zs_get_pool_index".Quoted 12 lines
include/linux/zsmalloc.h +7
-0+#else +static inline int get_zs_pool_index (struct zs_pool *pool) +{ +return -1 ; +} +#endif +#endif mm/Kconfig +0
-0mm/Kconfig
Quoted 7 lines
mm/Kconfig +4
-0+static int zs_stats_size_show(struct seq_file *s, void *v) +{ + int i; + struct zs_pool *pool = (struct zs_pool *)s->private;The typecast is unneeded and undesirable (it defeats typechecking).
Quoted 34 lines
mm/Kconfig +34
-0+ struct size_class *class; + int objs_per_zspage; + unsigned long obj_allocated, obj_used, pages_used; + unsigned long total_objs = 0, total_used_objs = 0, total_pages = 0; + + seq_printf(s, " %5s %5s %13s %10s %10s\n", "class", "size", + "obj_allocated", "obj_used", "pages_used"); + + for (i = 0; i < zs_size_classes; i++) { + class = pool->size_class[i]; + + if (class->index != i) + continue; + + spin_lock(&class->lock); + obj_allocated = zs_stat_get(class, OBJ_ALLOCATED); + obj_used = zs_stat_get(class, OBJ_USED); + spin_unlock(&class->lock); + + objs_per_zspage = get_maxobj_per_zspage(class->size, + class->pages_per_zspage); + pages_used = obj_allocated / objs_per_zspage * + class->pages_per_zspage; + + seq_printf(s, " %5u %5u %10lu %10lu %10lu\n", i, + class->size, obj_allocated, obj_used, pages_used); + + total_objs += obj_allocated; + total_used_objs += obj_used; + total_pages += pages_used; + } + + seq_puts(s, "\n"); + seq_printf(s, " %5s %5s %10lu %10lu %10lu\n", "Total", "",mm/Kconfig
Quoted 10 lines
mm/Kconfig +7
-0+ total_objs, total_used_objs, total_pages); + + return 0; +} +static int zs_pool_stat_create(struct zs_pool *pool) +{ + char name[10];This is not good. If the kernel creates and then destroys a pool 10000 times, zs_pool_index==10000 and we overrun the buffer. Could use
kasprintf()in here to fix this.
zs_pool_indexisn't a very good name - it doesn't index anything.zs_pool_idwould be better.mm/Kconfig
Quoted 12 lines
mm/Kconfig +12
-0+ struct dentry *entry; + + if (!zs_stat_root) + return -ENODEV; + + pool->index = atomic_inc_return(&zs_pool_index); + snprintf(name, sizeof(name), "pool-%d", pool->index); + entry = debugfs_create_dir(name, zs_stat_root); + if (!entry) { + pr_warn("pool %d, debugfs dir <%s> creation failed\n", + pool->index, name); + return -ENOMEM;Sigh. The debugfs interface does suck. Doesn't matter much.
Quoted 14 lines
mm/Kconfig +13
-0+ } + pool->stat_dentry = entry; + + entry = debugfs_create_file("obj_in_classes", S_IFREG | S_IRUGO, + pool->stat_dentry, pool, &zs_stat_size_ops); + if (!entry) { + pr_warn("pool %d, debugfs file entry <%s> creation failed\n", + pool->index, "obj_in_classes"); + return -ENOMEM; + } + + return 0; +}
Quoted 3 lines
Quoted 2 lines
...
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 2 lines · On Sat, 20 Dec 2014 08:39:37 +0900 Minchan Kim <[email protected]> wrote:
Then, we should fix
debugfs_create_dircan return errno to propagate the error to end user who can know it was failed ENOMEM or EEXIST.
Impractical. Every caller of every debugfs interface will need to be changed!
It's really irritating and dumb. What we're supposed to do is to optionally report the failure, then ignore it. This patch appears to be OK in that respect.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Minchan Kim
maintainerQuoted 7 lines · Andrew Morton
Quoted 2 lines · On Sat, 20 Dec 2014 08:39:37 +0900 Minchan Kim <[email protected]> wrote:
Then, we should fix
debugfs_create_dircan return errno to propagate the error to end user who can know it was failed ENOMEM or EEXIST.Impractical. Every caller of every debugfs interface will need to be changed!
If you don't like changing of all of current caller, maybe, we can define debugfs_create_dir_error and use it.
struct dentry *debugfs_create_dir_err(const char *name, struct dentry *parent, int *err) and tweak debugfs_create_dir.
struct dentry *debugfs_create_dir(const char *name, struct dentry *parent, int *err)
{
..
..
if (error) {
*err = error;
dentry = NULL;
}
}Why not?
Quoted 4 lines
It's really irritating and dumb. What we're supposed to do is to optionally report the failure, then ignore it. This patch appears to be OK in that respect.
At least, we should notify to the user why it was failed so he can fix the name if it was duplicated. So if you don't want debugfs, at least I want to warn all of reasons it can fail(at least, duplicated name) to the user.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 24 lines · On Sat, 20 Dec 2014 08:58:52 +0900 Minchan Kim <[email protected]> wrote:
Quoted 7 lines · Andrew Morton
Quoted 2 lines · On Sat, 20 Dec 2014 08:39:37 +0900 Minchan Kim <[email protected]> wrote:
Then, we should fix
debugfs_create_dircan return errno to propagate the error to end user who can know it was failed ENOMEM or EEXIST.Impractical. Every caller of every debugfs interface will need to be changed!
If you don't like changing of all of current caller, maybe, we can define
debugfs_create_dir_errorand use it.struct dentry *debugfs_create_dir_err(const char *name, struct dentry *parent, int *err) and tweak
debugfs_create_dir.
struct dentry *debugfs_create_dir(const char *name, struct dentry *parent, int *err){ .. .. if (error) { *err = error; dentry = NULL; } }
Quoted 1 line
Why not?
It involves rehashing a lengthy argument with Greg.
Quoted 9 lines
Quoted 4 lines
It's really irritating and dumb. What we're supposed to do is to optionally report the failure, then ignore it. This patch appears to be OK in that respect.
At least, we should notify to the user why it was failed so he can fix the name if it was duplicated. So if you don't want debugfs, at least I want to warn all of reasons it can
fail(at least, duplicated name)to the user.
Sure. The debugfs interface design is mistaken.
Minchan Kim
maintainerQuoted 11 lines · Andrew Morton
Quoted 9 lines · On Sat, 20 Dec 2014 08:58:52 +0900 Minchan Kim <[email protected]> wrote:
Quoted 7 lines · Andrew Morton
Quoted 2 lines · On Sat, 20 Dec 2014 08:39:37 +0900 Minchan Kim <[email protected]> wrote:
Then, we should fix
debugfs_create_dircan return errno to propagate the error to end user who can know it was failed ENOMEM or EEXIST.Impractical. Every caller of every debugfs interface will need to be changed!
Quoted 6 lines
Quoted 6 lines
If you don't like changing of all of current caller, maybe, we can define
debugfs_create_dir_errorand use it.struct dentry *debugfs_create_dir_err(const char *name, struct dentry *parent, int *err) and tweak
debugfs_create_dir.
struct dentry *debugfs_create_dir(const char *name, struct dentry *parent, int *err)
typo.
I meant this
static struct dentry *__create_file(const char *name, umode_t mode,
struct dentry *parent, void *data, const struct file_operations *fops, int *err)
Quoted 9 lines
Quoted 9 lines
{ .. .. if (error) { *err = error; dentry = NULL; } }
Quoted 3 lines
Quoted 1 line
Why not?
It involves rehashing a lengthy argument with Greg.
Okay. Then, Ganesh,
please add warn message about duplicaed name possibility althoug it's unlikely as it is.
Thanks.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
It's really irritating and dumb. What we're supposed to do is to optionally report the failure, then ignore it. This patch appears to be OK in that respect.
Quoted 6 lines
Quoted 4 lines
At least, we should notify to the user why it was failed so he can fix the name if it was duplicated. So if you don't want debugfs, at least I want to warn all of reasons it can
fail(at least, duplicated name)to the user.Sure. The debugfs interface design is mistaken.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 5 lines · On Sat, 20 Dec 2014 09:10:43 +0900 Minchan Kim <[email protected]> wrote:
Quoted 1 line
It involves rehashing a lengthy argument with Greg.
Okay. Then, Ganesh,
please add warn message about duplicaed name possibility althoug it's unlikely as it is.
Oh, getting EEXIST is easy with this patch. Just create and destroy a pool 2^32 times and the counter wraps ;) It's hardly a serious issue for a debugging patch.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Minchan Kim
maintainerQuoted 11 lines · Andrew Morton
Quoted 5 lines · On Sat, 20 Dec 2014 09:10:43 +0900 Minchan Kim <[email protected]> wrote:
Quoted 1 line
It involves rehashing a lengthy argument with Greg.
Okay. Then, Ganesh,
please add warn message about duplicaed name possibility althoug it's unlikely as it is.Oh, getting EEXIST is easy with this patch. Just create and destroy a pool 2^32 times and the counter wraps ;) It's hardly a serious issue for a debugging patch.
I meant that I wanted to change from index to name passed from caller like this
zram:
zs_create_pool(GFP_NOIO | __GFP_HIGHMEM, zram->disk->first_minor);
So, duplication should be rare. :)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Minchan Kim
maintainerQuoted 9 lines · Minchan Kim
Quoted 8 lines · Andrew Morton
Quoted 5 lines · On Sat, 20 Dec 2014 09:10:43 +0900 Minchan Kim <[email protected]> wrote:
Quoted 1 line
It involves rehashing a lengthy argument with Greg.
Okay. Then, Ganesh,
please add warn message about duplicaed name possibility althoug it's unlikely as it is.
Quoted 8 lines
Quoted 3 lines
Oh, getting EEXIST is easy with this patch. Just create and destroy a pool 2^32 times and the counter wraps ;) It's hardly a serious issue for a debugging patch.
I meant that I wanted to change from index to name passed from caller like this
zram:
zs_create_pool(GFP_NOIO | __GFP_HIGHMEM, zram->disk->first_minor);
Correction for clear my intention
sprintf(buf, "%zram%d", zram->disk->first_minor);
zs_create_pool(GFP_NOIO | __GFP_HIGHMEM, buf);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Hello Andrew,
Thanks for your review.
2014-12-20 6:32 GMT+08:00 Andrew Morton <[email protected]>:
Quoted 16 lines · On Fri, 19 Dec 2014 20:55:19 +0800 Ganesh Mahendran…
Quoted 8 lines
Keeping fragmentation of zsmalloc in a low level is our target. But now we still need to add the debug code in zsmalloc to get the quantitative data.
This patch adds a new configuration
CONFIG_ZSMALLOC_STATto enable the statistics collection for developers. Currently only the objects statatitics in each class are collected. User can get the information via debugfs.cat /sys/kernel/debug/zsmalloc/pool-1/...Is everyone OK with this now?
Quoted 4 lines
include/linux/zsmalloc.h +0
-0@@ -48,4 +48,13 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle);
Quoted 7 lines
include/linux/zsmalloc.h void zs_unmap_object(struct zs_pool *pool, unsigned long handle); · line 52
Quoted 4 lines
include/linux/zsmalloc.h +2
-0unsigned long zs_get_total_pages (struct zs_pool *pool); +#ifdef CONFIG_ZSMALLOC_STAT +int get_zs_pool_index (struct zs_pool *pool);The name is inconsistent with the rest of zsmalloc and with preferred kernel naming conventions. Should be "
zs_get_pool_index".
Okay, I will modify it.
Quoted 64 lines
Quoted 13 lines
include/linux/zsmalloc.h +7
-0+#else +static inline int get_zs_pool_index (struct zs_pool *pool) +{ +return -1 ; +} +#endif +#endif mm/Kconfig +0
-0mm/Kconfig
Quoted 7 lines
mm/Kconfig +4
-0+static int zs_stats_size_show(struct seq_file *s, void *v) +{ + int i; + struct zs_pool *pool = (struct zs_pool *)s->private;The typecast is unneeded and undesirable (it defeats typechecking).
Quoted 41 lines
mm/Kconfig +38
-0+ struct size_class *class; + int objs_per_zspage; + unsigned long obj_allocated, obj_used, pages_used; + unsigned long total_objs = 0, total_used_objs = 0, total_pages = 0; + + seq_printf(s, " %5s %5s %13s %10s %10s\n", "class", "size", + "obj_allocated", "obj_used", "pages_used"); + + for (i = 0; i < zs_size_classes; i++) { + class = pool->size_class[i]; + + if (class->index != i) + continue; + + spin_lock(&class->lock); + obj_allocated = zs_stat_get(class, OBJ_ALLOCATED); + obj_used = zs_stat_get(class, OBJ_USED); + spin_unlock(&class->lock); + + objs_per_zspage = get_maxobj_per_zspage(class->size, + class->pages_per_zspage); + pages_used = obj_allocated / objs_per_zspage * + class->pages_per_zspage; + + seq_printf(s, " %5u %5u %10lu %10lu %10lu\n", i, + class->size, obj_allocated, obj_used, pages_used); + + total_objs += obj_allocated; + total_used_objs += obj_used; + total_pages += pages_used; + } + + seq_puts(s, "\n"); + seq_printf(s, " %5s %5s %10lu %10lu %10lu\n", "Total", "", + total_objs, total_used_objs, total_pages); + + return 0; +}
Quoted 7 lines
mm/Kconfig
Quoted 3 lines
mm/Kconfig +3
-0+static int zs_pool_stat_create(struct zs_pool *pool) +{ + char name[10];This is not good. If the kernel creates and then destroys a pool 10000 times, zs_pool_index==10000 and we overrun the buffer. Could use
kasprintf()in here to fix this.
Yes, kasprintf() is better. Although I used snprintf(). I will change it.
Quoted 3 lines
zs_pool_indexisn't a very good name - it doesn't index anything.zs_pool_idwould be better.
Okay.
Quoted 30 lines
mm/Kconfig
Quoted 13 lines
mm/Kconfig +12
-0+ struct dentry *entry; + + if (!zs_stat_root) + return -ENODEV; + + pool->index = atomic_inc_return(&zs_pool_index); + snprintf(name, sizeof(name), "pool-%d", pool->index); + entry = debugfs_create_dir(name, zs_stat_root); + if (!entry) { + pr_warn("pool %d, debugfs dir <%s> creation failed\n", + pool->index, name); + return -ENOMEM;Sigh. The debugfs interface does suck. Doesn't matter much.
Quoted 14 lines
mm/Kconfig +13
-0+ } + pool->stat_dentry = entry; + + entry = debugfs_create_file("obj_in_classes", S_IFREG | S_IRUGO, + pool->stat_dentry, pool, &zs_stat_size_ops); + if (!entry) { + pr_warn("pool %d, debugfs file entry <%s> creation failed\n", + pool->index, "obj_in_classes"); + return -ENOMEM; + } + + return 0; +}
Quoted 3 lines
Quoted 2 lines
...
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
2014-12-20 8:23 GMT+08:00 Minchan Kim <[email protected]>:
Quoted 13 lines · Andrew Morton
Quoted 11 lines · On Sat, 20 Dec 2014 09:10:43 +0900 Minchan Kim <[email protected]> wrote:
Quoted 6 lines
Quoted 2 lines
It involves rehashing a lengthy argument with Greg.
Okay. Then, Ganesh,
please add warn message about duplicaed name possibility althoug it's unlikely as it is.Oh, getting EEXIST is easy with this patch. Just create and destroy a pool 2^32 times and the counter wraps ;) It's hardly a serious issue for a debugging patch.
Quoted 6 lines
I meant that I wanted to change from index to name passed from caller like this
zram:
zs_create_pool(GFP_NOIO | __GFP_HIGHMEM, zram->disk->first_minor);So, duplication should be rare. :)
We still can not know whether the name is duplicated if we do not change the debugfs API.
The API does not return the errno to us.
How about just zsmalloc decides the name of the pool-id, like pool-x. When the pool-id reaches
0xffff.ffff, we print warn message about duplicated name, and stop creating the debugfs entry
for the user.
Thanks.
Minchan Kim
maintainerHey Ganesh,
Quoted 25 lines · Ganesh Mahendran
2014-12-20 8:23 GMT+08:00 Minchan Kim <[email protected]>:
Quoted 13 lines · Andrew Morton
Quoted 11 lines · On Sat, 20 Dec 2014 09:10:43 +0900 Minchan Kim <[email protected]> wrote:
Quoted 6 lines
Quoted 2 lines
It involves rehashing a lengthy argument with Greg.
Okay. Then, Ganesh,
please add warn message about duplicaed name possibility althoug it's unlikely as it is.Oh, getting EEXIST is easy with this patch. Just create and destroy a pool 2^32 times and the counter wraps ;) It's hardly a serious issue for a debugging patch.
Quoted 6 lines
I meant that I wanted to change from index to name passed from caller like this
zram:
zs_create_pool(GFP_NOIO | __GFP_HIGHMEM, zram->disk->first_minor);So, duplication should be rare. :)
We still can not know whether the name is duplicated if we do not change the debugfs API.
The API does not return the errno to us.
Quoted 5 lines
How about just zsmalloc decides the name of the pool-id, like pool-x. When the pool-id reaches
0xffff.ffff, we print warn message about duplicated name, and stop creating the debugfs entry
for the user.
The idea is from the developer point of view to implement thing easy but my point is we should take care of user(ie, admin) rather than developer(ie, we).
For user, /sys/kernel/debug/zsmalloc/zram0 would be more straightforward and even it doesn't need zram to export /sys/block/zram0/pool-id.
Thanks.
Quoted 2 lines
Thanks.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Hello Minchan
2014-12-20 10:25 GMT+08:00 Minchan Kim <[email protected]>:
Quoted 34 lines
Hey Ganesh,
Quoted 25 lines · Ganesh Mahendran
2014-12-20 8:23 GMT+08:00 Minchan Kim <[email protected]>:
Quoted 13 lines · Andrew Morton
Quoted 11 lines · On Sat, 20 Dec 2014 09:10:43 +0900 Minchan Kim <[email protected]> wrote:
Quoted 6 lines
Quoted 2 lines
It involves rehashing a lengthy argument with Greg.
Okay. Then, Ganesh,
please add warn message about duplicaed name possibility althoug it's unlikely as it is.Oh, getting EEXIST is easy with this patch. Just create and destroy a pool 2^32 times and the counter wraps ;) It's hardly a serious issue for a debugging patch.
Quoted 6 lines
I meant that I wanted to change from index to name passed from caller like this
zram:
zs_create_pool(GFP_NOIO | __GFP_HIGHMEM, zram->disk->first_minor);So, duplication should be rare. :)
We still can not know whether the name is duplicated if we do not change the debugfs API.
The API does not return the errno to us.Quoted 5 lines
How about just zsmalloc decides the name of the pool-id, like pool-x. When the pool-id reaches
0xffff.ffff, we print warn message about duplicated name, and stop creating the debugfs entry
for the user.
Quoted 3 lines
The idea is from the developer point of view to implement thing easy but my point is we should take care of
user(ie, admin)rather thandeveloper(ie, we).
Yes. I got it.
Quoted 4 lines
For user,
/sys/kernel/debug/zsmalloc/zram0would be more straightforward and even it doesn't need zram to export/sys/block/zram0/pool-id.
BTW, If we add a new argument in zs_create_pool(). It seems we also need to add argument in zs_zpool_create(). So, zpool/zswap/zbud will be modified to support
the new API.
Is that acceptable?
Thanks.
Quoted 5 lines
Thanks.
Quoted 2 lines
Thanks.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Minchan Kim
maintainerHi Ganesh,
Quoted 48 lines · Ganesh Mahendran
Hello Minchan
2014-12-20 10:25 GMT+08:00 Minchan Kim <[email protected]>:
Quoted 34 lines
Hey Ganesh,
Quoted 25 lines · Ganesh Mahendran
2014-12-20 8:23 GMT+08:00 Minchan Kim <[email protected]>:
Quoted 13 lines · Andrew Morton
Quoted 11 lines · On Sat, 20 Dec 2014 09:10:43 +0900 Minchan Kim <[email protected]> wrote:
Quoted 6 lines
Quoted 2 lines
It involves rehashing a lengthy argument with Greg.
Okay. Then, Ganesh,
please add warn message about duplicaed name possibility althoug it's unlikely as it is.Oh, getting EEXIST is easy with this patch. Just create and destroy a pool 2^32 times and the counter wraps ;) It's hardly a serious issue for a debugging patch.
Quoted 6 lines
I meant that I wanted to change from index to name passed from caller like this
zram:
zs_create_pool(GFP_NOIO | __GFP_HIGHMEM, zram->disk->first_minor);So, duplication should be rare. :)
We still can not know whether the name is duplicated if we do not change the debugfs API.
The API does not return the errno to us.Quoted 5 lines
How about just zsmalloc decides the name of the pool-id, like pool-x. When the pool-id reaches
0xffff.ffff, we print warn message about duplicated name, and stop creating the debugfs entry
for the user.Quoted 3 lines
The idea is from the developer point of view to implement thing easy but my point is we should take care of
user(ie, admin)rather thandeveloper(ie, we).Yes. I got it.
Quoted 4 lines
For user,
/sys/kernel/debug/zsmalloc/zram0would be more straightforward and even it doesn't need zram to export/sys/block/zram0/pool-id.
Quoted 5 lines
BTW, If we add a new argument in
zs_create_pool(). It seems we also need to add argument inzs_zpool_create(). So, zpool/zswap/zbud will be modified to support
the new API.
Is that acceptable?
I think it's doable.
The zpool_create_pool has already zswap_zpool_type. Ccing maintainers for double check.
Many thanks.
Quoted 14 lines
Thanks.
Quoted 5 lines
Thanks.
Quoted 2 lines
Thanks.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 8 lines
Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 57 lines · Minchan Kim
Hi Ganesh,
Quoted 48 lines · Ganesh Mahendran
Hello Minchan
2014-12-20 10:25 GMT+08:00 Minchan Kim <[email protected]>:
Quoted 34 lines
Hey Ganesh,
Quoted 25 lines · Ganesh Mahendran
2014-12-20 8:23 GMT+08:00 Minchan Kim <[email protected]>:
Quoted 13 lines · Andrew Morton
Quoted 11 lines · On Sat, 20 Dec 2014 09:10:43 +0900 Minchan Kim <[email protected]> wrote:
Quoted 6 lines
Quoted 2 lines
It involves rehashing a lengthy argument with Greg.
Okay. Then, Ganesh,
please add warn message about duplicaed name possibility althoug it's unlikely as it is.Oh, getting EEXIST is easy with this patch. Just create and destroy a pool 2^32 times and the counter wraps ;) It's hardly a serious issue for a debugging patch.
Quoted 6 lines
I meant that I wanted to change from index to name passed from caller like this
zram:
zs_create_pool(GFP_NOIO | __GFP_HIGHMEM, zram->disk->first_minor);So, duplication should be rare. :)
We still can not know whether the name is duplicated if we do not change the debugfs API.
The API does not return the errno to us.Quoted 5 lines
How about just zsmalloc decides the name of the pool-id, like pool-x. When the pool-id reaches
0xffff.ffff, we print warn message about duplicated name, and stop creating the debugfs entry
for the user.Quoted 3 lines
The idea is from the developer point of view to implement thing easy but my point is we should take care of
user(ie, admin)rather thandeveloper(ie, we).Yes. I got it.
Quoted 4 lines
For user,
/sys/kernel/debug/zsmalloc/zram0would be more straightforward and even it doesn't need zram to export/sys/block/zram0/pool-id.Quoted 5 lines
BTW, If we add a new argument in
zs_create_pool(). It seems we also need to add argument inzs_zpool_create(). So, zpool/zswap/zbud will be modified to support
the new API.
Is that acceptable?
Quoted 3 lines
I think it's doable.
Thezpool_create_poolhas alreadyzswap_zpool_type. Ccing maintainers for double check.
Late response, but fine by me.
Seth
Quoted 11 lines
Many thanks.
Quoted 7 lines
Thanks.
Quoted 4 lines
Thanks.
Quoted 1 line
Quoted 17 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Thanks.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>Signature · 8 lines
Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>