[PATCH 0/3] Optimize code generation during context
Xie Yuanbin
qq570070308 at gmail.com
Sat Oct 25 10:37:00 PDT 2025
On Fri, 24 Oct 2025 17:36:06 -0400, Rik van Riel wrote:
> Also, what kind of performance improvement
> have you measured with these changes?
When I debugged performance issues before, I used the company's equipment.
I could only observe the macro business performance data, but not the
specific scheduling time. Today I did some testing using my devices,
and the testing logic is as follows:
```
- return finish_task_switch(prev);
+ start_time = rdtsc();
+ barrier();
+ rq = finish_task_switch(prev);
+ barrier();
+ end_time = rdtsc;
+ return rq;
```
The test data is as follows:
1. mitigations Off, without patches: 13.5 - 13.7
2. mitigations Off, with patches: 13.5 - 13.7
3. mitigations On, without patches: 23.3 - 23.6
4. mitigations On, with patches: 16.6 - 16.8
On my device, these patches have very little effect when mitigations off,
but the improvement was still very noticeable when the mitigation was on.
I suspect this is because I'm using a recent Ryzen CPU with a very
powerful instruction cache and branch prediction capabilities, so without
considering the Spectre vulnerability, inlining is less effective.
However, on embedded devices with small instruction caches, these patches
should still be effective even with mitigations off.
Xie Yuanbin
More information about the linux-riscv
mailing list