Skip to contentSkip to conversation

sched: Removed redundant set_current_state in "yield"

PATCH In review Sasikantha babu 2 participants 3 messages Apr 10, 2012 – May 8, 2012 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched: Removed redundant set_current_state in "yield"

Removed redundant setting current task state to TASK_RUNNING.

During yield process will always remains in TASK_RUNNING state.

Process state of yielded process will not change from TASK_RUNNING, so it does not make sense setting the process state again to TASK_RUNNING (TASK_RUNNING -> TASK_RUNNING).

---
 kernel/sched/core.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
kernel/sched/core.c +0 -1
index 4603b9d..c2a357d 100644
@@ -4624,7 +4624,6 @@ EXPORT_SYMBOL(__cond_resched_softirq);
  */
 void __sched yield(void)
 {
-	set_current_state(TASK_RUNNING);
 	sys_sched_yield();
 }
 EXPORT_SYMBOL(yield);
Signature · 1 line
1.7.3.4
#1 lore raw
Quoted 3 lines · Sasikantha babu

Removed redundant setting current task state to TASK_RUNNING.

During yield process will always remains in TASK_RUNNING state.

Uhm, no, if you call yield() with !TASK_RUNNING you'll block and need a proper wakeup. That is, you can in fact abuse yield() as schedule().

Quoted 2 lines

Process state of yielded process will not change from TASK_RUNNING, so it does not make sense setting the process state again to TASK_RUNNING (TASK_RUNNING -> TASK_RUNNING).

No real objections, but have you tested/verified that all users are indeed unaffected by this change?

Quoted 17 lines
---
 kernel/sched/core.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
kernel/sched/core.c +0 -1
index 4603b9d..c2a357d 100644
@@ -4624,7 +4624,6 @@ EXPORT_SYMBOL(__cond_resched_softirq);
  */
 void __sched yield(void)
 {
-	set_current_state(TASK_RUNNING);
 	sys_sched_yield();
 }
 EXPORT_SYMBOL(yield);
#2 lore raw
Quoted 7 lines · Peter Zijlstra
Quoted 3 lines · Sasikantha babu

Removed redundant setting current task state to TASK_RUNNING.

During yield process will always remains in TASK_RUNNING state.

Uhm, no, if you call yield() with !TASK_RUNNING you'll block and need a proper wakeup. That is, you can in fact abuse yield() as schedule().

With the current code even if we call yield with !TASK_RUNNING, we are setting it
back to TASK_RUNNING in yield. is this the expected behavior?.

void __sched yield(void)

 {
        set_current_state(TASK_RUNNING);
        sys_sched_yield();

}

In the code I could not find yield was called with !TASK_RUNNING.

Quoted 6 lines
Quoted 3 lines

Process state of  yielded process will not change from TASK_RUNNING, so it does not make sense setting the process state again to TASK_RUNNING (TASK_RUNNING -> TASK_RUNNING).

No real objections, but have you tested/verified that all users are indeed unaffected by this change?

I did minimal testing on changes (Could not able to test all
scenarios, suggest me if there is anyway to test all cases) and
verified none of the code path is going affected by this change.

Quoted 21 lines
Quoted 18 lines

---
 kernel/sched/core.c |    1 -

 1 files changed, 0 insertions(+), 1 deletions(-)
kernel/sched/core.c +0 -1
index 4603b9d..c2a357d 100644
@@ -4624,7 +4624,6 @@ EXPORT_SYMBOL(__cond_resched_softirq);
   */
  void __sched yield(void)
  {
-     set_current_state(TASK_RUNNING);
       sys_sched_yield();
  }
  EXPORT_SYMBOL(yield);