<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">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></body></html>