The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH -tip] sched: Pair ttwu_activate() with uwtt_deactivate()
@ 2013-01-16 10:14 Alexander Gordeev
  2013-01-16 15:05 ` Mike Galbraith
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Gordeev @ 2013-01-16 10:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Peter Zijlstra

Try to make reading of __schedule() bit more easy.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
 kernel/sched/core.c |   42 ++++++++++++++++++++++++------------------
 1 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 38413f6..dd54ded 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1272,6 +1272,27 @@ static void ttwu_activate(struct rq *rq, struct task_struct *p, int en_flags)
 		wq_worker_waking_up(p, cpu_of(rq));
 }
 
+static void try_to_wake_up_local(struct task_struct *p);
+
+static void uwtt_deactivate(struct rq *rq, struct task_struct *p, int de_flags)
+{
+	deactivate_task(rq, p, de_flags);
+	p->on_rq = 0;
+
+	/*
+	 * If a worker went to sleep, notify and ask workqueue
+	 * whether it wants to wake up a task to maintain
+	 * concurrency.
+	 */
+	if (p->flags & PF_WQ_WORKER) {
+		struct task_struct *to_wakeup;
+
+		to_wakeup = wq_worker_sleeping(p, cpu_of(rq));
+		if (to_wakeup)
+			try_to_wake_up_local(to_wakeup);
+	}
+}
+
 /*
  * Mark the task runnable and perform wakeup-preemption.
  */
@@ -2907,25 +2928,10 @@ need_resched:
 
 	switch_count = &prev->nivcsw;
 	if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
-		if (unlikely(signal_pending_state(prev->state, prev))) {
+		if (unlikely(signal_pending_state(prev->state, prev)))
 			prev->state = TASK_RUNNING;
-		} else {
-			deactivate_task(rq, prev, DEQUEUE_SLEEP);
-			prev->on_rq = 0;
-
-			/*
-			 * If a worker went to sleep, notify and ask workqueue
-			 * whether it wants to wake up a task to maintain
-			 * concurrency.
-			 */
-			if (prev->flags & PF_WQ_WORKER) {
-				struct task_struct *to_wakeup;
-
-				to_wakeup = wq_worker_sleeping(prev, cpu);
-				if (to_wakeup)
-					try_to_wake_up_local(to_wakeup);
-			}
-		}
+		else
+			uwtt_deactivate(rq, prev, DEQUEUE_SLEEP);
 		switch_count = &prev->nvcsw;
 	}
 
-- 
1.7.7.6


-- 
Regards,
Alexander Gordeev
agordeev@redhat.com

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH -tip] sched: Pair ttwu_activate() with uwtt_deactivate()
  2013-01-16 10:14 [PATCH -tip] sched: Pair ttwu_activate() with uwtt_deactivate() Alexander Gordeev
@ 2013-01-16 15:05 ` Mike Galbraith
  0 siblings, 0 replies; 2+ messages in thread
From: Mike Galbraith @ 2013-01-16 15:05 UTC (permalink / raw)
  To: Alexander Gordeev; +Cc: linux-kernel, Ingo Molnar, Peter Zijlstra

On Wed, 2013-01-16 at 11:14 +0100, Alexander Gordeev wrote: 
> Try to make reading of __schedule() bit more easy.

You didn't succeed in doing that for me.  Moving that code away just
obfuscates the special case for worker-bees scheduling off, and while
ttwu is shorthand for try_to_wake_up, uuwt is.. a lysdexic typo.

> Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
> ---
>  kernel/sched/core.c |   42 ++++++++++++++++++++++++------------------
>  1 files changed, 24 insertions(+), 18 deletions(-)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 38413f6..dd54ded 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -1272,6 +1272,27 @@ static void ttwu_activate(struct rq *rq, struct task_struct *p, int en_flags)
>  		wq_worker_waking_up(p, cpu_of(rq));
>  }
>  
> +static void try_to_wake_up_local(struct task_struct *p);
> +
> +static void uwtt_deactivate(struct rq *rq, struct task_struct *p, int de_flags)
> +{
> +	deactivate_task(rq, p, de_flags);
> +	p->on_rq = 0;
> +
> +	/*
> +	 * If a worker went to sleep, notify and ask workqueue
> +	 * whether it wants to wake up a task to maintain
> +	 * concurrency.
> +	 */
> +	if (p->flags & PF_WQ_WORKER) {
> +		struct task_struct *to_wakeup;
> +
> +		to_wakeup = wq_worker_sleeping(p, cpu_of(rq));
> +		if (to_wakeup)
> +			try_to_wake_up_local(to_wakeup);
> +	}
> +}
> +
>  /*
>   * Mark the task runnable and perform wakeup-preemption.
>   */
> @@ -2907,25 +2928,10 @@ need_resched:
>  
>  	switch_count = &prev->nivcsw;
>  	if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
> -		if (unlikely(signal_pending_state(prev->state, prev))) {
> +		if (unlikely(signal_pending_state(prev->state, prev)))
>  			prev->state = TASK_RUNNING;
> -		} else {
> -			deactivate_task(rq, prev, DEQUEUE_SLEEP);
> -			prev->on_rq = 0;
> -
> -			/*
> -			 * If a worker went to sleep, notify and ask workqueue
> -			 * whether it wants to wake up a task to maintain
> -			 * concurrency.
> -			 */
> -			if (prev->flags & PF_WQ_WORKER) {
> -				struct task_struct *to_wakeup;
> -
> -				to_wakeup = wq_worker_sleeping(prev, cpu);
> -				if (to_wakeup)
> -					try_to_wake_up_local(to_wakeup);
> -			}
> -		}
> +		else
> +			uwtt_deactivate(rq, prev, DEQUEUE_SLEEP);
>  		switch_count = &prev->nvcsw;
>  	}
>  
> -- 
> 1.7.7.6
> 
> 



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-01-16 15:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-16 10:14 [PATCH -tip] sched: Pair ttwu_activate() with uwtt_deactivate() Alexander Gordeev
2013-01-16 15:05 ` Mike Galbraith

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox