Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Dec 2013 11:45:47 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-current@freebsd.org
Cc:        Luigi Rizzo <rizzo@iet.unipi.it>, current@freebsd.org
Subject:   Re: RFC can we use __builtin_prefetch() directly in our kernel sources ?
Message-ID:  <201312231145.47679.jhb@freebsd.org>
In-Reply-To: <20131216165014.GA15126@onelab2.iet.unipi.it>
References:  <20131216165014.GA15126@onelab2.iet.unipi.it>

next in thread | previous in thread | raw e-mail | index | archive | help
On Monday, December 16, 2013 11:50:14 am Luigi Rizzo wrote:
> Is it ok in kernel code to use __builtin_prefetch() and assume that
> all supported compilers will do the right thing for all architectures ?
> 
> I am asking is because I need to use prefetch() in a small number
> of places in my netmap code, and nothing in our kernel sources uses
> __builtin_prefetch() directly.  In the (very few, mostly 10G drivers)
> cases where prefetch() is used the drivers redefine the function
> themselves as some inline asm() or an empty
> 
> 	#define prefetch(x)
> 
> This also happens in many places in the linux kernel, for what matters
> (relevant because hte netmap kernel code also needs to compile there).
> 
> Anyways, so far in the netmap code i have followed the established
> practice but my (re)definition of prefetch() in netmap_kern.h
> clashes with some in the individual drivers, so I'd rather
> find a better way.

Hmmmm, have you considered using a 'netmap_prefetch' macro or the like?  You 
can likely just use __builtin_prefetch() on FreeBSD I think, but that might
also let you avoid collisions on Linux as well.  I think you can use 
__builtin_prefetch(), I'm just not sure, and it's kind of ugly to see 
__builtin_*() in code directly IMHO.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201312231145.47679.jhb>