linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Glauber Costa <glommer@parallels.com>
To: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Pekka Enberg <penberg@kernel.org>,
	David Rientjes <rientjes@google.com>,
	Christoph Lameter <cl@linux.com>,
	Glauber Costa <glommer@parallels.com>,
	Pekka Enberg <penberg@cs.helsinki.fi>
Subject: [PATCH 3/4] slub: move slub internal functions to its header
Date: Thu, 27 Sep 2012 18:37:39 +0400	[thread overview]
Message-ID: <1348756660-16929-4-git-send-email-glommer@parallels.com> (raw)
In-Reply-To: <1348756660-16929-1-git-send-email-glommer@parallels.com>

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@parallels.com>
CC: Christoph Lameter <cl@linux.com>
CC: Pekka Enberg <penberg@cs.helsinki.fi>
CC: David Rientjes <rientjes@google.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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2012-09-27 14:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-27 14:37 [PATCH 0/4] move slabinfo processing to common code Glauber Costa
2012-09-27 14:37 ` [PATCH 1/4] sl[au]b: move slabinfo processing to slab_common.c Glauber Costa
2012-09-27 14:50   ` Christoph Lameter
2012-09-27 14:37 ` [PATCH 2/4] sl[au]b: move print_slabinfo_header " Glauber Costa
2012-09-27 14:51   ` Christoph Lameter
2012-09-27 14:37 ` Glauber Costa [this message]
2012-09-27 14:53   ` [PATCH 3/4] slub: move slub internal functions to its header Christoph Lameter
2012-09-27 14:37 ` [PATCH 4/4] sl[au]b: process slabinfo_show in common code Glauber Costa
2012-09-27 15:07   ` Christoph Lameter
2012-09-27 16:38     ` Glauber Costa
2012-09-27 17:53       ` Christoph Lameter
2012-09-27 14:48 ` [PATCH 0/4] move slabinfo processing to " Christoph Lameter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1348756660-16929-4-git-send-email-glommer@parallels.com \
    --to=glommer@parallels.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@cs.helsinki.fi \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox