aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2009-10-15 05:20:22 -0400
committerPekka Enberg <penberg@cs.helsinki.fi>2009-10-15 14:34:12 -0400
commit78eb00cc574d3dbf8e6bed804948a89e8110a064 (patch)
treec0cefa5b5787bb234ba8931775da2071c908e071
parent374576a8b6f865022c0fd1ca62396889b23d66dd (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>
-rw-r--r--Documentation/ABI/testing/sysfs-kernel-slab109
-rw-r--r--mm/slub.c18
2 files changed, 75 insertions, 52 deletions
diff --git a/Documentation/ABI/testing/sysfs-kernel-slab b/Documentation/ABI/testing/sysfs-kernel-slab
index 6dcf75e594fb..8b093f8222d3 100644
--- a/Documentation/ABI/testing/sysfs-kernel-slab
+++ b/Documentation/ABI/testing/sysfs-kernel-slab
@@ -45,8 +45,9 @@ KernelVersion: 2.6.25
45Contact: Pekka Enberg <penberg@cs.helsinki.fi>, 45Contact: Pekka Enberg <penberg@cs.helsinki.fi>,
46 Christoph Lameter <cl@linux-foundation.org> 46 Christoph Lameter <cl@linux-foundation.org>
47Description: 47Description:
48 The alloc_fastpath file is read-only and specifies how many 48 The alloc_fastpath file shows how many objects have been
49 objects have been allocated using the fast path. 49 allocated using the fast path. It can be written to clear the
50 current count.
50 Available when CONFIG_SLUB_STATS is enabled. 51 Available when CONFIG_SLUB_STATS is enabled.
51 52
52What: /sys/kernel/slab/cache/alloc_from_partial 53What: /sys/kernel/slab/cache/alloc_from_partial
@@ -55,9 +56,10 @@ KernelVersion: 2.6.25
55Contact: Pekka Enberg <penberg@cs.helsinki.fi>, 56Contact: Pekka Enberg <penberg@cs.helsinki.fi>,
56 Christoph Lameter <cl@linux-foundation.org> 57 Christoph Lameter <cl@linux-foundation.org>
57Description: 58Description:
58 The alloc_from_partial file is read-only and specifies how 59 The alloc_from_partial file shows how many times a cpu slab has
59 many times a cpu slab has been full and it has been refilled 60 been full and it has been refilled by using a slab from the list
60 by using a slab from the list of partially used slabs. 61 of partially used slabs. It can be written to clear the current
62 count.
61 Available when CONFIG_SLUB_STATS is enabled. 63 Available when CONFIG_SLUB_STATS is enabled.
62 64
63What: /sys/kernel/slab/cache/alloc_refill 65What: /sys/kernel/slab/cache/alloc_refill
@@ -66,9 +68,9 @@ KernelVersion: 2.6.25
66Contact: Pekka Enberg <penberg@cs.helsinki.fi>, 68Contact: Pekka Enberg <penberg@cs.helsinki.fi>,
67 Christoph Lameter <cl@linux-foundation.org> 69 Christoph Lameter <cl@linux-foundation.org>
68Description: 70Description:
69 The alloc_refill file is read-only and specifies how many 71 The alloc_refill file shows how many times the per-cpu freelist
70 times the per-cpu freelist was empty but there were objects 72 was empty but there were objects available as the result of
71 available as the result of remote cpu frees. 73 remote cpu frees. It can be written to clear the current count.
72 Available when CONFIG_SLUB_STATS is enabled. 74 Available when CONFIG_SLUB_STATS is enabled.
73 75
74What: /sys/kernel/slab/cache/alloc_slab 76What: /sys/kernel/slab/cache/alloc_slab
@@ -77,8 +79,9 @@ KernelVersion: 2.6.25
77Contact: Pekka Enberg <penberg@cs.helsinki.fi>, 79Contact: Pekka Enberg <penberg@cs.helsinki.fi>,
78 Christoph Lameter <cl@linux-foundation.org> 80 Christoph Lameter <cl@linux-foundation.org>
79Description: 81Description:
80 The alloc_slab file is read-only and specifies how many times 82 The alloc_slab file is shows how many times a new slab had to
81 a new slab had to be allocated from the page allocator. 83 be allocated from the page allocator. It can be written to
84 clear the current count.
82 Available when CONFIG_SLUB_STATS is enabled. 85 Available when CONFIG_SLUB_STATS is enabled.
83 86
84What: /sys/kernel/slab/cache/alloc_slowpath 87What: /sys/kernel/slab/cache/alloc_slowpath
@@ -87,9 +90,10 @@ KernelVersion: 2.6.25
87Contact: Pekka Enberg <penberg@cs.helsinki.fi>, 90Contact: Pekka Enberg <penberg@cs.helsinki.fi>,
88 Christoph Lameter <cl@linux-foundation.org> 91 Christoph Lameter <cl@linux-foundation.org>
89Description: 92Description:
90 The alloc_slowpath file is read-only and specifies how many 93 The alloc_slowpath file shows how many objects have been
91 objects have been allocated using the slow path because of a 94 allocated using the slow path because of a refill or
92 refill or allocation from a partial or new slab. 95 allocation from a partial or new slab. It can be written to
96 clear the current count.
93 Available when CONFIG_SLUB_STATS is enabled. 97 Available when CONFIG_SLUB_STATS is enabled.
94 98
95What: /sys/kernel/slab/cache/cache_dma 99What: /sys/kernel/slab/cache/cache_dma
@@ -117,10 +121,11 @@ KernelVersion: 2.6.31
117Contact: Pekka Enberg <penberg@cs.helsinki.fi>, 121Contact: Pekka Enberg <penberg@cs.helsinki.fi>,
118 Christoph Lameter <cl@linux-foundation.org> 122 Christoph Lameter <cl@linux-foundation.org>
119Description: 123Description:
120 The file cpuslab_flush is read-only and specifies how many 124 The file cpuslab_flush shows how many times a cache's cpu slabs
121 times a cache's cpu slabs have been flushed as the result of 125 have been flushed as the result of destroying or shrinking a
122 destroying or shrinking a cache, a cpu going offline, or as 126 cache, a cpu going offline, or as the result of forcing an
123 the result of forcing an allocation from a certain node. 127 allocation from a certain node. It can be written to clear the
128 current count.
124 Available when CONFIG_SLUB_STATS is enabled. 129 Available when CONFIG_SLUB_STATS is enabled.
125 130
126What: /sys/kernel/slab/cache/ctor 131What: /sys/kernel/slab/cache/ctor
@@ -139,8 +144,8 @@ KernelVersion: 2.6.25
139Contact: Pekka Enberg <penberg@cs.helsinki.fi>, 144Contact: Pekka Enberg <penberg@cs.helsinki.fi>,
140 Christoph Lameter <cl@linux-foundation.org> 145 Christoph Lameter <cl@linux-foundation.org>
141Description: 146Description:
142 The file deactivate_empty is read-only and specifies how many 147 The deactivate_empty file shows how many times an empty cpu slab
143 times an empty cpu slab was deactivated. 148 was deactivated. It can be written to clear the current count.
144 Available when CONFIG_SLUB_STATS is enabled. 149 Available when CONFIG_SLUB_STATS is enabled.
145 150
146What: /sys/kernel/slab/cache/deactivate_full 151What: /sys/kernel/slab/cache/deactivate_full
@@ -149,8 +154,8 @@ KernelVersion: 2.6.25
149Contact: Pekka Enberg <penberg@cs.helsinki.fi>, 154Contact: Pekka Enberg <penberg@cs.helsinki.fi>,
150 Christoph Lameter <cl@linux-foundation.org> 155 Christoph Lameter <cl@linux-foundation.org>
151Description: 156Description:
152 The file deactivate_full is read-only and specifies how many 157 The deactivate_full file shows how many times a full cpu slab
153 times a full cpu slab was deactivated. 158 was deactivated. It can be written to clear the current count.
154 Available when CONFIG_SLUB_STATS is enabled. 159 Available when CONFIG_SLUB_STATS is enabled.
155 160
156What: /sys/kernel/slab/cache/deactivate_remote_frees 161What: /sys/kernel/slab/cache/deactivate_remote_frees
@@ -159,9 +164,9 @@ KernelVersion: 2.6.25
159Contact: Pekka Enberg <penberg@cs.helsinki.fi>, 164Contact: Pekka Enberg <penberg@cs.helsinki.fi>,
160 Christoph Lameter <cl@linux-foundation.org> 165 Christoph Lameter <cl@linux-foundation.org>
161Description: 166Description:
162 The file deactivate_remote_frees is read-only and specifies how 167 The deactivate_remote_frees file shows how many times a cpu slab
163 many times a cpu slab has been deactivated and contained free 168 has been deactivated and contained free objects that were freed
164 objects that were freed remotely. 169 remotely. It can be written to clear the current count.
165 Available when CONFIG_SLUB_STATS is enabled. 170 Available when CONFIG_SLUB_STATS is enabled.
166 171
167What: /sys/kernel/slab/cache/deactivate_to_head 172What: /sys/kernel/slab/cache/deactivate_to_head
@@ -170,9 +175,9 @@ KernelVersion: 2.6.25
170Contact: Pekka Enberg <penberg@cs.helsinki.fi>, 175Contact: Pekka Enberg <penberg@cs.helsinki.fi>,
171 Christoph Lameter <cl@linux-foundation.org> 176 Christoph Lameter <cl@linux-foundation.org>
172Description: 177Description:
173 The file deactivate_to_head is read-only and specifies how 178 The deactivate_to_head file shows how many times a partial cpu
174 many times a partial cpu slab was deactivated and added to the 179 slab was deactivated and added to the head of its node's partial
175 head of its node's partial list. 180 list. It can be written to clear the current count.
176 Available when CONFIG_SLUB_STATS is enabled. 181 Available when CONFIG_SLUB_STATS is enabled.
177 182
178What: /sys/kernel/slab/cache/deactivate_to_tail 183What: /sys/kernel/slab/cache/deactivate_to_tail
@@ -181,9 +186,9 @@ KernelVersion: 2.6.25
181Contact: Pekka Enberg <penberg@cs.helsinki.fi>, 186Contact: Pekka Enberg <penberg@cs.helsinki.fi>,
182 Christoph Lameter <cl@linux-foundation.org> 187 Christoph Lameter <cl@linux-foundation.org>
183Description: 188Description:
184 The file deactivate_to_tail is read-only and specifies how 189 The deactivate_to_tail file shows how many times a partial cpu
185 many times a partial cpu slab was deactivated and added to the 190 slab was deactivated and added to the tail of its node's partial
186 tail of its node's partial list. 191 list. It can be written to clear the current count.
187 Available when CONFIG_SLUB_STATS is enabled. 192 Available when CONFIG_SLUB_STATS is enabled.
188 193
189What: /sys/kernel/slab/cache/destroy_by_rcu 194What: /sys/kernel/slab/cache/destroy_by_rcu
@@ -201,9 +206,9 @@ KernelVersion: 2.6.25
201Contact: Pekka Enberg <penberg@cs.helsinki.fi>, 206Contact: Pekka Enberg <penberg@cs.helsinki.fi>,
202 Christoph Lameter <cl@linux-foundation.org> 207 Christoph Lameter <cl@linux-foundation.org>
203Description: 208Description:
204 The file free_add_partial is read-only and specifies how many 209 The free_add_partial file shows how many times an object has
205 times an object has been freed in a full slab so that it had to 210 been freed in a full slab so that it had to added to its node's
206 added to its node's partial list. 211 partial list. It can be written to clear the current count.
207 Available when CONFIG_SLUB_STATS is enabled. 212 Available when CONFIG_SLUB_STATS is enabled.
208 213
209What: /sys/kernel/slab/cache/free_calls 214What: /sys/kernel/slab/cache/free_calls
@@ -222,9 +227,9 @@ KernelVersion: 2.6.25
222Contact: Pekka Enberg <penberg@cs.helsinki.fi>, 227Contact: Pekka Enberg <penberg@cs.helsinki.fi>,
223 Christoph Lameter <cl@linux-foundation.org> 228 Christoph Lameter <cl@linux-foundation.org>
224Description: 229Description:
225 The free_fastpath file is read-only and specifies how many 230 The free_fastpath file shows how many objects have been freed
226 objects have been freed using the fast path because it was an 231 using the fast path because it was an object from the cpu slab.
227 object from the cpu slab. 232 It can be written to clear the current count.
228 Available when CONFIG_SLUB_STATS is enabled. 233 Available when CONFIG_SLUB_STATS is enabled.
229 234
230What: /sys/kernel/slab/cache/free_frozen 235What: /sys/kernel/slab/cache/free_frozen
@@ -233,9 +238,9 @@ KernelVersion: 2.6.25
233Contact: Pekka Enberg <penberg@cs.helsinki.fi>, 238Contact: Pekka Enberg <penberg@cs.helsinki.fi>,
234 Christoph Lameter <cl@linux-foundation.org> 239 Christoph Lameter <cl@linux-foundation.org>
235Description: 240Description:
236 The free_frozen file is read-only and specifies how many 241 The free_frozen file shows how many objects have been freed to
237 objects have been freed to a frozen slab (i.e. a remote cpu 242 a frozen slab (i.e. a remote cpu slab). It can be written to
238 slab). 243 clear the current count.
239 Available when CONFIG_SLUB_STATS is enabled. 244 Available when CONFIG_SLUB_STATS is enabled.
240 245
241What: /sys/kernel/slab/cache/free_remove_partial 246What: /sys/kernel/slab/cache/free_remove_partial
@@ -244,9 +249,10 @@ KernelVersion: 2.6.25
244Contact: Pekka Enberg <penberg@cs.helsinki.fi>, 249Contact: Pekka Enberg <penberg@cs.helsinki.fi>,
245 Christoph Lameter <cl@linux-foundation.org> 250 Christoph Lameter <cl@linux-foundation.org>
246Description: 251Description:
247 The file free_remove_partial is read-only and specifies how 252 The free_remove_partial file shows how many times an object has
248 many times an object has been freed to a now-empty slab so 253 been freed to a now-empty slab so that it had to be removed from
249 that it had to be removed from its node's partial list. 254 its node's partial list. It can be written to clear the current
255 count.
250 Available when CONFIG_SLUB_STATS is enabled. 256 Available when CONFIG_SLUB_STATS is enabled.
251 257
252What: /sys/kernel/slab/cache/free_slab 258What: /sys/kernel/slab/cache/free_slab
@@ -255,8 +261,9 @@ KernelVersion: 2.6.25
255Contact: Pekka Enberg <penberg@cs.helsinki.fi>, 261Contact: Pekka Enberg <penberg@cs.helsinki.fi>,
256 Christoph Lameter <cl@linux-foundation.org> 262 Christoph Lameter <cl@linux-foundation.org>
257Description: 263Description:
258 The free_slab file is read-only and specifies how many times an 264 The free_slab file shows how many times an empty slab has been
259 empty slab has been freed back to the page allocator. 265 freed back to the page allocator. It can be written to clear
266 the current count.
260 Available when CONFIG_SLUB_STATS is enabled. 267 Available when CONFIG_SLUB_STATS is enabled.
261 268
262What: /sys/kernel/slab/cache/free_slowpath 269What: /sys/kernel/slab/cache/free_slowpath
@@ -265,9 +272,9 @@ KernelVersion: 2.6.25
265Contact: Pekka Enberg <penberg@cs.helsinki.fi>, 272Contact: Pekka Enberg <penberg@cs.helsinki.fi>,
266 Christoph Lameter <cl@linux-foundation.org> 273 Christoph Lameter <cl@linux-foundation.org>
267Description: 274Description:
268 The free_slowpath file is read-only and specifies how many 275 The free_slowpath file shows how many objects have been freed
269 objects have been freed using the slow path (i.e. to a full or 276 using the slow path (i.e. to a full or partial slab). It can
270 partial slab). 277 be written to clear the current count.
271 Available when CONFIG_SLUB_STATS is enabled. 278 Available when CONFIG_SLUB_STATS is enabled.
272 279
273What: /sys/kernel/slab/cache/hwcache_align 280What: /sys/kernel/slab/cache/hwcache_align
@@ -346,10 +353,10 @@ KernelVersion: 2.6.26
346Contact: Pekka Enberg <penberg@cs.helsinki.fi>, 353Contact: Pekka Enberg <penberg@cs.helsinki.fi>,
347 Christoph Lameter <cl@linux-foundation.org> 354 Christoph Lameter <cl@linux-foundation.org>
348Description: 355Description:
349 The file order_fallback is read-only and specifies how many 356 The order_fallback file shows how many times an allocation of a
350 times an allocation of a new slab has not been possible at the 357 new slab has not been possible at the cache's order and instead
351 cache's order and instead fallen back to its minimum possible 358 fallen back to its minimum possible order. It can be written to
352 order. 359 clear the current count.
353 Available when CONFIG_SLUB_STATS is enabled. 360 Available when CONFIG_SLUB_STATS is enabled.
354 361
355What: /sys/kernel/slab/cache/partial 362What: /sys/kernel/slab/cache/partial
diff --git a/mm/slub.c b/mm/slub.c
index 4996fc719552..ac0ca4c0d054 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -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
4374static 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) \
4375static ssize_t text##_show(struct kmem_cache *s, char *buf) \ 4383static 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} \
4379SLAB_ATTR_RO(text); \ 4387static 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} \
4395SLAB_ATTR(text); \
4380 4396
4381STAT_ATTR(ALLOC_FASTPATH, alloc_fastpath); 4397STAT_ATTR(ALLOC_FASTPATH, alloc_fastpath);
4382STAT_ATTR(ALLOC_SLOWPATH, alloc_slowpath); 4398STAT_ATTR(ALLOC_SLOWPATH, alloc_slowpath);