public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Christoph Lameter <cl@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] SLUB - define OO_ macro instead of hardcoded numbers
Date: Wed, 22 Oct 2008 21:58:27 +0400	[thread overview]
Message-ID: <20081022175827.GL9639@localhost> (raw)
In-Reply-To: <48FF6800.20705@cs.helsinki.fi>

[Pekka Enberg - Wed, Oct 22, 2008 at 08:50:56PM +0300]
> Christoph Lameter wrote:
>> On Wed, 22 Oct 2008, Cyrill Gorcunov wrote:
>>
>>> Christoph how about this one?
>>
>> Ok. Looks a bit better but we still have two maxes here
>>
>> s->max which refers to the maximum number of objects per slab page for 
>> a specific slab cache (depends on the runtime configuration). 
>> OO_MAX_OBJS refers to the maximum number of objects per slab page that 
>> any slab cache can be configured for which is a compile time limit.
>>
>> Maybe this is okay, Pekka?
>
> Maybe call the page->objects maximum MAX_OBJS_PER_PAGE as it's not  
> strictly related to the other OO code?
>
> 		Pekka
>

Something like that?

		- Cyrill -
---

 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 21:57:11.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 /* see struct page.objects */
+
 /* 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);

  reply	other threads:[~2008-10-22 17:58 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-22 16:18 [RFC] SLUB - define OO_ macro instead of hardcoded numbers Cyrill Gorcunov
2008-10-22 16:28 ` Christoph Lameter
2008-10-22 16:35   ` Cyrill Gorcunov
2008-10-22 16:53     ` Cyrill Gorcunov
2008-10-22 17:21       ` Cyrill Gorcunov
2008-10-22 17:47         ` Christoph Lameter
2008-10-22 17:50           ` Pekka Enberg
2008-10-22 17:58             ` Cyrill Gorcunov [this message]
2008-10-22 18:01               ` Pekka Enberg
2008-10-22 18:10               ` Christoph Lameter
2008-10-22 18:15                 ` Cyrill Gorcunov
2008-10-22 18:24                   ` Christoph Lameter
2008-10-22 18:30                     ` Cyrill Gorcunov
2008-10-22 18:45                       ` Christoph Lameter
2008-10-22 18:52                         ` Cyrill Gorcunov
2008-10-22 18:42                     ` Cyrill Gorcunov
2008-10-22 18:49                       ` Christoph Lameter
2008-10-22 18:53                         ` Cyrill Gorcunov
2008-10-22 18:03             ` Christoph Lameter
2008-10-22 17:54           ` Cyrill Gorcunov

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=20081022175827.GL9639@localhost \
    --to=gorcunov@gmail.com \
    --cc=cl@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penberg@cs.helsinki.fi \
    /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