lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1348756660-16929-4-git-send-email-glommer@parallels.com>
Date:	Thu, 27 Sep 2012 18:37:39 +0400
From:	Glauber Costa <glommer@...allels.com>
To:	<linux-mm@...ck.org>
Cc:	<linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Pekka Enberg <penberg@...nel.org>,
	David Rientjes <rientjes@...gle.com>,
	Christoph Lameter <cl@...ux.com>,
	Glauber Costa <glommer@...allels.com>,
	Pekka Enberg <penberg@...helsinki.fi>
Subject: [PATCH 3/4] slub: move slub internal functions to its header

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@...allels.com>
CC: Christoph Lameter <cl@...ux.com>
CC: Pekka Enberg <penberg@...helsinki.fi>
CC: David Rientjes <rientjes@...gle.com>
---
 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@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ