验证从何处调用"kworker/n:n"(在ps -aux中) [英] verifying where 'kworker/n:n' (in ps -aux) is invoked from

查看:33
本文介绍了验证从何处调用"kworker/n:n"(在ps -aux中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于'ps -aux'的结果,我找不到如何验证从中创建'kworker/...'以及与之相关的模块/功能的信息.

In the result of 'ps -aux', I couldn't find how to verify that 'kworker/...' are created from and what module/functions are related to it.

请告诉我如何通过 pid 或其他方式找出 kworkers 的来源.

Please let me know how I find out kworkers are from with pid or else.

我尝试检查/proc中的文件,对此一无所获.

I've try to check files in /proc, nothing is shown about this.

$ ps -aux | grep kworker
root        15  0.0  0.0      0     0 ?        S    Aug12   0:00 [kworker/1:0]
root        16  0.0  0.0      0     0 ?        S<   Aug12   0:00 [kworker/1:0H]
root        85  0.0  0.0      0     0 ?        S<   Aug12   0:09 [kworker/0:1H]
root      3562  0.0  0.0      0     0 ?        S<   Aug12   0:00 [kworker/0:2H]
root      5578  0.0  0.0      0     0 ?        S    11:13   0:01 [kworker/0:0]
root      5579  0.0  0.0      0     0 ?        S    11:13   0:00 [kworker/u4:1]
root      8789  0.1  0.0      0     0 ?        S    12:19   0:10 [kworker/0:2]
root     30236  0.0  0.0      0     0 ?        S    08:39   0:01 [kworker/u4:0]

推荐答案

对于我所熟悉的这类问题,一个很好的解决方案是使用 perf工具.默认设置,您可能需要在设备上安装perf ).

A good solution for these kinds of problems that I'm familiar with is to use the perf tool (It's not always enabled by default and you may need to install perf on your device).

步骤1:设置性能以记录工作队列事件:

Step 1: Set perf to record workqueue events:

perf record -e 'workqueue:*' -ag -T

第2步:只要您认为自己需要赶上该事件,就可以运行它(如果此事件足够频繁,则可以等待10秒,但您可以让它运行更长的时间,取决于您已经留在设备上的可用可用空间),然后按 Ctrl + C 停止它.

Step 2: Run it as long as you think you need to catch the event (10 seconds should be ok if this event is frequent enough, but you can let it run longer, depending on the available free space you have left on your device) and then stop it with Ctrl + C.

第3步:(在Linux版本< 4.1上,我认为应该是-f而不是-F)打印捕获的事件:

Step 3: Print the captured events (on Linux versions < 4.1 I think it should be -f and not -F):

perf script -F comm,pid,tid,time,event,trace

这将显示如下内容:

      task-name    pid/tid     timestamp    event 
------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
    turtle        9201/9201   1473.339166:  workqueue:workqueue_queue_work:    work struct=0xef20d4c4 function=pm_runtime_work workqueue=0xef1cb600 req_cpu=8 cpu=1
    turtle        9201/9201   1473.339176:  workqueue:workqueue_activate_work: work struct 0xef20d4c4
    kworker/0:3  24223/24223  1473.339221:  workqueue:workqueue_execute_start: work struct 0xef20d4c4: function pm_runtime_work
    kworker/0:3  24223/24223  1473.339248:  workqueue:workqueue_execute_end:   work struct 0xef20d4c4

步骤4:分析上表:

在第一行中,名为 turtle(pid 9201)的任务将工作 pm_runtime_work 推送到工作队列.在第三行中,我们看到 kworker/0:3(pid 24223)正在执行该工作.

In the first row, a task named turtle (pid 9201) is pushing the work pm_runtime_work to the workqueue. In the third row, we can see that the kworker/0:3 (pid 24223) is executing that work.

摘要:现在回到您的问题,我们看到 turtle 任务已请求 kworker/0:3 来运行 pm_runtime_work 函数.现在,如果您想进一步研究,您将进入代码中,看看 pm_runtime_work 函数的作用.祝你好运!

Summary: Now back to your questions, we see that kworker/0:3 has been requested by turtle task to run the pm_runtime_work function. Now, if you want to dig further, you'll have step into the code and see what the pm_runtime_work function does. Good luck !!!

这篇关于验证从何处调用"kworker/n:n"(在ps -aux中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆