Ubuntu 20.10 上的 CPU 使用率过高

Ubuntu 20.10 上的 CPU 使用率过高

几天前,我的戴尔 Latitude 5480 上的所有东西都变慢了。我有 16GB 的 RAM,它的使用率很少超过 40%,但通常不会使用那么多 CPU 的应用程序现在却高达 100%,尤其是视频。我尝试从 Firefox 切换到 Chromium,我禁用了 Firefox 上的 GPU 加速,但无济于事。在这些情况下,top 会显示 Firefox 或 Chromium 是罪魁祸首,但在 Firefox 任务控制台中没有任何问题,在 Firefox 看来,没有哪个选项卡特别占用过多的 CPU。我想强调的是,几天前根本没有发生这种情况。以下是 @heynnema 在类似情况下要求提供的一些信息(Ubuntu 20.04 使用后速度变慢):https://paste.ubuntu.com/p/qpFg8gkV8f/

$ top

top - 20:54:37 up 3 min,  1 user,  load average: 6,82, 3,20, 1,26
Tasks: 254 total,   3 running, 251 sleeping,   0 stopped,   0 zombie
%Cpu(s): 75,5 us, 23,5 sy,  0,0 ni,  1,0 id,  0,0 wa,  0,0 hi,  0,0 si,  0,0 st
MiB Mem :  15871,7 total,  11662,1 free,   2618,7 used,   1590,9 buff/cache
MiB Swap:  30518,0 total,  30518,0 free,      0,0 used.  12718,8 avail Mem 

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                                        
   2153 leandro   20   0 3692108 551256 171408 R 170,0   3,4   2:58.64 firefox                                                                        
   2701 leandro   20   0 2845060 376568 176988 R  75,0   2,3   0:44.78 Web Content                                                                    
   2432 leandro   20   0   26,9g 571352  98404 S  45,0   3,5   1:04.69 WebExtensions                                                                  
   2825 leandro   20   0  218560  58392  42652 S  20,0   0,4   0:01.66 RDD Process                                                                    
   2902 leandro   20   0   21524   4312   3512 R  20,0   0,0   0:00.08 top                                                                            
   2275 leandro   20   0 2711824 302536 103468 S  15,0   1,9   0:45.91 Web Content                                                                    
   1655 leandro   20   0  862908  73856  49624 S  10,0   0,5   0:14.60 Xorg                                                                           
   1856 leandro   20   0 4007508 267416 103672 S  10,0   1,6   0:35.87 gnome-shell                                                                    
   2504 leandro   20   0 2486004 157748 100972 S  10,0   1,0   0:06.86 Web Content                                                                    
   2213 leandro   20   0 2523948 177836 108792 S   5,0   1,1   0:13.12 Web Content                                                                    
   2331 leandro   20   0  835556  62888  40308 S   5,0   0,4   0:04.37 terminator                                                                     
      1 root      20   0  169312  12420   8652 S   0,0   0,1   0:03.93 systemd                                                                        
      2 root      20   0       0      0      0 S   0,0   0,0   0:00.00 kthreadd                                                                       
      3 root       0 -20       0      0      0 I   0,0   0,0   0:00.00 rcu_gp                                                                         
      4 root       0 -20       0      0      0 I   0,0   0,0   0:00.00 rcu_par_gp                                                                     
      5 root      20   0       0      0      0 I   0,0   0,0   0:00.00 kworker/0:0-events                                                             
      6 root       0 -20       0      0      0 I   0,0   0,0   0:00.00 kworker/0:0H-kblockd                                                           
      7 root      20   0       0      0      0 I   0,0   0,0   0:00.00 kworker/0:1-events                                                             
      8 root      20   0       0      0      0 I   0,0   0,0   0:00.14 kworker/u8:0-ext4-rsv-conversion                                               
      9 root       0 -20       0      0      0 I   0,0   0,0   0:00.00 mm_percpu_wq                                                                   
     10 root      20   0       0      0      0 S   0,0   0,0   0:00.07 ksoftirqd/0                                                                    
     11 root      20   0       0      0      0 I   0,0   0,0   0:00.65 rcu_sched                                                                      
     12 root      rt   0       0      0      0 S   0,0   0,0   0:00.00 migration/0                                                                    
     13 root     -51   0       0      0      0 S   0,0   0,0   0:00.00 idle_inject/0                                                                  
     14 root      20   0       0      0      0 S   0,0   0,0   0:00.00 cpuhp/0                                                                        
     15 root      20   0       0      0      0 S   0,0   0,0   0:00.00 cpuhp/1                                                                        
     16 root     -51   0       0      0      0 S   0,0   0,0   0:00.00 idle_inject/1                                                                  
     17 root      rt   0       0      0      0 S   0,0   0,0   0:00.21 migration/1                                                                    
     18 root      20   0       0      0      0 S   0,0   0,0   0:00.08 ksoftirqd/1                                                                    
     19 root      20   0       0      0      0 I   0,0   0,0   0:00.01 kworker/1:0-events                                                             
     20 root       0 -20       0      0      0 I   0,0   0,0   0:00.00 kworker/1:0H-kblockd                                                           
     21 root      20   0       0      0      0 S   0,0   0,0   0:00.00 cpuhp/2       

$ free -h
              total        used        free      shared  buff/cache   available
Mem:           15Gi       2,4Gi        11Gi       206Mi       1,5Gi        12Gi
Swap:          29Gi          0B        29Gi


$ sudo turbostat --Summary --show Busy%,Bzy_MHz,IRQ,PkgWatt,PkgTmp,RAMWatt,GFXWatt --interval 15
turbostat version 20.03.20 - Len Brown <[email protected]>
CPUID(0): GenuineIntel 0x16 CPUID levels; 0x80000008 xlevels; family:model:stepping 0x6:8e:9 (6:142:9)
CPUID(1): SSE3 MONITOR SMX EIST TM2 TSC MSR ACPI-TM HT TM
CPUID(6): APERF, TURBO, DTS, PTM, HWP, HWPnotify, HWPwindow, HWPepp, No-HWPpkg, EPB
cpu2: MSR_IA32_MISC_ENABLE: 0x00850089 (TCC EIST MWAIT PREFETCH TURBO)
CPUID(7): SGX
cpu2: MSR_IA32_FEATURE_CONTROL: 0x00000005 (Locked )
CPUID(0x15): eax_crystal: 2 ebx_tsc: 226 ecx_crystal_hz: 0
TSC: 2712 MHz (24000000 Hz * 226 / 2 / 1000000)
CPUID(0x16): base_mhz: 2700 max_mhz: 3500 bus_mhz: 100
cpu2: MSR_MISC_PWR_MGMT: 0x00401cc0 (ENable-EIST_Coordination DISable-EPB DISable-OOB)
RAPL: 17476 sec. Joule Counter Range, at 15 Watts
cpu2: MSR_PLATFORM_INFO: 0x804043df1011b00
4 * 100.0 = 400.0 MHz max efficiency frequency
27 * 100.0 = 2700.0 MHz base frequency
cpu2: MSR_IA32_POWER_CTL: 0x0024005d (C1E auto-promotion: DISabled)
cpu2: MSR_TURBO_RATIO_LIMIT: 0x23232323
35 * 100.0 = 3500.0 MHz max turbo 4 active cores
35 * 100.0 = 3500.0 MHz max turbo 3 active cores
35 * 100.0 = 3500.0 MHz max turbo 2 active cores
35 * 100.0 = 3500.0 MHz max turbo 1 active cores
cpu2: MSR_CONFIG_TDP_NOMINAL: 0x0000001a (base_ratio=26)
cpu2: MSR_CONFIG_TDP_LEVEL_1: 0x0008003c (PKG_MIN_PWR_LVL1=0 PKG_MAX_PWR_LVL1=0 LVL1_RATIO=8 PKG_TDP_LVL1=60)
cpu2: MSR_CONFIG_TDP_LEVEL_2: 0x001b00c8 (PKG_MIN_PWR_LVL2=0 PKG_MAX_PWR_LVL2=0 LVL2_RATIO=27 PKG_TDP_LVL2=200)
cpu2: MSR_CONFIG_TDP_CONTROL: 0x00000000 ( lock=0)
cpu2: MSR_TURBO_ACTIVATION_RATIO: 0x00000017 (MAX_NON_TURBO_RATIO=23 lock=0)
cpu2: MSR_PKG_CST_CONFIG_CONTROL: 0x1e008008 (UNdemote-C3, UNdemote-C1, demote-C3, demote-C1, locked, pkg-cstate-limit=8 (unlimited))
cpu2: cpufreq driver: intel_pstate
cpu2: cpufreq governor: powersave
cpufreq intel_pstate no_turbo: 0
cpu2: MSR_MISC_FEATURE_CONTROL: 0x00000000 (L2-Prefetch L2-Prefetch-pair L1-Prefetch L1-IP-Prefetch)
cpu0: MSR_PM_ENABLE: 0x00000001 (HWP)
cpu0: MSR_HWP_CAPABILITIES: 0x01081a23 (high 35 guar 26 eff 8 low 1)
cpu0: MSR_HWP_REQUEST: 0x80002304 (min 4 max 35 des 0 epp 0x80 window 0x0 pkg 0x0)
cpu0: MSR_HWP_INTERRUPT: 0x00000000 (Dis_Guaranteed_Perf_Change, Dis_Excursion_Min)
cpu0: MSR_HWP_STATUS: 0x00000000 (No-Guaranteed_Perf_Change, No-Excursion_Min)
cpu0: MSR_IA32_ENERGY_PERF_BIAS: 0x00000006 (balanced)
cpu0: MSR_RAPL_POWER_UNIT: 0x000a0e03 (0.125000 Watts, 0.000061 Joules, 0.000977 sec.)
cpu0: MSR_PKG_POWER_INFO: 0x00000078 (15 W TDP, RAPL 0 - 0 W, 0.000000 sec.)
cpu0: MSR_PKG_POWER_LIMIT: 0x4280c800dd8078 (UNlocked)
cpu0: PKG Limit #1: ENabled (15.000000 Watts, 28.000000 sec, clamp ENabled)
cpu0: PKG Limit #2: ENabled (25.000000 Watts, 0.002441* sec, clamp DISabled)
cpu0: MSR_DRAM_POWER_LIMIT: 0x5400de00000000 (UNlocked)
cpu0: DRAM Limit: DISabled (0.000000 Watts, 0.000977 sec, clamp DISabled)
cpu0: MSR_PP0_POLICY: 0
cpu0: MSR_PP0_POWER_LIMIT: 0x00000000 (UNlocked)
cpu0: Cores Limit: DISabled (0.000000 Watts, 0.000977 sec, clamp DISabled)
cpu0: MSR_PP1_POLICY: 0
cpu0: MSR_PP1_POWER_LIMIT: 0x00000000 (UNlocked)
cpu0: GFX Limit: DISabled (0.000000 Watts, 0.000977 sec, clamp DISabled)
cpu0: MSR_IA32_TEMPERATURE_TARGET: 0x02640000 (100 C)
cpu0: MSR_IA32_PACKAGE_THERM_STATUS: 0x883a0008 (42 C)
cpu0: MSR_IA32_PACKAGE_THERM_INTERRUPT: 0x00000003 (100 C, 100 C)
cpu2: MSR_PKGC3_IRTL: 0x0000884e (valid, 79872 ns)
cpu2: MSR_PKGC6_IRTL: 0x00008876 (valid, 120832 ns)
cpu2: MSR_PKGC7_IRTL: 0x00008894 (valid, 151552 ns)
cpu2: MSR_PKGC8_IRTL: 0x000088fa (valid, 256000 ns)
cpu2: MSR_PKGC9_IRTL: 0x0000894c (valid, 339968 ns)
cpu2: MSR_PKGC10_IRTL: 0x00008bf2 (valid, 1034240 ns)
Busy%   Bzy_MHz IRQ PkgTmp  PkgWatt GFXWatt RAMWatt
81.37   628 120145  42  1.86    0.08    0.53
78.13   615 124712  42  1.77    0.07    0.51
49.01   637 80666   41  1.45    0.04    0.36

$ sudo dmidecode -s bios-version
1.17.1

$ swapon -s
Filename                Type        Size    Used    Priority
/dev/sda3                               partition   31250428    0   -2

$ grep -i swap /etc/fstab
# swap was on /dev/sda3 during installation
UUID=174e804f-da04-4503-81f9-999b012324a1 none            swap    sw              0       0

$ sysctl vm.swappiness
vm.swappiness = 60

答案1

电源管理器

由于电池/电源问题...

关闭计算机后,按住电源键约 30 秒。这将重置电源管理器。查看操作是否有任何改进。

BIOS

戴尔 Latitude 5480

您的 BIOS 版本为 1.17.1,发布日期为 2020 年 1 月 7 日。现在有更新的 BIOS 可用,版本为 1.19.2,发布日期为 2021 年 5 月 4 日,可以下载这里

笔记:确认我拥有适合您型号的正确网页。

笔记:更新 BIOS 之前请做好备份。

交换

30G 交换空间太疯狂了。假设您使用的是 /swapfile,而不是磁盘分区,并且没有休眠,我们将把 /swapfile 减少到 4G。


更新:您正在使用 /dev/sda3 作为交换分区。我们仍然可以使用以下步骤创建一个 4G /swapfile,然后使用它gparted删除 /dev/sda3。仅当您未处于休眠状态时才执行此操作。还要在 /etc/fstab 中注释掉以下行...

UUID=174e804f-da04-4503-81f9-999b012324a1 none            swap    sw              0       0

笔记:错误使用rmdd命令可能会导致数据丢失。建议复制/粘贴。

在里面terminal...

sudo swapoff -a           # turn off swap
sudo rm -i /swapfile      # remove old /swapfile

sudo dd if=/dev/zero of=/swapfile bs=1M count=4096

sudo chmod 600 /swapfile  # set proper file protections
sudo mkswap /swapfile     # init /swapfile
sudo swapon /swapfile     # turn on swap
free -h                   # confirm 16G RAM and 4G swap

sudo -H gedit /etc/fstab使用或编辑 /etc/fstab sudo pico /etc/fstab

确认 /etc/fstab 中的此 /swapfile 行...并确认没有其他“交换”行...在此行中使用空格...确认没有制表符...

/swapfile  none  swap  sw  0  0

reboot                    # reboot and verify operation

vm.swappiness

您的 vm.swappiness 当前设置为默认值 60。

即将编辑...

gnome 外壳

https://extensions.gnome.org/local/并暂时禁用disable-gesturessystem-monitorgnome-shell 扩展,然后重新启动 gnome-shell 或重新启动。看看情况是否有所改善。

火狐

即将编辑...

相关内容