From owner-freebsd-current@FreeBSD.ORG Mon Dec 23 19:43:52 2013 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 865684A1; Mon, 23 Dec 2013 19:43:52 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 5EFCE190B; Mon, 23 Dec 2013 19:43:52 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 51C52B968; Mon, 23 Dec 2013 14:43:51 -0500 (EST) From: John Baldwin To: freebsd-current@freebsd.org Subject: Re: RFC can we use __builtin_prefetch() directly in our kernel sources ? Date: Mon, 23 Dec 2013 11:45:47 -0500 User-Agent: KMail/1.13.5 (FreeBSD/8.4-CBSD-20130906; KDE/4.5.5; amd64; ; ) References: <20131216165014.GA15126@onelab2.iet.unipi.it> In-Reply-To: <20131216165014.GA15126@onelab2.iet.unipi.it> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201312231145.47679.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Mon, 23 Dec 2013 14:43:51 -0500 (EST) Cc: Luigi Rizzo , current@freebsd.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Dec 2013 19:43:52 -0000 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