linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] mm/slub: some debug enhancements
@ 2022-07-27  7:10 Feng Tang
  2022-07-27  7:10 ` [PATCH v3 1/3] mm/slub: enable debugging memory wasting of kmalloc Feng Tang
                   ` (2 more replies)
  0 siblings, 3 replies; 31+ messages in thread
From: Feng Tang @ 2022-07-27  7:10 UTC (permalink / raw)
  To: Andrew Morton, Vlastimil Babka, Christoph Lameter, Pekka Enberg,
	David Rientjes, Joonsoo Kim, Roman Gushchin, Hyeonggon Yoo,
	linux-mm, linux-kernel
  Cc: Dave Hansen, Robin Murphy, John Garry, Kefeng Wang, Feng Tang

kmalloc's API family is critical for mm, and one of its nature is that
it will round up the request size to a fixed one (mostly power of 2).
When user requests memory for '2^n + 1' bytes, actually 2^(n+1) bytes
could be allocated, so in worst case, there is around 50% memory space
waste.

The wastage is not a big issue for requests that get allocated/freed 
quickly, but may cause problems with objects that have longer life time,
and there were some OOM cases in some extrem cases.

This patchset tries to :
* Add a debug method to track each kmalloced object's wastage info,
  and show the call stack of original allocation
* Extend the redzone sanity check to the extra kmalloced buffer than
  requested, to better detect un-legitimate access to it.

Please help to review, thanks!

- Feng

---
Changelogs:

  since v2:
    * rebased against slab tree's 'for-next' branch
    * fix pointer handling (Kefeng Wang)
    * move kzalloc zeroing handling change to a separate patch (Vlastimil Babka) 
    * make 'orig_size' only depend on KMALLOC & STORE_USER flag
      bits (Vlastimil Babka)

  since v1:
    * limit the 'orig_size' to kmalloc objects only, and save
      it after track in metadata (Vlastimil Babka)
    * fix a offset calculation problem in print_trailer

  since RFC:
    * fix problems in kmem_cache_alloc_bulk() and records sorting,
      improve the print format (Hyeonggon Yoo)
    * fix a compiling issue found by 0Day bot
    * update the commit log based info from iova developers


Feng Tang (3):
  mm/slub: enable debugging memory wasting of kmalloc
  mm/slub: only zero the requested size of buffer for kzalloc
  mm/slub: extend redzone check to cover extra allocated kmalloc space
    than requested

 include/linux/slab.h |   2 +
 mm/slab.c            |   8 +--
 mm/slab.h            |   9 ++-
 mm/slub.c            | 157 ++++++++++++++++++++++++++++++++++++-------
 4 files changed, 146 insertions(+), 30 deletions(-)

-- 
2.27.0


^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2022-08-16 14:13 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-27  7:10 [PATCH v3 0/3] mm/slub: some debug enhancements Feng Tang
2022-07-27  7:10 ` [PATCH v3 1/3] mm/slub: enable debugging memory wasting of kmalloc Feng Tang
2022-07-27 10:20   ` Christoph Lameter
2022-07-27 12:59     ` Feng Tang
2022-07-27 14:12     ` Vlastimil Babka
2022-07-27  7:10 ` [PATCH v3 2/3] mm/slub: only zero the requested size of buffer for kzalloc Feng Tang
2022-07-27  7:10 ` [PATCH v3 3/3] mm/slub: extend redzone check to cover extra allocated kmalloc space than requested Feng Tang
2022-07-31  6:53   ` [mm/slub] 3616799128: BUG_kmalloc-#(Not_tainted):kmalloc_Redzone_overwritten kernel test robot
2022-07-31  8:16     ` Feng Tang
2022-08-01  6:21       ` Feng Tang
2022-08-01  7:26         ` Dmitry Vyukov
2022-08-01  7:48           ` Feng Tang
2022-08-01  8:13             ` Christoph Lameter
2022-08-01 14:23         ` Vlastimil Babka
2022-08-02  6:54           ` Feng Tang
2022-08-02  7:06             ` Dmitry Vyukov
2022-08-02  7:46               ` Feng Tang
2022-08-02  7:59                 ` Dmitry Vyukov
2022-08-02  8:44                   ` Feng Tang
2022-08-02  9:43               ` Vlastimil Babka
2022-08-02 10:30                 ` Dmitry Vyukov
2022-08-02 13:36                   ` Feng Tang
2022-08-02 14:38                     ` Dmitry Vyukov
2022-08-04  6:28                       ` Feng Tang
2022-08-04 10:47                         ` Dmitry Vyukov
2022-08-04 12:22                           ` Feng Tang
2022-08-15  7:27                             ` Feng Tang
2022-08-16 13:27                               ` Oliver Sang
2022-08-16 14:12                                 ` Feng Tang
2022-08-02 10:31                 ` Dmitry Vyukov
2022-08-02  6:59           ` Dmitry Vyukov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).