我最近遇到了一个问题。系统无法进入c7s睡眠,只能进入c3。
(c状态不能达到c7s,cpu的c状态,c0是运行状态,其他状态是空闲状态,睡眠越深,c的-state值越大)这时的第一感觉是系统忙。使用perttop查看消耗CPU的进程和热功能:1perftop-E100--stdio“ perf-top.txt219.85%perf [。
] __ Symbols__insert37.68%perf [。 ] Rb_next44.60%libc-2.26.so [。
] __ Strcmp_sse2_unaligned54.20%libelf-0.168.so [。 ] Gelf_getsym63.92%perf [。
] Dso__load_sym73.86%libc-2.26.so [。 ] _Int_malloc83.60%libc-2.26.so [。
] __Libc_calloc93.30%libc-2.26.so [。 ] Vfprintf102.95%perf [。
] Rb_insert_color112.61%[内核] [k] prepare_exit_to_usermode122.51%perf [。 ] Machine__map_x86_64_entry_trampolines132.31%perf [。
] Symbol__new142.22%[kernel] [k] do_syscall_64152.11%libc-2.26.so [。 ] __Strlen_avx2发现只有perf工具本身会消耗系统中的cpu :(然后,我想知道系统中的某个进程是否没有使cpu进入c7s睡眠。
这时,请使用traceevent监视系统中的sched_switch事件。使用跟踪-CMD的工具监视器上进行30秒所有的CPU都sched_switch(处理切换)事件:#跟踪cmdrecord-esched:sched_switch-M-1sleep302CPU0datarecordedatoffset = 0x63e0003102400bytesinsize4CPU1datarecordedatoffset = 0x65700058192bytesinsize6CPU2datarecordedatoffset =在原始数据的0x6590007203480bytesinsize82065bytes的traceoffset = 0x65700058192bytesinsize6CPU2datarecordedatoffset = 0x6590007203480bytesinsize82045不够直观,没有统计信息可以切换到某个过程:1#trace-cmdreport2cpus = 43trace-cmd-19794 [001] 225127.464466:sched_switch:trace-cmd:19794 [120] S ==》 swapper / 1 :0 [120] 4trace-cmd-19795 [003] 225127.464601:sched_switch:trace-cmd:19795 [120] S ==》 swapper / 3:0 [120] 5sleep-19796 [ 002] 225127.464792:sched_switch:睡眠:19796 [120] S ==》交换器/ 2:0 [120] 6《空闲》 -0 [003] 225127.471948:sched_switch:swipper / 3:0 [120] R ==》 rcu_sched :11 [120] 7rcu_sched-11 [003] 225127.471950:计划开关:rcu_sched:11 [120] W ==》 swapper / 3:0 [120] 8《空闲》 -0 [003] 225127.479959:sched_switch:swaper / 3: 0 [120] R ==》 rcu_sched:11 [120] 9rcu_sched-11 [003] 2251 27.479960:sched_switch:rcu_sched:11 [120] W ==》 swapper / 3:0 [120] 10《空闲》 -0 [ 003] 225127.487959:sched_switch:swapper / 3:0 [120] R ==》 rcu_sched:11 [120] 11rcu_sched-11 [003] 225127.487961:sched_switch:rcu_sched:11 [120] W ==” swapper / 3:0 [120] 12个“空闲” -0 [002] 225127.491959:sched_switch:交换器/ 2:0 [120] R ==》 kworker / 2:2:19735 [120] 13kworker / 2:2-19735 [002] 225127.491972 :sched_switch:kworker / 2:2:19735 [120] W ==》 swapper / 2:0 [120]。
..使用正则表达式过滤trace-cmdreport的结果,然后对其进行排序和计数:1trace-cmdreport | grep-o'==》 [^] + :? ' | sort | uniq-c23 ==》 irqbalance:103433 ==》 khugepaged:43420 ==》 ksoftirqd / 0:1051 ==》 ksoftirqd / 1:18618 ==》 ksoftirqd / 3:3071 ==》 kthreadd :1979881 = =》 kthreadd:294 ==》 kworker / 0:0:19785101 ==》 kworker / 0:1:19736115 ==》 kworker / 0:1:19798125 ==》 kworker / 0:1H:3641353 == 》 kworker / 0:2:196141419 ==》 kworker / 1:1:76651530 ==》调谐:1949819。 ..找到可调整的可疑线程,并将其切换为在30秒内运行30次,其他线程为常规线程。
此时,请检查系统中是否启用了调优服务:确实系统已经启用了调优服务,然后调出了名为tuned的线程。检查已调整服务的配置文件:localhost:/ home / jeff#tuned-admactiveCurrentactiveprofile:sap-hanalocalhost:/home/jeff#cat/usr/lib/tuned/sap-hana/tuned.conf [main] summary = OptimizeforSAPNetWeaver ,基于SAPHANA和HANA的产品force_latency = 70发现,关于cpu项,将强制延迟时间设置为70秒,force_latency = 70,这是为了优化HANA数据库。
force_latency如何工作?搜索后,我发现此值已设置为/ dev / cpu_dma_latency。使用lsof / dev / cpu_dma_latency,我发现调整后的线程确实正在运行此文件#lsof / dev / cpu_dma_latencyCOMMANDPIDUSERFDTYPEDEVICESIZE / OFFNODENAME1400,dev / cpu_dma_latency和Linux内核文档也解释了/ dev / cpu_dma_latency文件。
如果要写入,打开后写入数据后不要关闭。如果释放文件描述符,它将被恢复为默认值。
它还确认上面的lsof / dev / cpu_dma_latency的输出。在PMQoS文档中指定的https://github.com/torvalds/linux/blob/v5.8/Documentation/trace/coresight/coresight-cpu-debug.rstAsspec中指定的参数将保持有效,直到文件描述发布为止。
例如:#exec3《》 / dev / cpu_dma_latency; echo0》& 3。 ..Dosomework .. ..。
#exec3《》-检查/ dev / cpu_dma_latency文件的内容,确实是70,即(force_latency = 70)localhost:/ home / jeff#cat / dev / cpu_dma_l。