导航:首页 > 操作系统 > linuxpercpu

linuxpercpu

发布时间:2024-10-27 04:31:23

‘壹’ 如何查看linux服务器的cpu数量,内核数,和cpu线程数

lscpu命令,查看的是cpu的统计信息.x0dx0ablue@blue-pc:~$ lscpux0dx0aArchitecture: i686 #cpu架构x0dx0aCPU op-mode(s): 32-bit, 64-bitx0dx0aByte Order: Little Endian #小尾序x0dx0aCPU(s): 4 #总共有4核x0dx0aOn-line CPU(s) list: 0-3x0dx0aThread(s) per core: 1 #每个cpu核,只能支持一个线程,即不支持超线程x0dx0aCore(s) per socket: 4 #每个cpu,有4个核x0dx0aSocket(s): 1 #总共有1一个cpux0dx0aVendor ID: GenuineIntel #cpu产商 intelx0dx0aCPU family: 6x0dx0aModel: 42x0dx0aStepping: 7x0dx0aCPU MHz: 1600.000x0dx0aBogoMIPS: 5986.12x0dx0aVirtualization: VT-x #支持cpu虚拟化技术x0dx0aL1d cache: 32Kx0dx0aL1i cache: 32Kx0dx0aL2 cache: 256Kx0dx0aL3 cache: 6144Kx0dx0a x0dx0a 查看/proc/cpuinfo,可以知道每个cpu信息,如每个CPU的型号,主频等。x0dx0a#cat /proc/cpuinfox0dx0aprocessor : 0x0dx0avendor_id : GenuineIntelx0dx0acpu family : 6x0dx0amodel : 42x0dx0amodel name : Intel(R) Core(TM) i5-2320 CPU @ 3.00GHzx0dx0a.....x0dx0a 上面输出的是第一个cpu部分信息,还有3个cpu信息省略了。x0dx0a x0dx0a 内存x0dx0a 概要查看内存情况x0dx0a free -mx0dx0a total used free shared buffers cachedx0dx0a Mem: 3926 3651 274 0 12 404x0dx0a -/+ buffers/cache: 3235 691x0dx0a Swap: 9536 31 9505x0dx0a 这里的单位是MB,总共的内存是3926MB。x0dx0a x0dx0a 查看内存详细使用x0dx0a# cat /proc/meminfox0dx0aMemTotal: 4020868 kBx0dx0aMemFree: 230884 kBx0dx0aBuffers: 7600 kBx0dx0aCached: 454772 kBx0dx0aSwapCached: 836 kBx0dx0a.....x0dx0a x0dx0a 查看内存硬件信息x0dx0admidecode -t memoryx0dx0a# dmidecode 2.11x0dx0aSMBIOS 2.7 present.x0dx0aHandle 0x0008, DMI type 16, 23 bytesx0dx0aPhysical Memory Arrayx0dx0a Location: System Board Or Motherboardx0dx0a....x0dx0a Maximum Capacity: 32 GBx0dx0a....x0dx0aHandle 0x000A, DMI type 17, 34 bytesx0dx0a....x0dx0aMemory Devicex0dx0a Array Handle: 0x0008x0dx0a Error Information Handle: Not Providedx0dx0a Total Width: 64 bitsx0dx0a Data Width: 64 bitsx0dx0a Size: 4096 MBx0dx0a.....x0dx0a 我的主板有4个槽位,只用了一个槽位,上面插了一条4096MB的内存。x0dx0a x0dx0a 磁盘x0dx0a 查看硬盘和分区分布x0dx0a# lsblkx0dx0aNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTx0dx0asda 8:0 0 465.8G 0 diskx0dx0a├—sda1 8:1 0 1G 0 part /bootx0dx0a├—sda2 8:2 0 9.3G 0 part [SWAP]x0dx0a├—sda3 8:3 0 74.5G 0 part /x0dx0a├—sda4 8:4 0 1K 0 partx0dx0a├—sda5 8:5 0 111.8G 0 part /homex0dx0a└—sda6 8:6 0 269.2G 0 partx0dx0a 显示很直观x0dx0a x0dx0a 如果要看硬盘和分区的详细信息x0dx0a# fdisk -lx0dx0aDisk /dev/sda: 500.1 GB, 500107862016 bytesx0dx0a255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectorsx0dx0aUnits = sectors of 1 * 512 = 512 bytesx0dx0aSector size (logical/physical): 512 bytes / 4096 bytesx0dx0aI/O size (minimum/optimal): 4096 bytes / 4096 bytesx0dx0aDisk identifier: 0x00023728x0dx0a Device Boot Start End Blocks Id Systemx0dx0a/dev/sda1 * 2048 2148351 1073152 83 Linuxx0dx0a/dev/sda2 2148352 21680127 9765888 82 Linux swap / Solarisx0dx0a/dev/sda3 21680128 177930239 78125056 83 Linuxx0dx0a/dev/sda4 177932286 976771071 399419393 5 Extended/dev/sda5 177932288 412305407 117186560 83 Linuxx0dx0a/dev/sda6 412307456 976771071 282231808 83 Linuxx0dx0a x0dx0a 网卡x0dx0a 查看网卡硬件信息x0dx0a# lspci | grep -i 'eth'x0dx0a02:00.0 Ethernet controller: Realtek Semiconctor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 06)x0dx0a x0dx0a 查看系统的所有网络接口x0dx0a# ifconfig -ax0dx0aeth0 Link encap:以太网 硬件地址 b8:97:5a:17:b3:8f x0dx0a .....x0dx0alo Link encap:本地环回 x0dx0a .....x0dx0a 或者是x0dx0aip link showx0dx0a1: lo: mtu 16436 qdisc noqueue state DOWNx0dx0alink/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00x0dx0a2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000x0dx0alink/ether b8:97:5a:17:b3:8f brd ff:ff:ff:ff:ff:ffx0dx0a x0dx0a 如果要查看某个网络接口的详细信息,例如eth0的详细参数和指标x0dx0a# ethtool eth0x0dx0aSettings for eth0:x0dx0a Supported ports: [ TP MII ]x0dx0a Supported link modes: 10baseT/Half 10baseT/Fullx0dx0a 100baseT/Half 100baseT/Fullx0dx0a 1000baseT/Half 1000baseT/Full #支持千兆半双工,全双工模式x0dx0a Supported pause frame use: Nox0dx0a Supports auto-negotiation: Yes #支持自适应模式,一般都支持x0dx0a Advertised link modes: 10baseT/Half 10baseT/Fullx0dx0a 100baseT/Half 100baseT/Fullx0dx0a 1000baseT/Half 1000baseT/Fullx0dx0a Advertised pause frame use: Symmetric Receive-onlyx0dx0a Advertised auto-negotiation: Yes #默认使用自适应模式x0dx0a Link partner advertised link modes: 10baseT/Half 10baseT/Fullx0dx0a 100baseT/Half 100baseT/Fullx0dx0a .....x0dx0a Speed: 100Mb/s #现在网卡的速度是100Mb,网卡使用自适应模式,所以推测路由是100Mb,导致网卡从支 持千兆,变成要支持百兆x0dx0a Duplex: Full #全双工x0dx0a .....x0dx0a Link detected: yes #表示有网线连接,和路由是通的x0dx0ax0dx0a其他x0dx0a 查看pci信息,即主板所有硬件槽信息。x0dx0alspcix0dx0a00:00.0 Host bridge: Intel Corporation 2nd Generation Core Processor Family DRAM Controller (rev 09) #主板芯片x0dx0a00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09) #显卡x0dx0a00:14.0 USB controller: Intel Corporation Panther Point USB xHCI Host Controller (rev 04) #usb控制器x0dx0a00:16.0 Communication controller: Intel Corporation Panther Point MEI Controller #1 (rev 04)x0dx0a00:1a.0 USB controller: Intel Corporation Panther Point USB Enhanced Host Controller #2 (rev 04)x0dx0a00:1b.0 Audio device: Intel Corporation Panther Point High Definition Audio Controller (rev 04) #声卡x0dx0a00:1c.0 PCI bridge: Intel Corporation Panther Point PCI Express Root Port 1 (rev c4) #pci 插槽x0dx0a00:1c.2 PCI bridge: Intel Corporation Panther Point PCI Express Root Port 3 (rev c4)x0dx0a00:1c.3 PCI bridge: Intel Corporation Panther Point PCI Express Root Port 4 (rev c4)x0dx0a00:1d.0 USB controller: Intel Corporation Panther Point USB Enhanced Host Controller #1 (rev 04)x0dx0a00:1f.0 ISA bridge: Intel Corporation Panther Point LPC Controller (rev 04)x0dx0a00:1f.2 IDE interface: Intel Corporation Panther Point 4 port SATA Controller [IDE mode] (rev 04) #硬盘接口x0dx0a00:1f.3 SMBus: Intel Corporation Panther Point SMBus Controller (rev 04)x0dx0a00:1f.5 IDE interface: Intel Corporation Panther Point 2 port SATA Controller [IDE mode] (rev 04) #硬盘接口x0dx0a02:00.0 Ethernet controller: Realtek Semiconctor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 06) #网卡x0dx0a03:00.0 PCI bridge: Integrated Technology Express, Inc. Device 8893 (rev 41)x0dx0a 如果要更详细的信息:lspci -v 或者 lspci -vvx0dx0a 如果要看设备树:lscpi -tx0dx0a x0dx0a 查看bios信息x0dx0a# dmidecode -t biosx0dx0a......x0dx0aBIOS Informationx0dx0a Vendor: American Megatrends Inc.x0dx0a Version: 4.6.5x0dx0a Release Date: 04/25/2012x0dx0a .......x0dx0a BIOS Revision: 4.6x0dx0a......x0dx0a dmidecode以一种可读的方式mp出机器的DMI(Desktop Management Interface)信息。这些信息包括了硬件以及BIOS,既可以得到当前的配置,也可以得到系统支持的最大配置,比如说支持的最大内存数等。x0dx0a 如果要查看所有有用信息x0dx0a dmidecode -qx0dx0a 以上是linux查看硬件信息的所有命令,可以查看CPU、硬盘、网卡、磁盘等硬件的信息。

‘贰’ linux查看cpu核心数

两种方法在linux可查看cpu,第一种为打开终端命令行直接输入lscpu,在cpu(s)和core(s) per-socket能看到真实的逻辑与物理核心数量:

‘叁’ 如何使用Linux工作队列workqueue

创建一个per-CPU
*编译期间静态创建一个per-CPU
DEFINE_PER_CPU(type, name)
创建一个名为name,数据类型为type的per-CPU,比如static DEFINE_PER_CPU(struct sk_buff_head, bs_cpu_queues),此时每个CPU都有一个名叫bs_cpu_queues,数据结构为sk_buff_head的变量副本。每个副本都是在自己的CPU上工作。

* 动态创建per-CPU,以下代码是内核create_workqueue实现的片断
struct workqueue_struct *__create_workqueue(const char *name,
int singlethread)
{
int cpu, destroy = 0;
struct workqueue_struct *wq;
struct task_struct *p;

wq = kzalloc(sizeof(*wq), GFP_KERNEL);
if (!wq)
return NULL;

wq->cpu_wq = alloc_percpu(struct cpu_workqueue_struct);
if (!wq->cpu_wq) {
kfree(wq);
return NULL;
}
……
}

阅读全文

与linuxpercpu相关的资料

热点内容
it程序员在国企的感受 浏览:495
快手app哪里看物流 浏览:209
梁的加密区在梁的什么位置 浏览:634
萝卜源码编译 浏览:976
安卓手机连不上苹果热点是为什么 浏览:437
微信加密密保问题忘记怎么办 浏览:920
在哪里能制作手机app 浏览:165
python搭建web网站 浏览:685
空乘程序员 浏览:349
玩加密币犯法吗 浏览:245
html加载pdf 浏览:1002
git源码如何本地编译命令 浏览:868
单片机研究报告 浏览:265
天正建筑命令栏 浏览:598
加密货币应税事件 浏览:459
宋pro的app哪里下载 浏览:207
单片机原理与接口技术第三版课后答案 浏览:890
程序员小明教学 浏览:613
linuxbin解压缩 浏览:382
四川电信服务器租用云空间 浏览:31