From: Jay Vosburgh <jay.vosburgh@canonical.com>
To: Hannes Frederic Sowa <hannes@stressinduktion.org>
Cc: netdev@vger.kernel.org, ogerlitz@mellanox.com,
pshelar@nicira.com, jesse@nicira.com, discuss@openvswitch.org
Subject: Re: [PATCH net-next v3] fast_hash: clobber registers correctly for inline function use
Date: Fri, 14 Nov 2014 09:57:27 -0800 [thread overview]
Message-ID: <15618.1415987847@famine> (raw)
In-Reply-To: <6751d6af4301f283134a419385f65dfcf92a44ab.1415978153.git.hannes@stressinduktion.org>
Hannes Frederic Sowa <hannes@stressinduktion.org> wrote:
>In case the arch_fast_hash call gets inlined we need to tell gcc which
>registers are clobbered with. rhashtable was fine, because it used
>arch_fast_hash via function pointer and thus the compiler took care of
>that. In case of openvswitch the call got inlined and arch_fast_hash
>touched registeres which gcc didn't know about.
>
>Also don't use conditional compilation inside arguments, as this confuses
>sparse.
>
>Fixes: e5a2c899957659c ("fast_hash: avoid indirect function calls")
>Reported-by: Jay Vosburgh <jay.vosburgh@canonical.com>
>Cc: Pravin Shelar <pshelar@nicira.com>
>Cc: Jesse Gross <jesse@nicira.com>
>Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
>---
>
>
>v2)
>After studying gcc documentation again, it occured to me that I need to
>specificy all input operands in the clobber section, too. Otherwise gcc
>can expect that the inline assembler section won't modify the inputs,
>which is not true.
>
>v3)
>added Fixes tag
This patch does not compile for me when applied to today's
net-next:
CC [M] fs/nfsd/nfs4state.o
In file included from ./arch/x86/include/asm/bitops.h:16:0,
from include/linux/bitops.h:33,
from include/linux/kernel.h:10,
from include/linux/list.h:8,
from include/linux/wait.h:6,
from include/linux/fs.h:6,
from fs/nfsd/nfs4state.c:36:
fs/nfsd/nfs4state.c: In function ‘nfsd4_cb_recall_prepare’:
./arch/x86/include/asm/alternative.h:185:2: error: ‘asm’ operand has impossible constraints
asm volatile (ALTERNATIVE("call %P[old]", "call %P[new]", feature) \
^
./arch/x86/include/asm/hash.h:27:2: note: in expansion of macro ‘alternative_call’
alternative_call(__jhash, __intel_crc4_2_hash, X86_FEATURE_XMM4_2,
^
make[2]: *** [fs/nfsd/nfs4state.o] Error 1
make[1]: *** [fs/nfsd] Error 2
make: *** [fs] Error 2
-J
>Bye,
>Hannes
>
> arch/x86/include/asm/hash.h | 20 ++++++++++++++------
> 1 file changed, 14 insertions(+), 6 deletions(-)
>
>diff --git a/arch/x86/include/asm/hash.h b/arch/x86/include/asm/hash.h
>index a881d78..a25c45a 100644
>--- a/arch/x86/include/asm/hash.h
>+++ b/arch/x86/include/asm/hash.h
>@@ -23,11 +23,15 @@ static inline u32 arch_fast_hash(const void *data, u32 len, u32 seed)
> {
> u32 hash;
>
>- alternative_call(__jhash, __intel_crc4_2_hash, X86_FEATURE_XMM4_2,
> #ifdef CONFIG_X86_64
>- "=a" (hash), "D" (data), "S" (len), "d" (seed));
>+ alternative_call(__jhash, __intel_crc4_2_hash, X86_FEATURE_XMM4_2,
>+ "=a" (hash), "D" (data), "S" (len), "d" (seed)
>+ : "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r10", "r11",
>+ "cc", "memory");
> #else
>- "=a" (hash), "a" (data), "d" (len), "c" (seed));
>+ alternative_call(__jhash, __intel_crc4_2_hash, X86_FEATURE_XMM4_2,
>+ "=a" (hash), "a" (data), "d" (len), "c" (seed)
>+ : "edx", "ecx", "cc", "memory");
> #endif
> return hash;
> }
>@@ -36,11 +40,15 @@ static inline u32 arch_fast_hash2(const u32 *data, u32 len, u32 seed)
> {
> u32 hash;
>
>- alternative_call(__jhash2, __intel_crc4_2_hash2, X86_FEATURE_XMM4_2,
> #ifdef CONFIG_X86_64
>- "=a" (hash), "D" (data), "S" (len), "d" (seed));
>+ alternative_call(__jhash2, __intel_crc4_2_hash2, X86_FEATURE_XMM4_2,
>+ "=a" (hash), "D" (data), "S" (len), "d" (seed)
>+ : "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r10", "r11",
>+ "cc", "memory");
> #else
>- "=a" (hash), "a" (data), "d" (len), "c" (seed));
>+ alternative_call(__jhash2, __intel_crc4_2_hash2, X86_FEATURE_XMM4_2,
>+ "=a" (hash), "a" (data), "d" (len), "c" (seed)
>+ : "edx", "ecx", "cc", "memory");
> #endif
> return hash;
> }
>--
>1.9.3
---
-Jay Vosburgh, jay.vosburgh@canonical.com
prev parent reply other threads:[~2014-11-14 17:57 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
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 [this message]
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=15618.1415987847@famine \
--to=jay.vosburgh@canonical.com \
--cc=discuss@openvswitch.org \
--cc=hannes@stressinduktion.org \
--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).