lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Thu, 16 Mar 2023 09:25:17 +0800 From: gouhao@...ontech.com To: cl@...ux.com, penberg@...nel.org, rientjes@...gle.com, iamjoonsoo.kim@....com, akpm@...ux-foundation.org, vbabka@...e.cz, roman.gushchin@...ux.dev, 42.hyeyoo@...il.com, keescook@...omium.org Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org Subject: [PATCH] mm/slub: reduce the calculation times of 'MAX_OBJS_PER_PAGE' From: Gou Hao <gouhao@...ontech.com> when calling calc_slab_order(), 'slub_min_order' and 'size' are fixed values, if the condition of 'MAX_OBJS_PER_PAGE' is true, it will be returned from here every time. So we can calculate the condition of 'MAX_OBJS_PER_PAGE' before calling calculate_order(). Signed-off-by: Gou Hao <gouhao@...ontech.com> --- mm/slub.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 39327e98fce3..ed6d797a5cd8 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -4094,9 +4094,6 @@ static inline unsigned int calc_slab_order(unsigned int size, unsigned int min_order = slub_min_order; unsigned int order; - if (order_objects(min_order, size) > MAX_OBJS_PER_PAGE) - return get_order(size * MAX_OBJS_PER_PAGE) - 1; - for (order = max(min_order, (unsigned int)get_order(min_objects * size)); order <= max_order; order++) { @@ -4457,9 +4454,14 @@ static int calculate_sizes(struct kmem_cache *s) size = ALIGN(size, s->align); s->size = size; s->reciprocal_size = reciprocal_value(size); - order = calculate_order(size); - if ((int)order < 0) + + if (order_objects(slub_min_order, size) > MAX_OBJS_PER_PAGE) + order = get_order(size * MAX_OBJS_PER_PAGE) - 1; + else + order = calculate_order(size); + + if ((int)order < 0 || order > slub_max_order) return 0; s->allocflags = 0; -- 2.34.1
Powered by blists - more mailing lists