• Linus Torvalds's avatar
    Revert "slub: do not put a slab to cpu partial list when cpu_partial is 0" · 37090506
    Linus Torvalds authored
    This reverts commit 318df36e.
    
    This commit caused Steven Rostedt's hackbench runs to run out of memory
    due to a leak.  As noted by Joonsoo Kim, it is buggy in the following
    scenario:
    
     "I guess, you may set 0 to all kmem caches's cpu_partial via sysfs,
      doesn't it?
    
      In this case, memory leak is possible in following case.  Code flow of
      possible leak is follwing case.
    
       * in __slab_free()
       1. (!new.inuse || !prior) && !was_frozen
       2. !kmem_cache_debug && !prior
       3. new.frozen = 1
       4. after cmpxchg_double_slab, run the (!n) case with new.frozen=1
       5. with this patch, put_cpu_partial() doesn't do anything,
          because this cache's cpu_partial is 0
       6. return
    
      In step 5, leak occur"
    
    And Steven does indeed have cpu_partial set to 0 due to RT testing.
    
    Joonsoo is cooking up a patch, but everybody agrees that reverting this
    for now is the right thing to do.
    Reported-and-bisected-by: default avatarSteven Rostedt <rostedt@goodmis.org>
    Acked-by: default avatarJoonsoo Kim <iamjoonsoo.kim@lge.com>
    Acked-by: default avatarPekka Enberg <penberg@kernel.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    37090506
slub.c 126 KB