Skip to content

Commit

Permalink
mm, slab: remove unnecessary unlikely()
Browse files Browse the repository at this point in the history
WARN_ON() already contains an unlikely(), so it's not necessary to use
unlikely.

Also change WARN_ON() back to WARN_ON_ONCE() to avoid potentially
spamming dmesg with user-triggerable large allocations.

[[email protected]: s/WARN_ON/WARN_ON_ONCE/, per Vlastimil]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Yangtao Li <[email protected]>
Acked-by: Vlastimil Babka <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Acked-by: David Rientjes <[email protected]>
Cc: Christoph Lameter <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
TinyWindzz authored and torvalds committed Dec 28, 2018
1 parent 70306d9 commit 221d7da
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions mm/slab_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1029,10 +1029,8 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)

index = size_index[size_index_elem(size)];
} else {
if (unlikely(size > KMALLOC_MAX_CACHE_SIZE)) {
WARN_ON(1);
if (WARN_ON_ONCE(size > KMALLOC_MAX_CACHE_SIZE))
return NULL;
}
index = fls(size - 1);
}

Expand Down

0 comments on commit 221d7da

Please sign in to comment.