導航:首頁 > 操作系統 > 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相關的資料

熱點內容
安卓apaid怎麼發朋友圈 瀏覽:853
怎麼幫安卓手機換電池 瀏覽:384
python做伺服器監控 瀏覽:905
如何將pdf文件轉成jpg 瀏覽:130
破解so文件源碼 瀏覽:927
怎麼用命令符修復病毒 瀏覽:237
假裝程序員怎麼做 瀏覽:945
輕量應用伺服器怎麼改模板 瀏覽:828
網站源碼是多少文件 瀏覽:859
c語言版的演算法書 瀏覽:961
電子文檔加密碼忘了怎麼辦 瀏覽:141
掃描pdfjpg格式 瀏覽:248
python開發游戲腳本 瀏覽:855
重慶源碼時代培訓怎麼樣 瀏覽:371
程序員會不會學奧數 瀏覽:870
走遍中國pdf 瀏覽:657
保姆在哪裡找app 瀏覽:208
餓了么合作方案在app哪裡查看 瀏覽:909
lua免費編寫反編譯軟體 瀏覽:731
命令行打開u盤 瀏覽:252