diff options
author | Cyrill Gorcunov <gorcunov@gmail.com> | 2008-10-22 15:00:38 -0400 |
---|---|---|
committer | Pekka Enberg <penberg@cs.helsinki.fi> | 2008-11-26 09:47:24 -0500 |
commit | 210b5c06130f266370b5ff86e3cb6d860e1be29c (patch) | |
tree | 060d23ad4dc3a776d31ab543fe35a60fb0ff1d3d /mm | |
parent | ed313489badef16d700f5a3be50e8fd8f8294bc8 (diff) |
SLUB: cleanup - define macros instead of hardcoded numbers
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Acked-by: Christoph Lameter <cl@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/slub.c | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -153,6 +153,10 @@ | |||
153 | #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long) | 153 | #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long) |
154 | #endif | 154 | #endif |
155 | 155 | ||
156 | #define OO_SHIFT 16 | ||
157 | #define OO_MASK ((1 << OO_SHIFT) - 1) | ||
158 | #define MAX_OBJS_PER_PAGE 65535 /* since page.objects is u16 */ | ||
159 | |||
156 | /* Internal SLUB flags */ | 160 | /* Internal SLUB flags */ |
157 | #define __OBJECT_POISON 0x80000000 /* Poison object */ | 161 | #define __OBJECT_POISON 0x80000000 /* Poison object */ |
158 | #define __SYSFS_ADD_DEFERRED 0x40000000 /* Not yet visible via sysfs */ | 162 | #define __SYSFS_ADD_DEFERRED 0x40000000 /* Not yet visible via sysfs */ |
@@ -290,7 +294,7 @@ static inline struct kmem_cache_order_objects oo_make(int order, | |||
290 | unsigned long size) | 294 | unsigned long size) |
291 | { | 295 | { |
292 | struct kmem_cache_order_objects x = { | 296 | struct kmem_cache_order_objects x = { |
293 | (order << 16) + (PAGE_SIZE << order) / size | 297 | (order << OO_SHIFT) + (PAGE_SIZE << order) / size |
294 | }; | 298 | }; |
295 | 299 | ||
296 | return x; | 300 | return x; |
@@ -298,12 +302,12 @@ static inline struct kmem_cache_order_objects oo_make(int order, | |||
298 | 302 | ||
299 | static inline int oo_order(struct kmem_cache_order_objects x) | 303 | static inline int oo_order(struct kmem_cache_order_objects x) |
300 | { | 304 | { |
301 | return x.x >> 16; | 305 | return x.x >> OO_SHIFT; |
302 | } | 306 | } |
303 | 307 | ||
304 | static inline int oo_objects(struct kmem_cache_order_objects x) | 308 | static inline int oo_objects(struct kmem_cache_order_objects x) |
305 | { | 309 | { |
306 | return x.x & ((1 << 16) - 1); | 310 | return x.x & OO_MASK; |
307 | } | 311 | } |
308 | 312 | ||
309 | #ifdef CONFIG_SLUB_DEBUG | 313 | #ifdef CONFIG_SLUB_DEBUG |
@@ -764,8 +768,8 @@ static int on_freelist(struct kmem_cache *s, struct page *page, void *search) | |||
764 | } | 768 | } |
765 | 769 | ||
766 | max_objects = (PAGE_SIZE << compound_order(page)) / s->size; | 770 | max_objects = (PAGE_SIZE << compound_order(page)) / s->size; |
767 | if (max_objects > 65535) | 771 | if (max_objects > MAX_OBJS_PER_PAGE) |
768 | max_objects = 65535; | 772 | max_objects = MAX_OBJS_PER_PAGE; |
769 | 773 | ||
770 | if (page->objects != max_objects) { | 774 | if (page->objects != max_objects) { |
771 | slab_err(s, page, "Wrong number of objects. Found %d but " | 775 | slab_err(s, page, "Wrong number of objects. Found %d but " |
@@ -1807,8 +1811,8 @@ static inline int slab_order(int size, int min_objects, | |||
1807 | int rem; | 1811 | int rem; |
1808 | int min_order = slub_min_order; | 1812 | int min_order = slub_min_order; |
1809 | 1813 | ||
1810 | if ((PAGE_SIZE << min_order) / size > 65535) | 1814 | if ((PAGE_SIZE << min_order) / size > MAX_OBJS_PER_PAGE) |
1811 | return get_order(size * 65535) - 1; | 1815 | return get_order(size * MAX_OBJS_PER_PAGE) - 1; |
1812 | 1816 | ||
1813 | for (order = max(min_order, | 1817 | for (order = max(min_order, |
1814 | fls(min_objects * size - 1) - PAGE_SHIFT); | 1818 | fls(min_objects * size - 1) - PAGE_SHIFT); |