lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YsGlAYujuJSTBLLf@ip-172-31-24-42.ap-northeast-1.compute.internal>
Date:   Sun, 3 Jul 2022 14:17:37 +0000
From:   Hyeonggon Yoo <42.hyeyoo@...il.com>
To:     Feng Tang <feng.tang@...el.com>
Cc:     Christoph Lameter <cl@...two.de>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Pekka Enberg <penberg@...nel.org>,
        David Rientjes <rientjes@...gle.com>,
        Joonsoo Kim <iamjoonsoo.kim@....com>,
        Vlastimil Babka <vbabka@...e.cz>,
        Roman Gushchin <roman.gushchin@...ux.dev>, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org, dave.hansen@...el.com,
        Robin Murphy <robin.murphy@....com>,
        John Garry <john.garry@...wei.com>
Subject: Re: [PATCH v1] mm/slub: enable debugging memory wasting of kmalloc

On Fri, Jul 01, 2022 at 11:04:51PM +0800, Feng Tang wrote:
> Hi Christoph,
> 
> On Fri, Jul 01, 2022 at 04:37:00PM +0200, Christoph Lameter wrote:
> > On Fri, 1 Jul 2022, Feng Tang wrote:
> > 
> > >  static void *__slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
> > > -			  unsigned long addr, struct kmem_cache_cpu *c)
> > > +			  unsigned long addr, struct kmem_cache_cpu *c, unsigned int orig_size)
> > >  {
> > 
> > It would be good to avoid expanding the basic slab handling functions for
> > kmalloc. Can we restrict the mods to the kmalloc related functions?
> 
> Yes, this is the part that concerned me. I tried but haven't figured
> a way.
> 
> I started implemting it several month ago, and stuck with several
> kmalloc APIs in a hacky way like dump_stack() when there is a waste
> over 1/4 of the object_size of the kmalloc_caches[][].
> 
> Then I found one central API which has all the needed info (object_size &
> orig_size) that we can yell about the waste :
> 
> static __always_inline void *slab_alloc_node(struct kmem_cache *s, struct list_lru *lru,
>                 gfp_t gfpflags, int node, unsigned long addr, size_t orig_size)
> 
> which I thought could be still hacky, as the existing 'alloc_traces'
> can't be resued which already has the count/call-stack info. Current
> solution leverage it at the cost of adding 'orig_size' parameters, but
> I don't know how to pass the 'waste' info through as track/location is
> in the lowest level.

If adding cost of orig_size parameter for non-debugging case is concern,
what about doing this in userspace script that makes use of kmalloc
tracepoints?

	kmalloc: call_site=tty_buffer_alloc+0x43/0x90 ptr=00000000b78761e1
	bytes_req=1056 bytes_alloc=2048 gfp_flags=GFP_ATOMIC|__GFP_NOWARN
	accounted=false

calculating sum of (bytes_alloc - bytes_req) for each call_site
may be an alternative solution.

Thanks,
Hyeonggon

> Thanks,
> Feng
> 
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ