work queue

户户 6563572 at 163.com
Wed Nov 19 10:21:23 EST 2014


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 


More information about the Kernelnewbies mailing list