public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Feng Tang <feng.tang@intel.com>
Cc: Christoph Lameter <cl@linux.com>,
	Pekka Enberg <penberg@kernel.org>,
	David Rientjes <rientjes@google.com>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Vlastimil Babka <vbabka@suse.cz>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Hyeonggon Yoo <42.hyeyoo@gmail.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	dave.hansen@intel.com, Joerg Roedel <jroedel@suse.de>
Subject: Re: [RFC PATCH] mm/slub: enable debugging memory wasting of kmalloc
Date: Thu, 30 Jun 2022 09:52:12 +0100	[thread overview]
Message-ID: <2cf27cd6-5cb9-57e7-dc52-e39f37945343@arm.com> (raw)
In-Reply-To: <20220629194747.62effc10a994f67e26fe96af@linux-foundation.org>

On 2022-06-30 03:47, Andrew Morton wrote:
> On Thu, 30 Jun 2022 10:38:44 +0800 Feng Tang <feng.tang@intel.com> wrote:
> 
>> Hi Andrew,
>>
>> Thanks for the review!
>>
>> On Wed, Jun 29, 2022 at 07:30:06PM -0700, Andrew Morton wrote:
>>> On Thu, 30 Jun 2022 09:47:15 +0800 Feng Tang <feng.tang@intel.com> wrote:
>>>
>>>> kmalloc's API family is critical for mm, with one shortcoming that
>>>> its object size is fixed to be power of 2. When user requests memory
>>>> for '2^n + 1' bytes, actually 2^(n+1) bytes will be allocated, so
>>>> in worst case, there is around 50% memory space waste.
>>>>
>>>> We've met a kernel boot OOM panic, and from the dumped slab info:
>>>>
>>>>      [   26.062145] kmalloc-2k            814056KB     814056KB
>>>>
>>>> >From debug we found there are huge number of 'struct iova_magazine',
>>>> whose size is 1032 bytes (1024 + 8), so each allocation will waste
>>>> 1016 bytes. Though the issue is solved by giving the right(bigger)
>>>> size of RAM, it is still better to optimize the size (either use
>>>> a kmalloc friendly size or create a dedicated slab for it).
>>>
>>> Well that's nice, and additional visibility is presumably a good thing.
>>>
>>> But what the heck is going on with iova_magazine?  Is anyone looking at
>>> moderating its impact?
>>
>> Yes, I have a very simple patch at hand
>>
>> --- a/drivers/iommu/iova.c
>> +++ b/drivers/iommu/iova.c
>> @@ -614,7 +614,7 @@ EXPORT_SYMBOL_GPL(reserve_iova);
>>    * dynamic size tuning described in the paper.
>>    */
>>   
>> -#define IOVA_MAG_SIZE 128
>> +#define IOVA_MAG_SIZE 127
> 
> Well OK.  Would benefit from a comment explaining the reasoning.
> 
> But we still have eleventy squillion of these things in flight.  Why?

They're storage for a per-CPU caching scheme - for n CPUs, there should 
currently be (2n + 32) * 6 in flight, since there's one set for each of 
6 sizes. The 32 really should be n or 2n as well since it's needlessly 
large for small systems and a bottleneck for large ones, but it needs 
some unpicking to allow for dynamic allocations.

Thanks,
Robin.


  parent reply	other threads:[~2022-06-30  8:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-30  1:47 [RFC PATCH] mm/slub: enable debugging memory wasting of kmalloc Feng Tang
2022-06-30  2:30 ` Andrew Morton
2022-06-30  2:38   ` Feng Tang
2022-06-30  2:47     ` Andrew Morton
2022-06-30  3:23       ` Feng Tang
2022-06-30  8:52       ` Robin Murphy [this message]
2022-06-30 14:38 ` Hyeonggon Yoo
2022-06-30 14:55   ` Hyeonggon Yoo
2022-07-01  2:23   ` Feng Tang
2022-07-01  9:29     ` Hyeonggon Yoo
2022-07-01 11:13       ` Feng Tang

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=2cf27cd6-5cb9-57e7-dc52-e39f37945343@arm.com \
    --to=robin.murphy@arm.com \
    --cc=42.hyeyoo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=dave.hansen@intel.com \
    --cc=feng.tang@intel.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=jroedel@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=vbabka@suse.cz \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox