> -----Original Message----- > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Bruce Richardson > Sent: Tuesday, May 03, 2016 11:20 AM > To: Ivan Boule > Cc: Jerin Jacob; dev at dpdk.org; De Lara Guarch, Pablo > Subject: Re: [dpdk-dev] [PATCH] app/testpmd: add packet data prefetch in > macswap loop > > On Tue, May 03, 2016 at 11:50:31AM +0200, Ivan Boule wrote: > > On 05/03/2016 11:45 AM, Bruce Richardson wrote: > > >On Mon, May 02, 2016 at 05:29:37PM +0530, Jerin Jacob wrote: > > >>prefetch the next packet data address in advance in macswap loop > > >>for performance improvement. > > >> > > >>... > > >> for (i = 0; i < nb_rx; i++) { > > >>+ if (likely(i < nb_rx - 1)) > > >>+ rte_prefetch0(rte_pktmbuf_mtod(pkts_burst[i + 1], > > >>+ void *)); > > > > > >At least on IA platforms, there is no issue with prefetching beyond the > > >end of > > >the array, since it's only a hint to the cpu. If this is true for other > > >platforms, > > >then I suggest we just drop the conditional and just always prefetch. > > > > This is an interesting point. > > Bruce, are you suggesting that prefetching at an invalid [virtual] address > > won't trigger a CPU exception? > > > > Yep. For example, adding "rte_prefetch0(NULL)" at the start of main in testpmd > causes no ill effects when running the app. >
One correction - while on IA prefetch(inval_addr) wouldn't cause any functional problems, it still might cause DTLB miss and can be a source of noticeable performance degradation. So it is better to avoid such constructions for performance critical code. Konstantin