From: Andrew Morton <akpm@linux-foundation.org>
To: Christoph Lameter <clameter@sgi.com>
Cc: mroos@linux.ee, David Miller <davem@davemloft.net>,
sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: slab hang on boot
Date: Tue, 15 May 2007 16:56:36 -0700 [thread overview]
Message-ID: <20070515165636.5057456e.akpm@linux-foundation.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0705151642530.3886@schroedinger.engr.sgi.com>
On Tue, 15 May 2007 16:45:22 -0700 (PDT)
Christoph Lameter <clameter@sgi.com> wrote:
> On Tue, 15 May 2007, Andrew Morton wrote:
>
> > On Mon, 14 May 2007 16:46:17 -0700 (PDT)
> > Christoph Lameter <clameter@sgi.com> wrote:
> >
> > > @@ -86,6 +87,9 @@ static inline int kmalloc_index(int size
> > > */
> > > WARN_ON_ONCE(size == 0);
> > >
> > > + if (size >= (1UL << KMALLOC_SHIFT_HIGH))
> > > + return -1;
> > > +
> >
> > I don't quite understand why we did this. The subsequent logic in
> > kmalloc_index() should return -1 for this `size' anyway. If it doesn't,
> > it's bust, isn't it?
>
> KMALLOC_SHIFT_HIGH is not a constant but may be less than 25.
It darn well better be a compile-time constant.
And look:
static inline int kmalloc_index(int size)
{
/*
* We should return 0 if size == 0 but we use the smallest object
* here for SLAB legacy reasons.
*/
WARN_ON_ONCE(size == 0);
if (size > (1 << KMALLOC_SHIFT_HIGH))
return -1;
if (size > 64 && size <= 96)
return 1;
if (size > 128 && size <= 192)
return 2;
if (size <= 8) return 3;
if (size <= 16) return 4;
if (size <= 32) return 5;
if (size <= 64) return 6;
if (size <= 128) return 7;
if (size <= 256) return 8;
if (size <= 512) return 9;
if (size <= 1024) return 10;
if (size <= 2 * 1024) return 11;
if (size <= 4 * 1024) return 12;
if (size <= 8 * 1024) return 13;
if (size <= 16 * 1024) return 14;
if (size <= 32 * 1024) return 15;
if (size <= 64 * 1024) return 16;
if (size <= 128 * 1024) return 17;
if (size <= 256 * 1024) return 18;
#if KMALLOC_SHIFT_HIGH > 18
if (size <= 512 * 1024) return 19;
if (size <= 1024 * 1024) return 20;
#endif
#if KMALLOC_SHIFT_HIGH > 20
if (size <= 2 * 1024 * 1024) return 21;
if (size <= 4 * 1024 * 1024) return 22;
if (size <= 8 * 1024 * 1024) return 23;
if (size <= 16 * 1024 * 1024) return 24;
if (size <= 32 * 1024 * 1024) return 25;
#endif
return -1;
/*
* What we really wanted to do and cannot do because of compiler issues is:
* int i;
* for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++)
* if (size <= (1 << i))
* return i;
*/
}
Either that newly-added test isn't needed, or those ifdefs aren't needed?
next prev parent reply other threads:[~2007-05-16 0:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Pine.SOC.4.64.0705142133190.17204@math>
2007-05-14 22:11 ` slab hang on boot David Miller
2007-05-14 23:46 ` Christoph Lameter
2007-05-15 0:15 ` Andrew Morton
2007-05-15 23:33 ` Andrew Morton
2007-05-15 23:45 ` Christoph Lameter
2007-05-15 23:56 ` Andrew Morton [this message]
2007-05-16 0:14 ` David Miller
2007-05-16 0:29 ` Andrew Morton
2007-05-16 0:38 ` David Miller
2007-05-16 1:00 ` Christoph Lameter
2007-05-16 1:03 ` David Miller
2007-05-16 6:43 ` David Miller
2007-05-16 0:51 ` Christoph Lameter
2007-05-16 0:50 ` 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=20070515165636.5057456e.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=clameter@sgi.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mroos@linux.ee \
--cc=sparclinux@vger.kernel.org \
/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