<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Steve has submitted a patch to remove the __builtin_constant_p issue. :)</div><div><br></div><div>Behan<br><br>Sent from my Mobile Computer which is also a phone</div>
<div><br>Begin forwarded message:<br><br></div><blockquote type="cite"><div><b>From:</b> Steven Rostedt &lt;<a href="mailto:rostedt@goodmis.org">rostedt@goodmis.org</a>&gt;<br><b>Date:</b> 17 April, 2013 12:09:36 PM PDT<br>
<b>To:</b> LKML &lt;<a href="mailto:linux-kernel@vger.kernel.org">linux-kernel@vger.kernel.org</a>&gt;, <a href="mailto:linux-mm@kvack.org">linux-mm@kvack.org</a><br><b>Cc:</b> Christoph Lameter &lt;<a href="mailto:cl@linux.com">cl@linux.com</a>&gt;, Behan Webster &lt;<a href="mailto:behanw@converseincode.com">behanw@converseincode.com</a>&gt;,  Andrew Morton &lt;<a href="mailto:akpm@linux-foundation.org">akpm@linux-foundation.org</a>&gt;<br>
<b>Subject:</b> <b>[PATCH] slab: Remove unnecessary __builtin_constant_p()</b><br><br></div></blockquote><blockquote type="cite"><div><span>The slab.c code has a size check macro that checks the size of the</span><br><span>following structs:</span><br>
<span></span><br><span>struct arraycache_init</span><br><span>struct kmem_list3</span><br><span></span><br><span>The index_of() function that takes the sizeof() of the above two structs</span><br><span>and does an unnecessary __builtin_constant_p() on that. As sizeof() will</span><br>
<span>always end up being a constant making this always be true. The code is</span><br><span>not incorrect, but it just adds added complexity, and confuses users and</span><br><span>wastes the time of reviewers of the code, who spends time trying to</span><br>
<span>figure out why the builtin_constant_p() was used.</span><br><span></span><br><span>This patch is just a clean up that makes the index_of() code a little</span><br><span>bit less complex.</span><br><span></span><br><span>Signed-off-by: Steven Rostedt &lt;<a href="mailto:rostedt@goodmis.org">rostedt@goodmis.org</a>&gt;</span><br>
<span></span><br><span>diff --git a/mm/slab.c b/mm/slab.c</span><br><span>index 856e4a1..6047900 100644</span><br><span>--- a/mm/slab.c</span><br><span>+++ b/mm/slab.c</span><br><span>@@ -325,9 +325,7 @@ static void cache_reap(struct work_struct *unused);</span><br>
<span> static __always_inline int index_of(const size_t size)</span><br><span> {</span><br><span>     extern void __bad_size(void);</span><br><span>-</span><br><span>-    if (__builtin_constant_p(size)) {</span><br><span>-        int i = 0;</span><br>
<span>+    int i = 0;</span><br><span></span><br><span> #define CACHE(x) \</span><br><span>     if (size &lt;=x) \</span><br><span>@@ -336,9 +334,7 @@ static __always_inline int index_of(const size_t size)</span><br><span>         i++;</span><br>
<span> #include &lt;linux/kmalloc_sizes.h&gt;</span><br><span> #undef CACHE</span><br><span>-        __bad_size();</span><br><span>-    } else</span><br><span>-        __bad_size();</span><br><span>+    __bad_size();</span><br>
<span>     return 0;</span><br><span> }</span><br><span></span><br><span></span><br><span></span><br></div></blockquote></body></html>