slab: Remove special-casing of const 0 size allocations
authorKees Cook <keescook@chromium.org>
Fri, 18 Nov 2022 03:51:59 +0000 (19:51 -0800)
committerVlastimil Babka <vbabka@suse.cz>
Mon, 21 Nov 2022 09:27:00 +0000 (10:27 +0100)
commit6fa57d78aa7f212fd7c0de70f5756e18513dcdcf
treef8cdf805bbacc1861a0eb35116582a55089b1c52
parent3bf019334fbbb51723587f9819c62d3d6f9d6f3f
slab: Remove special-casing of const 0 size allocations

Passing a constant-0 size allocation into kmalloc() or kmalloc_node()
does not need to be a fast-path operation, so the static return value
can be removed entirely. This makes sure that all paths through the
inlines result in a full extern function call, where __alloc_size()
hints will actually be seen[1] by GCC. (A constant return value of 0
means the "0" allocation size won't be propagated by the inline.)

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96503

Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Cc: linux-mm@kvack.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
include/linux/slab.h