From: Hannes Frederic Sowa <hannes@stressinduktion.org>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: netdev@vger.kernel.org, ogerlitz@mellanox.com,
pshelar@nicira.com, jesse@nicira.com, jay.vosburgh@canonical.com,
discuss@openvswitch.org
Subject: Re: [PATCH net-next] fast_hash: clobber registers correctly for inline function use
Date: Fri, 14 Nov 2014 16:46:18 +0100 [thread overview]
Message-ID: <1415979978.15154.41.camel@localhost> (raw)
In-Reply-To: <1415979181.17262.45.camel@edumazet-glaptop2.roam.corp.google.com>
On Fr, 2014-11-14 at 07:33 -0800, Eric Dumazet wrote:
> On Fri, 2014-11-14 at 16:13 +0100, Hannes Frederic Sowa wrote:
> > >
> > >
> > > Thats a lot of clobbers.
> >
> > Yes, those are basically all callee-clobbered registers for the
> > particular architecture. I didn't look at the generated code for jhash
> > and crc_hash because I want this code to always be safe, independent of
> > the version and optimization levels of gcc.
> >
> > > Alternative would be to use an assembly trampoline to save/restore them
> > > before calling __jhash2
> >
> > This version provides the best hints on how to allocate registers to the
> > optimizers. E.g. it could avoid using callee-clobbered registers but use
> > callee-saved ones. If we build a trampoline, we need to save and reload
> > all registers all the time. This version just lets gcc decide how to do
> > that.
> >
> > > __intel_crc4_2_hash2 can probably be written in assembly, it is quite
> > > simple.
> >
> > Sure, but all the pre and postconditions must hold for both, jhash and
> > intel_crc4_2_hash and I don't want to rewrite jhash in assembler.
>
> We write optimized code for current cpus.
>
> With current generation of cpus, we have crc32 support.
__intel_crc4_2_hash(2) does already make use of crc32 instruction. I'll
have a closer look at what gcc generates.
> The fallback having to save/restore few registers, we don't care, as the
> fallback has huge cost anyway.
>
> You don't have to write jhash() in assembler, you misunderstood me.
Ok, understood, so we only clobber the registers needed in the
crc32_hash implementation and only if we branch to jhash we save all the
other ones in a trampoline directly before jhash.
> We only have to provide a trampoline in assembler, with maybe 10
> instructions.
>
> Then gcc will know that we do not clobber registers for the optimized
> case.
Yes, makes sense.
I would still like to see the current proposed fix getting applied and
we can do this on-top. The inline call after this patch reassembles a
direct function call, so besides the long list of clobbers, it should
still be pretty fast.
Thanks,
Hannes
next prev parent reply other threads:[~2014-11-14 15:46 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-14 14:06 [PATCH net-next] fast_hash: clobber registers correctly for inline function use Hannes Frederic Sowa
2014-11-14 14:40 ` [PATCH net-next v2] " Hannes Frederic Sowa
2014-11-14 14:50 ` [PATCH net-next] " Eric Dumazet
2014-11-14 15:13 ` Hannes Frederic Sowa
2014-11-14 15:33 ` Eric Dumazet
2014-11-14 15:46 ` Hannes Frederic Sowa [this message]
2014-11-14 18:38 ` David Miller
2014-11-14 19:02 ` Cong Wang
2014-11-14 20:42 ` Hannes Frederic Sowa
2014-11-14 21:35 ` David Miller
2014-11-14 19:05 ` [PATCH net-next] Revert "fast_hash: avoid indirect function calls" Jay Vosburgh
2014-11-14 21:36 ` David Miller
2014-11-14 21:43 ` Hannes Frederic Sowa
2014-11-14 20:04 ` [PATCH net-next] fast_hash: clobber registers correctly for inline function use Hannes Frederic Sowa
2014-11-14 20:10 ` Hannes Frederic Sowa
2014-11-14 20:15 ` Jay Vosburgh
2014-11-14 20:35 ` Hannes Frederic Sowa
2014-11-14 22:10 ` Jay Vosburgh
2014-11-14 22:37 ` Hannes Frederic Sowa
2014-11-14 15:17 ` [PATCH net-next v3] " Hannes Frederic Sowa
2014-11-14 17:57 ` Jay Vosburgh
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=1415979978.15154.41.camel@localhost \
--to=hannes@stressinduktion.org \
--cc=discuss@openvswitch.org \
--cc=eric.dumazet@gmail.com \
--cc=jay.vosburgh@canonical.com \
--cc=jesse@nicira.com \
--cc=netdev@vger.kernel.org \
--cc=ogerlitz@mellanox.com \
--cc=pshelar@nicira.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).