irq_pipeline: likely/unlikely macro usage
Hi all,
while staring at the irq_pipelining implementation, I noticed that there are some locations that use the unlikely macro for the OOB fast path, e.g., [1].
Could someone explain why we are optimizing for the in-band path here? Although the in-band path is indeed more likely, I would have expected that we would want to optimize for the OOB path anyway, since this is where the saved cycles really matter.
Best,
Tobias
Quoted 11 lines · Tobias Schaffner
Hi all,
while staring at the
irq_pipeliningimplementation, I noticed that there are some locations that use the unlikely macro for the OOB fast path, e.g., [1].Could someone explain why we are optimizing for the in-band path here? Although the in-band path is indeed more likely, I would have expected that we would want to optimize for the OOB path anyway, since this is where the saved cycles really matter.
Likely/unlikely optimizations are generally tricky. They are hints which might even be ignored by concrete archs or in concrete situations.
If they lead to consistently higher latency for oob, I would agree that we should lean to that path instead. However, if they reduce the average latency for inband and practically do not increase the worst-case for oob, it might be a better decision to take that performance optimization because the worst-case latency is what matters for oob more.
But it remains a fair question whether we can answer that question whenever we added [un]likely... Did you find inconsistencies in their usage as well?
Jan
Quoted 6 lines
Best,
Tobias[1] https://gitlab.com/Xenomai/linux-dovetail/-/blob/v5.10.y-dovetail/
arch/x86/kernel/irq_pipeline.c?ref_type=heads#L260
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
Quoted 22 lines · Jan Kiszka
Quoted 11 lines · Tobias Schaffner
Hi all,
while staring at the
irq_pipeliningimplementation, I noticed that there are some locations that use the unlikely macro for the OOB fast path, e.g., [1].Could someone explain why we are optimizing for the in-band path here? Although the in-band path is indeed more likely, I would have expected that we would want to optimize for the OOB path anyway, since this is where the saved cycles really matter.
Likely/unlikely optimizations are generally tricky. They are hints which might even be ignored by concrete archs or in concrete situations.
If they lead to consistently higher latency for oob, I would agree that we should lean to that path instead. However, if they reduce the average latency for inband and practically do not increase the worst-case for oob, it might be a better decision to take that performance optimization because the worst-case latency is what matters for oob more.
Quoted 3 lines
But it remains a fair question whether we can answer that question whenever we added [un]likely... Did you find inconsistencies in their usage as well?
No, it does not look inconsistent to me. It looks like the more frequent path is consistently chosen. And I wondered if this is correct.
Best,
Tobias
Quoted 9 lines
Jan
Quoted 6 lines
Best,
Tobias[1] https://gitlab.com/Xenomai/linux-dovetail/-/blob/v5.10.y-dovetail/
arch/x86/kernel/irq_pipeline.c?ref_type=heads#L260