Closed vineetgarc closed 3 years ago
This turned out to be much more mundane and silly than expected.
First of all it was a regression caused by the prior fix for exact same issue, merged in v4.9-rc4, commit feb92d7d3813456c11dce21 "(ARC: perf: don't bail setup if pct irq missing in device-tree)"
Second it was the most basic "C" coding bug almost a newbie to "C" would code. The assignment and comparison in an if statement were not bracketed correctly, leaving the order of evaluation undefined.
if (has_interrupts && (irq = platform_get_irq(pdev, 0) >= 0)) {
^^^ ^^^^
And given such a chance, the compiler will bite you hard, fully entitled to generating this piece of beauty:
bl @platform_get_irq <-- irq returned in r0
setge r2, r0, 0 <-- r2 is bool 1 or 0 depending on irq >= 0 true/false
brlt.d r0, 0, @.L114
st_s r2,[sp] <-- irq saved is bool 1 or 0, not actual return val [NOK]
st 1,[r3,160] # arc_pmu.18_29->irq <-- drops bool and assumes 1 [NOK]
bl.d @__request_percpu_irq;
mov_s r0,1 <-- drops even bool and assumes 1 which fails [NOK]
With the snafu fixed, everything is as expected.
bl @platform_get_irq <-- returns irq in r0
mov_s r2,r0
brlt.d r2, 0, @.L112
st_s r0,[sp] <-- irq isaved is actual return value above
st r0,[r13,160] #arc_pmu.18_27->irq
bl.d @__request_percpu_irq <-- r0 unchanged so actual irq returned
add r4,r4,r12 #, tmp363, __ptr
Fix effectively is
- if (has_interrupts && (irq = platform_get_irq(pdev, 0) >= 0)) {
+ if (has_interrupts && ((irq = platform_get_irq(pdev, 0)) >= 0)) {
But the real commit reworks the code a bit more to simplify setting PERF_PMU_CAP_NO_INTERRUPT
Pull request with fix for 5.10-rc1 sent to Linus
Fix merged upstream: 8c42a5c02bec6c ARC: perf: redo the pct irq missing in device-tree handling
This came up in recent benchmarking activity. In mainline kernels statistical profiling or perf record is broken
At first glance it seemed like my recent commits to enable perf on HSDK-4xD merged upstream were missing, specifically 2020-07-09 fe81d927b78c ARC: HSDK: wireup perf irq
2020-07-26 feb92d7d3813 ARC: perf: don't bail setup if pct irq missing in device-tree
However this is v5.9 which already has my changes. Initial investigation reveals pct IRQ not getting enabled hence the issue with statistical profiling
Added a diagnostic patch (slated for mainline after merge window) 66f825cc25fbfc8, "(ARC: perf: check if pct irq request fails )" which at least shows the root cause.
But I don't know why this is and thus needs to be debugged.