linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kthread_bind: don't wait in kthread_bind for presmp initcalls
@ 2013-09-27 16:47 Abbas Raza
  2013-10-30 16:00 ` Abbas Raza
  0 siblings, 1 reply; 2+ messages in thread
From: Abbas Raza @ 2013-09-27 16:47 UTC (permalink / raw)
  To: linux-kernel; +Cc: Abbas Raza

From: Abbas Raza <Abbas_Raza@mentor.com>

wait_task_inactive shouldn't be called in __kthread_bind for presmp
initcalls the same way it is done in !SMP case.

more info here:
http://permalink.gmane.org/gmane.linux.kernel.embedded/4046

This patch improves boot time for pre-smp initcalls as given below

boot time with this patch:

calling  spawn_ksoftirqd+0x0/0x30 @ 1
initcall spawn_ksoftirqd+0x0/0x30 returned 0 after 0 usecs

boot time without this patch:

calling  spawn_ksoftirqd+0x0/0x30 @ 1
initcall spawn_ksoftirqd+0x0/0x30 returned 0 after 19531 usecs

Signed-off-by: Abbas Raza <Abbas_Raza@mentor.com>
---
 kernel/kthread.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/kernel/kthread.c b/kernel/kthread.c
index 760e86d..28b5c4b 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -290,11 +290,17 @@ EXPORT_SYMBOL(kthread_create_on_node);
 
 static void __kthread_bind(struct task_struct *p, unsigned int cpu, long state)
 {
-	/* Must have done schedule() in kthread() before we set_task_cpu */
-	if (!wait_task_inactive(p, state)) {
-		WARN_ON(1);
-		return;
+	if (!((num_online_cpus() == 1) && !cpu)) {
+		/*
+		 * Must have done schedule() in kthread() before
+		 * we set_task_cpu
+		 */
+		if (!wait_task_inactive(p, state)) {
+			WARN_ON(1);
+			return;
+		}
 	}
+
 	/* It's safe because the task is inactive. */
 	do_set_cpus_allowed(p, cpumask_of(cpu));
 	p->flags |= PF_NO_SETAFFINITY;
-- 
1.8.3.2


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

* Re: [PATCH] kthread_bind: don't wait in kthread_bind for presmp initcalls
  2013-09-27 16:47 [PATCH] kthread_bind: don't wait in kthread_bind for presmp initcalls Abbas Raza
@ 2013-10-30 16:00 ` Abbas Raza
  0 siblings, 0 replies; 2+ messages in thread
From: Abbas Raza @ 2013-10-30 16:00 UTC (permalink / raw)
  To: linux-kernel; +Cc: mingo, peterz, Xie XiuQi

Hi,

Any thoughts here please?

Thanks .
Abbas Raza

On 09/27/2013 09:47 PM, Abbas Raza wrote:
> From: Abbas Raza <Abbas_Raza@mentor.com>
>
> wait_task_inactive shouldn't be called in __kthread_bind for presmp
> initcalls the same way it is done in !SMP case.
>
> more info here:
> http://permalink.gmane.org/gmane.linux.kernel.embedded/4046
>
> This patch improves boot time for pre-smp initcalls as given below
>
> boot time with this patch:
>
> calling  spawn_ksoftirqd+0x0/0x30 @ 1
> initcall spawn_ksoftirqd+0x0/0x30 returned 0 after 0 usecs
>
> boot time without this patch:
>
> calling  spawn_ksoftirqd+0x0/0x30 @ 1
> initcall spawn_ksoftirqd+0x0/0x30 returned 0 after 19531 usecs
>
> Signed-off-by: Abbas Raza <Abbas_Raza@mentor.com>
> ---
>  kernel/kthread.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/kthread.c b/kernel/kthread.c
> index 760e86d..28b5c4b 100644
> --- a/kernel/kthread.c
> +++ b/kernel/kthread.c
> @@ -290,11 +290,17 @@ EXPORT_SYMBOL(kthread_create_on_node);
>  
>  static void __kthread_bind(struct task_struct *p, unsigned int cpu, long state)
>  {
> -	/* Must have done schedule() in kthread() before we set_task_cpu */
> -	if (!wait_task_inactive(p, state)) {
> -		WARN_ON(1);
> -		return;
> +	if (!((num_online_cpus() == 1) && !cpu)) {
> +		/*
> +		 * Must have done schedule() in kthread() before
> +		 * we set_task_cpu
> +		 */
> +		if (!wait_task_inactive(p, state)) {
> +			WARN_ON(1);
> +			return;
> +		}
>  	}
> +
>  	/* It's safe because the task is inactive. */
>  	do_set_cpus_allowed(p, cpumask_of(cpu));
>  	p->flags |= PF_NO_SETAFFINITY;


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

end of thread, other threads:[~2013-10-30 16:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-27 16:47 [PATCH] kthread_bind: don't wait in kthread_bind for presmp initcalls Abbas Raza
2013-10-30 16:00 ` Abbas Raza

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).