On Sat, Feb 03, 2018 at 02:46:47PM +0000, David Woodhouse wrote: > > For the simple case how about wrapping the if into > > > > call_likely(foo->bar, usualfunction, args) > > > > as a companion to > > > > foo->bar(args) > > > > that can resolve to nothing special on architectures that don't need it, > > an if/else case on platforms with spectre, and potentially clever > > stuff on any platform where you can beat the compiler by knowing > > probabilities it can't infer ? > > Yeah. I'm keen on being able to use something like alternatives to > *change* 'usualfunction' at runtime though. I suspect it'll be a win > for stuff like dma_ops. > > But I'm also keen to actually base such things on real data, not just > go randomly "optimising" stuff just because we can. Let's try to make > sure we fix up the real bottlenecks, and not just go crazy. Google has a fairly long history of using feedback driven optimization compiles for the kernel. They were also the ones that developed perf autofdo tooling IIRC. https://gcc.gnu.org/wiki/AutoFDO/Tutorial One of the things pjt promised was a series of patches doing the proposed optimization for the scheduler code based on their results.