On Mon, May 18, 2026 at 01:40:18PM +0100, Pavel Begunkov wrote:
When that is really a performance critical path then you can use the likely() and unlikely() macros to give the compiler the hint which one to prefer.
That might be more penalising than placing them in the right order, and it might be fine as it's new and all that, but it's not a clear cut as it's definitely not created to be a slow path.
Yes. Whatever the caller is using at a given time is the fast path here, and dynamic branch prediction in modern cpus handles this really well.
TBH, not sure why we're bike shedding such things, is it somewhere in the code style?
It makes reading the code annoying, so it better have a good reason. Now for a single conditional it's not much of an issue, but these things tend to pile up and then start to get really annoying. Always write your code the most straight forward way unless you have a good reason not to.
What could be useful is to have the true path for the more common and the false path for the less common case for documentation purposes, but in that case I would expected some code comments as well.
What kind of comment are you thinking about? A "this is not a likely path" type of comment before each mention of the flag is usually not very useful.
Indeed. It's also not true here. If the workload uses dmabufs, the path obviously is very likely.