Re: [RFC] avoid indirect calls for DMA direct mappings

From: Linus Torvalds
Date: Thu Dec 06 2018 - 13:51:56 EST


On Thu, Dec 6, 2018 at 10:43 AM Christoph Hellwig <hch@xxxxxx> wrote:
>
> >
> > (a) the dma_is_direct() function/macro uses "likely()" for the test
>
> I'm a little worried about that. Yes, for the common case it is
> likely. But if you run a setup where you say always have an iommu
> it is not, in fact it is never called in that case, but we only know
> that at runtime.

Note that "likely()" doesn't have any really huge overhead - it just
makes the compiler move the unlikely case out-of-line.

Compared to the overhead of the indirect branch, it's simply not a
huge deal, it's more a mispredict and cache layout issue.

So marking something "likely()" when it isn't doesn't really penalize
things too much. It's not like an exception or anything like that,
it's really just a marker for better code layout.

Linus