Skip to content

sched: simplify xex() and expand cluster_sched test coverage#51

Merged
zbelinsk merged 3 commits into
masterfrom
cluster_sched_testing
Jun 19, 2026
Merged

sched: simplify xex() and expand cluster_sched test coverage#51
zbelinsk merged 3 commits into
masterfrom
cluster_sched_testing

Conversation

@zbelinsk

Copy link
Copy Markdown
Contributor

Replace xex()'s branch-heavy switch with a branchless arithmetic equivalent: HVX(xe) and HLX(xe3) share one coproc slot, so their contribution to coproc_count is (new_xe|new_xe3) - (cur_xe|cur_xe3); HMX(xe2) is its own slot using plain subtraction. Verified equivalent by truth table and by comparing compiled result- 5 insns / 0 branches vs 15 / 3.

Expand the readylist CLUSTER_SCHED test to cover all five code paths in H2K_ready_head: early-out, fits
locally, full+no-waiters oversubscribe, full+handoff, and ring-walk-exhausted/ring-walk-finds-fitter. Add slot- accounting correctness checks verifying xe, xe|xe3, and xe|xe3|xe2 each charge the expected count delta.

@zbelinsk zbelinsk force-pushed the cluster_sched_testing branch from 3ebb636 to 9e1c89a Compare June 13, 2026 23:17
zbelinsk added 3 commits June 13, 2026 18:27
Replace xex()'s branch-heavy switch with a branchless arithmetic
equivalent: HVX(xe) and HLX(xe3) share one coproc slot, so their
contribution to coproc_count is (new_xe|new_xe3) - (cur_xe|cur_xe3);
HMX(xe2) is its own slot using plain subtraction. Verified equivalent
by truth table. Comparing compiled result- 5 insns / 0 branches vs 15 / 3.

Expand the readylist CLUSTER_SCHED test to cover all code paths
in H2K_ready_head. Add slot-accounting correctness checks verifying
xe, xe|xe3, and xe|xe3|xe2 each charge the expected count delta.

Signed-off-by: Zeev Belinsky <zbelinsk@qti.qualcomm.com>
Signed-off-by: zbelinsk <zbelinsk@qti.qualcomm.com>
Signed-off-by: Zeev Belinsky <zbelinsk@qti.qualcomm.com>
@zbelinsk zbelinsk force-pushed the cluster_sched_testing branch from ed69362 to 818db5d Compare June 14, 2026 01:31
@zbelinsk zbelinsk requested a review from bryanb-h2 June 14, 2026 13:43

@bryanb-h2 bryanb-h2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great work; thanks!

Would be good to see before/after coverage data.

count += 1;
}
/* HVX (xe) and HLX (xe3) share ONE coproc slot: the slot is occupied
* iff either is set, so its occupancy is (xe | xe3). The slot's

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, much better!

#ifdef CLUSTER_SCHED
if ((!H2K_gp->cluster_sched) || H2K_gp->coproc_max == -1) {
return ret;
return head;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think maybe the compiler would already do this optimization :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think maybe the compiler would already do this optimization :)

I agree with you, this is the big win compile time ifdef, just made the change for readability.

/* This hthread is going to sleep, so no longer using xe/xe2/xe3 */
ssr &= ~SSR_XE_BIT_MASK;
ssr &= ~SSR_XE2_BIT_MASK;
ssr &= ~(SSR_XE_BIT_MASK | SSR_XE2_BIT_MASK);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The human optimizer strikes again.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The human optimizer strikes again.

Just thought It is better for readability. Was easier for me when reading the code first time to think about it like that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, it's a good change. Go ahead and merge.

@zbelinsk

Copy link
Copy Markdown
Contributor Author

This is great work; thanks!

Would be good to see before/after coverage data.

I did not run any coverage on old version. But, I glanced at it, it intended to test around half of the scheduling cases.

@zbelinsk zbelinsk merged commit 43c0714 into master Jun 19, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants