diff options
author | David Rientjes <rientjes@google.com> | 2009-10-15 05:20:22 -0400 |
---|---|---|
committer | Pekka Enberg <penberg@cs.helsinki.fi> | 2009-10-15 14:34:12 -0400 |
commit | 78eb00cc574d3dbf8e6bed804948a89e8110a064 (patch) | |
tree | c0cefa5b5787bb234ba8931775da2071c908e071 /mm/slub.c | |
parent | 374576a8b6f865022c0fd1ca62396889b23d66dd (diff) |
slub: allow stats to be cleared
When collecting slub stats for particular workloads, it's necessary to
collect each statistic for all caches before the job is even started
because the counters are usually greater than zero just from boot and
initialization.
This allows a statistic to be cleared on each cpu by writing '0' to its
sysfs file. This creates a baseline for statistics of interest before
the workload is started.
Setting a statistic to a particular value is not supported, so all values
written to these files other than '0' returns -EINVAL.
Cc: Christoph Lameter <cl@linux-foundation.org>
Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Diffstat (limited to 'mm/slub.c')
-rw-r--r-- | mm/slub.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -4371,12 +4371,28 @@ static int show_stat(struct kmem_cache *s, char *buf, enum stat_item si) | |||
4371 | return len + sprintf(buf + len, "\n"); | 4371 | return len + sprintf(buf + len, "\n"); |
4372 | } | 4372 | } |
4373 | 4373 | ||
4374 | static void clear_stat(struct kmem_cache *s, enum stat_item si) | ||
4375 | { | ||
4376 | int cpu; | ||
4377 | |||
4378 | for_each_online_cpu(cpu) | ||
4379 | get_cpu_slab(s, cpu)->stat[si] = 0; | ||
4380 | } | ||
4381 | |||
4374 | #define STAT_ATTR(si, text) \ | 4382 | #define STAT_ATTR(si, text) \ |
4375 | static ssize_t text##_show(struct kmem_cache *s, char *buf) \ | 4383 | static ssize_t text##_show(struct kmem_cache *s, char *buf) \ |
4376 | { \ | 4384 | { \ |
4377 | return show_stat(s, buf, si); \ | 4385 | return show_stat(s, buf, si); \ |
4378 | } \ | 4386 | } \ |
4379 | SLAB_ATTR_RO(text); \ | 4387 | static ssize_t text##_store(struct kmem_cache *s, \ |
4388 | const char *buf, size_t length) \ | ||
4389 | { \ | ||
4390 | if (buf[0] != '0') \ | ||
4391 | return -EINVAL; \ | ||
4392 | clear_stat(s, si); \ | ||
4393 | return length; \ | ||
4394 | } \ | ||
4395 | SLAB_ATTR(text); \ | ||
4380 | 4396 | ||
4381 | STAT_ATTR(ALLOC_FASTPATH, alloc_fastpath); | 4397 | STAT_ATTR(ALLOC_FASTPATH, alloc_fastpath); |
4382 | STAT_ATTR(ALLOC_SLOWPATH, alloc_slowpath); | 4398 | STAT_ATTR(ALLOC_SLOWPATH, alloc_slowpath); |