<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>Thank you for reply,<br><br>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?<br>is "queue_work_on(get_cpu(), test_queue_ptr, &test_work);" gonna put the work(test_work) in workqueue pointed by "test_queue_ptr"?<br><br>My Kernel release:<br></div><div>Linux test 3.10.58 #2 SMP Sun Oct 19 23:29:54 CST 2014 x86_64 x86_64 x86_64 GNU/Linux<br><br>Thanks<br>Jay<br></div><div></div><div id="divNeteaseMailCard"></div><br>At 2014-11-20 01:02:46, "Dave Tian" <dave.jing.tian@gmail.com> wrote:<br> <blockquote id="isReplyContent" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">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.<div class=""><br class=""><div apple-content-edited="true" class="">
<div class="">Dave Tian</div><div class=""><a href="mailto:dave.jing.tian@gmail.com" class="">dave.jing.tian@gmail.com</a></div><div class=""><br class=""></div><br class="Apple-interchange-newline">
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Nov 19, 2014, at 11:21 PM, ȤȤ <<a href="mailto:6563572@163.com" class="">6563572@163.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="line-height: 1.7; font-size: 14px; font-family: Arial;" class=""><div class="">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.<br class=""><br class="">static int __init test_init(void)<br class="">{<br class=""> pr_info(" (*) test_init start - pid:%d. cpu:%d\n", current->pid, get_cpu());<br class=""> int ret = 0;<br class=""> test_queue_ptr = create_workqueue("myfoo");<br class=""> // test_queue_ptr = create_singlethread_workqueue("test_workqueue");<br class=""> <br class=""> if(!test_queue_ptr){<br class=""> goto test_queue_ptr_error;<br class=""> }<br class=""> INIT_WORK(&test_work, test_cb);<br class=""> // ret = queue_work(test_queue_ptr, &test_work);<br class=""> ret = queue_work_on(get_cpu(), test_queue_ptr, &test_work);<br class=""> // schedule_work(&test_work);<br class=""> pr_info(" (*) test_init - queue_work_on return:%d. \n", ret);<br class=""> return 0;<br class="">test_queue_ptr_error:<br class=""> destroy_workqueue(test_queue_ptr);<br class=""> return 0;<br class="">}<br class=""><br class="">static void test_cb(struct work_struct *work)<br class="">{<br class=""> pr_info(" (*) test_cb - pid:%d. cpu:%d\n", current->pid, get_cpu());<br class="">}<br class=""><br class="">isnmod the module gives me the output :<br class=""><br class="">Nov 19 23:11:18 test kernel: [ 3031.766137] (*) test_init start - pid:8594. cpu:3<br class="">Nov 19 23:11:18 test kernel: [ 3031.766371] (*) test_init - queue_work_on return:1. <br class="">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]).<br class=""><br class="">ps aux<br class="">....<br class="">root 82 0.0 0.0 0 0 ? S< 22:20 0:00 [charger_manager]<br class="">root 83 0.0 0.0 0 0 ? S 22:20 0:00 [kworker/3:1]<br class="">root 85 0.0 0.0 0 0 ? S 22:20 0:00 [kworker/0:2]<br class="">root 217 0.0 0.0 0 0 ? S< 22:20 0:00 [mpt_poll_0]<br class=""><br class="">Thanks<br class="">Jay<br class=""><br class=""><br class=""></div></div><br class=""><br class=""><span title="neteasefooter" class=""><span id="netease_mail_footer" class=""></span></span>_______________________________________________<br class="">Kernelnewbies mailing list<br class=""><a href="mailto:Kernelnewbies@kernelnewbies.org" class="">Kernelnewbies@kernelnewbies.org</a><br class="">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies<br class=""></div></blockquote></div><br class=""></div></blockquote></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>