1. 04 9月, 2021 7 次提交
  2. 14 8月, 2021 3 次提交
  3. 31 7月, 2021 1 次提交
  4. 18 7月, 2021 1 次提交
  5. 16 7月, 2021 1 次提交
  6. 09 7月, 2021 1 次提交
  7. 30 6月, 2021 8 次提交
  8. 17 6月, 2021 4 次提交
  9. 23 5月, 2021 1 次提交
  10. 15 5月, 2021 1 次提交
    • V
      mm, slub: move slub_debug static key enabling outside slab_mutex · afe0c26d
      Vlastimil Babka 提交于
      Paul E.  McKenney reported [1] that commit 1f0723a4 ("mm, slub: enable
      slub_debug static key when creating cache with explicit debug flags")
      results in the lockdep complaint:
      
       ======================================================
       WARNING: possible circular locking dependency detected
       5.12.0+ #15 Not tainted
       ------------------------------------------------------
       rcu_torture_sta/109 is trying to acquire lock:
       ffffffff96063cd0 (cpu_hotplug_lock){++++}-{0:0}, at: static_key_enable+0x9/0x20
      
       but task is already holding lock:
       ffffffff96173c28 (slab_mutex){+.+.}-{3:3}, at: kmem_cache_create_usercopy+0x2d/0x250
      
       which lock already depends on the new lock.
      
       the existing dependency chain (in reverse order) is:
      
       -> #1 (slab_mutex){+.+.}-{3:3}:
              lock_acquire+0xb9/0x3a0
              __mutex_lock+0x8d/0x920
              slub_cpu_dead+0x15/0xf0
              cpuhp_invoke_callback+0x17a/0x7c0
              cpuhp_invoke_callback_range+0x3b/0x80
              _cpu_down+0xdf/0x2a0
              cpu_down+0x2c/0x50
              device_offline+0x82/0xb0
              remove_cpu+0x1a/0x30
              torture_offline+0x80/0x140
              torture_onoff+0x147/0x260
              kthread+0x10a/0x140
              ret_from_fork+0x22/0x30
      
       -> #0 (cpu_hotplug_lock){++++}-{0:0}:
              check_prev_add+0x8f/0xbf0
              __lock_acquire+0x13f0/0x1d80
              lock_acquire+0xb9/0x3a0
              cpus_read_lock+0x21/0xa0
              static_key_enable+0x9/0x20
              __kmem_cache_create+0x38d/0x430
              kmem_cache_create_usercopy+0x146/0x250
              kmem_cache_create+0xd/0x10
              rcu_torture_stats+0x79/0x280
              kthread+0x10a/0x140
              ret_from_fork+0x22/0x30
      
       other info that might help us debug this:
      
        Possible unsafe locking scenario:
      
              CPU0                    CPU1
              ----                    ----
         lock(slab_mutex);
                                      lock(cpu_hotplug_lock);
                                      lock(slab_mutex);
         lock(cpu_hotplug_lock);
      
        *** DEADLOCK ***
      
       1 lock held by rcu_torture_sta/109:
        #0: ffffffff96173c28 (slab_mutex){+.+.}-{3:3}, at: kmem_cache_create_usercopy+0x2d/0x250
      
       stack backtrace:
       CPU: 3 PID: 109 Comm: rcu_torture_sta Not tainted 5.12.0+ #15
       Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-1ubuntu1.1 04/01/2014
       Call Trace:
        dump_stack+0x6d/0x89
        check_noncircular+0xfe/0x110
        ? lock_is_held_type+0x98/0x110
        check_prev_add+0x8f/0xbf0
        __lock_acquire+0x13f0/0x1d80
        lock_acquire+0xb9/0x3a0
        ? static_key_enable+0x9/0x20
        ? mark_held_locks+0x49/0x70
        cpus_read_lock+0x21/0xa0
        ? static_key_enable+0x9/0x20
        static_key_enable+0x9/0x20
        __kmem_cache_create+0x38d/0x430
        kmem_cache_create_usercopy+0x146/0x250
        ? rcu_torture_stats_print+0xd0/0xd0
        kmem_cache_create+0xd/0x10
        rcu_torture_stats+0x79/0x280
        ? rcu_torture_stats_print+0xd0/0xd0
        kthread+0x10a/0x140
        ? kthread_park+0x80/0x80
        ret_from_fork+0x22/0x30
      
      This is because there's one order of locking from the hotplug callbacks:
      
      lock(cpu_hotplug_lock); // from hotplug machinery itself
      lock(slab_mutex); // in e.g. slab_mem_going_offline_callback()
      
      And commit 1f0723a4 made the reverse sequence possible:
      lock(slab_mutex); // in kmem_cache_create_usercopy()
      lock(cpu_hotplug_lock); // kmem_cache_open() -> static_key_enable()
      
      The simplest fix is to move static_key_enable() to a place before slab_mutex is
      taken. That means kmem_cache_create_usercopy() in mm/slab_common.c which is not
      ideal for SLUB-specific code, but the #ifdef CONFIG_SLUB_DEBUG makes it
      at least self-contained and obvious.
      
      [1] https://lore.kernel.org/lkml/20210502171827.GA3670492@paulmck-ThinkPad-P17-Gen-1/
      
      Link: https://lkml.kernel.org/r/20210504120019.26791-1-vbabka@suse.cz
      Fixes: 1f0723a4 ("mm, slub: enable slub_debug static key when creating cache with explicit debug flags")
      Signed-off-by: NVlastimil Babka <vbabka@suse.cz>
      Reported-by: NPaul E. McKenney <paulmck@kernel.org>
      Tested-by: NPaul E. McKenney <paulmck@kernel.org>
      Acked-by: NDavid Rientjes <rientjes@google.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      afe0c26d
  11. 11 5月, 2021 2 次提交
    • M
      mm/slub: Add Support for free path information of an object · e548eaa1
      Maninder Singh 提交于
      This commit adds enables a stack dump for the last free of an object:
      
      slab kmalloc-64 start c8ab0140 data offset 64 pointer offset 0 size 64 allocated at meminfo_proc_show+0x40/0x4fc
      [   20.192078]     meminfo_proc_show+0x40/0x4fc
      [   20.192263]     seq_read_iter+0x18c/0x4c4
      [   20.192430]     proc_reg_read_iter+0x84/0xac
      [   20.192617]     generic_file_splice_read+0xe8/0x17c
      [   20.192816]     splice_direct_to_actor+0xb8/0x290
      [   20.193008]     do_splice_direct+0xa0/0xe0
      [   20.193185]     do_sendfile+0x2d0/0x438
      [   20.193345]     sys_sendfile64+0x12c/0x140
      [   20.193523]     ret_fast_syscall+0x0/0x58
      [   20.193695]     0xbeeacde4
      [   20.193822]  Free path:
      [   20.193935]     meminfo_proc_show+0x5c/0x4fc
      [   20.194115]     seq_read_iter+0x18c/0x4c4
      [   20.194285]     proc_reg_read_iter+0x84/0xac
      [   20.194475]     generic_file_splice_read+0xe8/0x17c
      [   20.194685]     splice_direct_to_actor+0xb8/0x290
      [   20.194870]     do_splice_direct+0xa0/0xe0
      [   20.195014]     do_sendfile+0x2d0/0x438
      [   20.195174]     sys_sendfile64+0x12c/0x140
      [   20.195336]     ret_fast_syscall+0x0/0x58
      [   20.195491]     0xbeeacde4
      Acked-by: NVlastimil Babka <vbabka@suse.cz>
      Co-developed-by: NVaneet Narang <v.narang@samsung.com>
      Signed-off-by: NVaneet Narang <v.narang@samsung.com>
      Signed-off-by: NManinder Singh <maninder1.s@samsung.com>
      Signed-off-by: NPaul E. McKenney <paulmck@kernel.org>
      e548eaa1
    • M
      mm/slub: Fix backtrace of objects to handle redzone adjustment · 0cbc124b
      Maninder Singh 提交于
      This commit fixes commit 8e7f37f2 ("mm: Add mem_dump_obj() to print
      source of memory block").
      
      With current code, the backtrace of allocated object is incorrect:
      / # cat /proc/meminfo
      [   14.969843]  slab kmalloc-64 start c8ab0140 data offset 64 pointer offset 0 size 64 allocated at 0x6b6b6b6b
      [   14.970635]     0x6b6b6b6b
      [   14.970794]     0x6b6b6b6b
      [   14.970932]     0x6b6b6b6b
      [   14.971077]     0x6b6b6b6b
      [   14.971202]     0x6b6b6b6b
      [   14.971317]     0x6b6b6b6b
      [   14.971423]     0x6b6b6b6b
      [   14.971635]     0x6b6b6b6b
      [   14.971740]     0x6b6b6b6b
      [   14.971871]     0x6b6b6b6b
      [   14.972229]     0x6b6b6b6b
      [   14.972363]     0x6b6b6b6b
      [   14.972505]     0xa56b6b6b
      [   14.972631]     0xbbbbbbbb
      [   14.972734]     0xc8ab0400
      [   14.972891]     meminfo_proc_show+0x40/0x4fc
      
      The reason is that the object address was not adjusted for the red zone.
      With this fix, the backtrace is correct:
      / # cat /proc/meminfo
      [   14.870782]  slab kmalloc-64 start c8ab0140 data offset 64 pointer offset 128 size 64 allocated at meminfo_proc_show+0x40/0x4f4
      [   14.871817]     meminfo_proc_show+0x40/0x4f4
      [   14.872035]     seq_read_iter+0x18c/0x4c4
      [   14.872229]     proc_reg_read_iter+0x84/0xac
      [   14.872433]     generic_file_splice_read+0xe8/0x17c
      [   14.872621]     splice_direct_to_actor+0xb8/0x290
      [   14.872747]     do_splice_direct+0xa0/0xe0
      [   14.872896]     do_sendfile+0x2d0/0x438
      [   14.873044]     sys_sendfile64+0x12c/0x140
      [   14.873229]     ret_fast_syscall+0x0/0x58
      [   14.873372]     0xbe861de4
      Acked-by: NVlastimil Babka <vbabka@suse.cz>
      Signed-off-by: NVaneet Narang <v.narang@samsung.com>
      Signed-off-by: NManinder Singh <maninder1.s@samsung.com>
      Signed-off-by: NPaul E. McKenney <paulmck@kernel.org>
      0cbc124b
  12. 07 5月, 2021 1 次提交
  13. 01 5月, 2021 4 次提交
  14. 19 3月, 2021 2 次提交
  15. 11 3月, 2021 1 次提交
    • L
      Revert "mm, slub: consider rest of partial list if acquire_slab() fails" · 9b1ea29b
      Linus Torvalds 提交于
      This reverts commit 8ff60eb0.
      
      The kernel test robot reports a huge performance regression due to the
      commit, and the reason seems fairly straightforward: when there is
      contention on the page list (which is what causes acquire_slab() to
      fail), we do _not_ want to just loop and try again, because that will
      transfer the contention to the 'n->list_lock' spinlock we hold, and
      just make things even worse.
      
      This is admittedly likely a problem only on big machines - the kernel
      test robot report comes from a 96-thread dual socket Intel Xeon Gold
      6252 setup, but the regression there really is quite noticeable:
      
         -47.9% regression of stress-ng.rawpkt.ops_per_sec
      
      and the commit that was marked as being fixed (7ced3719: "slub:
      Acquire_slab() avoid loop") actually did the loop exit early very
      intentionally (the hint being that "avoid loop" part of that commit
      message), exactly to avoid this issue.
      
      The correct thing to do may be to pick some kind of reasonable middle
      ground: instead of breaking out of the loop on the very first sign of
      contention, or trying over and over and over again, the right thing may
      be to re-try _once_, and then give up on the second failure (or pick
      your favorite value for "once"..).
      Reported-by: Nkernel test robot <oliver.sang@intel.com>
      Link: https://lore.kernel.org/lkml/20210301080404.GF12822@xsang-OptiPlex-9020/
      Cc: Jann Horn <jannh@google.com>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Acked-by: NChristoph Lameter <cl@linux.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      9b1ea29b
  16. 09 3月, 2021 1 次提交
    • P
      mm: Don't build mm_dump_obj() on CONFIG_PRINTK=n kernels · 5bb1bb35
      Paul E. McKenney 提交于
      The mem_dump_obj() functionality adds a few hundred bytes, which is a
      small price to pay.  Except on kernels built with CONFIG_PRINTK=n, in
      which mem_dump_obj() messages will be suppressed.  This commit therefore
      makes mem_dump_obj() be a static inline empty function on kernels built
      with CONFIG_PRINTK=n and excludes all of its support functions as well.
      This avoids kernel bloat on systems that cannot use mem_dump_obj().
      
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: <linux-mm@kvack.org>
      Suggested-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NPaul E. McKenney <paulmck@kernel.org>
      5bb1bb35
  17. 27 2月, 2021 1 次提交
    • A
      kasan, mm: optimize kmalloc poisoning · e2db1a9a
      Andrey Konovalov 提交于
      For allocations from kmalloc caches, kasan_kmalloc() always follows
      kasan_slab_alloc().  Currenly, both of them unpoison the whole object,
      which is unnecessary.
      
      This patch provides separate implementations for both annotations:
      kasan_slab_alloc() unpoisons the whole object, and kasan_kmalloc() only
      poisons the redzone.
      
      For generic KASAN, the redzone start might not be aligned to
      KASAN_GRANULE_SIZE.  Therefore, the poisoning is split in two parts:
      kasan_poison_last_granule() poisons the unaligned part, and then
      kasan_poison() poisons the rest.
      
      This patch also clarifies alignment guarantees of each of the poisoning
      functions and drops the unnecessary round_up() call for redzone_end.
      
      With this change, the early SLUB cache annotation needs to be changed to
      kasan_slab_alloc(), as kasan_kmalloc() doesn't unpoison objects now.  The
      number of poisoned bytes for objects in this cache stays the same, as
      kmem_cache_node->object_size is equal to sizeof(struct kmem_cache_node).
      
      Link: https://lkml.kernel.org/r/7e3961cb52be380bc412860332063f5f7ce10d13.1612546384.git.andreyknvl@google.comSigned-off-by: NAndrey Konovalov <andreyknvl@google.com>
      Reviewed-by: NMarco Elver <elver@google.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
      Cc: Branislav Rankov <Branislav.Rankov@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Evgenii Stepanov <eugenis@google.com>
      Cc: Kevin Brodsky <kevin.brodsky@arm.com>
      Cc: Peter Collingbourne <pcc@google.com>
      Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e2db1a9a