[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <c06636f6-d8fc-4836-b843-a9e9cb15b0db@suse.cz>
Date: Thu, 5 Sep 2024 14:47:58 +0200
From: Vlastimil Babka <vbabka@...e.cz>
To: Xavier <xavier_qy@....com>, cl@...ux.com, penberg@...nel.org,
rientjes@...gle.com, iamjoonsoo.kim@....com, akpm@...ux-foundation.org,
roman.gushchin@...ux.dev, 42.hyeyoo@...il.com
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1] mm/slab: Optimize the code logic in find_mergeable()
On 9/4/24 9:40 AM, Xavier wrote:
> We can first assess the flags, if it's unmergeable, there's no need
> to calculate the size and align.
>
> Signed-off-by: Xavier <xavier_qy@....com>
OK, applied to slab/for-next. Thanks.
Note this is not a hotpath so no need to micro-optimize, but it makes
the code cleaner - no more calculate_alignment() using flags before we
adjust them by kmem_cache_flags(). This currently doesn't matter as it
cares only about SLAB_HWCACHE_ALIGN which is not affected, but will be
more robust in case of future changes.
> ---
> mm/slab_common.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/mm/slab_common.c b/mm/slab_common.c
> index 40b582a014b8..aaf5989f7ffe 100644
> --- a/mm/slab_common.c
> +++ b/mm/slab_common.c
> @@ -169,14 +169,15 @@ struct kmem_cache *find_mergeable(unsigned int size, unsigned int align,
> if (ctor)
> return NULL;
>
> - size = ALIGN(size, sizeof(void *));
> - align = calculate_alignment(flags, align, size);
> - size = ALIGN(size, align);
> flags = kmem_cache_flags(flags, name);
>
> if (flags & SLAB_NEVER_MERGE)
> return NULL;
>
> + size = ALIGN(size, sizeof(void *));
> + align = calculate_alignment(flags, align, size);
> + size = ALIGN(size, align);
> +
> list_for_each_entry_reverse(s, &slab_caches, list) {
> if (slab_unmergeable(s))
> continue;
Powered by blists - more mailing lists