PHYSICAL=`cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l`ĬORES=`cat /proc/cpuinfo | grep "cpu cores" | sort | uniq | cut -d':' -f2`Įcho "Including hyperthreading cores $ALL" MODEL=`cat /cpu/procinfo | grep "model name" | sort | uniq`ĪLL=`cat /proc/cpuinfo | grep "bogo" | wc -l` That said, you can modify the following script to get the answers that you need. As someone who writes a lot of programs with thread pools, you really need to know the count of physical cores vs cores/hyperthreads. Hyperthreaded (virtual) cores would not be included (at least to my mind). The number of "cores" would be physical cores. The number of "processors" would be the physical number installed in sockets on the machine. 4.When someone asks for "the number of processors/cores" there are 2 answers being requested. In the next section, we’ll look at some of the important flags that can help us understand what our CPU can do. Vmx flags : vnmi preemption_timer invvpid ept_x_only ept_ad ept_1gb flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest ple pmlīugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit srbdsĪddress sizes : 39 bits physical, 48 bits virtualĪs we can see, it prints our CPU’s specification containing the flags field. Model name : Intel(R) Celeron(R) CPU G3900 2.80GHzįlags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust erms invpcid rdseed smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d We’ll use the cat command to read the file: # cat /proc/cpuinfo processor : 0 The /proc /cpuinfo virtual file contains information about the CPUs currently available in our system’s motherboard. The command will list many files, but we’re only interested in the cpuinfo file, which happens to be inside the base directory. r-r-r- 1 root root 0 Jul 13 00:18 zoneinfo r-r-r- 1 root root 0 Jul 13 00:18 vmstat r-r-r- 1 root root 0 Jul 13 00:18 filesystemsĭr-xr-xr-x 5 root root 0 Jul 13 00:18 fs/ r-r-r- 1 root root 0 Jul 13 00:18 diskstats r-r-r- 1 root root 0 Jul 13 00:14 devices r-r-r- 1 root root 0 Jul 13 00:14 cpuinfo r-r-r- 1 root root 0 Jul 13 00:18 consoles Let’s see what’s inside the /proc directory: # ls -halF /proc total 4.0K We might need root access to read some of the virtual files. On most Linux distributions, virtual files are located in the /proc directory. Unlike a regular file, virtual files don’t take space on the disk and are only created when we read them. So, they’re kind of lenses through which we can peek at the running Linux kernel. By reading virtual files, we can see what the Linux kernel is doing at the moment. A virtual file is a special type of file available on Linux-based operating systems.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |