linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] slab: Remove unnecessary __builtin_constant_p()
@ 2013-04-17 19:09 Steven Rostedt
  2013-04-18  0:03 ` David Rientjes
  2013-04-18  0:15 ` Will Huck
  0 siblings, 2 replies; 11+ messages in thread
From: Steven Rostedt @ 2013-04-17 19:09 UTC (permalink / raw)
  To: LKML, linux-mm; +Cc: Christoph Lameter, Behan Webster, Andrew Morton

The slab.c code has a size check macro that checks the size of the
following structs:

struct arraycache_init
struct kmem_list3

The index_of() function that takes the sizeof() of the above two structs
and does an unnecessary __builtin_constant_p() on that. As sizeof() will
always end up being a constant making this always be true. The code is
not incorrect, but it just adds added complexity, and confuses users and
wastes the time of reviewers of the code, who spends time trying to
figure out why the builtin_constant_p() was used.

This patch is just a clean up that makes the index_of() code a little
bit less complex.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

diff --git a/mm/slab.c b/mm/slab.c
index 856e4a1..6047900 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -325,9 +325,7 @@ static void cache_reap(struct work_struct *unused);
 static __always_inline int index_of(const size_t size)
 {
 	extern void __bad_size(void);
-
-	if (__builtin_constant_p(size)) {
-		int i = 0;
+	int i = 0;
 
 #define CACHE(x) \
 	if (size <=x) \
@@ -336,9 +334,7 @@ static __always_inline int index_of(const size_t size)
 		i++;
 #include <linux/kmalloc_sizes.h>
 #undef CACHE
-		__bad_size();
-	} else
-		__bad_size();
+	__bad_size();
 	return 0;
 }
 


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-04-24  7:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-17 19:09 [PATCH] slab: Remove unnecessary __builtin_constant_p() Steven Rostedt
2013-04-18  0:03 ` David Rientjes
2013-04-22 20:44   ` Andrew Morton
2013-04-22 20:58     ` Steven Rostedt
2013-04-22 21:16       ` Andrew Morton
2013-04-22 23:15         ` Steven Rostedt
2013-04-24  7:31         ` Pekka Enberg
2013-04-23  5:06       ` Behan Webster
2013-04-18  0:15 ` Will Huck
2013-04-18  0:32   ` David Rientjes
2013-04-18 10:24     ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).