kworker线程的起源 [英] Origin of a kworker-thread

查看:363
本文介绍了kworker线程的起源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用内核3.2的新安装的系统上,我看到一个kworker线程,该线程一直在消耗CPU.我想找出内核/模块的哪个部分创建了此工作队列.

On my newly installed system using kernel 3.2 I see a kworker-thread which is constantly consuming CPU. I'd like to find out which part of kernel/module has created this workqueue.

如何跟踪名为"kworker/0:3"的kworker线程到其在内核空间中的起源?

How to track a kworker-thread named for example ''kworker/0:3 to its origin in kernel-space?

我试图查看/sys/kernel/debug/tracing/events/workqueue,但无法弄清楚.

I tried to look into /sys/kernel/debug/tracing/events/workqueue, but wasn't able to figure it out.

推荐答案

(在我看来,这在这里不太合适,但这是unix.stackexchange.com.)

(Seems to me this is rather off topic here, but here's the answer I posted on unix.stackexchange.com.)

我发现此lkml线程可以回答您的问题. (似乎Linus本人也对如何找出这些线程的起源感到困惑.)

I found this thread on lkml that answers your question a little. (It seems even Linus himself was puzzled as to how to find out the origin of those threads.)

基本上,有两种方法可以做到这一点:

Basically, there are two ways of doing this:

$ echo workqueue:workqueue_queue_work > /sys/kernel/debug/tracing/set_event
$ cat /sys/kernel/debug/tracing/trace_pipe > out.txt
(wait a few secs)

为此,您需要在内核中编译 ftrace .

For this you will need ftrace to be compiled in your kernel.

这将输出所有线程正在执行的操作,对于跟踪多个小型作业很有用.

This will output what threads are all doing, and is useful for tracing multiple small jobs.

cat /proc/THE_OFFENDING_KWORKER/stack

这将输出一个单线程的堆栈,需要执行大量工作.它可能允许您找出导致此特定线程占用CPU的原因(例如). THE_OFFENDING_KWORKER是进程列表中kworker的pid.

This will output the stack of a single thread doing a lot of work. It may allow you to find out what caused this specific thread to hog the CPU (for example). THE_OFFENDING_KWORKER is the pid of the kworker in the process list.

这篇关于kworker线程的起源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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