cpuidコマンドでCPU情報をダンプする

はじめに

LinuxでCPUの詳細情報を取得するコマンドとしてlscpu/proc/cpuinfoが有名だが、より低レベルな情報や生のCPUID命令の結果を確認したい場合にcpuidコマンドというのものがあるとのことで使ってみる。

cpuidコマンドは、CPUID命令から収集されたCPUに関する詳細情報をダンプし、CPUの正確なモデルを判定してくれるツールである。

環境

Ubuntu 24.04.3 LTS

cpuidのインストール

cpuidコマンドは標準ではインストールされていないことが多いため、パッケージマネージャーからインストールする。

Ubuntu/Debian系の場合

sudo apt update
sudo apt install cpuid
ログ
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  crack-common gyp libcares2 libgl1-amber-dri libglapi-mesa libjs-async libjs-events libjs-inherits
  libjs-is-typedarray libjs-prettify libjs-regenerate libjs-source-map libjs-sprintf-js
  libjs-typedarray-to-buffer libllvm17t64 liblttng-ust-common1t64 liblttng-ust-ctl5t64 liblttng-ust1t64
  libnotify-bin libqt5x11extras5 libre2-10 libssl-dev libuv1-dev libxcb-damage0 mesa-utils-bin node-abbrev
  node-ampproject-remapping node-ansi-regex node-ansi-styles node-aproba node-are-we-there-yet node-arrify
  node-async node-async-each node-auto-bind node-babel-plugin-add-module-exports node-babel7-runtime
  node-balanced-match node-base64-js node-binary-extensions node-brace-expansion node-busboy
  node-camelcase node-caniuse-lite node-chownr node-chrome-trace-event node-ci-info node-cjs-module-lexer
  node-cli-boxes node-cli-cursor node-clone node-collection-visit node-color-convert node-color-name
  node-colors node-commander node-commondir node-concat-stream node-console-control-strings
  node-convert-source-map node-core-js node-core-js-pure node-core-util-is node-data-uri-to-buffer
  node-decompress-response node-deep-is node-defaults node-define-property node-delegates node-depd
  node-diff node-electron-to-chromium node-encoding node-end-of-stream node-err-code node-error-ex
  node-es-module-lexer node-escape-string-regexp node-eslint-utils node-eslint-visitor-keys node-esquery
  node-estraverse node-esutils node-events node-fancy-log node-fast-deep-equal node-fast-levenshtein
  node-fetch node-find-up node-flatted node-foreground-child node-fs-readdir-recursive
  node-fs-write-stream-atomic node-fs.realpath node-function-bind node-get-caller-file node-get-stream
  node-get-value node-glob node-globals node-got node-graceful-fs node-growl node-has-flag
  node-has-unicode node-has-value node-has-values node-hosted-git-info node-iconv-lite node-ieee754
  node-iferr node-imurmurhash node-indent-string node-inflight node-inherits node-ini node-interpret
  node-ip node-ip-regex node-is-arrayish node-is-binary-path node-is-buffer node-is-descriptor
  node-is-extglob node-is-path-cwd node-is-plain-obj node-is-plain-object node-is-stream
  node-is-typedarray node-is-windows node-isarray node-isexe node-isobject node-js-tokens node-json-buffer
  node-json-parse-better-errors node-json-schema node-json-schema-traverse node-json-stable-stringify
  node-jsonify node-jsonparse node-kind-of node-levn node-loader-runner node-locate-path
  node-lodash-packages node-lowercase-keys node-lru-cache node-map-visit node-memfs node-merge-stream
  node-mimic-response node-minimatch node-minimist node-minipass node-mute-stream node-n3 node-negotiator
  node-npm-run-path node-object-inspect node-object-visit node-once node-optimist node-optionator
  node-osenv node-p-cancelable node-p-limit node-p-locate node-p-map node-pascalcase node-path-dirname
  node-path-exists node-path-is-absolute node-path-is-inside node-path-type node-pify node-pkg-dir
  node-postcss-value-parser node-prelude-ls node-process-nextick-args node-promise-inflight
  node-promise-retry node-promzard node-prr node-pump node-punycode node-quick-lru node-randombytes
  node-read node-readable-stream node-rechoir node-regenerator-runtime node-regenerator-transform
  node-regexpp node-regjsgen node-repeat-string node-require-directory node-require-from-string
  node-resolve node-resolve-cwd node-resolve-from node-restore-cursor node-resumer node-retry
  node-run-queue node-safe-buffer node-serialize-javascript node-set-blocking node-set-immediate-shim
  node-shebang-command node-shebang-regex node-shell-quote node-signal-exit node-slash node-slice-ansi
  node-source-list-map node-source-map node-spdx-correct node-spdx-exceptions node-spdx-expression-parse
  node-spdx-license-ids node-sprintf-js node-ssri node-stack-utils node-string-decoder node-strip-bom
  node-supports-color node-tapable node-terser node-text-table node-through node-time-stamp
  node-to-fast-properties node-tslib node-type-check node-typedarray node-typedarray-to-buffer node-undici
  node-unicode-canonical-property-names-ecmascript node-unicode-match-property-value-ecmascript
  node-unicode-property-aliases-ecmascript node-unset-value node-uri-js node-util-deprecate node-uuid
  node-v8flags node-validate-npm-package-license node-wcwidth.js node-webpack-sources node-wordwrap
  node-wrappy node-write-file-atomic node-xtend node-y18n node-yallist node-yaml nodejs-doc xbitmaps
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  cpuid
0 upgraded, 1 newly installed, 0 to remove and 113 not upgraded.
Need to get 112 kB of archives.
After this operation, 482 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu noble/universe amd64 cpuid amd64 20240330-1ubuntu2 [112 kB]
Fetched 112 kB in 1s (74.8 kB/s)
Selecting previously unselected package cpuid.
(Reading database ... 118887 files and directories currently installed.)
Preparing to unpack .../cpuid_20240330-1ubuntu2_amd64.deb ...
Unpacking cpuid (20240330-1ubuntu2) ...
Setting up cpuid (20240330-1ubuntu2) ...
Processing triggers for man-db (2.12.0-4build2) ...

基本的な使い方

ヘルプの表示

オプションを確認するには-hまたは--helpを使用する。

cpuid --help
usage: cpuid [options...]

Dump detailed information about the CPU(s) gathered from the CPUID instruction,
and also determine the exact model of CPU(s).

options:

   -1,      --one-cpu    display information only for the current CPU
   -f FILE, --file=FILE  read raw hex information (-r output) from FILE instead
                         of from executions of the cpuid instruction.
                         If FILE is '-', read from stdin.
   -l V,    --leaf=V     display information for the single specified leaf.
                         If -s/--subleaf is not specified, 0 is assumed.
                         NOTE: If a leaf cannot be interpreted in isolation, it
                         will be displayed as raw hex.
   -s V,    --subleaf=V  display information for the single specified subleaf.
                         It requires -l/--leaf.
   -h, -H,  --help       display this help information
   -i,      --inst       use the CPUID instruction: The information it provides
                         is reliable.  It is not necessary to be root.
                         (This option is the default.)
   -k,      --kernel     use the CPUID kernel module: The information does not
                         seem to be reliable on all combinations of CPU type
                         and kernel version.  Typically, it is necessary to be
                         root.
   -r,      --raw        display raw hex information with no decoding
   -S,      --simple     display (simple synth), based on only single leaves
   -v,      --version    display cpuid version

CPU情報のダンプ

引数なしで実行すると、全ての論理CPUについての詳細情報が表示される。
出力は非常に長くなるため、ページャーと組み合わせるのが良い。

cpuid | less
cpuid結果一部
CPU:
   vendor_id = "AuthenticAMD"
   version information (1/eax):
      processor type  = primary processor (0)
      family          = 0xf (15)
      model           = 0x1 (1)
      stepping id     = 0x2 (2)
      extended family = 0xa (10)
      extended model  = 0x6 (6)
      (family synth)  = 0x19 (25)
      (model synth)   = 0x61 (97)
   miscellaneous (1/ebx):
      process local APIC physical ID = 0x1 (1)
      maximum IDs for CPUs in pkg    = 0x20 (32)
      CLFLUSH line size              = 0x8 (8)
      brand index                    = 0x0 (0)
   brand id = 0x00 (0): unknown
   feature information (1/edx):
      x87 FPU on chip                        = true
      VME: virtual-8086 mode enhancement     = true
      DE: debugging extensions               = true
      PSE: page size extensions              = true
      TSC: time stamp counter                = true
      RDMSR and WRMSR support                = true
      PAE: physical address extensions       = true
      MCE: machine check exception           = true
      CMPXCHG8B inst.                        = true
      APIC on chip                           = true
      SYSENTER and SYSEXIT                   = true
      MTRR: memory type range registers      = true
      PTE global bit                         = true
      MCA: machine check architecture        = true
      CMOV: conditional move/compare instr   = true
      PAT: page attribute table              = true
      PSE-36: page size extension            = true
      PSN: processor serial number           = false
      CLFLUSH instruction                    = true
      DS: debug store                        = false
      ACPI: thermal monitor and clock ctrl   = false
      MMX Technology                         = true
      FXSAVE/FXRSTOR                         = true
      SSE extensions                         = true
      SSE2 extensions                        = true
      SS: self snoop                         = false
      hyper-threading / multi-core supported = true
      TM: therm. monitor                     = false
      IA64                                   = false
      PBE: pending break event               = false
   feature information (1/ecx):
      PNI/SSE3: Prescott New Instructions     = true
      PCLMULDQ instruction                    = true
      DTES64: 64-bit debug store              = false
      MONITOR/MWAIT                           = false
      CPL-qualified debug store               = false
      VMX: virtual machine extensions         = false
      SMX: safer mode extensions              = false
      Enhanced Intel SpeedStep Technology     = false
      TM2: thermal monitor 2                  = false
      SSSE3 extensions                        = true
      context ID: adaptive or shared L1 data  = false
      SDBG: IA32_DEBUG_INTERFACE              = false
      FMA instruction                         = true
      CMPXCHG16B instruction                  = true
      xTPR disable                            = false
      PDCM: perfmon and debug                 = false
      PCID: process context identifiers       = false
      DCA: direct cache access                = false
      SSE4.1 extensions                       = true
      SSE4.2 extensions                       = true
      x2APIC: extended xAPIC support          = false
      MOVBE instruction                       = true
      POPCNT instruction                      = true
      time stamp counter deadline             = false
      AES instruction                         = true
      XSAVE/XSTOR states                      = true
      OS-enabled XSAVE/XSTOR                  = true
      AVX: advanced vector extensions         = true
      F16C half-precision convert instruction = true
      RDRAND instruction                      = true
      hypervisor guest status                 = true
   cache and TLB information (2):
   processor serial number = 00A6-0F12-0000-0000-0000-0000
   deterministic cache parameters (4):

表示内容の解説

項目説明
vendor_idCPUベンダーのID(例: “AuthenticAMD” や “GenuineIntel”)。
version informationファミリー、モデル、ステッピングなどのプロセッサ識別情報。
feature informationCPUがサポートする機能のフラグ一覧。
AVX: Advanced Vector Extensions (ベクトル演算命令セット)
AES: AES暗号化命令セット
VMX / SVM: 仮想化支援機能(Intel VMX, AMD SVM)
hyper-threading: ハイパースレッディングのサポート有無
cache and TLB informationキャッシュメモリやTLB(Translation Lookaside Buffer)に関する情報。

現在のCPUのみ表示

マルチコア環境では同じ情報が繰り返し表示されることがある。現在のCPU(実行中のコア)のみの情報を表示するには-1または--one-cpuオプションを使用する。

cpuid -1

Rawデータの表示

デコードなしの生の16進数情報を表示するには-rまたは--rawを使用する。

cpuid -r

参考

おわりに

cpuidコマンドを使うことで、CPUの機能フラグやキャッシュトポロジーなど、細かいハードウェア情報を確認することができる。
パフォーマンスチューニングや、特定の命令セットのサポート状況を確認したい場合に活用できる。

Hugo で構築されています。
テーマ StackJimmy によって設計されています。