patches.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Feng Tang <feng.tang@intel.com>
Cc: David Rientjes <rientjes@google.com>,
	Christoph Lameter <cl@linux.com>,
	Hyeonggon Yoo <42.hyeyoo@gmail.com>,
	Jay Patel <jaypatel@linux.ibm.com>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Pekka Enberg <penberg@kernel.org>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"patches@lists.linux.dev" <patches@lists.linux.dev>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/4] mm/slub: simplify the last resort slab order calculation
Date: Wed, 20 Sep 2023 08:38:05 +0200	[thread overview]
Message-ID: <9f0ac6a5-7b13-7ce0-ead3-03746a31040e@suse.cz> (raw)
In-Reply-To: <ZQlUKJXKYYY5fxL4@feng-clx>

On 9/19/23 09:56, Feng Tang wrote:
> Hi Vlastimil,
> 
> On Fri, Sep 08, 2023 at 10:53:04PM +0800, Vlastimil Babka wrote:
>> If calculate_order() can't fit even a single large object within
>> slub_max_order, it will try using the smallest necessary order that may
>> exceed slub_max_order but not MAX_ORDER.
>> 
>> Currently this is done with a call to calc_slab_order() which is
>> unecessary. We can simply use get_order(size). No functional change.
>> 
>> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
>> ---
>>  mm/slub.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/mm/slub.c b/mm/slub.c
>> index f7940048138c..c6e694cb17b9 100644
>> --- a/mm/slub.c
>> +++ b/mm/slub.c
>> @@ -4193,7 +4193,7 @@ static inline int calculate_order(unsigned int size)
>>  	/*
>>  	 * Doh this slab cannot be placed using slub_max_order.
>>  	 */
>> -	order = calc_slab_order(size, 1, MAX_ORDER, 1);
>> +	order = get_order(size);
> 
> 
> This patchset is a nice cleanup, and my previous test all looked fine. 
> And one 'slub_min_order' setup reminded by Christopher [1] doesn't
> work as not taking affect with this 1/4 patch.

Hmm I see. Well the trick should keep working if you pass both
slab_min_order=9 slab_max_order=9 ? Maybe Christopher actually does that,
but didn't type it fully in the mail.

> The root cause seems to be, in current kernel, the 'slub_max_order'
> is not ajusted  accordingly with 'slub_min_order', so there is case
> that 'slub_min_order' is bigger than the default 'slub_max_order' (3).
> 
> And it could be fixed by the below patch 
> 
> diff --git a/mm/slub.c b/mm/slub.c
> index 1c91f72c7239..dbe950783105 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -4702,6 +4702,9 @@ static int __init setup_slub_min_order(char *str)
>  {
>  	get_option(&str, (int *)&slub_min_order);
>  
> +	if (slub_min_order > slub_max_order)
> +		slub_max_order = slub_min_order;
> +
>  	return 1;
>  }

Sounds like a good idea. Would also do analogous thing in setup_slub_max_order.

> Though the formal fix may also need to cover case like this kind of
> crazy setting "slub_min_order=6 slub_max_order=5" 

Doing both should cover even this, and AFAICS how param processing works the
last one passed would "win" so it would set min=max=5 in that case. That's
probably the most sane way we can handle such scenarios.

Want to set a full patch or should I finalize it? I would put it as a new
1/5 before the rest. Thanks!

> [1]. https://lore.kernel.org/lkml/21a0ba8b-bf05-0799-7c78-2a35f8c8d52a@os.amperecomputing.com/
> 
> Thanks,
> Feng
> 
>>  	if (order <= MAX_ORDER)
>>  		return order;
>>  	return -ENOSYS;
>> -- 
>> 2.42.0
>> 
>> 


  reply	other threads:[~2023-09-20  6:38 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-08 14:53 [PATCH 0/4] SLUB: calculate_order() cleanups Vlastimil Babka
2023-09-08 14:53 ` [PATCH 1/4] mm/slub: simplify the last resort slab order calculation Vlastimil Babka
2023-09-19  7:56   ` Feng Tang
2023-09-20  6:38     ` Vlastimil Babka [this message]
2023-09-20  7:09       ` Feng Tang
2023-09-08 14:53 ` [PATCH 2/4] mm/slub: remove min_objects loop from calculate_order() Vlastimil Babka
2023-09-08 14:53 ` [PATCH 3/4] mm/slub: attempt to find layouts up to 1/2 waste in calculate_order() Vlastimil Babka
2023-09-20 13:11   ` Feng Tang
2023-09-08 14:53 ` [PATCH 4/4] mm/slub: refactor calculate_order() and calc_slab_order() Vlastimil Babka
2023-09-11  5:56   ` kernel test robot
2023-09-15 13:36     ` Vlastimil Babka
2023-09-16  1:28   ` Baoquan He
2023-09-22  7:00     ` Vlastimil Babka
2023-09-22  7:29       ` Baoquan He
2023-09-20 13:36   ` Feng Tang
2023-09-22  6:55     ` Vlastimil Babka
2023-09-28  4:46 ` [PATCH 0/4] SLUB: calculate_order() cleanups Jay Patel
2023-10-02 12:38   ` Vlastimil Babka

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=9f0ac6a5-7b13-7ce0-ead3-03746a31040e@suse.cz \
    --to=vbabka@suse.cz \
    --cc=42.hyeyoo@gmail.com \
    --cc=cl@linux.com \
    --cc=feng.tang@intel.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=jaypatel@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=patches@lists.linux.dev \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    /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;
as well as URLs for NNTP newsgroup(s).