linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: David Rientjes <rientjes@google.com>,
	Pekka Enberg <penberg@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-mm@kvack.org, Christoph Lameter <cl@linux.com>,
	Behan Webster <behanw@converseincode.com>
Subject: Re: [PATCH] slab: Remove unnecessary __builtin_constant_p()
Date: Mon, 22 Apr 2013 19:15:18 -0400	[thread overview]
Message-ID: <1366672518.9609.142.camel@gandalf.local.home> (raw)
In-Reply-To: <20130422141621.384eb93a6a8f3d441cd1a991@linux-foundation.org>

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>

  reply	other threads:[~2013-04-22 23:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-17 19:09 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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1366672518.9609.142.camel@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=behanw@converseincode.com \
    --cc=cl@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox