[PATCH 3/4] slub: move slub internal functions to its header

From: Glauber Costa
Date: Thu Sep 27 2012 - 10:41:42 EST


The functions oo_order() and oo_objects() are used by the slub to
determine respectively the order of a candidate allocation, and the
number of objects made available from it. I would like a stable visible
location outside slub.c so it can be acessed from slab_common.c.

I considered also just making it a common field between slub and slab,
but decided to move those to slub_def.h due to two main reasons: first,
it still deals with implementation specific details of the caches, so it
is better to just use wrappers. Second, because it is not necessarily
the order determined at cache creation time, but possibly a smaller
order in case of a retry. When we use it in slab_common.c we will be
talking about "base" values, but those functions would still have to
exist inside slub, so doing this we can just reuse them.

Signed-off-by: Glauber Costa <glommer@xxxxxxxxxxxxx>
CC: Christoph Lameter <cl@xxxxxxxxx>
CC: Pekka Enberg <penberg@xxxxxxxxxxxxxx>
CC: David Rientjes <rientjes@xxxxxxxxxx>
---
include/linux/slub_def.h | 14 ++++++++++++++
mm/slub.c | 14 --------------
2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index df448ad..f1590c9 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -73,6 +73,20 @@ struct kmem_cache_order_objects {
unsigned long x;
};

+#define OO_SHIFT 16
+#define OO_MASK ((1 << OO_SHIFT) - 1)
+#define MAX_OBJS_PER_PAGE 32767 /* since page.objects is u15 */
+
+static inline int oo_order(struct kmem_cache_order_objects x)
+{
+ return x.x >> OO_SHIFT;
+}
+
+static inline int oo_objects(struct kmem_cache_order_objects x)
+{
+ return x.x & OO_MASK;
+}
+
/*
* Slab cache management.
*/
diff --git a/mm/slub.c b/mm/slub.c
index 4c2c092..9e72722 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -171,10 +171,6 @@ static inline int kmem_cache_debug(struct kmem_cache *s)
#define SLUB_MERGE_SAME (SLAB_DEBUG_FREE | SLAB_RECLAIM_ACCOUNT | \
SLAB_CACHE_DMA | SLAB_NOTRACK)

-#define OO_SHIFT 16
-#define OO_MASK ((1 << OO_SHIFT) - 1)
-#define MAX_OBJS_PER_PAGE 32767 /* since page.objects is u15 */
-
/* Internal SLUB flags */
#define __OBJECT_POISON 0x80000000UL /* Poison object */
#define __CMPXCHG_DOUBLE 0x40000000UL /* Use cmpxchg_double */
@@ -325,16 +321,6 @@ static inline struct kmem_cache_order_objects oo_make(int order,
return x;
}

-static inline int oo_order(struct kmem_cache_order_objects x)
-{
- return x.x >> OO_SHIFT;
-}
-
-static inline int oo_objects(struct kmem_cache_order_objects x)
-{
- return x.x & OO_MASK;
-}
-
/*
* Per slab locking using the pagelock
*/
--
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/