linux开机发现会有个kworker进程规律性占用CPU负载超过50%

kworker 进程是内核工作进程,并且有很多进程是无害的。

内核工作线程可以做任何事情,例如一些随机的例子:

  1. 做页面缓存写回
  2. 处理某些种类的硬件事件 (如硬件中断,定时器,I / O等)
  3. 很多很多其他的东西

要知道任何kworker在做什么,你可以看看。

1 cat /proc/<kworker_pid>/stack

第一种思路是使用perf进行排查,执行以下代码

1 sudo echo "l" > /proc/sysrq-trigger   //将loglevel设置为1

2 sudo perf record -g -a sleep 10     // 记录10s内所有进程进行的动作,动作完成后会在当前目录下生成一个perf.data

3 sudo perf report         // 通过该命令进行查看

sysrq可以使用的command

66 'b'     - Will immediately reboot the system without syncing or unmounting 67           your disks. 68  69 
'c' - Will perform a system crash by a NULL pointer dereference. 70 A crashdump will be taken if configured. 71 72
'd' - Shows all locks that are held. 73 74
'e' - Send a SIGTERM to all processes, except for init. 75 76
'f' - Will call oom_kill to kill a memory hog process. 77 78
'g' - Used by kgdb on ppc and sh platforms. 79 80
'h' - Will display help (actually any other key than those listed 81 here will display help. but 'h' is easy to remember :-) 82 83
'i' - Send a SIGKILL to all processes, except for init. 84 85
'j' - Forcibly "Just thaw it" - filesystems frozen by the FIFREEZE ioctl. 86 87
'k' - Secure Access Key (SAK) Kills all programs on the current virtual 88 console. NOTE: See important comments below in SAK section. 89 90
'l' - Shows a stack backtrace for all active CPUs. 91 92
'm' - Will dump current memory info to your console. 93 94
'n' - Used to make RT tasks nice-able 95 96
'o' - Will shut your system off (if configured and supported). 97 98
'p' - Will dump the current registers and flags to your console. 99 100
'q' - Will dump per CPU lists of all armed hrtimers (but NOT regular 101 timer_list timers) and detailed information about all 102 clockevent devices. 103 104
'r' - Turns off keyboard raw mode and sets it to XLATE. 105 106
's' - Will attempt to sync all mounted filesystems. 107 108
't' - Will dump a list of current tasks and their information to your 109 console. 110 111
'u' - Will attempt to remount all mounted filesystems read-only. 112 113
'v' - Dumps Voyager SMP processor info to your console. 114 115
'w' - Dumps tasks that are in uninterruptable (blocked) state. 116 117
'x' - Used by xmon interface on ppc/powerpc platforms. 118 119
'z' - Dump the ftrace buffer 120 121
'0'-'9' - Sets the console log level, controlling which kernel messages 122 will be printed to your console. ('0', for example would make 123 it so that only emergency messages like PANICs or OOPSes would 124 make it to your console.) 125

  

根据kworker中执行的程序分析到有一些i2c传输的信息。执行

1 dmesg | grep i2c

对比正常的机器跟不正常的机器发现,不正常的机器一直在定时调度EDID。并且访问不到。所以判断是显卡出现了问题,因为用的是PCI接口的集成显卡

执行 

1 lspci | grep VGA

查找到对应的pci设备号,然后执行以下命令移除集成显卡

1 echo 1 > /sys/bus/pci/devices/对应的pci设备号/remove

移除后发现CPU负载下降为正常时候,不再出现定时负载超过50%的情况。由此推断出是因为集成显卡驱动的问题,所以需要联系集成显卡厂商,让他们进行修改

原文地址:https://www.cnblogs.com/zongfanstudy/p/14791847.html