<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>Thank you for reply,<br><br>Isn't&nbsp; 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, &amp;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" &lt;dave.jing.tian@gmail.com&gt; 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, »§»§ &lt;<a href="mailto:6563572@163.com" class="">6563572@163.com</a>&gt; 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="">&nbsp;&nbsp;&nbsp; pr_info(" (*) test_init start - pid:%d. cpu:%d\n", current-&gt;pid, get_cpu());<br class="">&nbsp;&nbsp;&nbsp; int ret = 0;<br class="">&nbsp;&nbsp;&nbsp; test_queue_ptr = create_workqueue("myfoo");<br class="">&nbsp;&nbsp;&nbsp; // test_queue_ptr = create_singlethread_workqueue("test_workqueue");<br class="">&nbsp;&nbsp;&nbsp; <br class="">&nbsp;&nbsp;&nbsp; if(!test_queue_ptr){<br class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; goto test_queue_ptr_error;<br class="">&nbsp;&nbsp;&nbsp; }<br class="">&nbsp;&nbsp;&nbsp; INIT_WORK(&amp;test_work, test_cb);<br class="">&nbsp;&nbsp;&nbsp; // ret = queue_work(test_queue_ptr, &amp;test_work);<br class="">&nbsp;&nbsp;&nbsp; ret = queue_work_on(get_cpu(), test_queue_ptr, &amp;test_work);<br class="">&nbsp;&nbsp;&nbsp; // schedule_work(&amp;test_work);<br class="">&nbsp;&nbsp;&nbsp; pr_info(" (*) test_init - queue_work_on return:%d. \n", ret);<br class="">&nbsp;&nbsp;&nbsp; return 0;<br class="">test_queue_ptr_error:<br class="">&nbsp;&nbsp;&nbsp; destroy_workqueue(test_queue_ptr);<br class="">&nbsp;&nbsp;&nbsp; return 0;<br class="">}<br class=""><br class="">static void test_cb(struct work_struct *work)<br class="">{<br class="">&nbsp;&nbsp;&nbsp; pr_info(" (*) test_cb - pid:%d. cpu:%d\n", current-&gt;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]&nbsp; (*) test_init start - pid:8594. cpu:3<br class="">Nov 19 23:11:18 test kernel: [ 3031.766371]&nbsp; (*) test_init - queue_work_on return:1. <br class="">Nov 19 23:11:18 test kernel: [ 3031.766672]&nbsp; (*) test_cb - pid:83. cpu:3&nbsp; &lt;--- 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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 82&nbsp; 0.0&nbsp; 0.0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0 ?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; S&lt;&nbsp;&nbsp; 22:20&nbsp;&nbsp; 0:00 [charger_manager]<br class="">root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 83&nbsp; 0.0&nbsp; 0.0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0 ?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; S&nbsp;&nbsp;&nbsp; 22:20&nbsp;&nbsp; 0:00 [kworker/3:1]<br class="">root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 85&nbsp; 0.0&nbsp; 0.0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0 ?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; S&nbsp;&nbsp;&nbsp; 22:20&nbsp;&nbsp; 0:00 [kworker/0:2]<br class="">root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 217&nbsp; 0.0&nbsp; 0.0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0 ?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; S&lt;&nbsp;&nbsp; 22:20&nbsp;&nbsp; 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>