diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-10-28 11:26:12 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-10-28 11:26:12 -0400 |
commit | 7a9787e1eba95a166265e6a260cf30af04ef0a99 (patch) | |
tree | e730a4565e0318140d2fbd2f0415d18a339d7336 /mm/slab.c | |
parent | 41b9eb264c8407655db57b60b4457fe1b2ec9977 (diff) | |
parent | 0173a3265b228da319ceb9c1ec6a5682fd1b2d92 (diff) |
Merge commit 'v2.6.28-rc2' into x86/pci-ioapic-boot-irq-quirks
Diffstat (limited to 'mm/slab.c')
-rw-r--r-- | mm/slab.c | 64 |
1 files changed, 55 insertions, 9 deletions
@@ -95,6 +95,7 @@ | |||
95 | #include <linux/init.h> | 95 | #include <linux/init.h> |
96 | #include <linux/compiler.h> | 96 | #include <linux/compiler.h> |
97 | #include <linux/cpuset.h> | 97 | #include <linux/cpuset.h> |
98 | #include <linux/proc_fs.h> | ||
98 | #include <linux/seq_file.h> | 99 | #include <linux/seq_file.h> |
99 | #include <linux/notifier.h> | 100 | #include <linux/notifier.h> |
100 | #include <linux/kallsyms.h> | 101 | #include <linux/kallsyms.h> |
@@ -406,7 +407,7 @@ struct kmem_cache { | |||
406 | unsigned int dflags; /* dynamic flags */ | 407 | unsigned int dflags; /* dynamic flags */ |
407 | 408 | ||
408 | /* constructor func */ | 409 | /* constructor func */ |
409 | void (*ctor)(struct kmem_cache *, void *); | 410 | void (*ctor)(void *obj); |
410 | 411 | ||
411 | /* 5) cache creation/removal */ | 412 | /* 5) cache creation/removal */ |
412 | const char *name; | 413 | const char *name; |
@@ -2137,8 +2138,7 @@ static int __init_refok setup_cpu_cache(struct kmem_cache *cachep) | |||
2137 | */ | 2138 | */ |
2138 | struct kmem_cache * | 2139 | struct kmem_cache * |
2139 | kmem_cache_create (const char *name, size_t size, size_t align, | 2140 | kmem_cache_create (const char *name, size_t size, size_t align, |
2140 | unsigned long flags, | 2141 | unsigned long flags, void (*ctor)(void *)) |
2141 | void (*ctor)(struct kmem_cache *, void *)) | ||
2142 | { | 2142 | { |
2143 | size_t left_over, slab_size, ralign; | 2143 | size_t left_over, slab_size, ralign; |
2144 | struct kmem_cache *cachep = NULL, *pc; | 2144 | struct kmem_cache *cachep = NULL, *pc; |
@@ -2653,7 +2653,7 @@ static void cache_init_objs(struct kmem_cache *cachep, | |||
2653 | * They must also be threaded. | 2653 | * They must also be threaded. |
2654 | */ | 2654 | */ |
2655 | if (cachep->ctor && !(cachep->flags & SLAB_POISON)) | 2655 | if (cachep->ctor && !(cachep->flags & SLAB_POISON)) |
2656 | cachep->ctor(cachep, objp + obj_offset(cachep)); | 2656 | cachep->ctor(objp + obj_offset(cachep)); |
2657 | 2657 | ||
2658 | if (cachep->flags & SLAB_RED_ZONE) { | 2658 | if (cachep->flags & SLAB_RED_ZONE) { |
2659 | if (*dbg_redzone2(cachep, objp) != RED_INACTIVE) | 2659 | if (*dbg_redzone2(cachep, objp) != RED_INACTIVE) |
@@ -2669,7 +2669,7 @@ static void cache_init_objs(struct kmem_cache *cachep, | |||
2669 | cachep->buffer_size / PAGE_SIZE, 0); | 2669 | cachep->buffer_size / PAGE_SIZE, 0); |
2670 | #else | 2670 | #else |
2671 | if (cachep->ctor) | 2671 | if (cachep->ctor) |
2672 | cachep->ctor(cachep, objp); | 2672 | cachep->ctor(objp); |
2673 | #endif | 2673 | #endif |
2674 | slab_bufctl(slabp)[i] = i + 1; | 2674 | slab_bufctl(slabp)[i] = i + 1; |
2675 | } | 2675 | } |
@@ -3093,7 +3093,7 @@ static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep, | |||
3093 | #endif | 3093 | #endif |
3094 | objp += obj_offset(cachep); | 3094 | objp += obj_offset(cachep); |
3095 | if (cachep->ctor && cachep->flags & SLAB_POISON) | 3095 | if (cachep->ctor && cachep->flags & SLAB_POISON) |
3096 | cachep->ctor(cachep, objp); | 3096 | cachep->ctor(objp); |
3097 | #if ARCH_SLAB_MINALIGN | 3097 | #if ARCH_SLAB_MINALIGN |
3098 | if ((u32)objp & (ARCH_SLAB_MINALIGN-1)) { | 3098 | if ((u32)objp & (ARCH_SLAB_MINALIGN-1)) { |
3099 | printk(KERN_ERR "0x%p: not aligned to ARCH_SLAB_MINALIGN=%d\n", | 3099 | printk(KERN_ERR "0x%p: not aligned to ARCH_SLAB_MINALIGN=%d\n", |
@@ -4259,7 +4259,7 @@ static int s_show(struct seq_file *m, void *p) | |||
4259 | * + further values on SMP and with statistics enabled | 4259 | * + further values on SMP and with statistics enabled |
4260 | */ | 4260 | */ |
4261 | 4261 | ||
4262 | const struct seq_operations slabinfo_op = { | 4262 | static const struct seq_operations slabinfo_op = { |
4263 | .start = s_start, | 4263 | .start = s_start, |
4264 | .next = s_next, | 4264 | .next = s_next, |
4265 | .stop = s_stop, | 4265 | .stop = s_stop, |
@@ -4316,6 +4316,19 @@ ssize_t slabinfo_write(struct file *file, const char __user * buffer, | |||
4316 | return res; | 4316 | return res; |
4317 | } | 4317 | } |
4318 | 4318 | ||
4319 | static int slabinfo_open(struct inode *inode, struct file *file) | ||
4320 | { | ||
4321 | return seq_open(file, &slabinfo_op); | ||
4322 | } | ||
4323 | |||
4324 | static const struct file_operations proc_slabinfo_operations = { | ||
4325 | .open = slabinfo_open, | ||
4326 | .read = seq_read, | ||
4327 | .write = slabinfo_write, | ||
4328 | .llseek = seq_lseek, | ||
4329 | .release = seq_release, | ||
4330 | }; | ||
4331 | |||
4319 | #ifdef CONFIG_DEBUG_SLAB_LEAK | 4332 | #ifdef CONFIG_DEBUG_SLAB_LEAK |
4320 | 4333 | ||
4321 | static void *leaks_start(struct seq_file *m, loff_t *pos) | 4334 | static void *leaks_start(struct seq_file *m, loff_t *pos) |
@@ -4444,13 +4457,47 @@ static int leaks_show(struct seq_file *m, void *p) | |||
4444 | return 0; | 4457 | return 0; |
4445 | } | 4458 | } |
4446 | 4459 | ||
4447 | const struct seq_operations slabstats_op = { | 4460 | static const struct seq_operations slabstats_op = { |
4448 | .start = leaks_start, | 4461 | .start = leaks_start, |
4449 | .next = s_next, | 4462 | .next = s_next, |
4450 | .stop = s_stop, | 4463 | .stop = s_stop, |
4451 | .show = leaks_show, | 4464 | .show = leaks_show, |
4452 | }; | 4465 | }; |
4466 | |||
4467 | static int slabstats_open(struct inode *inode, struct file *file) | ||
4468 | { | ||
4469 | unsigned long *n = kzalloc(PAGE_SIZE, GFP_KERNEL); | ||
4470 | int ret = -ENOMEM; | ||
4471 | if (n) { | ||
4472 | ret = seq_open(file, &slabstats_op); | ||
4473 | if (!ret) { | ||
4474 | struct seq_file *m = file->private_data; | ||
4475 | *n = PAGE_SIZE / (2 * sizeof(unsigned long)); | ||
4476 | m->private = n; | ||
4477 | n = NULL; | ||
4478 | } | ||
4479 | kfree(n); | ||
4480 | } | ||
4481 | return ret; | ||
4482 | } | ||
4483 | |||
4484 | static const struct file_operations proc_slabstats_operations = { | ||
4485 | .open = slabstats_open, | ||
4486 | .read = seq_read, | ||
4487 | .llseek = seq_lseek, | ||
4488 | .release = seq_release_private, | ||
4489 | }; | ||
4490 | #endif | ||
4491 | |||
4492 | static int __init slab_proc_init(void) | ||
4493 | { | ||
4494 | proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations); | ||
4495 | #ifdef CONFIG_DEBUG_SLAB_LEAK | ||
4496 | proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations); | ||
4453 | #endif | 4497 | #endif |
4498 | return 0; | ||
4499 | } | ||
4500 | module_init(slab_proc_init); | ||
4454 | #endif | 4501 | #endif |
4455 | 4502 | ||
4456 | /** | 4503 | /** |
@@ -4473,4 +4520,3 @@ size_t ksize(const void *objp) | |||
4473 | 4520 | ||
4474 | return obj_size(virt_to_cache(objp)); | 4521 | return obj_size(virt_to_cache(objp)); |
4475 | } | 4522 | } |
4476 | EXPORT_SYMBOL(ksize); | ||