public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] init,cpuset: fix initialize order
@ 2009-03-25  9:06 Lai Jiangshan
  2009-03-25 13:51 ` Frederic Weisbecker
  2009-03-25 17:33 ` [tip:tracing/ftrace] " Lai Jiangshan
  0 siblings, 2 replies; 4+ messages in thread
From: Lai Jiangshan @ 2009-03-25  9:06 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Paul Menage, miaoxie, Li Zefan, Ingo Molnar, Steven Rostedt,
	Frederic Weisbecker, LKML


(After these two fixes applied:
[PATCH 1/2] trace_stat: keep original order
[PATCH 2/2] trace_workqueues: fix empty line's output
)
When I read /debugfs/tracing/trace_stat/workqueues,
and the I got this:

# CPU  INSERTED  EXECUTED   NAME
# |      |         |          |

  0      0          0       cpuset
  0    285        285       events/0
  0      2          2       work_on_cpu/0
  0   1115       1115       khelper
  0    325        325       kblockd/0
  0      0          0       kacpid
  0      0          0       kacpi_notify
  0      0          0       ata/0
  0      0          0       ata_aux
  0      0          0       ksuspend_usbd
  0      0          0       aio/0
  0      0          0       nfsiod
  0      0          0       kpsmoused
  0      0          0       kstriped
  0      0          0       kondemand/0
  0      1          1       hid_compat
  0      0          0       rpciod/0

  1     64         64       events/1
  1      2          2       work_on_cpu/1
  1      5          5       kblockd/1
  1      0          0       ata/1
  1      0          0       aio/1
  1      0          0       kondemand/1
  1      0          0       rpciod/1

I found "cpuset" is at the earliest.
---------

Subject: [PATCH] init,cpuset: fix initialize order

Impact: cpuset_wq should be initialized after init_workqueues()

I found a create_singlethread_workqueue() is earlier than
init_workqueues():

kernel_init()
->cpuset_init_smp()
  ->create_singlethread_workqueue()
->do_basic_setup()
  ->init_workqueues()

I think it's better that create_singlethread_workqueue() is called
after workqueue subsystem has been initialized.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
diff --git a/init/main.c b/init/main.c
index 1ce6931..91d5047 100644
--- a/init/main.c
+++ b/init/main.c
@@ -773,6 +773,7 @@ static void __init do_basic_setup(void)
 {
 	rcu_init_sched(); /* needed by module_init stage. */
 	init_workqueues();
+	cpuset_init_smp();
 	usermodehelper_init();
 	driver_init();
 	init_irq_proc();
@@ -869,8 +870,6 @@ static int __init kernel_init(void * unused)
 	smp_init();
 	sched_init_smp();
 
-	cpuset_init_smp();
-
 	do_basic_setup();
 
 	/*



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

* Re: [PATCH] init,cpuset: fix initialize order
  2009-03-25  9:06 [PATCH] init,cpuset: fix initialize order Lai Jiangshan
@ 2009-03-25 13:51 ` Frederic Weisbecker
  2009-03-25 14:00   ` Frederic Weisbecker
  2009-03-25 17:33 ` [tip:tracing/ftrace] " Lai Jiangshan
  1 sibling, 1 reply; 4+ messages in thread
From: Frederic Weisbecker @ 2009-03-25 13:51 UTC (permalink / raw)
  To: Lai Jiangshan
  Cc: Andrew Morton, Paul Menage, miaoxie, Li Zefan, Ingo Molnar,
	Steven Rostedt, LKML

On Wed, Mar 25, 2009 at 05:06:30PM +0800, Lai Jiangshan wrote:
> 
> (After these two fixes applied:
> [PATCH 1/2] trace_stat: keep original order
> [PATCH 2/2] trace_workqueues: fix empty line's output
> )
> When I read /debugfs/tracing/trace_stat/workqueues,
> and the I got this:
> 
> # CPU  INSERTED  EXECUTED   NAME
> # |      |         |          |
> 
>   0      0          0       cpuset
>   0    285        285       events/0
>   0      2          2       work_on_cpu/0
>   0   1115       1115       khelper
>   0    325        325       kblockd/0
>   0      0          0       kacpid
>   0      0          0       kacpi_notify
>   0      0          0       ata/0
>   0      0          0       ata_aux
>   0      0          0       ksuspend_usbd
>   0      0          0       aio/0
>   0      0          0       nfsiod
>   0      0          0       kpsmoused
>   0      0          0       kstriped
>   0      0          0       kondemand/0
>   0      1          1       hid_compat
>   0      0          0       rpciod/0
> 
>   1     64         64       events/1
>   1      2          2       work_on_cpu/1
>   1      5          5       kblockd/1
>   1      0          0       ata/1
>   1      0          0       aio/1
>   1      0          0       kondemand/1
>   1      0          0       rpciod/1
> 
> I found "cpuset" is at the earliest.
> ---------
> 
> Subject: [PATCH] init,cpuset: fix initialize order
> 
> Impact: cpuset_wq should be initialized after init_workqueues()
> 
> I found a create_singlethread_workqueue() is earlier than
> init_workqueues():
> 
> kernel_init()
> ->cpuset_init_smp()
>   ->create_singlethread_workqueue()
> ->do_basic_setup()
>   ->init_workqueues()
> 
> I think it's better that create_singlethread_workqueue() is called
> after workqueue subsystem has been initialized.
> 
> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
> ---


Indeed it seems to be a bug.
If init_workqueues() have not been called:

- cpu_singlethread_map = NULL
- singlethread_cpu = 0

create_workqueue_thread() will be called with cpu = 0 and
then: kthread_create(worker_thread, cwq, fmt, wq->name, cpu = 0);

Meaning that cpuset is only bound to the first cpu.

Frederic.


> diff --git a/init/main.c b/init/main.c
> index 1ce6931..91d5047 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -773,6 +773,7 @@ static void __init do_basic_setup(void)
>  {
>  	rcu_init_sched(); /* needed by module_init stage. */
>  	init_workqueues();
> +	cpuset_init_smp();
>  	usermodehelper_init();
>  	driver_init();
>  	init_irq_proc();
> @@ -869,8 +870,6 @@ static int __init kernel_init(void * unused)
>  	smp_init();
>  	sched_init_smp();
>  
> -	cpuset_init_smp();
> -
>  	do_basic_setup();
>  
>  	/*
> 
> 


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

* Re: [PATCH] init,cpuset: fix initialize order
  2009-03-25 13:51 ` Frederic Weisbecker
@ 2009-03-25 14:00   ` Frederic Weisbecker
  0 siblings, 0 replies; 4+ messages in thread
From: Frederic Weisbecker @ 2009-03-25 14:00 UTC (permalink / raw)
  To: Lai Jiangshan
  Cc: Andrew Morton, Paul Menage, miaoxie, Li Zefan, Ingo Molnar,
	Steven Rostedt, LKML

On Wed, Mar 25, 2009 at 02:51:39PM +0100, Frederic Weisbecker wrote:
> On Wed, Mar 25, 2009 at 05:06:30PM +0800, Lai Jiangshan wrote:
> > 
> > (After these two fixes applied:
> > [PATCH 1/2] trace_stat: keep original order
> > [PATCH 2/2] trace_workqueues: fix empty line's output
> > )
> > When I read /debugfs/tracing/trace_stat/workqueues,
> > and the I got this:
> > 
> > # CPU  INSERTED  EXECUTED   NAME
> > # |      |         |          |
> > 
> >   0      0          0       cpuset
> >   0    285        285       events/0
> >   0      2          2       work_on_cpu/0
> >   0   1115       1115       khelper
> >   0    325        325       kblockd/0
> >   0      0          0       kacpid
> >   0      0          0       kacpi_notify
> >   0      0          0       ata/0
> >   0      0          0       ata_aux
> >   0      0          0       ksuspend_usbd
> >   0      0          0       aio/0
> >   0      0          0       nfsiod
> >   0      0          0       kpsmoused
> >   0      0          0       kstriped
> >   0      0          0       kondemand/0
> >   0      1          1       hid_compat
> >   0      0          0       rpciod/0
> > 
> >   1     64         64       events/1
> >   1      2          2       work_on_cpu/1
> >   1      5          5       kblockd/1
> >   1      0          0       ata/1
> >   1      0          0       aio/1
> >   1      0          0       kondemand/1
> >   1      0          0       rpciod/1
> > 
> > I found "cpuset" is at the earliest.
> > ---------
> > 
> > Subject: [PATCH] init,cpuset: fix initialize order
> > 
> > Impact: cpuset_wq should be initialized after init_workqueues()
> > 
> > I found a create_singlethread_workqueue() is earlier than
> > init_workqueues():
> > 
> > kernel_init()
> > ->cpuset_init_smp()
> >   ->create_singlethread_workqueue()
> > ->do_basic_setup()
> >   ->init_workqueues()
> > 
> > I think it's better that create_singlethread_workqueue() is called
> > after workqueue subsystem has been initialized.
> > 
> > Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
> > ---
> 
> 
> Indeed it seems to be a bug.
> If init_workqueues() have not been called:
> 
> - cpu_singlethread_map = NULL
> - singlethread_cpu = 0
> 
> create_workqueue_thread() will be called with cpu = 0 and
> then: kthread_create(worker_thread, cwq, fmt, wq->name, cpu = 0);
> 
> Meaning that cpuset is only bound to the first cpu.
> 
> Frederic.
> 


Ah no, kthread_bind is called just after with -1 for the cpu.

Frederic.

 
> > diff --git a/init/main.c b/init/main.c
> > index 1ce6931..91d5047 100644
> > --- a/init/main.c
> > +++ b/init/main.c
> > @@ -773,6 +773,7 @@ static void __init do_basic_setup(void)
> >  {
> >  	rcu_init_sched(); /* needed by module_init stage. */
> >  	init_workqueues();
> > +	cpuset_init_smp();
> >  	usermodehelper_init();
> >  	driver_init();
> >  	init_irq_proc();
> > @@ -869,8 +870,6 @@ static int __init kernel_init(void * unused)
> >  	smp_init();
> >  	sched_init_smp();
> >  
> > -	cpuset_init_smp();
> > -
> >  	do_basic_setup();
> >  
> >  	/*
> > 
> > 
> 


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

* [tip:tracing/ftrace] init,cpuset: fix initialize order
  2009-03-25  9:06 [PATCH] init,cpuset: fix initialize order Lai Jiangshan
  2009-03-25 13:51 ` Frederic Weisbecker
@ 2009-03-25 17:33 ` Lai Jiangshan
  1 sibling, 0 replies; 4+ messages in thread
From: Lai Jiangshan @ 2009-03-25 17:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, lizf, menage, fweisbec, akpm, srostedt,
	tglx, miaox, laijs, mingo

Commit-ID:  759ee0915dd713361e72facb78b66600b5712d65
Gitweb:     http://git.kernel.org/tip/759ee0915dd713361e72facb78b66600b5712d65
Author:     Lai Jiangshan <laijs@cn.fujitsu.com>
AuthorDate: Wed, 25 Mar 2009 17:06:30 +0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Wed, 25 Mar 2009 18:32:35 +0100

init,cpuset: fix initialize order

Impact: cpuset_wq should be initialized after init_workqueues()

When I read /debugfs/tracing/trace_stat/workqueues,
I got this:

 # CPU  INSERTED  EXECUTED   NAME
 # |      |         |          |

   0      0          0       cpuset
   0    285        285       events/0
   0      2          2       work_on_cpu/0
   0   1115       1115       khelper
   0    325        325       kblockd/0
   0      0          0       kacpid
   0      0          0       kacpi_notify
   0      0          0       ata/0
   0      0          0       ata_aux
   0      0          0       ksuspend_usbd
   0      0          0       aio/0
   0      0          0       nfsiod
   0      0          0       kpsmoused
   0      0          0       kstriped
   0      0          0       kondemand/0
   0      1          1       hid_compat
   0      0          0       rpciod/0

   1     64         64       events/1
   1      2          2       work_on_cpu/1
   1      5          5       kblockd/1
   1      0          0       ata/1
   1      0          0       aio/1
   1      0          0       kondemand/1
   1      0          0       rpciod/1

I found "cpuset" is at the earliest.

I found a create_singlethread_workqueue() is earlier than
init_workqueues():

kernel_init()
->cpuset_init_smp()
  ->create_singlethread_workqueue()
->do_basic_setup()
  ->init_workqueues()

I think it's better that create_singlethread_workqueue() is called
after workqueue subsystem has been initialized.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Acked-by: Steven Rostedt <srostedt@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Menage <menage@google.com>
Cc: miaoxie <miaox@cn.fujitsu.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
LKML-Reference: <49C9F416.1050707@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 init/main.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/init/main.c b/init/main.c
index 20d784a..b0097d2 100644
--- a/init/main.c
+++ b/init/main.c
@@ -772,6 +772,7 @@ static void __init do_basic_setup(void)
 {
 	rcu_init_sched(); /* needed by module_init stage. */
 	init_workqueues();
+	cpuset_init_smp();
 	usermodehelper_init();
 	driver_init();
 	init_irq_proc();
@@ -865,8 +866,6 @@ static int __init kernel_init(void * unused)
 	smp_init();
 	sched_init_smp();
 
-	cpuset_init_smp();
-
 	do_basic_setup();
 
 	/*

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

end of thread, other threads:[~2009-03-25 17:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-25  9:06 [PATCH] init,cpuset: fix initialize order Lai Jiangshan
2009-03-25 13:51 ` Frederic Weisbecker
2009-03-25 14:00   ` Frederic Weisbecker
2009-03-25 17:33 ` [tip:tracing/ftrace] " Lai Jiangshan

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