1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | # cat /proc/cpuinfo processor : 0 CPU : POWER6 (raw), altivec supported clock : 4005.000000MHz revision : 3.1 (pvr 003e 0301) processor : 1 CPU : POWER6 (raw), altivec supported clock : 4005.000000MHz revision : 3.1 (pvr 003e 0301) processor : 2 CPU : POWER6 (raw), altivec supported clock : 4005.000000MHz revision : 3.1 (pvr 003e 0301) processor : 3 CPU : POWER6 (raw), altivec supported clock : 4005.000000MHz revision : 3.1 (pvr 003e 0301) processor : 4 CPU : POWER6 (raw), altivec supported clock : 4005.000000MHz revision : 3.1 (pvr 003e 0301) processor : 5 CPU : POWER6 (raw), altivec supported clock : 4005.000000MHz revision : 3.1 (pvr 003e 0301) processor : 6 CPU : POWER6 (raw), altivec supported clock : 4005.000000MHz revision : 3.1 (pvr 003e 0301) processor : 7 CPU : POWER6 (raw), altivec supported clock : 4005.000000MHz revision : 3.1 (pvr 003e 0301) clock : 4005.000000MHz revision : 3.1 (pvr 003e 0301) timebase : 512000000 platform : pSeries model : IBM,7998-61X machine : CHRP IBM,7998-61X |
1 2 | # ppc64_cpu --smt smt is on |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel CPU family : 6 model : 2 model name : QEMU Virtual CPU version 0.9.1 stepping : 3 CPU MHz : 2660.129 cache size : 2048 KB fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes CPUid level : 2 wp : yes flags : fpu de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 nx lm up pni bogomips : 5326.47 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | # 得到 /proc/cpuinfo 文件的内容 my $cpu_file = '/proc/cpuinfo'; open FILE, "<$cpu_file" or die "Failed to open $cpu_file.\n"; my @contents = <FILE>; close FILE; my ($smt, $dedicate); # Power 服务器上运行的 Linux 发行版有自己的命令和配置文件 my $arch = `arch`; if ($arch =~ /ppc64/){ # 得到 Power 服务器上的 SMT 配置 my $output = `ppc64_cpu --smt`; if ($output =~ m/off/){ $smt = "off"; }elsif ($output =~ m/on/){ $smt = "on"; }else{ die "Command ppc64_cpu does not work well. Please reinstall powerpc-utils to fix this issue.\n"; } # 从 lparcfg 文件读出处理器运行模式 my $cfg_file = '/proc/ppc64/lparcfg'; open FILE, "<$cfg_file" or die "Failed to open $cfg_file.\n"; my @cfgs = <FILE>; close FILE; foreach my $line (@cfgs){ if ($line =~ /shared_processor_mode=0/){ $dedicate = 1; # dedicated CPU last; } } } # 解析 /proc/cpuinfo 文件的内容 my $proc_num = 0; my $line_num = 0; my (@physical_ids, $latest_proc_line_num); foreach my $line (@contents){ $line_num ++; chomp $line; # 得到虚拟处理器的个数 if ($line =~ /processor\s+: \d/){ $proc_num ++; $latest_proc_line_num = $line_num; } if ($arch =~ /86/ && $line =~ /physical id/ && !grep (/^\Q$line\E$/, @physical_ids)){ push @physical_ids, $line; } } # 得到 x86 构架系统的 SMT 配置 my $phy_proc_num = scalar(@physical_ids); if ($arch =~ /86/ && ($proc_num > $phy_proc_num)){ $smt = "on"; }elsif ($arch =~ /86/ && ($proc_num == $phy_proc_num)){ $smt = "off"; } # 得到 Power 服务器的虚拟处理器个数 my $vir_proc_num; if ($arch =~ /ppc64/ && $smt eq "on"){ $vir_proc_num = $proc_num/2; }elsif ($arch =~ /ppc64/ && $smt eq "off"){ $vir_proc_num = $proc_num; } # 输出处理器个数 if ($arch =~ /86/){ print "There exist $phy_proc_num physical processors and $proc_num logical processors in the system.\n"; }elsif ($arch =~ /ppc64/){ print "There exist $vir_proc_num virtual processors and $proc_num logical processors in the system.\n"; } # 输出 SMT 配置 if ($smt eq "on"){ print "SMT is $smt on this machine.\n"; }else{ print "SMT is $smt on this machine. This means potential performance issue in some applications. Please make sure that's the configuration you want.\n"; } # 输出处理器运行模式 if ($arch =~ /ppc64/ && $dedicate){ print "System processors are dedicated.\n"; }elsif ($arch =~ /ppc64/ && !$dedicate){ print "System processors are shared.\n"; } # 输出 /proc/cpuinfo 中的处理器关键信息 for (my $i = $latest_proc_line_num; $i < scalar(@contents); $i ++){ print "$contents[$i]\n"; } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |