* [PATCH] SLUB: cleanup - define macroses instead of hardcoded numbers
@ 2008-10-22 19:00 Cyrill Gorcunov
2008-10-23 8:49 ` Pekka Enberg
0 siblings, 1 reply; 2+ messages in thread
From: Cyrill Gorcunov @ 2008-10-22 19:00 UTC (permalink / raw)
To: Pekka Enberg; +Cc: Christoph Lameter, LKML
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Acked-by: Christoph Lameter <cl@linux-foundation.org>
---
mm/slub.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
Index: linux-2.6.git/mm/slub.c
===================================================================
--- linux-2.6.git.orig/mm/slub.c 2008-10-22 21:11:26.000000000 +0400
+++ linux-2.6.git/mm/slub.c 2008-10-22 22:53:43.000000000 +0400
@@ -153,6 +153,10 @@
#define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
#endif
+#define OO_SHIFT 16
+#define OO_MASK ((1 << OO_SHIFT) - 1)
+#define MAX_OBJS_PER_PAGE 65535 /* since page.objects is u16 */
+
/* Internal SLUB flags */
#define __OBJECT_POISON 0x80000000 /* Poison object */
#define __SYSFS_ADD_DEFERRED 0x40000000 /* Not yet visible via sysfs */
@@ -290,7 +294,7 @@ static inline struct kmem_cache_order_ob
unsigned long size)
{
struct kmem_cache_order_objects x = {
- (order << 16) + (PAGE_SIZE << order) / size
+ (order << OO_SHIFT) + (PAGE_SIZE << order) / size
};
return x;
@@ -298,12 +302,12 @@ static inline struct kmem_cache_order_ob
static inline int oo_order(struct kmem_cache_order_objects x)
{
- return x.x >> 16;
+ return x.x >> OO_SHIFT;
}
static inline int oo_objects(struct kmem_cache_order_objects x)
{
- return x.x & ((1 << 16) - 1);
+ return x.x & OO_MASK;
}
#ifdef CONFIG_SLUB_DEBUG
@@ -764,8 +768,8 @@ static int on_freelist(struct kmem_cache
}
max_objects = (PAGE_SIZE << compound_order(page)) / s->size;
- if (max_objects > 65535)
- max_objects = 65535;
+ if (max_objects > MAX_OBJS_PER_PAGE)
+ max_objects = MAX_OBJS_PER_PAGE;
if (page->objects != max_objects) {
slab_err(s, page, "Wrong number of objects. Found %d but "
@@ -1819,8 +1823,8 @@ static inline int slab_order(int size, i
int rem;
int min_order = slub_min_order;
- if ((PAGE_SIZE << min_order) / size > 65535)
- return get_order(size * 65535) - 1;
+ if ((PAGE_SIZE << min_order) / size > MAX_OBJS_PER_PAGE)
+ return get_order(size * MAX_OBJS_PER_PAGE) - 1;
for (order = max(min_order,
fls(min_objects * size - 1) - PAGE_SHIFT);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] SLUB: cleanup - define macroses instead of hardcoded numbers
2008-10-22 19:00 [PATCH] SLUB: cleanup - define macroses instead of hardcoded numbers Cyrill Gorcunov
@ 2008-10-23 8:49 ` Pekka Enberg
0 siblings, 0 replies; 2+ messages in thread
From: Pekka Enberg @ 2008-10-23 8:49 UTC (permalink / raw)
To: Cyrill Gorcunov; +Cc: Christoph Lameter, LKML
On Wed, 2008-10-22 at 23:00 +0400, Cyrill Gorcunov wrote:
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> Acked-by: Christoph Lameter <cl@linux-foundation.org>
Applied, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-10-23 8:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-22 19:00 [PATCH] SLUB: cleanup - define macroses instead of hardcoded numbers Cyrill Gorcunov
2008-10-23 8:49 ` Pekka Enberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox