summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorXavier <xavier_qy@163.com>2024-09-04 10:40:37 +0300
committerVlastimil Babka <vbabka@suse.cz>2024-09-05 15:42:23 +0300
commite02147cb703412fa13dd31908c734d7fb2314f55 (patch)
treec14a212f0109bc1c4e6e381c695496737b352665 /mm
parent59090e479ac78ae18facd4c58eb332562a23020e (diff)
downloadlinux-e02147cb703412fa13dd31908c734d7fb2314f55.tar.xz
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')
-rw-r--r--mm/slab_common.c7
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;