Sample Header Ad - 728x90

Alternate way to get the CPU cache size

1 vote
0 answers
68 views
I have a project where I need to get the size of the cache on my Linux machine. I don't know the linux distro, and the /etc/os-release file does not exist. I only know the kernel and architecture: Kernel: Linux 6.1.20-rt8 Architecture: arm64 I cannot install libraries onto the machine. To get the size of the cache, I tried the following methods, all of which failed:
$ lscpu | grep cache
L1d cache:           unknown size
L1i cache:           unknown size
L2 cache:            unknown size
$ cat /proc/cpuinfo | grep cache
$
$ ls /sys/devices/system/cpu/cpu*/cache/index*/size
ls: /sys/devices/system/cpu/cpu*/cache/index*/size: No such file or directory
dmesg | grep -i cache
[    0.000000] Detected VIPT I-cache on CPU0
[    0.000000] Dentry cache hash table entries: 524288 (order: 10, 4194304 bytes, linear)
[    0.000000] Inode-cache hash table entries: 262144 (order: 9, 2097152 bytes, linear)
[    0.405602] Mount-cache hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.405623] Mountpoint-cache hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.490323] Detected VIPT I-cache on CPU1
[    0.508655] Detected VIPT I-cache on CPU2
[    0.526850] Detected VIPT I-cache on CPU3
[    0.547628] Detected PIPT I-cache on CPU4
[    0.591655] Detected PIPT I-cache on CPU5
[    0.762359] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
[   22.216417] Detected PIPT I-cache on CPU4
[   22.412738] Detected PIPT I-cache on CPU5
The /proc/cpu info file:
$ cat /proc/cpuinfo
processor       : 0
BogoMIPS        : 16.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 1
BogoMIPS        : 16.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 2
BogoMIPS        : 16.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 3
BogoMIPS        : 16.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 4
BogoMIPS        : 16.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd08
CPU revision    : 2

processor       : 5
BogoMIPS        : 16.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd08
CPU revision    : 2
The full lscpu:
$ lscpu
Architecture:        aarch64
Byte Order:          Little Endian
CPU(s):              6
On-line CPU(s) list: 0-5
Thread(s) per core:  1
Core(s) per socket:  6
Socket(s):           1
NUMA node(s):        1
Vendor ID:           ARM
Model:               4
Model name:          Cortex-A53
Stepping:            r0p4
BogoMIPS:            16.00
L1d cache:           unknown size
L1i cache:           unknown size
L2 cache:            unknown size
NUMA node0 CPU(s):   0-5
Flags:               fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
Asked by Plat00n (111 rep)
Feb 6, 2025, 08:48 AM
Last activity: Feb 6, 2025, 12:28 PM