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

来源:互联网 发布:淘宝好的精品店 编辑:程序博客网 时间:2024/06/05 19:26

什么 是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/sdadefault=0timeout=5splashimage=(hd0,0)/grub/splash.xpm.gzhiddenmenutitle Red Hat Enterprise Linux AS (2.6.9-67.ELsmp)root (hd0,0)kernel /vmlinuz-2.6.9-67.ELsmp ro root=LABEL=/12initrd /initrd-2.6.9-67.ELsmp.imgtitle Red Hat Enterprise Linux AS-up (2.6.9-67.EL)root (hd0,0)kernel /vmlinuz-2.6.9-67.EL ro root=LABEL=/12initrd /initrd-2.6.9-67.EL.imgRedhat、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/cpuinfoprocessor: 0vendor_id: GenuineIntelcpu family: 15model: 3model name: Intel(R) Xeon(TM) CPU 3.00GHzstepping: 4cpu MHz: 3000.605cache size: 1024 KBphysical id: 0siblings: 2core id: 0cpu cores: 1fdiv_bug: nohlt_bug: nof00f_bug: nocoma_bug: nofpu: yesfpu_exception: yescpuid level: 5wp: yesflags: 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 xtprbogomips: 6003.74processor: 1vendor_id: GenuineIntelcpu family: 15model: 3model name: Intel(R) Xeon(TM) CPU 3.00GHzstepping: 4cpu MHz: 3000.605cache size: 1024 KBphysical id: 0siblings: 2core id: 0cpu cores: 1fdiv_bug: nohlt_bug: nof00f_bug: nocoma_bug: nofpu: yesfpu_exception: yescpuid level: 5wp: yesflags: 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 xtprbogomips: 6000.36[root@goface ~]# grep -c ^processor /proc/cpuinfo2

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=Linuxroot (hd0,0)kernel /boot/vmlinuz ... nosmpinitrd /boot/initrd ...
kernel行添加nosmp参数
0 0
原创粉丝点击