Linux kernel 验证何处';kworker/n:n';(在ps-aux中)从
在“ps-aux”的结果中,我找不到如何验证“kworker/…”是从中创建的,以及与之相关的模块/函数 请让我知道我是如何通过pid或其他方式找到kworkers的 我尝试在/proc中检查文件,但没有显示任何有关此的内容Linux kernel 验证何处';kworker/n:n';(在ps-aux中)从,linux-kernel,Linux Kernel,在“ps-aux”的结果中,我找不到如何验证“kworker/…”是从中创建的,以及与之相关的模块/函数 请让我知道我是如何通过pid或其他方式找到kworkers的 我尝试在/proc中检查文件,但没有显示任何有关此的内容 $ 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
$ 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]
$ps-aux | grep kworker
根15 0.0 0.0?八月十二日上午十时正[kworker/1:0]
根16 0.0 0.0?S<2012年8月0:00[kworker/1:0小时]
根85 0.0 0.0?S
对于我熟悉的这类问题,一个很好的解决方案是使用性能工具(默认情况下并不总是启用,您可能需要在设备上启用)
步骤1:设置性能以记录工作队列事件:
perf record -e 'workqueue:*' -ag -T
第2步:只要您认为需要捕获事件,就可以运行它(如果此事件足够频繁,10秒应该可以,但您可以让它运行更长时间,具体取决于设备上剩余的可用空间),然后使用Ctrl+C
停止它
步骤3:打印捕获的事件(在Linux版本<4.1上,我认为应该是-f而不是-f):
这将显示如下内容:
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\u runtime\u work
推送到工作队列。
在第三行中,我们可以看到kworker/0:3(pid 24223)
正在执行该工作
摘要:现在回到您的问题,我们看到kworker/0:3
已被turtle
任务请求运行pm\u runtime\u work
功能。
现在,如果您想进一步挖掘,您需要深入代码,了解
pm\u runtime\u work
函数的功能。祝你好运 您知道kworker只是一个完全在内核代码中创建的内核线程,是吗?您可以在Ask Ubuntu上查看此问题:。
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