TOP does not show CPU usage for any process (0.0)

本文详细介绍了在Red Hat Enterprise Linux 7.6中,当遇到top命令无法正确显示进程CPU使用率的问题时的解决方案。故障可能源于TSC同步失败,重启机器并检查错误消息是否消失是一种解决办法。若问题持续,建议更新BIOS或升级内核到版本3.10.0-957.21.3.el7,该版本包含了更新的TSC时钟驱动。

 

TOP does not show CPU usage for any process (0.0)

 SOLUTION 已验证 - 已更新 2019年七月25日16:56 - 

English 

环境

  • Red Hat Enterprise Linux 7.6

问题

  • TOP does not show CPU usage for any process (0.0)

决议

  • Restart the machine and check whether the TSC error message disappears.
  • A BIOS update is suggested.
  • If the error persists, update kernel to version kernel-3.10.0-957.21.3.el7 which has updated TSC clock drivers

根源

  • Due to a failure in TSC synchronization, top utility does not show CPU usage properly in the RHEL7.
  • The issue was identified in some Dell servers.

诊断步骤

After top had been running for around 1 minute while high intensive CPU operations were being executed, all processes showed no CPU usage.

You can verify that by running top in batch mode, then checking if some process is showing CPU usage (not 0.0).

Raw

#top -b -n10 > /tmp/top.txt
#awk '{if($1 ~ /^[0-9]/ && $9 != "0.0") print}' /tmp/top.txt

In a normal scenario, some output should appear (as the sample below).

Raw

#awk '{if($1 ~ /^[0-9]/ && $9 != "0.0") print}' /tmp/top.txt
19534 root       0 -20       0      0      0 I   0.3   0.0   0:07.00 kworker/u17:3-kcryptd/253:0
19880 root       0 -20       0      0      0 I   0.3   0.0   0:06.66 kworker/u17:7-kcryptd/253:0
20337 root       0 -20       0      0      0 I   0.3   0.0   0:04.18 kworker/u17:6-kcryptd/253:0
21208 root       20   0 2936108 282856 170584 S   0.3   1.8   0:09.72 Web Content
21299 root      20   0       0      0      0 I   0.3   0.0   0:00.05 kworker/7:2-mm_percpu_wq
21305 root       20   0 2874484 272912 136212 S   0.3   1.7   0:08.12 Web Content
21704 root       0 -20       0      0      0 I   0.3   0.0   0:00.45 kworker/u17:8-kcryptd/253:0

If no process appears, that may be a problem.

In addition to that, check whether the TSC clocksource error appeared in dmesg logs:

Raw

#dmesg | grep -ir "tsc\|clocksource"  
[    0.000000] tsc: Detected 2600.000 MHz processor
[    0.195594] TSC deadline timer enabled
[    0.201405] TSC synchronization [CPU#0 -> CPU#1]:
[    0.201407] Measured 249252531012 cycles TSC warp between CPUs, turning off TSC clock.
[    0.201409] tsc: Marking TSC unstable due to check_tsc_sync_source failed
[    0.456994] Switched to clocksource hpet

You should also see TSC clock is not available in available_clocksource file.

Raw

#cat sys/devices/system/clocksource/clocksource0/available_clocksource 
hpet acpi_pm 

As a consequence, the OS will switch to an alternative clocksource. Here, in this case, it's "hpet" and incorrect information may appear in top utility.

Raw

#cat sys/devices/system/clocksource/clocksource0/current_clocksource  
hpet
### 解决 Vue 中 `Property data does not exist on type any[]` 的类型错误 在使用 Vue 3 和 TypeScript 的组合式 API 时,如果尝试访问一个数组对象的 `.data` 属性,TypeScript 可能会报错:`Property 'data' does not exist on type 'any[]'`。这种问题通常出现在未正确声明响应式变量的结构类型,导致 TypeScript 推断其为数组而非具有 `data` 属性的对象。 #### 显式定义数据结构并使用 `ref` 为了避免该错误,应显式定义数据结构并通过 `ref` 进行类型标注: ```ts import { ref } from 'vue'; interface DataItem { id: number; name: string; } interface DataSource { data: DataItem[]; } const dataSource = ref<DataSource | null>(null); ``` 通过这种方式,TypeScript 能够识别 `dataSource.value?.data` 是一个 `DataItem[]` 类型的数组,并允许对其进行 `map` 操作[^2]: ```ts if (dataSource.value && dataSource.value.data) { const result = dataSource.value.data.map(item => item.name); } ``` #### 使用可选链操作符简化访问逻辑 为了进一步提升代码简洁性与安全性,可以使用可选链(`?.`)来避免空值访问错误: ```ts const result = dataSource.value?.data?.map(item => item.id); ``` 该方式确保即使 `dataSource.value` 或 `data` 为 `null` 或 `undefined`,也不会抛出异常,同时保持类型安全[^2]。 #### 使用 `computed` 属性进行派生数据处理 若需对 `data` 数组进行计算处理,建议使用 `computed` 属性封装逻辑: ```ts import { computed } from 'vue'; const processedNames = computed(() => { return dataSource.value?.data?.map(item => item.name.toUpperCase()) || []; }); ``` 此方法不仅提高了代码的可读性和维护性,还增强了响应式更新的能力,适用于模板中直接绑定使用[^1]。 --- ###
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值