Linux内核与SMP(对称多处理)

什么 是SMP?

SMP的全称是“对称多处理“(Symmetrical Multi-Processing)技术,是指在一个计算机上汇集了一组处理器(多CPU),各CPU之间共享内存子系统以及总线结构。它是相对非对称多处理技术而言的、应用十分广泛的并行技术。在这种架构中,一台电脑不再由单个CPU组成,而同时由多个处理器运行操作系统的单一复本,并共享内存和一台计算机的其他资源。虽然同时使用多个CPU,但是从管理的角度来看,它们的表现就像一台单机一样。系统将任务队列对称地分布于多个CPU之上,从而极大地提高了整个系统的数据处理能力。所有的处理器都可以平等地访问内存、I/O和外部中断。在对称多处理系统中,系统资源被系统中所有CPU共享,工作负载能够均匀地分配到所有可用处理器之上。

另外你可能需要理解就是Non-Uniform Memory Access(NUMA)架构。每个处理器拥有自己的内存,访问共享内存时具有不同的访问延迟。

“可以通过多种方法提高 Linux 系统的性能,而其中最流行的一种是提高处理器的性能。一个明显的解决方案是使用具有更快时钟频率的处理器,但是对于任何特定技术来讲都存在一个物理极限,时钟频率也有这样的极限。当达到那个极限时,可使用 “越多越好” 的方法应用多处理器。不幸的是,多处理器的性能并不与单个处理器性能的总和成线性比例。”

Linux内核与SMP

Linux内核编译时,CONFIG_SMP配置项控制内核是否支持SMP.

现在的内核包从2.4.23以后就没有专门的SMP内核包,在安装Linux系统时,会自动监测,如果检查到了多个CPU或多核,超线程时,会自动安装两个Linux内核,其中一个是带SMP的,在GRUB引导列表里会出现两个内核选择,默认使用SMP引导.

如:

[root@goface ~]# cat /boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/sda3
#          initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux AS (2.6.9-67.ELsmp)
	root (hd0,0)
	kernel /vmlinuz-2.6.9-67.ELsmp ro root=LABEL=/12
	initrd /initrd-2.6.9-67.ELsmp.img
title Red Hat Enterprise Linux AS-up (2.6.9-67.EL)
	root (hd0,0)
	kernel /vmlinuz-2.6.9-67.EL ro root=LABEL=/12
	initrd /initrd-2.6.9-67.EL.img
Redhat、CentOS、SUSE安装时都有支持smp的内核。
版本号-default: SUSE Linux kernel for uniprocessor machines <---- 默认选项,支持单处理器机器
  版本号-smp: SUSE Linux kernel that supports symmetric multiprocessing (multiple processor machines) and up to 4 GB of RAM <---- 支持4GB内存的对称
多处理器机器
  版本号-bigsmp: SUSE Linux kernel that supports symmetric multiprocessing and up to 64 GB of RAM <---- 支持64GB内存的对称多处理器机器

  Red Hat Linux/CentOS

  版本号.EL: Red Hat Linux kernel for uniprocessor machines <---- 支持单处理器机器
  版本号.ELhugemem: Red Hat Linux kernel that supports up to 64 GB of RAM <---- 支持64GB内存的对称多处理器机器
  版本号.ELsmp: Red Hat Linux kernel that supports symmetric multiprocessing (multiple processor machines) <---- 对称多处理器机器

查看CPU信息

[root@goface~]# cat /proc/cpuinfo
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 15
model		: 3
model name	: Intel(R) Xeon(TM) CPU 3.00GHz
stepping	: 4
cpu MHz		: 3000.605
cache size	: 1024 KB
physical id	: 0
siblings	: 2
core id		: 0
cpu cores	: 1
fdiv_bug	: no
hlt_bug		: no
f00f_bug	: no
coma_bug	: no
fpu		: yes
fpu_exception	: yes
cpuid level	: 5
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe lm constant_tsc pni monitor ds_cpl cid xtpr
bogomips	: 6003.74

processor	: 1
vendor_id	: GenuineIntel
cpu family	: 15
model		: 3
model name	: Intel(R) Xeon(TM) CPU 3.00GHz
stepping	: 4
cpu MHz		: 3000.605
cache size	: 1024 KB
physical id	: 0
siblings	: 2
core id		: 0
cpu cores	: 1
fdiv_bug	: no
hlt_bug		: no
f00f_bug	: no
coma_bug	: no
fpu		: yes
fpu_exception	: yes
cpuid level	: 5
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe lm constant_tsc pni monitor ds_cpl cid xtpr
bogomips	: 6000.36

[root@goface ~]# grep -c ^processor /proc/cpuinfo
2

Linux内核报错与SMP

在国外论坛上看到有人说他的服务器内核报错如下:

kernel panic – not syncing: Fatal exception in interrupt
BUG: warning at arch/i386/kernel/smp.c:547/smp_call_function()

最后得知他的服务器只有一块CPU。可以在grub设置启动不启用SMP。

解决方法:

#vi /boot/grub/grub.conf
title=Linux
root (hd0,0)
kernel /boot/vmlinuz ... nosmp
initrd /boot/initrd ...
kernel行添加nosmp参数
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值