开发者

Linux and Physical and Virtual CPUs

开发者 https://www.devze.com 2023-01-26 15:01 出处:网络
How to find out how many cpu\'s a linux machine is using (for an application and for the whole system) and if they are physical or virtual?开发者_高级运维The command

How to find out how many cpu's a linux machine is using (for an application and for the whole system) and if they are physical or virtual?开发者_高级运维


The command

cat /proc/cpuinfo

Will tell you how many CPUs were detected by the kernel. I am unsure exactly what you mean by "physical" as compared to "virtual" CPUs -- unless the OS is being run in a virtualized/emulated environment, the CPUs listed there will all be physical.

As for which CPUs an application is using, it will by default use any and all available CPUs. Even if there is only one thread in the process, this thread may still switch between CPUs when the kernel deems it necessary.

You can use the taskset command to set the CPU affinity of a process, which will limit which CPUs it is allowed to run on. To fetch the CPU affinity of a process, run

taskset -p $PID_OF_PROCESS


cat /proc/cpuinfo


for linux you type:
dmesg |grep DMI

VIRTUAL HOST OUTPUT

[root@myhost ~]# dmesg |grep DMI
DMI 2.3 present.
DMI: Microsoft Corporation Virtual Machine/Virtual Machine, BIOS 090006 05/23/2012

[root@myhost ~]# dmesg |grep -i virtual
DMI: Microsoft Corporation Virtual Machine/Virtual Machine, BIOS 090006 05/23/2012
Booting paravirtualized kernel on bare hardware
input: Macintosh mouse button emulation as /devices/virtual/input/input1
scsi 0:0:0:0: Direct-Access Msft Virtual Disk 1.0 PQ: 0 ANSI: 4
input: Microsoft Vmbus HID-compliant Mouse as /devices/virtual/input/input4


FOR PHYSICAL HOST EXAMPLE

[root@backdev1 ~]# dmesg |grep DMI
DMI 2.5 present.
DMI: IBM System x3650 M3 -[7945AC1]-/90Y4784, BIOS -[D6E153AUS-1.12]- 06/30/2011

0

精彩评论

暂无评论...
验证码 换一张
取 消