* work queue
@ 2014-11-19 15:21 户户
2014-11-19 17:02 ` Dave Tian
0 siblings, 1 reply; 4+ messages in thread
From: 户户 @ 2014-11-19 15:21 UTC (permalink / raw)
To: kernelnewbies
I'm playing around with work_queue in my VMware workstation. but I hit a problem that the work is processed by [kworker/3:1] other than my work queue.
static int __init test_init(void)
{
pr_info(" (*) test_init start - pid:%d. cpu:%d\n", current->pid, get_cpu());
int ret = 0;
test_queue_ptr = create_workqueue("myfoo");
// test_queue_ptr = create_singlethread_workqueue("test_workqueue");
if(!test_queue_ptr){
goto test_queue_ptr_error;
}
INIT_WORK(&test_work, test_cb);
// ret = queue_work(test_queue_ptr, &test_work);
ret = queue_work_on(get_cpu(), test_queue_ptr, &test_work);
// schedule_work(&test_work);
pr_info(" (*) test_init - queue_work_on return:%d. \n", ret);
return 0;
test_queue_ptr_error:
destroy_workqueue(test_queue_ptr);
return 0;
}
static void test_cb(struct work_struct *work)
{
pr_info(" (*) test_cb - pid:%d. cpu:%d\n", current->pid, get_cpu());
}
isnmod the module gives me the output :
Nov 19 23:11:18 test kernel: [ 3031.766137] (*) test_init start - pid:8594. cpu:3
Nov 19 23:11:18 test kernel: [ 3031.766371] (*) test_init - queue_work_on return:1.
Nov 19 23:11:18 test kernel: [ 3031.766672] (*) test_cb - pid:83. cpu:3 <--- this line indicates "test_cb" function is running on process 83 ([kworker/3:1]).
ps aux
....
root 82 0.0 0.0 0 0 ? S< 22:20 0:00 [charger_manager]
root 83 0.0 0.0 0 0 ? S 22:20 0:00 [kworker/3:1]
root 85 0.0 0.0 0 0 ? S 22:20 0:00 [kworker/0:2]
root 217 0.0 0.0 0 0 ? S< 22:20 0:00 [mpt_poll_0]
Thanks
Jay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20141119/5cf967f0/attachment.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* work queue
2014-11-19 15:21 work queue 户户
@ 2014-11-19 17:02 ` Dave Tian
2014-11-20 13:36 ` 户户
0 siblings, 1 reply; 4+ messages in thread
From: Dave Tian @ 2014-11-19 17:02 UTC (permalink / raw)
To: kernelnewbies
You were not creating a new worker but using the generic kernel worker (kworker) to handle your work. Besides, there is no CPU bound for this work, which means any CPU is able to run the work.
Dave Tian
dave.jing.tian at gmail.com
> On Nov 19, 2014, at 11:21 PM, ?? <6563572@163.com> wrote:
>
> I'm playing around with work_queue in my VMware workstation. but I hit a problem that the work is processed by [kworker/3:1] other than my work queue.
>
> static int __init test_init(void)
> {
> pr_info(" (*) test_init start - pid:%d. cpu:%d\n", current->pid, get_cpu());
> int ret = 0;
> test_queue_ptr = create_workqueue("myfoo");
> // test_queue_ptr = create_singlethread_workqueue("test_workqueue");
>
> if(!test_queue_ptr){
> goto test_queue_ptr_error;
> }
> INIT_WORK(&test_work, test_cb);
> // ret = queue_work(test_queue_ptr, &test_work);
> ret = queue_work_on(get_cpu(), test_queue_ptr, &test_work);
> // schedule_work(&test_work);
> pr_info(" (*) test_init - queue_work_on return:%d. \n", ret);
> return 0;
> test_queue_ptr_error:
> destroy_workqueue(test_queue_ptr);
> return 0;
> }
>
> static void test_cb(struct work_struct *work)
> {
> pr_info(" (*) test_cb - pid:%d. cpu:%d\n", current->pid, get_cpu());
> }
>
> isnmod the module gives me the output :
>
> Nov 19 23:11:18 test kernel: [ 3031.766137] (*) test_init start - pid:8594. cpu:3
> Nov 19 23:11:18 test kernel: [ 3031.766371] (*) test_init - queue_work_on return:1.
> Nov 19 23:11:18 test kernel: [ 3031.766672] (*) test_cb - pid:83. cpu:3 <--- this line indicates "test_cb" function is running on process 83 ([kworker/3:1]).
>
> ps aux
> ....
> root 82 0.0 0.0 0 0 ? S< 22:20 0:00 [charger_manager]
> root 83 0.0 0.0 0 0 ? S 22:20 0:00 [kworker/3:1]
> root 85 0.0 0.0 0 0 ? S 22:20 0:00 [kworker/0:2]
> root 217 0.0 0.0 0 0 ? S< 22:20 0:00 [mpt_poll_0]
>
> Thanks
> Jay
>
>
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20141120/d683449c/attachment.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* work queue
2014-11-19 17:02 ` Dave Tian
@ 2014-11-20 13:36 ` 户户
2014-11-25 12:22 ` Arun KS
0 siblings, 1 reply; 4+ messages in thread
From: 户户 @ 2014-11-20 13:36 UTC (permalink / raw)
To: kernelnewbies
Thank you for reply,
Isn't this function 'create_workqueue("myfoo");' gonna create a new worker? it is expanded to "alloc_workqueue((name), WQ_MEM_RECLAIM, 1)" which means it is not a UNBOUND work queue. am I right?
is "queue_work_on(get_cpu(), test_queue_ptr, &test_work);" gonna put the work(test_work) in workqueue pointed by "test_queue_ptr"?
My Kernel release:
Linux test 3.10.58 #2 SMP Sun Oct 19 23:29:54 CST 2014 x86_64 x86_64 x86_64 GNU/Linux
Thanks
Jay
At 2014-11-20 01:02:46, "Dave Tian" <dave.jing.tian@gmail.com> wrote:
You were not creating a new worker but using the generic kernel worker (kworker) to handle your work. Besides, there is no CPU bound for this work, which means any CPU is able to run the work.
Dave Tian
dave.jing.tian at gmail.com
On Nov 19, 2014, at 11:21 PM, ?? <6563572@163.com> wrote:
I'm playing around with work_queue in my VMware workstation. but I hit a problem that the work is processed by [kworker/3:1] other than my work queue.
static int __init test_init(void)
{
pr_info(" (*) test_init start - pid:%d. cpu:%d\n", current->pid, get_cpu());
int ret = 0;
test_queue_ptr = create_workqueue("myfoo");
// test_queue_ptr = create_singlethread_workqueue("test_workqueue");
if(!test_queue_ptr){
goto test_queue_ptr_error;
}
INIT_WORK(&test_work, test_cb);
// ret = queue_work(test_queue_ptr, &test_work);
ret = queue_work_on(get_cpu(), test_queue_ptr, &test_work);
// schedule_work(&test_work);
pr_info(" (*) test_init - queue_work_on return:%d. \n", ret);
return 0;
test_queue_ptr_error:
destroy_workqueue(test_queue_ptr);
return 0;
}
static void test_cb(struct work_struct *work)
{
pr_info(" (*) test_cb - pid:%d. cpu:%d\n", current->pid, get_cpu());
}
isnmod the module gives me the output :
Nov 19 23:11:18 test kernel: [ 3031.766137] (*) test_init start - pid:8594. cpu:3
Nov 19 23:11:18 test kernel: [ 3031.766371] (*) test_init - queue_work_on return:1.
Nov 19 23:11:18 test kernel: [ 3031.766672] (*) test_cb - pid:83. cpu:3 <--- this line indicates "test_cb" function is running on process 83 ([kworker/3:1]).
ps aux
....
root 82 0.0 0.0 0 0 ? S< 22:20 0:00 [charger_manager]
root 83 0.0 0.0 0 0 ? S 22:20 0:00 [kworker/3:1]
root 85 0.0 0.0 0 0 ? S 22:20 0:00 [kworker/0:2]
root 217 0.0 0.0 0 0 ? S< 22:20 0:00 [mpt_poll_0]
Thanks
Jay
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20141120/aaf10448/attachment.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* work queue
2014-11-20 13:36 ` 户户
@ 2014-11-25 12:22 ` Arun KS
0 siblings, 0 replies; 4+ messages in thread
From: Arun KS @ 2014-11-25 12:22 UTC (permalink / raw)
To: kernelnewbies
Hello Jay,
On Thu, Nov 20, 2014 at 7:06 PM, ?? <6563572@163.com> wrote:
> Thank you for reply,
>
> Isn't this function 'create_workqueue("myfoo");' gonna create a new worker?
create_workqueue will not create a new worker. Workers are created and
destroyed dynamically, and is independent of the workqueue. The
implementation is changed.
You can start with this nice documentation of CMWQ,
Documentation/workqueue.txt
Thanks,
Arun
> it is expanded to "alloc_workqueue((name), WQ_MEM_RECLAIM, 1)" which means
> it is not a UNBOUND work queue. am I right?
> is "queue_work_on(get_cpu(), test_queue_ptr, &test_work);" gonna put the
> work(test_work) in workqueue pointed by "test_queue_ptr"?
>
> My Kernel release:
> Linux test 3.10.58 #2 SMP Sun Oct 19 23:29:54 CST 2014 x86_64 x86_64 x86_64
> GNU/Linux
>
> Thanks
> Jay
>
> At 2014-11-20 01:02:46, "Dave Tian" <dave.jing.tian@gmail.com> wrote:
>
> You were not creating a new worker but using the generic kernel worker
> (kworker) to handle your work. Besides, there is no CPU bound for this work,
> which means any CPU is able to run the work.
>
> Dave Tian
> dave.jing.tian at gmail.com
>
>
>
> On Nov 19, 2014, at 11:21 PM, ?? <6563572@163.com> wrote:
>
> I'm playing around with work_queue in my VMware workstation. but I hit a
> problem that the work is processed by [kworker/3:1] other than my work
> queue.
>
> static int __init test_init(void)
> {
> pr_info(" (*) test_init start - pid:%d. cpu:%d\n", current->pid,
> get_cpu());
> int ret = 0;
> test_queue_ptr = create_workqueue("myfoo");
> // test_queue_ptr = create_singlethread_workqueue("test_workqueue");
>
> if(!test_queue_ptr){
> goto test_queue_ptr_error;
> }
> INIT_WORK(&test_work, test_cb);
> // ret = queue_work(test_queue_ptr, &test_work);
> ret = queue_work_on(get_cpu(), test_queue_ptr, &test_work);
> // schedule_work(&test_work);
> pr_info(" (*) test_init - queue_work_on return:%d. \n", ret);
> return 0;
> test_queue_ptr_error:
> destroy_workqueue(test_queue_ptr);
> return 0;
> }
>
> static void test_cb(struct work_struct *work)
> {
> pr_info(" (*) test_cb - pid:%d. cpu:%d\n", current->pid, get_cpu());
> }
>
> isnmod the module gives me the output :
>
> Nov 19 23:11:18 test kernel: [ 3031.766137] (*) test_init start - pid:8594.
> cpu:3
> Nov 19 23:11:18 test kernel: [ 3031.766371] (*) test_init - queue_work_on
> return:1.
> Nov 19 23:11:18 test kernel: [ 3031.766672] (*) test_cb - pid:83. cpu:3
> <--- this line indicates "test_cb" function is running on process 83
> ([kworker/3:1]).
>
> ps aux
> ....
> root 82 0.0 0.0 0 0 ? S< 22:20 0:00
> [charger_manager]
> root 83 0.0 0.0 0 0 ? S 22:20 0:00
> [kworker/3:1]
> root 85 0.0 0.0 0 0 ? S 22:20 0:00
> [kworker/0:2]
> root 217 0.0 0.0 0 0 ? S< 22:20 0:00
> [mpt_poll_0]
>
> Thanks
> Jay
>
>
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
>
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-11-25 12:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-19 15:21 work queue 户户
2014-11-19 17:02 ` Dave Tian
2014-11-20 13:36 ` 户户
2014-11-25 12:22 ` Arun KS
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).