All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Lameter <cl@linux.com>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: glommer@parallels.com, penberg@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [linux-next-20130422] Bug in SLAB?
Date: Fri, 10 May 2013 15:57:30 +0000	[thread overview]
Message-ID: <0000013e8f295277-653bcbfa-e1cc-4c05-8e6d-eb6a5a661f6f-000000@email.amazonses.com> (raw)
In-Reply-To: <201305102138.BDF90621.LFFOFtHSQOMVOJ@I-love.SAKURA.ne.jp>

On Fri, 10 May 2013, Tetsuo Handa wrote:

> Tetsuo Handa wrote:
> > Can we manage with allocating only 26 elements when MAX_ORDER + PAGE_SHIFT > 26
> > (e.g. PAGE_SIZE == 256 * 1024) ?
> >
> > Can kmalloc_index()/kmalloc_size()/kmalloc_slab() etc. work correctly when
> > MAX_ORDER + PAGE_SHIFT > 26 (e.g. PAGE_SIZE == 256 * 1024) ?
> >
> Today I compared SLAB/SLUB code. If I understood correctly, the line
>
>   if (size <=  64 * 1024 * 1024) return 26;
>
> in kmalloc_index() is redundant (in fact, kmalloc_caches[26] is out of range)
> and conflicts with what the comment

True we could remove it but it does not hurt. There is a bounding of size
before any call to kmalloc_index.

>   * The largest kmalloc size supported by the SLAB allocators is
>   * 32 megabyte (2^25) or the maximum allocatable page order if that is
>   * less than 32 MB.
>
> says, and 0 <= kmalloc_index() <= 25 is always true for SLAB and
> 0 <= kmalloc_index() <= PAGE_SHIFT+1 is always true for SLUB.
>
> Therefore, towards 3.10-rc1,
>
> > > -	for (i = 1; i < PAGE_SHIFT + MAX_ORDER; i++) {
> > > +	for (i = 1; i =< KMALLOC_SHIFT_HIGH; i++) {
> >
> -+	for (i = 1; i =< KMALLOC_SHIFT_HIGH; i++) {
> ++	for (i = 1; i <= KMALLOC_SHIFT_HIGH; i++) {
>
> would be the last fix for me. (I don't know why kmalloc_caches[0] is excluded.)

Yep. kmalloc[0] is not used. The first cache to be used is 1 and 2 which
are the non power of two caches. 3 and higher are the power of two caches.


Subject: SLAB: Fix init_lock_keys

init_lock_keys goes too far in initializing values in kmalloc_caches because
it assumed that the size of the kmalloc array goes up to MAX_ORDER. However, the size
of the kmalloc array for SLAB may be restricted due to increased page sizes or CONFIG_FORCE_MAX_ZONEORDER.

Reported-by: Tetsuo Handa <penguin-kernel@I-Love.SAKURA.ne.jp>
Signed-off-by: Christoph Lameter <cl@linux.com>

Index: linux/mm/slab.c
===================================================================
--- linux.orig/mm/slab.c	2013-05-09 09:06:20.000000000 -0500
+++ linux/mm/slab.c	2013-05-09 09:08:08.338606055 -0500
@@ -565,7 +565,7 @@ static void init_node_lock_keys(int q)
 	if (slab_state < UP)
 		return;

-	for (i = 1; i < PAGE_SHIFT + MAX_ORDER; i++) {
+	for (i = 1; i <= KMALLOC_SHIFT_HIGH; i++) {
 		struct kmem_cache_node *n;
 		struct kmem_cache *cache = kmalloc_caches[i];


  reply	other threads:[~2013-05-10 15:57 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-24 12:08 [linux-next-20130422] Bug in bootup code or debug code? Tetsuo Handa
2013-04-25 12:20 ` [linux-next-20130422] Bug in SLAB? Tetsuo Handa
2013-04-29  2:40   ` Tetsuo Handa
2013-04-29 10:12     ` Pekka Enberg
2013-04-29 14:44       ` Glauber Costa
2013-04-29 14:59         ` Christoph Lameter
2013-04-29 15:16           ` Glauber Costa
2013-04-29 15:46             ` Christoph Lameter
2013-04-29 15:54               ` Glauber Costa
2013-04-29 15:28           ` Tetsuo Handa
2013-04-29 16:16             ` Tetsuo Handa
2013-05-09 12:25               ` Tetsuo Handa
2013-05-09 14:14                 ` Christoph Lameter
2013-05-09 21:54                   ` Tetsuo Handa
2013-05-10 12:38                     ` Tetsuo Handa
2013-05-10 15:57                       ` Christoph Lameter [this message]
     [not found]                         ` <201305272153.HEH51089.OHFQMOOtFLSFVJ@I-love.SAKURA.ne.jp>
2013-06-17 11:59                           ` Tetsuo Handa
2013-04-29 17:48             ` Christoph Lameter
2013-04-29 21:45               ` Tetsuo Handa
2013-04-30 14:26                 ` Christoph Lameter
2013-04-30 16:01                   ` Tetsuo Handa
2013-04-30 17:27                     ` Christoph Lameter
2013-05-01  8:05                       ` Pekka Enberg
2013-05-02 15:12                         ` Christoph Lameter
2013-05-01 12:14                       ` Tetsuo Handa
2013-05-02 11:51                         ` Tetsuo Handa
2013-05-02 20:53                         ` Christoph Lameter
2013-05-03  8:26                           ` Tetsuo Handa
2013-05-03 15:43                             ` Christoph Lameter
2013-05-06  6:59                               ` Geert Uytterhoeven
2013-05-06  7:27                                 ` Pekka Enberg
2013-05-03 18:04                             ` Christoph Lameter
2013-05-03 18:48                               ` Tetsuo Handa
2013-05-03 19:21                                 ` Christoph Lameter
2013-05-04  0:15                                   ` Tetsuo Handa
2013-05-06 13:46                                     ` Christoph Lameter
2013-05-07 10:38                                       ` Tetsuo Handa
2013-05-07 14:28                                         ` Christoph Lameter
2013-07-01 20:09                                           ` Andrew Morton
2013-07-01 21:45                                             ` Tetsuo Handa
2013-07-01 21:53                                               ` Andrew Morton
2013-07-02 12:49                                                 ` Tetsuo Handa
2013-07-02 19:12                                                   ` Andrew Morton
2013-07-07 15:58                                                     ` Pekka Enberg
2013-05-06  6:32                               ` Pekka Enberg
2013-05-06 13:47                                 ` Christoph Lameter
2013-05-06 20:24                               ` Pekka Enberg
2013-05-07 14:23                                 ` Christoph Lameter
2013-05-07 14:44                                   ` Pekka Enberg
2013-05-07 15:40                                     ` Christoph Lameter
2013-04-30 14:34                 ` Christoph Lameter
2013-05-01  8:03                   ` Pekka Enberg
2013-05-02 15:13                     ` Christoph Lameter
2013-04-30 15:16                 ` Fix off by one error in slab.h Christoph Lameter
2013-04-29  2:56   ` [linux-next-20130422] Bug in SLAB? Zhan Jianyu
2013-04-29  2:56     ` Zhan Jianyu
2013-04-29  3:56     ` Tetsuo Handa

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=0000013e8f295277-653bcbfa-e1cc-4c05-8e6d-eb6a5a661f6f-000000@email.amazonses.com \
    --to=cl@linux.com \
    --cc=glommer@parallels.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penberg@kernel.org \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.