On Wed, Aug 19, 2020 at 10:00:25PM +0200, Sebastian Andrzej Siewior wrote: > sched_submit_work() is considered to be a hot path. The preempt_disable() > instruction is a compiler barrier and forces the compiler to load > task_struct::flags for the second comparison. > By using a local variable, the compiler can load the value once and keep it in > a register for the second comparison. > > Verified on x86-64 with gcc-10. > > Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> > --- > > Optimisation at molecule level, part two. Drop this in case this branch > isn't consider *that* hot and the cache hot value can be loaded again. > But then the value is around and be speculated early on :) That's fine, task->flags can only be changed by current. Patches look good to me, I'll stuff them in tomorrow. Thanks!