netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Hagen Paul Pfeifer <hagen@jauu.net>
Cc: David Miller <davem@davemloft.net>, tom <tom@herbertland.com>,
	herbert <herbert@gondor.apana.org.au>, tgraf <tgraf@suug.ch>,
	netdev <netdev@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	dvlasenk <dvlasenk@redhat.com>,
	"alexander.h.duyck" <alexander.h.duyck@redhat.com>,
	kadlec <kadlec@blackhole.kfki.hu>
Subject: Re: [PATCH v2] jhash: Deinline jhash, jhash2 and __jhash_nwords
Date: Fri, 17 Jul 2015 15:53:59 -0700	[thread overview]
Message-ID: <1437173639.2495.74.camel@perches.com> (raw)
In-Reply-To: <2035533471.2349.1437140685694.JavaMail.open-xchange@ox1app>

On Fri, 2015-07-17 at 15:44 +0200, Hagen Paul Pfeifer wrote:
> > On July 16, 2015 at 9:23 PM Joe Perches <joe@perches.com> wrote:
> > 
> > It might be useful to have these performance impacting
> > changes guarded by something like CONFIG_CC_OPTIMIZE_FOR_SIZE
> > with another static __always_inline __<func> and a function &
> > EXPORT_SYMBOL or just a static inline so that where code size
> > is critical it's uninlined.
> 
> But keep in mind that jhash, jhash2 and __jhash_nwords are *not*
> one-instruction long functions. We duplicate code over and over resulting
> probably in more cache misses. __always_inline__ is probably too strict
> and a vanilla inline is already for 99% of all distribution builds a
>  __always_inline__, see ARCH_SUPPORTS_OPTIMIZED_INLINING and
> CONFIG_CC_OPTIMIZE_FOR_SIZE.

Hello.

Perhaps I wasn't clear/explicit enough.

I tried to suggest using a single __always_inline like this:

Two #ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE (or some other
CONFIG_FOO) functions, one in a .h for the existing behavior
and another in a .c for more code space compact uses.

jhash.h

static __always_inline u32 __jhash(const void *key, u32 length, u32 initval)
{
	[current jhash implementation...]
}

#ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
u32 jhash(const void *key, u32 length, u32 initval);
#else
static inline u32 jhash(const void *key, u32 length, u32 initval)
{
	return __jhash(key, length, initval);	
}
#endif

jhash.c:

#ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
u32 jhash(const void *key, u32 length, u32 initval)
{
	return __jhash(key, length, initval);	
}
EXPORT_SYMBOL(jhash)
#endif

etc...

Perhaps the additional code complexity is not worth it.

  reply	other threads:[~2015-07-17 22:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-16 12:40 [PATCH v2] jhash: Deinline jhash, jhash2 and __jhash_nwords Denys Vlasenko
2015-07-16 14:26 ` Alexander Duyck
2015-07-16 15:43 ` Tom Herbert
2015-07-16 18:17   ` David Miller
2015-07-16 19:23     ` Joe Perches
2015-07-17 13:44       ` Hagen Paul Pfeifer
2015-07-17 22:53         ` Joe Perches [this message]
2015-07-19 15:14     ` Denys Vlasenko
2015-07-19 18:40       ` David Miller

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=1437173639.2495.74.camel@perches.com \
    --to=joe@perches.com \
    --cc=alexander.h.duyck@redhat.com \
    --cc=davem@davemloft.net \
    --cc=dvlasenk@redhat.com \
    --cc=hagen@jauu.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=kadlec@blackhole.kfki.hu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tgraf@suug.ch \
    --cc=tom@herbertland.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;
as well as URLs for NNTP newsgroup(s).