diff options
author | Christoph Lameter <clameter@sgi.com> | 2008-04-29 19:11:12 -0400 |
---|---|---|
committer | Pekka Enberg <penberg@cs.helsinki.fi> | 2008-05-01 17:26:31 -0400 |
commit | 0121c619d03820d965745e56f80f6eb5994533fe (patch) | |
tree | 75ecdc5dee9c3a6bb64ee095f51cc831be2cd475 /mm | |
parent | 886c35fbcf6fb2eee15687efc2d64d99b6ad9a4a (diff) |
slub: Whitespace cleanup and use of strict_strtoul
Fix some issues with wrapping and use strict_strtoul to make parameter
passing from sysfs safer.
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/slub.c | 38 |
1 files changed, 25 insertions, 13 deletions
@@ -814,7 +814,8 @@ static int on_freelist(struct kmem_cache *s, struct page *page, void *search) | |||
814 | return search == NULL; | 814 | return search == NULL; |
815 | } | 815 | } |
816 | 816 | ||
817 | static void trace(struct kmem_cache *s, struct page *page, void *object, int alloc) | 817 | static void trace(struct kmem_cache *s, struct page *page, void *object, |
818 | int alloc) | ||
818 | { | 819 | { |
819 | if (s->flags & SLAB_TRACE) { | 820 | if (s->flags & SLAB_TRACE) { |
820 | printk(KERN_INFO "TRACE %s %s 0x%p inuse=%d fp=0x%p\n", | 821 | printk(KERN_INFO "TRACE %s %s 0x%p inuse=%d fp=0x%p\n", |
@@ -1267,8 +1268,7 @@ static void add_partial(struct kmem_cache_node *n, | |||
1267 | spin_unlock(&n->list_lock); | 1268 | spin_unlock(&n->list_lock); |
1268 | } | 1269 | } |
1269 | 1270 | ||
1270 | static void remove_partial(struct kmem_cache *s, | 1271 | static void remove_partial(struct kmem_cache *s, struct page *page) |
1271 | struct page *page) | ||
1272 | { | 1272 | { |
1273 | struct kmem_cache_node *n = get_node(s, page_to_nid(page)); | 1273 | struct kmem_cache_node *n = get_node(s, page_to_nid(page)); |
1274 | 1274 | ||
@@ -1283,7 +1283,8 @@ static void remove_partial(struct kmem_cache *s, | |||
1283 | * | 1283 | * |
1284 | * Must hold list_lock. | 1284 | * Must hold list_lock. |
1285 | */ | 1285 | */ |
1286 | static inline int lock_and_freeze_slab(struct kmem_cache_node *n, struct page *page) | 1286 | static inline int lock_and_freeze_slab(struct kmem_cache_node *n, |
1287 | struct page *page) | ||
1287 | { | 1288 | { |
1288 | if (slab_trylock(page)) { | 1289 | if (slab_trylock(page)) { |
1289 | list_del(&page->lru); | 1290 | list_del(&page->lru); |
@@ -1420,8 +1421,8 @@ static void unfreeze_slab(struct kmem_cache *s, struct page *page, int tail) | |||
1420 | * so that the others get filled first. That way the | 1421 | * so that the others get filled first. That way the |
1421 | * size of the partial list stays small. | 1422 | * size of the partial list stays small. |
1422 | * | 1423 | * |
1423 | * kmem_cache_shrink can reclaim any empty slabs from the | 1424 | * kmem_cache_shrink can reclaim any empty slabs from |
1424 | * partial list. | 1425 | * the partial list. |
1425 | */ | 1426 | */ |
1426 | add_partial(n, page, 1); | 1427 | add_partial(n, page, 1); |
1427 | slab_unlock(page); | 1428 | slab_unlock(page); |
@@ -2909,7 +2910,7 @@ static int slab_mem_going_online_callback(void *arg) | |||
2909 | return 0; | 2910 | return 0; |
2910 | 2911 | ||
2911 | /* | 2912 | /* |
2912 | * We are bringing a node online. No memory is availabe yet. We must | 2913 | * We are bringing a node online. No memory is available yet. We must |
2913 | * allocate a kmem_cache_node structure in order to bring the node | 2914 | * allocate a kmem_cache_node structure in order to bring the node |
2914 | * online. | 2915 | * online. |
2915 | */ | 2916 | */ |
@@ -3812,7 +3813,12 @@ SLAB_ATTR_RO(objs_per_slab); | |||
3812 | static ssize_t order_store(struct kmem_cache *s, | 3813 | static ssize_t order_store(struct kmem_cache *s, |
3813 | const char *buf, size_t length) | 3814 | const char *buf, size_t length) |
3814 | { | 3815 | { |
3815 | int order = simple_strtoul(buf, NULL, 10); | 3816 | unsigned long order; |
3817 | int err; | ||
3818 | |||
3819 | err = strict_strtoul(buf, 10, &order); | ||
3820 | if (err) | ||
3821 | return err; | ||
3816 | 3822 | ||
3817 | if (order > slub_max_order || order < slub_min_order) | 3823 | if (order > slub_max_order || order < slub_min_order) |
3818 | return -EINVAL; | 3824 | return -EINVAL; |
@@ -4065,10 +4071,16 @@ static ssize_t remote_node_defrag_ratio_show(struct kmem_cache *s, char *buf) | |||
4065 | static ssize_t remote_node_defrag_ratio_store(struct kmem_cache *s, | 4071 | static ssize_t remote_node_defrag_ratio_store(struct kmem_cache *s, |
4066 | const char *buf, size_t length) | 4072 | const char *buf, size_t length) |
4067 | { | 4073 | { |
4068 | int n = simple_strtoul(buf, NULL, 10); | 4074 | unsigned long ratio; |
4075 | int err; | ||
4076 | |||
4077 | err = strict_strtoul(buf, 10, &ratio); | ||
4078 | if (err) | ||
4079 | return err; | ||
4080 | |||
4081 | if (ratio < 100) | ||
4082 | s->remote_node_defrag_ratio = ratio * 10; | ||
4069 | 4083 | ||
4070 | if (n < 100) | ||
4071 | s->remote_node_defrag_ratio = n * 10; | ||
4072 | return length; | 4084 | return length; |
4073 | } | 4085 | } |
4074 | SLAB_ATTR(remote_node_defrag_ratio); | 4086 | SLAB_ATTR(remote_node_defrag_ratio); |
@@ -4425,8 +4437,8 @@ __initcall(slab_sysfs_init); | |||
4425 | */ | 4437 | */ |
4426 | #ifdef CONFIG_SLABINFO | 4438 | #ifdef CONFIG_SLABINFO |
4427 | 4439 | ||
4428 | ssize_t slabinfo_write(struct file *file, const char __user * buffer, | 4440 | ssize_t slabinfo_write(struct file *file, const char __user *buffer, |
4429 | size_t count, loff_t *ppos) | 4441 | size_t count, loff_t *ppos) |
4430 | { | 4442 | { |
4431 | return -EINVAL; | 4443 | return -EINVAL; |
4432 | } | 4444 | } |