Commit 3eba0c6a56c04f2b017b43641a821f1ebfb7fb4c
Committed by
Linus Torvalds
1 parent
ee98016010
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
mm/zpool: add name argument to create zpool
Currently the underlay of zpool: zsmalloc/zbud, do not know who creates them. There is not a method to let zsmalloc/zbud find which caller they belong to. Now we want to add statistics collection in zsmalloc. We need to name the debugfs dir for each pool created. The way suggested by Minchan Kim is to use a name passed by caller(such as zram) to create the zsmalloc pool. /sys/kernel/debug/zsmalloc/zram0 This patch adds an argument `name' to zs_create_pool() and other related functions. Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com> Acked-by: Minchan Kim <minchan@kernel.org> Cc: Seth Jennings <sjennings@variantweb.net> Cc: Nitin Gupta <ngupta@vflare.org> Cc: Dan Streetman <ddstreet@ieee.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 7 changed files with 21 additions and 14 deletions Side-by-side Diff
drivers/block/zram/zram_drv.c
... | ... | @@ -327,9 +327,10 @@ |
327 | 327 | kfree(meta); |
328 | 328 | } |
329 | 329 | |
330 | -static struct zram_meta *zram_meta_alloc(u64 disksize) | |
330 | +static struct zram_meta *zram_meta_alloc(int device_id, u64 disksize) | |
331 | 331 | { |
332 | 332 | size_t num_pages; |
333 | + char pool_name[8]; | |
333 | 334 | struct zram_meta *meta = kmalloc(sizeof(*meta), GFP_KERNEL); |
334 | 335 | |
335 | 336 | if (!meta) |
... | ... | @@ -342,7 +343,8 @@ |
342 | 343 | goto out_error; |
343 | 344 | } |
344 | 345 | |
345 | - meta->mem_pool = zs_create_pool(GFP_NOIO | __GFP_HIGHMEM); | |
346 | + snprintf(pool_name, sizeof(pool_name), "zram%d", device_id); | |
347 | + meta->mem_pool = zs_create_pool(pool_name, GFP_NOIO | __GFP_HIGHMEM); | |
346 | 348 | if (!meta->mem_pool) { |
347 | 349 | pr_err("Error creating memory pool\n"); |
348 | 350 | goto out_error; |
... | ... | @@ -783,7 +785,7 @@ |
783 | 785 | return -EINVAL; |
784 | 786 | |
785 | 787 | disksize = PAGE_ALIGN(disksize); |
786 | - meta = zram_meta_alloc(disksize); | |
788 | + meta = zram_meta_alloc(zram->disk->first_minor, disksize); | |
787 | 789 | if (!meta) |
788 | 790 | return -ENOMEM; |
789 | 791 |
include/linux/zpool.h
... | ... | @@ -36,7 +36,8 @@ |
36 | 36 | ZPOOL_MM_DEFAULT = ZPOOL_MM_RW |
37 | 37 | }; |
38 | 38 | |
39 | -struct zpool *zpool_create_pool(char *type, gfp_t gfp, struct zpool_ops *ops); | |
39 | +struct zpool *zpool_create_pool(char *type, char *name, | |
40 | + gfp_t gfp, struct zpool_ops *ops); | |
40 | 41 | |
41 | 42 | char *zpool_get_type(struct zpool *pool); |
42 | 43 | |
... | ... | @@ -80,7 +81,7 @@ |
80 | 81 | atomic_t refcount; |
81 | 82 | struct list_head list; |
82 | 83 | |
83 | - void *(*create)(gfp_t gfp, struct zpool_ops *ops); | |
84 | + void *(*create)(char *name, gfp_t gfp, struct zpool_ops *ops); | |
84 | 85 | void (*destroy)(void *pool); |
85 | 86 | |
86 | 87 | int (*malloc)(void *pool, size_t size, gfp_t gfp, |
include/linux/zsmalloc.h
mm/zbud.c
... | ... | @@ -130,7 +130,8 @@ |
130 | 130 | .evict = zbud_zpool_evict |
131 | 131 | }; |
132 | 132 | |
133 | -static void *zbud_zpool_create(gfp_t gfp, struct zpool_ops *zpool_ops) | |
133 | +static void *zbud_zpool_create(char *name, gfp_t gfp, | |
134 | + struct zpool_ops *zpool_ops) | |
134 | 135 | { |
135 | 136 | return zbud_create_pool(gfp, zpool_ops ? &zbud_zpool_ops : NULL); |
136 | 137 | } |
mm/zpool.c
... | ... | @@ -129,6 +129,7 @@ |
129 | 129 | /** |
130 | 130 | * zpool_create_pool() - Create a new zpool |
131 | 131 | * @type The type of the zpool to create (e.g. zbud, zsmalloc) |
132 | + * @name The name of the zpool (e.g. zram0, zswap) | |
132 | 133 | * @gfp The GFP flags to use when allocating the pool. |
133 | 134 | * @ops The optional ops callback. |
134 | 135 | * |
... | ... | @@ -140,7 +141,8 @@ |
140 | 141 | * |
141 | 142 | * Returns: New zpool on success, NULL on failure. |
142 | 143 | */ |
143 | -struct zpool *zpool_create_pool(char *type, gfp_t gfp, struct zpool_ops *ops) | |
144 | +struct zpool *zpool_create_pool(char *type, char *name, gfp_t gfp, | |
145 | + struct zpool_ops *ops) | |
144 | 146 | { |
145 | 147 | struct zpool_driver *driver; |
146 | 148 | struct zpool *zpool; |
... | ... | @@ -168,7 +170,7 @@ |
168 | 170 | |
169 | 171 | zpool->type = driver->type; |
170 | 172 | zpool->driver = driver; |
171 | - zpool->pool = driver->create(gfp, ops); | |
173 | + zpool->pool = driver->create(name, gfp, ops); | |
172 | 174 | zpool->ops = ops; |
173 | 175 | |
174 | 176 | if (!zpool->pool) { |
mm/zsmalloc.c
... | ... | @@ -246,9 +246,9 @@ |
246 | 246 | |
247 | 247 | #ifdef CONFIG_ZPOOL |
248 | 248 | |
249 | -static void *zs_zpool_create(gfp_t gfp, struct zpool_ops *zpool_ops) | |
249 | +static void *zs_zpool_create(char *name, gfp_t gfp, struct zpool_ops *zpool_ops) | |
250 | 250 | { |
251 | - return zs_create_pool(gfp); | |
251 | + return zs_create_pool(name, gfp); | |
252 | 252 | } |
253 | 253 | |
254 | 254 | static void zs_zpool_destroy(void *pool) |
... | ... | @@ -1148,7 +1148,7 @@ |
1148 | 1148 | * On success, a pointer to the newly created pool is returned, |
1149 | 1149 | * otherwise NULL. |
1150 | 1150 | */ |
1151 | -struct zs_pool *zs_create_pool(gfp_t flags) | |
1151 | +struct zs_pool *zs_create_pool(char *name, gfp_t flags) | |
1152 | 1152 | { |
1153 | 1153 | int i; |
1154 | 1154 | struct zs_pool *pool; |
mm/zswap.c
... | ... | @@ -906,11 +906,12 @@ |
906 | 906 | |
907 | 907 | pr_info("loading zswap\n"); |
908 | 908 | |
909 | - zswap_pool = zpool_create_pool(zswap_zpool_type, gfp, &zswap_zpool_ops); | |
909 | + zswap_pool = zpool_create_pool(zswap_zpool_type, "zswap", gfp, | |
910 | + &zswap_zpool_ops); | |
910 | 911 | if (!zswap_pool && strcmp(zswap_zpool_type, ZSWAP_ZPOOL_DEFAULT)) { |
911 | 912 | pr_info("%s zpool not available\n", zswap_zpool_type); |
912 | 913 | zswap_zpool_type = ZSWAP_ZPOOL_DEFAULT; |
913 | - zswap_pool = zpool_create_pool(zswap_zpool_type, gfp, | |
914 | + zswap_pool = zpool_create_pool(zswap_zpool_type, "zswap", gfp, | |
914 | 915 | &zswap_zpool_ops); |
915 | 916 | } |
916 | 917 | if (!zswap_pool) { |