提交 4ecbca85 编写于 作者: S Serge Belyshev 提交者: Linus Torvalds

Remove unnecessary cast in prefetch()

It is ok to call prefetch() function with NULL argument, as specifically
commented in include/linux/prefetch.h.  But in standard C, it is invalid
to dereference NULL pointer (see C99 standard 6.5.3.2 paragraph 4 and
note #84).

prefetch() has a memory reference for its argument.

Newer gcc versions (4.3 and above) will use that to conclude that "x"
argument is non-null and thus wreaking havok everywhere prefetch() was
inlined.

Fixed by removing cast and changing asm constraint.

[ It seems in theory gcc 4.2 could miscompile this too; although no
  cases known.  In 2.6.24 we should probably switch to
  __builtin_prefetch() instead, but this is a simpler fix for now.
				-- AK ]
Signed-off-by: NSerge Belyshev <belyshev@depni.sinp.msu.ru>
Signed-off-by: NAndi Kleen <ak@suse.de>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 9cdcaa2c
...@@ -371,7 +371,7 @@ static inline void sync_core(void) ...@@ -371,7 +371,7 @@ static inline void sync_core(void)
#define ARCH_HAS_PREFETCH #define ARCH_HAS_PREFETCH
static inline void prefetch(void *x) static inline void prefetch(void *x)
{ {
asm volatile("prefetcht0 %0" :: "m" (*(unsigned long *)x)); asm volatile("prefetcht0 (%0)" :: "r" (x));
} }
#define ARCH_HAS_PREFETCHW 1 #define ARCH_HAS_PREFETCHW 1
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册