All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] slab: Remove unnecessary __builtin_constant_p()
@ 2013-04-17 19:09 ` Steven Rostedt
  0 siblings, 0 replies; 22+ 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;
 }
 



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

* [PATCH] slab: Remove unnecessary __builtin_constant_p()
@ 2013-04-17 19:09 ` Steven Rostedt
  0 siblings, 0 replies; 22+ 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] 22+ messages in thread

* Re: [PATCH] slab: Remove unnecessary __builtin_constant_p()
  2013-04-17 19:09 ` Steven Rostedt
@ 2013-04-18  0:03   ` David Rientjes
  -1 siblings, 0 replies; 22+ messages in thread
From: David Rientjes @ 2013-04-18  0:03 UTC (permalink / raw)
  To: Steven Rostedt, Pekka Enberg
  Cc: LKML, linux-mm, Christoph Lameter, Behan Webster, Andrew Morton

On Wed, 17 Apr 2013, Steven Rostedt wrote:

> 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>

Acked-by: David Rientjes <rientjes@google.com>

Adding Pekka to the cc.

> 
> 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;
>  }
>  

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

* Re: [PATCH] slab: Remove unnecessary __builtin_constant_p()
@ 2013-04-18  0:03   ` David Rientjes
  0 siblings, 0 replies; 22+ messages in thread
From: David Rientjes @ 2013-04-18  0:03 UTC (permalink / raw)
  To: Steven Rostedt, Pekka Enberg
  Cc: LKML, linux-mm, Christoph Lameter, Behan Webster, Andrew Morton

On Wed, 17 Apr 2013, Steven Rostedt wrote:

> 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>

Acked-by: David Rientjes <rientjes@google.com>

Adding Pekka to the cc.

> 
> 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	[flat|nested] 22+ messages in thread

* Re: [PATCH] slab: Remove unnecessary __builtin_constant_p()
  2013-04-17 19:09 ` Steven Rostedt
@ 2013-04-18  0:15   ` Will Huck
  -1 siblings, 0 replies; 22+ messages in thread
From: Will Huck @ 2013-04-18  0:15 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, linux-mm, Christoph Lameter, Behan Webster, Andrew Morton

Hi Steven,
On 04/18/2013 03:09 AM, Steven Rostedt wrote:
> 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.

In normal case, builtin_constant_p() is used for what?

>
> 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	[flat|nested] 22+ messages in thread

* Re: [PATCH] slab: Remove unnecessary __builtin_constant_p()
@ 2013-04-18  0:15   ` Will Huck
  0 siblings, 0 replies; 22+ messages in thread
From: Will Huck @ 2013-04-18  0:15 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, linux-mm, Christoph Lameter, Behan Webster, Andrew Morton

Hi Steven,
On 04/18/2013 03:09 AM, Steven Rostedt wrote:
> 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.

In normal case, builtin_constant_p() is used for what?

>
> 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>

--
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	[flat|nested] 22+ messages in thread

* Re: [PATCH] slab: Remove unnecessary __builtin_constant_p()
  2013-04-18  0:15   ` Will Huck
@ 2013-04-18  0:32     ` David Rientjes
  -1 siblings, 0 replies; 22+ messages in thread
From: David Rientjes @ 2013-04-18  0:32 UTC (permalink / raw)
  To: Will Huck
  Cc: Steven Rostedt, LKML, linux-mm, Christoph Lameter, Behan Webster,
	Andrew Morton

On Thu, 18 Apr 2013, Will Huck wrote:

> In normal case, builtin_constant_p() is used for what?
> 

http://gcc.gnu.org/onlinedocs/

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

* Re: [PATCH] slab: Remove unnecessary __builtin_constant_p()
@ 2013-04-18  0:32     ` David Rientjes
  0 siblings, 0 replies; 22+ messages in thread
From: David Rientjes @ 2013-04-18  0:32 UTC (permalink / raw)
  To: Will Huck
  Cc: Steven Rostedt, LKML, linux-mm, Christoph Lameter, Behan Webster,
	Andrew Morton

On Thu, 18 Apr 2013, Will Huck wrote:

> In normal case, builtin_constant_p() is used for what?
> 

http://gcc.gnu.org/onlinedocs/

--
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	[flat|nested] 22+ messages in thread

* Re: [PATCH] slab: Remove unnecessary __builtin_constant_p()
  2013-04-18  0:32     ` David Rientjes
@ 2013-04-18 10:24       ` Borislav Petkov
  -1 siblings, 0 replies; 22+ messages in thread
From: Borislav Petkov @ 2013-04-18 10:24 UTC (permalink / raw)
  To: David Rientjes
  Cc: Will Huck, Steven Rostedt, LKML, linux-mm, Christoph Lameter,
	Behan Webster, Andrew Morton

On Wed, Apr 17, 2013 at 05:32:03PM -0700, David Rientjes wrote:
> On Thu, 18 Apr 2013, Will Huck wrote:
> 
> > In normal case, builtin_constant_p() is used for what?
> > 
> http://gcc.gnu.org/onlinedocs/

Yeah, there's also this very educating site for situations like this
one:

http://lmgtfy.com

:-)

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

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

* Re: [PATCH] slab: Remove unnecessary __builtin_constant_p()
@ 2013-04-18 10:24       ` Borislav Petkov
  0 siblings, 0 replies; 22+ messages in thread
From: Borislav Petkov @ 2013-04-18 10:24 UTC (permalink / raw)
  To: David Rientjes
  Cc: Will Huck, Steven Rostedt, LKML, linux-mm, Christoph Lameter,
	Behan Webster, Andrew Morton

On Wed, Apr 17, 2013 at 05:32:03PM -0700, David Rientjes wrote:
> On Thu, 18 Apr 2013, Will Huck wrote:
> 
> > In normal case, builtin_constant_p() is used for what?
> > 
> http://gcc.gnu.org/onlinedocs/

Yeah, there's also this very educating site for situations like this
one:

http://lmgtfy.com

:-)

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

--
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	[flat|nested] 22+ messages in thread

* Re: [PATCH] slab: Remove unnecessary __builtin_constant_p()
  2013-04-18  0:03   ` David Rientjes
@ 2013-04-22 20:44     ` Andrew Morton
  -1 siblings, 0 replies; 22+ messages in thread
From: Andrew Morton @ 2013-04-22 20:44 UTC (permalink / raw)
  To: David Rientjes
  Cc: Steven Rostedt, Pekka Enberg, LKML, linux-mm, Christoph Lameter,
	Behan Webster

On Wed, 17 Apr 2013 17:03:21 -0700 (PDT) David Rientjes <rientjes@google.com> wrote:

> On Wed, 17 Apr 2013, Steven Rostedt wrote:
> 
> > 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>
> 
> Acked-by: David Rientjes <rientjes@google.com>
> 
> Adding Pekka to the cc.

I ducked this patch because it seemed rather pointless - but a little
birdie told me that there is a secret motivation which seems pretty
reasonable to me.  So I shall await chirp-the-second, which hopefully
will have a fuller and franker changelog ;)


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

* Re: [PATCH] slab: Remove unnecessary __builtin_constant_p()
@ 2013-04-22 20:44     ` Andrew Morton
  0 siblings, 0 replies; 22+ messages in thread
From: Andrew Morton @ 2013-04-22 20:44 UTC (permalink / raw)
  To: David Rientjes
  Cc: Steven Rostedt, Pekka Enberg, LKML, linux-mm, Christoph Lameter,
	Behan Webster

On Wed, 17 Apr 2013 17:03:21 -0700 (PDT) David Rientjes <rientjes@google.com> wrote:

> On Wed, 17 Apr 2013, Steven Rostedt wrote:
> 
> > 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>
> 
> Acked-by: David Rientjes <rientjes@google.com>
> 
> Adding Pekka to the cc.

I ducked this patch because it seemed rather pointless - but a little
birdie told me that there is a secret motivation which seems pretty
reasonable to me.  So I shall await chirp-the-second, which hopefully
will have a fuller and franker changelog ;)

--
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	[flat|nested] 22+ messages in thread

* Re: [PATCH] slab: Remove unnecessary __builtin_constant_p()
  2013-04-22 20:44     ` Andrew Morton
@ 2013-04-22 20:58       ` Steven Rostedt
  -1 siblings, 0 replies; 22+ messages in thread
From: Steven Rostedt @ 2013-04-22 20:58 UTC (permalink / raw)
  To: Andrew Morton
  Cc: David Rientjes, Pekka Enberg, LKML, linux-mm, Christoph Lameter,
	Behan Webster

On Mon, 2013-04-22 at 13:44 -0700, Andrew Morton wrote:
> On Wed, 17 Apr 2013 17:03:21 -0700 (PDT) David Rientjes <rientjes@google.com> wrote:
> 
> > On Wed, 17 Apr 2013, Steven Rostedt wrote:
> > 
> > > 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>
> > 
> > Acked-by: David Rientjes <rientjes@google.com>
> > 
> > Adding Pekka to the cc.
> 
> I ducked this patch because it seemed rather pointless - but a little
> birdie told me that there is a secret motivation which seems pretty
> reasonable to me.  So I shall await chirp-the-second, which hopefully
> will have a fuller and franker changelog ;)

<little birdie voice>
The real motivation behind this patch was it prevents LLVM (Clang) from
compiling the kernel. There's currently a bug in Clang where it can't
determine if a variable is constant or not, so instead, when
__builtin_constant_p() is used, it just treats it like it isn't a
constant (always taking the slow *safe* path).

Unfortunately, the "confusing" code of slub.c that unnecessarily uses
the __builtin_constant_p() will fail to compile if the variable passed
in is not constant. As Clang will say constants are not constant at this
point, the compile fails.

When looking into this, we found the only two users of the index_of()
static function that has this issue, passes in size_of(), which will
always be a constant, making the check redundant.

Note, this is a bug in Clang that will hopefully be fixed soon. But for
now, this strange redundant compile time check is preventing Clang from
even testing the Linux kernel build.
</little birdie voice>

And I still think the original change log has rational for the change,
as it does make it rather confusing to what is happening there.

-- Steve




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

* Re: [PATCH] slab: Remove unnecessary __builtin_constant_p()
@ 2013-04-22 20:58       ` Steven Rostedt
  0 siblings, 0 replies; 22+ messages in thread
From: Steven Rostedt @ 2013-04-22 20:58 UTC (permalink / raw)
  To: Andrew Morton
  Cc: David Rientjes, Pekka Enberg, LKML, linux-mm, Christoph Lameter,
	Behan Webster

On Mon, 2013-04-22 at 13:44 -0700, Andrew Morton wrote:
> On Wed, 17 Apr 2013 17:03:21 -0700 (PDT) David Rientjes <rientjes@google.com> wrote:
> 
> > On Wed, 17 Apr 2013, Steven Rostedt wrote:
> > 
> > > 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>
> > 
> > Acked-by: David Rientjes <rientjes@google.com>
> > 
> > Adding Pekka to the cc.
> 
> I ducked this patch because it seemed rather pointless - but a little
> birdie told me that there is a secret motivation which seems pretty
> reasonable to me.  So I shall await chirp-the-second, which hopefully
> will have a fuller and franker changelog ;)

<little birdie voice>
The real motivation behind this patch was it prevents LLVM (Clang) from
compiling the kernel. There's currently a bug in Clang where it can't
determine if a variable is constant or not, so instead, when
__builtin_constant_p() is used, it just treats it like it isn't a
constant (always taking the slow *safe* path).

Unfortunately, the "confusing" code of slub.c that unnecessarily uses
the __builtin_constant_p() will fail to compile if the variable passed
in is not constant. As Clang will say constants are not constant at this
point, the compile fails.

When looking into this, we found the only two users of the index_of()
static function that has this issue, passes in size_of(), which will
always be a constant, making the check redundant.

Note, this is a bug in Clang that will hopefully be fixed soon. But for
now, this strange redundant compile time check is preventing Clang from
even testing the Linux kernel build.
</little birdie voice>

And I still think the original change log has rational for the change,
as it does make it rather confusing to what is happening there.

-- Steve



--
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	[flat|nested] 22+ messages in thread

* Re: [PATCH] slab: Remove unnecessary __builtin_constant_p()
  2013-04-22 20:58       ` Steven Rostedt
@ 2013-04-22 21:16         ` Andrew Morton
  -1 siblings, 0 replies; 22+ messages in thread
From: Andrew Morton @ 2013-04-22 21:16 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: David Rientjes, Pekka Enberg, LKML, linux-mm, Christoph Lameter,
	Behan Webster

On Mon, 22 Apr 2013 16:58:21 -0400 Steven Rostedt <rostedt@goodmis.org> wrote:

> On Mon, 2013-04-22 at 13:44 -0700, Andrew Morton wrote:
> > On Wed, 17 Apr 2013 17:03:21 -0700 (PDT) David Rientjes <rientjes@google.com> wrote:
> > 
> > > On Wed, 17 Apr 2013, Steven Rostedt wrote:
> > > 
> > > > 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>
> > > 
> > > Acked-by: David Rientjes <rientjes@google.com>
> > > 
> > > Adding Pekka to the cc.
> > 
> > I ducked this patch because it seemed rather pointless - but a little
> > birdie told me that there is a secret motivation which seems pretty
> > reasonable to me.  So I shall await chirp-the-second, which hopefully
> > will have a fuller and franker changelog ;)
> 
> <little birdie voice>
> The real motivation behind this patch was it prevents LLVM (Clang) from
> compiling the kernel. There's currently a bug in Clang where it can't
> determine if a variable is constant or not, so instead, when
> __builtin_constant_p() is used, it just treats it like it isn't a
> constant (always taking the slow *safe* path).
> 
> Unfortunately, the "confusing" code of slub.c that unnecessarily uses
> the __builtin_constant_p() will fail to compile if the variable passed
> in is not constant. As Clang will say constants are not constant at this
> point, the compile fails.
> 
> When looking into this, we found the only two users of the index_of()
> static function that has this issue, passes in size_of(), which will
> always be a constant, making the check redundant.

Looking at the current callers is cheating.  What happens if someone
adds another caller which doesn't use sizeof?

> Note, this is a bug in Clang that will hopefully be fixed soon. But for
> now, this strange redundant compile time check is preventing Clang from
> even testing the Linux kernel build.
> </little birdie voice>
> 
> And I still think the original change log has rational for the change,
> as it does make it rather confusing to what is happening there.

The patch made index_of() weaker!

It's probably all a bit academic, given that linux-next does

-/*
- * This function must be completely optimized away if a constant is passed to
- * it.  Mostly the same as what is in linux/slab.h except it returns an index.
- */
-static __always_inline int index_of(const size_t size)
-{
-	extern void __bad_size(void);
-
-	if (__builtin_constant_p(size)) {
-		int i = 0;
-
-#define CACHE(x) \
-	if (size <=x) \
-		return i; \
-	else \
-		i++;
-#include <linux/kmalloc_sizes.h>
-#undef CACHE
-		__bad_size();
-	} else
-		__bad_size();
-	return 0;
-}
-


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

* Re: [PATCH] slab: Remove unnecessary __builtin_constant_p()
@ 2013-04-22 21:16         ` Andrew Morton
  0 siblings, 0 replies; 22+ messages in thread
From: Andrew Morton @ 2013-04-22 21:16 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: David Rientjes, Pekka Enberg, LKML, linux-mm, Christoph Lameter,
	Behan Webster

On Mon, 22 Apr 2013 16:58:21 -0400 Steven Rostedt <rostedt@goodmis.org> wrote:

> On Mon, 2013-04-22 at 13:44 -0700, Andrew Morton wrote:
> > On Wed, 17 Apr 2013 17:03:21 -0700 (PDT) David Rientjes <rientjes@google.com> wrote:
> > 
> > > On Wed, 17 Apr 2013, Steven Rostedt wrote:
> > > 
> > > > 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>
> > > 
> > > Acked-by: David Rientjes <rientjes@google.com>
> > > 
> > > Adding Pekka to the cc.
> > 
> > I ducked this patch because it seemed rather pointless - but a little
> > birdie told me that there is a secret motivation which seems pretty
> > reasonable to me.  So I shall await chirp-the-second, which hopefully
> > will have a fuller and franker changelog ;)
> 
> <little birdie voice>
> The real motivation behind this patch was it prevents LLVM (Clang) from
> compiling the kernel. There's currently a bug in Clang where it can't
> determine if a variable is constant or not, so instead, when
> __builtin_constant_p() is used, it just treats it like it isn't a
> constant (always taking the slow *safe* path).
> 
> Unfortunately, the "confusing" code of slub.c that unnecessarily uses
> the __builtin_constant_p() will fail to compile if the variable passed
> in is not constant. As Clang will say constants are not constant at this
> point, the compile fails.
> 
> When looking into this, we found the only two users of the index_of()
> static function that has this issue, passes in size_of(), which will
> always be a constant, making the check redundant.

Looking at the current callers is cheating.  What happens if someone
adds another caller which doesn't use sizeof?

> Note, this is a bug in Clang that will hopefully be fixed soon. But for
> now, this strange redundant compile time check is preventing Clang from
> even testing the Linux kernel build.
> </little birdie voice>
> 
> And I still think the original change log has rational for the change,
> as it does make it rather confusing to what is happening there.

The patch made index_of() weaker!

It's probably all a bit academic, given that linux-next does

-/*
- * This function must be completely optimized away if a constant is passed to
- * it.  Mostly the same as what is in linux/slab.h except it returns an index.
- */
-static __always_inline int index_of(const size_t size)
-{
-	extern void __bad_size(void);
-
-	if (__builtin_constant_p(size)) {
-		int i = 0;
-
-#define CACHE(x) \
-	if (size <=x) \
-		return i; \
-	else \
-		i++;
-#include <linux/kmalloc_sizes.h>
-#undef CACHE
-		__bad_size();
-	} else
-		__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	[flat|nested] 22+ messages in thread

* Re: [PATCH] slab: Remove unnecessary __builtin_constant_p()
  2013-04-22 21:16         ` Andrew Morton
@ 2013-04-22 23:15           ` Steven Rostedt
  -1 siblings, 0 replies; 22+ messages in thread
From: Steven Rostedt @ 2013-04-22 23:15 UTC (permalink / raw)
  To: Andrew Morton
  Cc: David Rientjes, Pekka Enberg, LKML, linux-mm, Christoph Lameter,
	Behan Webster

On Mon, 2013-04-22 at 14:16 -0700, Andrew Morton wrote:
> On Mon, 22 Apr 2013 16:58:21 -0400 Steven Rostedt <rostedt@goodmis.org> wrote:

> > When looking into this, we found the only two users of the index_of()
> > static function that has this issue, passes in size_of(), which will
> > always be a constant, making the check redundant.
> 
> Looking at the current callers is cheating.  What happens if someone
> adds another caller which doesn't use sizeof?

Well, as it required a size of something, if it was dynamic then what
would the size be of?

> 
> > Note, this is a bug in Clang that will hopefully be fixed soon. But for
> > now, this strange redundant compile time check is preventing Clang from
> > even testing the Linux kernel build.
> > </little birdie voice>
> > 
> > And I still think the original change log has rational for the change,
> > as it does make it rather confusing to what is happening there.
> 
> The patch made index_of() weaker!
> 
> It's probably all a bit academic, given that linux-next does
> 
> -/*
> - * This function must be completely optimized away if a constant is passed to
> - * it.  Mostly the same as what is in linux/slab.h except it returns an index.
> - */
> -static __always_inline int index_of(const size_t size)
> -{
> -	extern void __bad_size(void);
> -
> -	if (__builtin_constant_p(size)) {
> -		int i = 0;
> -
> -#define CACHE(x) \
> -	if (size <=x) \
> -		return i; \
> -	else \
> -		i++;
> -#include <linux/kmalloc_sizes.h>
> -#undef CACHE
> -		__bad_size();
> -	} else
> -		__bad_size();
> -	return 0;
> -}
> -

Looks like someone just ate the bird.

-- Steve



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

* Re: [PATCH] slab: Remove unnecessary __builtin_constant_p()
@ 2013-04-22 23:15           ` Steven Rostedt
  0 siblings, 0 replies; 22+ messages in thread
From: Steven Rostedt @ 2013-04-22 23:15 UTC (permalink / raw)
  To: Andrew Morton
  Cc: David Rientjes, Pekka Enberg, LKML, linux-mm, Christoph Lameter,
	Behan Webster

On Mon, 2013-04-22 at 14:16 -0700, Andrew Morton wrote:
> On Mon, 22 Apr 2013 16:58:21 -0400 Steven Rostedt <rostedt@goodmis.org> wrote:

> > When looking into this, we found the only two users of the index_of()
> > static function that has this issue, passes in size_of(), which will
> > always be a constant, making the check redundant.
> 
> Looking at the current callers is cheating.  What happens if someone
> adds another caller which doesn't use sizeof?

Well, as it required a size of something, if it was dynamic then what
would the size be of?

> 
> > Note, this is a bug in Clang that will hopefully be fixed soon. But for
> > now, this strange redundant compile time check is preventing Clang from
> > even testing the Linux kernel build.
> > </little birdie voice>
> > 
> > And I still think the original change log has rational for the change,
> > as it does make it rather confusing to what is happening there.
> 
> The patch made index_of() weaker!
> 
> It's probably all a bit academic, given that linux-next does
> 
> -/*
> - * This function must be completely optimized away if a constant is passed to
> - * it.  Mostly the same as what is in linux/slab.h except it returns an index.
> - */
> -static __always_inline int index_of(const size_t size)
> -{
> -	extern void __bad_size(void);
> -
> -	if (__builtin_constant_p(size)) {
> -		int i = 0;
> -
> -#define CACHE(x) \
> -	if (size <=x) \
> -		return i; \
> -	else \
> -		i++;
> -#include <linux/kmalloc_sizes.h>
> -#undef CACHE
> -		__bad_size();
> -	} else
> -		__bad_size();
> -	return 0;
> -}
> -

Looks like someone just ate the bird.

-- Steve


--
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	[flat|nested] 22+ messages in thread

* Re: [PATCH] slab: Remove unnecessary __builtin_constant_p()
  2013-04-22 20:58       ` Steven Rostedt
@ 2013-04-23  5:06         ` Behan Webster
  -1 siblings, 0 replies; 22+ messages in thread
From: Behan Webster @ 2013-04-23  5:06 UTC (permalink / raw)
  To: LKML
  Cc: Steven Rostedt, Andrew Morton, David Rientjes, Pekka Enberg,
	linux-mm, Christoph Lameter

On 13-04-22 03:58 PM, Steven Rostedt wrote:
> On Mon, 2013-04-22 at 13:44 -0700, Andrew Morton wrote:
>> On Wed, 17 Apr 2013 17:03:21 -0700 (PDT) David Rientjes <rientjes@google.com> wrote:
>>
>>> On Wed, 17 Apr 2013, Steven Rostedt wrote:
>>>
>>>> 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>
>>> Acked-by: David Rientjes <rientjes@google.com>
>>>
>>> Adding Pekka to the cc.
>> I ducked this patch because it seemed rather pointless - but a little
>> birdie told me that there is a secret motivation which seems pretty
>> reasonable to me.  So I shall await chirp-the-second, which hopefully
>> will have a fuller and franker changelog ;)
> <little birdie voice>
> The real motivation behind this patch was it prevents LLVM (Clang) from
> compiling the kernel. There's currently a bug in Clang where it can't
> determine if a variable is constant or not, so instead, when
> __builtin_constant_p() is used, it just treats it like it isn't a
> constant (always taking the slow *safe* path).
>
> Unfortunately, the "confusing" code of slub.c that unnecessarily uses
> the __builtin_constant_p() will fail to compile if the variable passed
> in is not constant. As Clang will say constants are not constant at this
> point, the compile fails.
>
> When looking into this, we found the only two users of the index_of()
> static function that has this issue, passes in size_of(), which will
> always be a constant, making the check redundant.
>
> Note, this is a bug in Clang that will hopefully be fixed soon. But for
> now, this strange redundant compile time check is preventing Clang from
> even testing the Linux kernel build.
> </little birdie voice>
>
> And I still think the original change log has rational for the change,
> as it does make it rather confusing to what is happening there.
>
> -- Steve
Just to pipe up since Steve was helping me out with this patch.

I just want to make it clear that in no way am I trying to sneak any 
code into the kernel in order to merely support Clang (certainly the 
motivation for the patch wasn't meant to be a secret). That in this case 
the code might be considered clearer at the same time as enabling Clang 
to be used to compile this portion of code seemed to be a win-win 
situation to me.

I certainly thank Steve, Christoph and Andrew for their support in 
principle in this particular matter (not that it is yet a done deal). I 
merely complained about this particular issue at my talk at the recent 
Collab Summit and Steve jumped in to follow up with this particular 
solution as well as connecting up myself with the three of them (all of 
us being in the same hotel in San Francisco at the same time). My god 
Steve works fast! It made my head spin.

My motivation (as a part of the LLVMLinux project) is purely to provide 
another choice of toolchain to the kernel developer and system 
integrator, some of whom would like the choice of using (or at least 
trying) Clang. I certainly do not intentionally want to negatively 
impact the performance nor code quality of the kernel code base to the 
best of my ability (quite the opposite actually).

I think I can safely say that the competition between the 2 toolchains 
has already made both even stronger than they were previously (certainly 
gcc 4.8 and the upcoming LLVM/Clang 3.3 seem to be the best either have 
ever been).

As far as __builtin_constant_p() in clang goes, it gets it right in many 
places (i.e. agrees with how gcc evaluates it), but in this particular 
situation it got it wrong. However, in this case I was having troubles 
understanding why __builtin_constant_p() was being used the way it was 
in slab.c at all...

Behan

-- 
Behan Webster
behanw@converseincode.com


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

* Re: [PATCH] slab: Remove unnecessary __builtin_constant_p()
@ 2013-04-23  5:06         ` Behan Webster
  0 siblings, 0 replies; 22+ messages in thread
From: Behan Webster @ 2013-04-23  5:06 UTC (permalink / raw)
  To: LKML
  Cc: Steven Rostedt, Andrew Morton, David Rientjes, Pekka Enberg,
	linux-mm, Christoph Lameter

On 13-04-22 03:58 PM, Steven Rostedt wrote:
> On Mon, 2013-04-22 at 13:44 -0700, Andrew Morton wrote:
>> On Wed, 17 Apr 2013 17:03:21 -0700 (PDT) David Rientjes <rientjes@google.com> wrote:
>>
>>> On Wed, 17 Apr 2013, Steven Rostedt wrote:
>>>
>>>> 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>
>>> Acked-by: David Rientjes <rientjes@google.com>
>>>
>>> Adding Pekka to the cc.
>> I ducked this patch because it seemed rather pointless - but a little
>> birdie told me that there is a secret motivation which seems pretty
>> reasonable to me.  So I shall await chirp-the-second, which hopefully
>> will have a fuller and franker changelog ;)
> <little birdie voice>
> The real motivation behind this patch was it prevents LLVM (Clang) from
> compiling the kernel. There's currently a bug in Clang where it can't
> determine if a variable is constant or not, so instead, when
> __builtin_constant_p() is used, it just treats it like it isn't a
> constant (always taking the slow *safe* path).
>
> Unfortunately, the "confusing" code of slub.c that unnecessarily uses
> the __builtin_constant_p() will fail to compile if the variable passed
> in is not constant. As Clang will say constants are not constant at this
> point, the compile fails.
>
> When looking into this, we found the only two users of the index_of()
> static function that has this issue, passes in size_of(), which will
> always be a constant, making the check redundant.
>
> Note, this is a bug in Clang that will hopefully be fixed soon. But for
> now, this strange redundant compile time check is preventing Clang from
> even testing the Linux kernel build.
> </little birdie voice>
>
> And I still think the original change log has rational for the change,
> as it does make it rather confusing to what is happening there.
>
> -- Steve
Just to pipe up since Steve was helping me out with this patch.

I just want to make it clear that in no way am I trying to sneak any 
code into the kernel in order to merely support Clang (certainly the 
motivation for the patch wasn't meant to be a secret). That in this case 
the code might be considered clearer at the same time as enabling Clang 
to be used to compile this portion of code seemed to be a win-win 
situation to me.

I certainly thank Steve, Christoph and Andrew for their support in 
principle in this particular matter (not that it is yet a done deal). I 
merely complained about this particular issue at my talk at the recent 
Collab Summit and Steve jumped in to follow up with this particular 
solution as well as connecting up myself with the three of them (all of 
us being in the same hotel in San Francisco at the same time). My god 
Steve works fast! It made my head spin.

My motivation (as a part of the LLVMLinux project) is purely to provide 
another choice of toolchain to the kernel developer and system 
integrator, some of whom would like the choice of using (or at least 
trying) Clang. I certainly do not intentionally want to negatively 
impact the performance nor code quality of the kernel code base to the 
best of my ability (quite the opposite actually).

I think I can safely say that the competition between the 2 toolchains 
has already made both even stronger than they were previously (certainly 
gcc 4.8 and the upcoming LLVM/Clang 3.3 seem to be the best either have 
ever been).

As far as __builtin_constant_p() in clang goes, it gets it right in many 
places (i.e. agrees with how gcc evaluates it), but in this particular 
situation it got it wrong. However, in this case I was having troubles 
understanding why __builtin_constant_p() was being used the way it was 
in slab.c at all...

Behan

-- 
Behan Webster
behanw@converseincode.com

--
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	[flat|nested] 22+ messages in thread

* Re: [PATCH] slab: Remove unnecessary __builtin_constant_p()
  2013-04-22 21:16         ` Andrew Morton
@ 2013-04-24  7:31           ` Pekka Enberg
  -1 siblings, 0 replies; 22+ messages in thread
From: Pekka Enberg @ 2013-04-24  7:31 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Steven Rostedt, David Rientjes, LKML, linux-mm,
	Christoph Lameter, Behan Webster

Hello,

On Tue, Apr 23, 2013 at 12:16 AM, Andrew Morton
<akpm@linux-foundation.org> wrote:
> The patch made index_of() weaker!
>
> It's probably all a bit academic, given that linux-next does
>
> -/*
> - * This function must be completely optimized away if a constant is passed to
> - * it.  Mostly the same as what is in linux/slab.h except it returns an index.
> - */
> -static __always_inline int index_of(const size_t size)
> -{
> -       extern void __bad_size(void);
> -
> -       if (__builtin_constant_p(size)) {
> -               int i = 0;
> -
> -#define CACHE(x) \
> -       if (size <=x) \
> -               return i; \
> -       else \
> -               i++;
> -#include <linux/kmalloc_sizes.h>
> -#undef CACHE
> -               __bad_size();
> -       } else
> -               __bad_size();
> -       return 0;
> -}
> -

Yup, Christoph nuked it in the following commit:

https://git.kernel.org/cgit/linux/kernel/git/penberg/linux.git/commit/?h=slab/next&id=2c59dd6544212faa5ce761920d2251f4152f408d

                        Pekka

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

* Re: [PATCH] slab: Remove unnecessary __builtin_constant_p()
@ 2013-04-24  7:31           ` Pekka Enberg
  0 siblings, 0 replies; 22+ messages in thread
From: Pekka Enberg @ 2013-04-24  7:31 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Steven Rostedt, David Rientjes, LKML, linux-mm,
	Christoph Lameter, Behan Webster

Hello,

On Tue, Apr 23, 2013 at 12:16 AM, Andrew Morton
<akpm@linux-foundation.org> wrote:
> The patch made index_of() weaker!
>
> It's probably all a bit academic, given that linux-next does
>
> -/*
> - * This function must be completely optimized away if a constant is passed to
> - * it.  Mostly the same as what is in linux/slab.h except it returns an index.
> - */
> -static __always_inline int index_of(const size_t size)
> -{
> -       extern void __bad_size(void);
> -
> -       if (__builtin_constant_p(size)) {
> -               int i = 0;
> -
> -#define CACHE(x) \
> -       if (size <=x) \
> -               return i; \
> -       else \
> -               i++;
> -#include <linux/kmalloc_sizes.h>
> -#undef CACHE
> -               __bad_size();
> -       } else
> -               __bad_size();
> -       return 0;
> -}
> -

Yup, Christoph nuked it in the following commit:

https://git.kernel.org/cgit/linux/kernel/git/penberg/linux.git/commit/?h=slab/next&id=2c59dd6544212faa5ce761920d2251f4152f408d

                        Pekka

--
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	[flat|nested] 22+ messages in thread

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

Thread overview: 22+ 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-17 19:09 ` Steven Rostedt
2013-04-18  0:03 ` David Rientjes
2013-04-18  0:03   ` David Rientjes
2013-04-22 20:44   ` Andrew Morton
2013-04-22 20:44     ` Andrew Morton
2013-04-22 20:58     ` Steven Rostedt
2013-04-22 20:58       ` Steven Rostedt
2013-04-22 21:16       ` Andrew Morton
2013-04-22 21:16         ` Andrew Morton
2013-04-22 23:15         ` Steven Rostedt
2013-04-22 23:15           ` Steven Rostedt
2013-04-24  7:31         ` Pekka Enberg
2013-04-24  7:31           ` Pekka Enberg
2013-04-23  5:06       ` Behan Webster
2013-04-23  5:06         ` Behan Webster
2013-04-18  0:15 ` Will Huck
2013-04-18  0:15   ` Will Huck
2013-04-18  0:32   ` David Rientjes
2013-04-18  0:32     ` David Rientjes
2013-04-18 10:24     ` Borislav Petkov
2013-04-18 10:24       ` Borislav Petkov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.