![kswapd0 在 RHEL 6.3 中占用 99% 到 100% CPU](https://linux22.com/image/29605/kswapd0%20%E5%9C%A8%20RHEL%206.3%20%E4%B8%AD%E5%8D%A0%E7%94%A8%2099%25%20%E5%88%B0%20100%25%20CPU.png)
我刚刚在 5 个系统上安装了 RHEL6。系统配置是
CPU-i7
HDD-500 GB
RAM-2 GB
交换空间- 4 GB
我已经按照旧系统安装了相同的软件和所有配置。但我的新系统运行速度非常慢!
top
命令输出如下:
[root@localhost ~]# top
top - 12:27:56 up 24 min, 3 users, load average: 1.00, 1.00, 0.82
Tasks: 214 total, 2 running, 212 sleeping, 0 stopped, 0 zombie
Cpu(s): 1.1%us, 13.0%sy, 0.0%ni, 85.9%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
我在旧系统中没有这样的问题,因为旧系统的配置比新系统少!
更新1:
我同意迈克尔和冯布兰德的观点。但我的系统仍然非常非常慢。特别是当我在 QtCreator 中编译一些东西时。甚至我的鼠标移动也变慢了。
我通过在交换分区之前添加注释/etc/fstab
并重新启动进行检查,交换显示 0.0GB,但 kswapd0 仍在使用 99% 到 100%。
为什么其他处理器没有充分利用!
我的 RAM (2GB) 较小
或者
是否有任何管理CPU的服务未启动?
更新2:
的输出dmesg
是:
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
alloc irq_desc for 16 on node -1
alloc kstat_irqs on node -1
alloc irq_2_iommu on node -1
ehci_hcd 0000:00:1a.0: PCI INT A -> GSI 16 (level, low) -> IRQ 16
ehci_hcd 0000:00:1a.0: setting latency timer to 64
ehci_hcd 0000:00:1a.0: EHCI Host Controller
ehci_hcd 0000:00:1a.0: new USB bus registered, assigned bus number 1
ehci_hcd 0000:00:1a.0: debug port 2
ehci_hcd 0000:00:1a.0: cache line size of 64 is not supported
ehci_hcd 0000:00:1a.0: irq 16, io mem 0xf7c38000
ehci_hcd 0000:00:1a.0: USB 2.0 started, EHCI 1.00
usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: EHCI Host Controller
usb usb1: Manufacturer: Linux 2.6.32-71.el6.x86_64 ehci_hcd
usb usb1: SerialNumber: 0000:00:1a.0
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 3 ports detected
alloc irq_desc for 23 on node -1
alloc kstat_irqs on node -1
alloc irq_2_iommu on node -1
ehci_hcd 0000:00:1d.0: PCI INT A -> GSI 23 (level, low) -> IRQ 23
ehci_hcd 0000:00:1d.0: setting latency timer to 64
ehci_hcd 0000:00:1d.0: EHCI Host Controller
ehci_hcd 0000:00:1d.0: new USB bus registered, assigned bus number 2
ehci_hcd 0000:00:1d.0: debug port 2
ehci_hcd 0000:00:1d.0: cache line size of 64 is not supported
ehci_hcd 0000:00:1d.0: irq 23, io mem 0xf7c37000
ehci_hcd 0000:00:1d.0: USB 2.0 started, EHCI 1.00
usb usb2: New USB device found, idVendor=1d6b, idProduct=0002
usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb2: Product: EHCI Host Controller
usb usb2: Manufacturer: Linux 2.6.32-71.el6.x86_64 ehci_hcd
usb usb2: SerialNumber: 0000:00:1d.0
usb usb2: configuration #1 chosen from 1 choice
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 3 ports detected
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
uhci_hcd: USB Universal Host Controller Interface driver
PNP: PS/2 Controller [PNP0303:PS2K,PNP0f03:PS2M] at 0x60,0x64 irq 1,12
serio: i8042 KBD port at 0x60,0x64 irq 1
serio: i8042 AUX port at 0x60,0x64 irq 12
mice: PS/2 mouse device common for all mice
rtc_cmos 00:06: RTC can wake from S4
rtc_cmos 00:06: rtc core: registered rtc_cmos as rtc0
rtc0: alarms up to one month, y3k, 242 bytes nvram, hpet irqs
cpuidle: using governor ladder
cpuidle: using governor menu
usbcore: registered new interface driver hiddev
usbcore: registered new interface driver usbhid
usbhid: v2.6:USB HID core driver
TCP cubic registered
Initializing XFRM netlink socket
NET: Registered protocol family 17
registered taskstats version 1
IMA: No TPM chip found, activating TPM-bypass!
rtc_cmos 00:06: setting system clock to 2013-03-04 14:10:29 UTC (1362406229)
Initalizing network drop monitor service
Freeing unused kernel memory: 1220k freed
Write protecting the kernel read-only data: 7176k
dracut: dracut-004-32.el6
dracut: rd_NO_LUKS: removing cryptoluks activation
dracut: rd_NO_LVM: removing LVM activation
device-mapper: uevent: version 1.0.3
device-mapper: ioctl: 4.17.0-ioctl (2010-03-05) initialised: [email protected]
udev: starting version 147
dracut: Starting plymouth daemon
dracut: rd_NO_DM: removing DM RAID activation
dracut: rd_NO_MD: removing MD RAID activation
ahci 0000:00:1f.2: version 3.0
ahci 0000:00:1f.2: PCI INT B -> GSI 19 (level, low) -> IRQ 19
alloc irq_desc for 31 on node -1
alloc kstat_irqs on node -1
alloc irq_2_iommu on node -1
ahci 0000:00:1f.2: irq 31 for MSI/MSI-X
ahci 0000:00:1f.2: AHCI 0001.0300 32 slots 6 ports 6 Gbps 0x5 impl SATA mode
ahci 0000:00:1f.2: flags: 64bit ncq pm led clo pio slum part ems apst
ahci 0000:00:1f.2: setting latency timer to 64
scsi0 : ahci
scsi1 : ahci
scsi2 : ahci
scsi3 : ahci
scsi4 : ahci
scsi5 : ahci
ata1: SATA max UDMA/133 abar m2048@0xf7c36000 port 0xf7c36100 irq 31
ata2: DUMMY
ata3: SATA max UDMA/133 abar m2048@0xf7c36000 port 0xf7c36200 irq 31
ata4: DUMMY
ata5: DUMMY
ata6: DUMMY
usb 1-1: new high speed USB device using ehci_hcd and address 2
usb 1-1: New USB device found, idVendor=8087, idProduct=0024
usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
usb 1-1: configuration #1 chosen from 1 choice
hub 1-1:1.0: USB hub found
hub 1-1:1.0: 6 ports detected
ata3: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
ata1.00: ACPI _SDD failed (AE 0x5)
ata3.00: ACPI _SDD failed (AE 0x5)
usb 2-1: new high speed USB device using ehci_hcd and address 2
usb 2-1: New USB device found, idVendor=8087, idProduct=0024
usb 2-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
usb 2-1: configuration #1 chosen from 1 choice
hub 2-1:1.0: USB hub found
hub 2-1:1.0: 8 ports detected
usb 2-1.3: new low speed USB device using ehci_hcd and address 3
usb 2-1.3: New USB device found, idVendor=04ca, idProduct=0062
usb 2-1.3: New USB device strings: Mfr=0, Product=2, SerialNumber=0
usb 2-1.3: Product: USB Optical Mouse
usb 2-1.3: configuration #1 chosen from 1 choice
input: USB Optical Mouse as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/input/input3
generic-usb 0003:04CA:0062.0001: input,hidraw0: USB HID v1.11 Mouse [USB Optical Mouse] on usb-0000:00:1d.0-1.3/input0
usb 2-1.4: new low speed USB device using ehci_hcd and address 4
usb 2-1.4: New USB device found, idVendor=03f0, idProduct=0024
usb 2-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 2-1.4: Product: HP Basic USB Keyboard
usb 2-1.4: Manufacturer: CHICONY
usb 2-1.4: configuration #1 chosen from 1 choice
input: CHICONY HP Basic USB Keyboard as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4:1.0/input/input4
generic-usb 0003:03F0:0024.0002: input,hidraw1: USB HID v1.11 Keyboard [CHICONY HP Basic USB Keyboard] on usb-0000:00:1d.0-1.4/input0
ata3: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
ata3.00: ACPI _SDD failed (AE 0x5)
ata3.00: ACPI: failed the second time, disabled
ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
ata3.00: ATAPI: hp DVD-RAM GH82N, R204, max UDMA/100, ATAPI AN
ata1.00: ACPI _SDD failed (AE 0x5)
ata1.00: ACPI: failed the second time, disabled
ata1.00: ATA-8: ST500DM002-1BD142, HP73, max UDMA/100
ata1.00: 976773168 sectors, multi 16: LBA48 NCQ (depth 31/32)
ata1.00: configured for UDMA/100
ata3.00: configured for UDMA/100
scsi 0:0:0:0: Direct-Access ATA ST500DM002-1BD14 HP73 PQ: 0 ANSI: 5
scsi 2:0:0:0: CD-ROM hp DVD-RAM GH82N R204 PQ: 0 ANSI: 5
sd 0:0:0:0: [sda] 976773168 512-byte logical blocks: (500 GB/465 GiB)
sd 0:0:0:0: [sda] 4096-byte physical blocks
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
sda: sda1 sda2 sda3 sda4 < sda5 sda6 sda7 >
sd 0:0:0:0: [sda] Attached SCSI disk
sr0: scsi3-mmc drive: 40x/40x writer dvd-ram cd/rw xa/form2 cdda tray
Uniform CD-ROM driver Revision: 3.20
sr 2:0:0:0: Attached scsi CD-ROM sr0
EXT4-fs (sda7): INFO: recovery required on readonly filesystem
EXT4-fs (sda7): write access will be enabled during recovery
EXT4-fs (sda7): orphan cleanup on readonly fs
EXT4-fs (sda7): ext4_orphan_cleanup: deleting unreferenced inode 15341115
EXT4-fs (sda7): ext4_orphan_cleanup: deleting unreferenced inode 1835089
EXT4-fs (sda7): ext4_orphan_cleanup: deleting unreferenced inode 1835088
EXT4-fs (sda7): ext4_orphan_cleanup: deleting unreferenced inode 1835087
EXT4-fs (sda7): ext4_orphan_cleanup: deleting unreferenced inode 1835085
EXT4-fs (sda7): ext4_orphan_cleanup: deleting unreferenced inode 1835081
EXT4-fs (sda7): ext4_orphan_cleanup: deleting unreferenced inode 1835080
EXT4-fs (sda7): ext4_orphan_cleanup: deleting unreferenced inode 1835079
EXT4-fs (sda7): ext4_orphan_cleanup: deleting unreferenced inode 1835076
EXT4-fs (sda7): ext4_orphan_cleanup: deleting unreferenced inode 1835075
EXT4-fs (sda7): ext4_orphan_cleanup: deleting unreferenced inode 1835067
EXT4-fs (sda7): 11 orphan inodes deleted
EXT4-fs (sda7): recovery complete
EXT4-fs (sda7): mounted filesystem with ordered data mode
dracut: Mounted root filesystem /dev/sda7
dracut: Loading SELinux policy
SELinux: Disabled at runtime.
SELinux: Unregistering netfilter hooks
type=1404 audit(1362406240.622:2): selinux=0 auid=4294967295 ses=4294967295
dracut: /sbin/load_policy: Can't load policy: No such file or directory
dracut: Switching root
udev: starting version 147
e1000e: Intel(R) PRO/1000 Network Driver - 1.2.7-k2
e1000e: Copyright (c) 1999 - 2009 Intel Corporation.
alloc irq_desc for 20 on node -1
alloc kstat_irqs on node -1
alloc irq_2_iommu on node -1
e1000e 0000:00:19.0: PCI INT A -> GSI 20 (level, low) -> IRQ 20
e1000e 0000:00:19.0: setting latency timer to 64
alloc irq_desc for 32 on node -1
alloc kstat_irqs on node -1
alloc irq_2_iommu on node -1
e1000e 0000:00:19.0: irq 32 for MSI/MSI-X
0000:00:19.0: eth0: (PCI Express:2.5GB/s:Width x1) 6c:3b:e5:13:26:21
0000:00:19.0: eth0: Intel(R) PRO/1000 Network Connection
0000:00:19.0: eth0: MAC: 10, PHY: 11, PBA No: 0100ff-0ff
sd 0:0:0:0: Attached scsi generic sg0 type 0
sr 2:0:0:0: Attached scsi generic sg1 type 5
ACPI: WMI: Mapper loaded
EXT4-fs (sda5): mounted filesystem with ordered data mode
microcode: CPU0 sig=0x306a9, pf=0x2, revision=0x12
platform microcode: firmware: requesting intel-ucode/06-3a-09
microcode: CPU1 sig=0x306a9, pf=0x2, revision=0x12
platform microcode: firmware: requesting intel-ucode/06-3a-09
microcode: CPU2 sig=0x306a9, pf=0x2, revision=0x12
platform microcode: firmware: requesting intel-ucode/06-3a-09
microcode: CPU3 sig=0x306a9, pf=0x2, revision=0x12
platform microcode: firmware: requesting intel-ucode/06-3a-09
microcode: CPU4 sig=0x306a9, pf=0x2, revision=0x12
platform microcode: firmware: requesting intel-ucode/06-3a-09
microcode: CPU5 sig=0x306a9, pf=0x2, revision=0x12
platform microcode: firmware: requesting intel-ucode/06-3a-09
microcode: CPU6 sig=0x306a9, pf=0x2, revision=0x12
platform microcode: firmware: requesting intel-ucode/06-3a-09
microcode: CPU7 sig=0x306a9, pf=0x2, revision=0x12
platform microcode: firmware: requesting intel-ucode/06-3a-09
Microcode Update Driver: v2.00 <[email protected]>, Peter Oruba
Microcode Update Driver: v2.00 removed.
ip_tables: (C) 2000-2006 Netfilter Core Team
NET: Registered protocol family 10
lo: Disabled Privacy Extensions
e1000e 0000:00:19.0: irq 32 for MSI/MSI-X
e1000e 0000:00:19.0: irq 32 for MSI/MSI-X
ADDRCONF(NETDEV_UP): eth0: link is not ready
e1000e: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
eth0: no IPv6 routers present
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
Bridge firewalling registered
virbr0: starting userspace STP failed, starting kernel STP
nf_conntrack version 0.5.0 (16384 buckets, 65536 max)
Ebtables v2.0 registered
fuse init (API version 7.13)
ip6_tables: (C) 2000-2006 Netfilter Core Team
lo: Disabled Privacy Extensions
tun: Universal TUN/TAP device driver, 1.6
tun: (C) 1999-2004 Max Krasnyansky <[email protected]>
device vnet0 entered promiscuous mode
virbr0: topology change detected, propagating
virbr0: port 1(vnet0) entering forwarding state
vnet0: no IPv6 routers present
kvm: 3639: cpu0 unimplemented perfctr wrmsr: 0xc1 data 0x0
kvm: 3639: cpu0 unimplemented perfctr wrmsr: 0x186 data 0x130079
kvm: 3639: cpu0 unimplemented perfctr wrmsr: 0xc1 data 0xffcc3e1a
kvm: 3639: cpu0 unimplemented perfctr wrmsr: 0x186 data 0x530079
kvm: 3639: cpu1 unimplemented perfctr wrmsr: 0xc1 data 0x0
kvm: 3639: cpu1 unimplemented perfctr wrmsr: 0x186 data 0x130079
kvm: 3639: cpu1 unimplemented perfctr wrmsr: 0xc1 data 0xffcc3e1a
kvm: 3639: cpu1 unimplemented perfctr wrmsr: 0x186 data 0x530079
kvm: 3639: cpu2 unimplemented perfctr wrmsr: 0xc1 data 0x0
virbr0: port 1(vnet0) entering disabled state
device vnet0 left promiscuous mode
virbr0: port 1(vnet0) entering disabled state
我没有注意到任何与swap
这里相关的内容。
更新3:
请参阅下面我的回答,Its a kernel bug
!
答案1
CPU 百分比基于一CPU,所以它很可能是 100% 的几倍。而且平均负载(等待 CPU 的进程的平均数量)很低,机器几乎 90% 处于空闲状态。没有理由担心。
答案2
喜欢@冯布兰德指出,CPU 使用百分比默认基于单个 CPU。因此,如果一个进程有多个线程,那么在多核或多 CPU 系统上,这个数字很容易超过 100%。
查看Cpu(s)
靠近顶部的行中找到的总数;它表示您的系统有 1.1% 的时间花在用户空间上,13.0% 的时间花在系统代码(基本上是内核)上,还有 85.9% 的时间处于空闲状态。这与多核 CPU 非常吻合,其中一个核心以 100% 的速度运行。
您可以top
通过按 在所谓的 Irix 模式和 Solaris 模式之间切换shifti。具有 Irix 模式离开,显示的 CPU 使用率将跨所有 CPU 和/或内核,而在 Irix 模式下在,即使在装备齐全的多处理器系统上,一个充分利用的核心也将显示为 100%。因此,在 Irix 模式关闭的情况下,在假设的 10 核系统上,其中两个核心充分利用而其他核心完全空闲,CPU 使用率将显示为预期的 20%,而不是 200%。
答案3
内核错误:我认为我的问题出在内核上,正如金发姑娘所注意到的那样。当我将 RAM 增加到 4GB 时,所有进程都稳定,即使使用带有 2GB RAM 的 Core 2 英特尔处理器盒也能正常工作。
答案4
在这里挖掘一个非常古老的问题 - 但我也遇到了同样的问题。对我来说,问题最终是 MYSQLD 运行。
首先,我注意到在切换到 ec2 中的 t1-nano ubuntu 实例(1 核 512 RAM)后,我的运行状况检查开始失败。当时我认为这很好,因为我只运行带有静态健康检查、301 条目和其他几个静态文件条目的 nginx。我忘记了几个月前我安装了wordpress和mysql供朋友使用。
我查看了输出TOP
,发现 kswapd0 占用了所有的 CPU。直到我使用htop
并按内存排序后,我才发现 mysql 占用了所有的内存。
我卸载了 mysql,一切正常了。