Skip to content

os/kernel/sched: Refine round-robin scheduling behavior on SMP - #7465

Open
hyunjongkim123 wants to merge 1 commit into
Samsung:masterfrom
hyunjongkim123:rr-sched-test-baseline
Open

os/kernel/sched: Refine round-robin scheduling behavior on SMP#7465
hyunjongkim123 wants to merge 1 commit into
Samsung:masterfrom
hyunjongkim123:rr-sched-test-baseline

Conversation

@hyunjongkim123

Copy link
Copy Markdown
Contributor
  1. Check both g_assignedtasks and g_readytorun for SMP round-robin scheduling.
  2. Select only tasks that can run on the target CPU based on CPU affinity.

@hyunjongkim123 hyunjongkim123 changed the title Refine round-robin scheduling behavior on SMP os/kernel/sched Refine round-robin scheduling behavior on SMP Jul 30, 2026
@hyunjongkim123 hyunjongkim123 changed the title os/kernel/sched Refine round-robin scheduling behavior on SMP os/kernel/sched: Refine round-robin scheduling behavior on SMP Jul 30, 2026
@hyunjongkim123
hyunjongkim123 force-pushed the rr-sched-test-baseline branch from 463d63c to f72f9ac Compare July 30, 2026 09:55

@seokhun-eom24 seokhun-eom24 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.

We need to update sched_timerexpiration.c file too.

Comment thread os/kernel/sched/sched_processtimer.c Outdated
@hyunjongkim123
hyunjongkim123 force-pushed the rr-sched-test-baseline branch 3 times, most recently from f7100cf to 2da9fcf Compare July 31, 2026 01:42
Comment on lines +169 to +171
if (rtcb->flink && rtcb->flink->sched_priority >= rtcb->sched_priority) {
do_reprioritize = true;
}

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.

Could you please let me know why checking this condition is needed?

Comment thread os/kernel/sched/sched_processtimer.c Outdated
* or higher priority task can run on this CPU.
*/

if (sched_islocked_global() || irq_cpu_locked(cpu)) {

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.

@hyunjongkim123 : I think it should be irq_cpu_locked(this_cpu()) instead of irq_cpu_locked(cpu).
Since only CPU0 receives the timer interrupt and when it tries to examine the CPU1 tasks during its tick handler
irq_cpu_locked(cpu1) always return true because cpu0 is already inside the critical section.
Hence, round robin scheduling will never run for cpu1.

@@ -132,6 +135,45 @@ static inline void sched_process_timeslice(int cpu)

rtcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL);

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.

@hyunjongkim123 : timeslice is reset here whereas the schedulr lock check is added later (at line 153).
If the scheduler is locked then task gets a full new timeslice instead of giving up CPU.

The lockcount checking case just above keeps the counter as it is, instead of resetting it.
Can we do the same here - check the lock before the timeslice reset?

Refine round-robin scheduling behavior on SMP systems.
@hyunjongkim123
hyunjongkim123 force-pushed the rr-sched-test-baseline branch from 2da9fcf to 7346e01 Compare August 5, 2026 03:40
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.

4 participants