diff options
author | Xavier <xavier_qy@163.com> | 2024-09-04 15:40:37 +0800 |
---|---|---|
committer | Vlastimil Babka <vbabka@suse.cz> | 2024-09-05 14:42:23 +0200 |
commit | e02147cb703412fa13dd31908c734d7fb2314f55 (patch) | |
tree | c14a212f0109bc1c4e6e381c695496737b352665 /mm/slab_common.c | |
parent | 59090e479ac78ae18facd4c58eb332562a23020e (diff) |
mm/slab: Optimize the code logic in find_mergeable()
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@163.com>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Diffstat (limited to 'mm/slab_common.c')
-rw-r--r-- | mm/slab_common.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/mm/slab_common.c b/mm/slab_common.c index ca694f5553b4..85afeb69b3c0 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -186,14 +186,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; |