如何找到Linux系统的虚拟内存大小和缓存大小?

pin*_*ple 12 memory linux virtual-memory

是否有任何命令可以获取 linux 系统的虚拟内存大小、缓存大小和前端总线速度?linux中的交换与虚拟内存相同吗?

小智 11

这个问题完全包含在你之前的问题How to find virtual memory size and cache size of a linux system?. 正如在该问题的回答中指出的那样,该sudo dmidecode --type processor命令为您提供“外部时钟”速度,而FSB 速度是该速度的倍数(通常为 2 或 4 倍)。

如果这对您不起作用,您应该编辑您的原始问题并告诉我们您得到了什么输出或错误是什么。你越具体,别人就越能帮助你。

正如 The Journeyman geek 所指出的,您通常可以从lshwcpu 相关输出中为“clock”报告的值中获得相同的“外部时钟”度量。

 *-cpu
      description: CPU
      product: Genuine Intel(R) CPU           T2300  @ 1.66GHz
      vendor: Intel Corp.
      physical id: 400
      bus info: cpu@0
      version: 6.14.8
      serial: 0000-06E8-0000-0000-0000-0000
      slot: Microprocessor
      size: 1GHz
      capacity: 1800MHz
      width: 32 bits
      clock: 133MHz
      capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx constant_tsc arch_perfmon bts pni monitor est tm2 xtpr pdcm cpufreq
      configuration: id=0
Run Code Online (Sandbox Code Playgroud)

最后,您可能会在 的输出中找到外部时钟速度dmesg,尽管这绝不是访问此信息的标准方式。您可以通过 BIOS 设置或通过查找 CPU 规格找到 FSB 速度,尽管这些不是特定于 linux 的。

  • 为什么这是公认的答案?它没有说明如何确定虚拟内存大小。 (3认同)
  • 我对如何接受这一点感到有点困惑。貌似只回答了部分问题 (2认同)

小智 10

是的,交换是虚拟内存。

虚拟内存大小 使用swapon -sfree

$ swapon -s
Filename                Type        Size    Used    Priority
/dev/sda6                               partition   1004020 39620   -1

$ free
             total       used       free     shared    buffers     cached
Mem:       3087892    2879036     208856          0     394288     835052
-/+ buffers/cache:    1649696    1438196
Swap:      1004020      39620     964400
Run Code Online (Sandbox Code Playgroud)

缓存大小/proc/cpuinfo获取。“缓存大小”字段为您提供 CPU 上的缓存。在多核机器上,您将看到每个处理器一个条目,具有自己的缓存值。

$ cat /proc/cpuinfo
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 14
model name  : Genuine Intel(R) CPU           T2300  @ 1.66GHz
stepping    : 8
cpu MHz     : 1000.000
cache size  : 2048 KB
physical id : 0
siblings    : 2
core id     : 0
cpu cores   : 2
apicid      : 0
initial apicid  : 0
fdiv_bug    : no
hlt_bug     : no
f00f_bug    : no
coma_bug    : no
fpu     : yes
fpu_exception   : yes
cpuid level : 10
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx constant_tsc arch_perfmon bts pni monitor est tm2 xtpr pdcm
bogomips    : 3324.64
clflush size    : 64
power management:
Run Code Online (Sandbox Code Playgroud)

前端总线 (FSB) 速度 您可以使用--type 处理器参数从dmidecode实用程序中获得此速度。您需要 sudo 权限才能运行此命令。FSB 由为“外部时钟”报告的速度指示。实际速度通常是报告速度的 4 倍,因为每个时钟周期执行这么多指令。

$ sudo dmidecode --type processor
# dmidecode 2.9
SMBIOS 2.4 present.

Handle 0x0400, DMI type 4, 32 bytes
Processor Information

Socket Designation: Microprocessor
Type: Central Processor
Family: Pentium M
Manufacturer: Intel
ID: E8 06 00 00 FF FB E9 BF
Signature: Type 0, Family 6, Model 14, Stepping 8
Flags:
    FPU (Floating-point unit on-chip)
    VME (Virtual mode extension)
    DE (Debugging extension)
    PSE (Page size extension)
    TSC (Time stamp counter)
    MSR (Model specific registers)
    PAE (Physical address extension)
    MCE (Machine check exception)
    CX8 (CMPXCHG8 instruction supported)
    APIC (On-chip APIC hardware supported)
    SEP (Fast system call)
    MTRR (Memory type range registers)
    PGE (Page global enable)
    MCA (Machine check architecture)
    CMOV (Conditional move instruction supported)
    PAT (Page attribute table)
    CLFSH (CLFLUSH instruction supported)
    DS (Debug store)
    ACPI (ACPI supported)
    MMX (MMX technology supported)
    FXSR (Fast floating-point save and restore)
    SSE (Streaming SIMD extensions)
    SSE2 (Streaming SIMD extensions 2)
    SS (Self-snoop)
    HTT (Hyper-threading technology)
    TM (Thermal monitor supported)
    PBE (Pending break enabled)
Version: Not Specified
Voltage: 3.3 V
External Clock: 133 MHz
Max Speed: 1800 MHz
Current Speed: 1000 MHz
Status: Populated, Enabled
Upgrade: None
L1 Cache Handle: 0x0700
L2 Cache Handle: 0x0701
L3 Cache Handle: Not Provided
Run Code Online (Sandbox Code Playgroud)