Is there any way to know the size of L1, L2, L3 cache and RAM in Linux?Is there a way to speed up boot time...

Is anyone against the rational teachings of Maimonides?

Code Golf Measurer © 2019

Showing a limit approaches e: base of natural log

3-prong to 4-prong conversion - EXTRA MISLABELLED WIRES - Dryer cable upgrade and installation

Can you upgrade armour from breastplate to halfplate?

How to protect my Wi-Fi password from being displayed by Android phones when sharing it with QR code?

Novel with a mix of real world and gods

Why does Principal Vagina say, "no relation" after introducing himself?

What does すきすき mean here?

Is Schrodinger's Cat itself an observer?

Are there 99 percentiles, or 100 percentiles? And are they groups of numbers, or dividers or pointers to individual numbers?

Neither Raman nor IR Active vibrational modes

Why does b+=(4,) work and b = b + (4,) doesn't work when b is a list?

Does a restocking fee still qualify as a business expense?

Can you set fire to beer barrels?

Satellite for internet... Safe enough?

"A tin of biscuits" vs "A biscuit tin"

Does really each and every single photon leave a dot on the screen in the bright area (double slit)?

Text on old-fashioned differential geometry

What does this text mean with capitalized letters?

Incorrect mmap behavior when assembly files included in the project

What is a gender neutral equivalent for the following phrase?

How should the 23rd judge vote?

Extra battery in the bay of an HDD



Is there any way to know the size of L1, L2, L3 cache and RAM in Linux?


Is there a way to speed up boot time by loading things into RAM immediately?RAM size and SWAP sizeHow do you empty the buffers and cache on a Linux system?Is there a linux OS that can be loaded entirely into RAM?Can a sparse file go beyond the ram size?Why linux system freezes and not recover from running out of RAMLinux Mint RAM Memory - Showing different usage and free spaceDisable buff/cache linux for fixing ubuntu hangs on full ram






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{
margin-bottom:0;
}








20

















Is there any way to know the size of L1, L2, L3 caches and RAM in Linux?










share|improve this question





























  • Cross-posted on: superuser.com/q/837970

    – maxschlepzig
    yesterday


















20

















Is there any way to know the size of L1, L2, L3 caches and RAM in Linux?










share|improve this question





























  • Cross-posted on: superuser.com/q/837970

    – maxschlepzig
    yesterday














20












20








20


8






Is there any way to know the size of L1, L2, L3 caches and RAM in Linux?










share|improve this question
















Is there any way to know the size of L1, L2, L3 caches and RAM in Linux?







hardware ram






share|improve this question















share|improve this question













share|improve this question




share|improve this question



share|improve this question








edited Sep 28 '16 at 20:08









Anton Leontiev

4853 silver badges11 bronze badges




4853 silver badges11 bronze badges










asked Nov 9 '14 at 23:50









user3692521user3692521

2031 gold badge2 silver badges4 bronze badges




2031 gold badge2 silver badges4 bronze badges
















  • Cross-posted on: superuser.com/q/837970

    – maxschlepzig
    yesterday



















  • Cross-posted on: superuser.com/q/837970

    – maxschlepzig
    yesterday

















Cross-posted on: superuser.com/q/837970

– maxschlepzig
yesterday





Cross-posted on: superuser.com/q/837970

– maxschlepzig
yesterday










7 Answers
7






active

oldest

votes


















22


















If you have lshw installed:



$ sudo lshw -C memory


Example



$ sudo lshw -C memory
...
*-cache:0
description: L1 cache
physical id: a
slot: Internal L1 Cache
size: 32KiB
capacity: 32KiB
capabilities: asynchronous internal write-through data
*-cache:1
description: L2 cache
physical id: b
slot: Internal L2 Cache
size: 256KiB
capacity: 256KiB
capabilities: burst internal write-through unified
*-cache:2
description: L3 cache
physical id: c
slot: Internal L3 Cache
size: 3MiB
capacity: 8MiB
capabilities: burst internal write-back
*-memory
description: System Memory
physical id: 2a
slot: System board or motherboard
size: 8GiB
*-bank:0
description: SODIMM DDR3 Synchronous 1334 MHz (0.7 ns)
product: M471B5273CH0-CH9
vendor: Samsung
physical id: 0
serial: 67010644
slot: DIMM 1
size: 4GiB
width: 64 bits
clock: 1334MHz (0.7ns)
*-bank:1
description: SODIMM DDR3 Synchronous 1334 MHz (0.7 ns)
product: 16JTF51264HZ-1G4H1
vendor: Micron Technology
physical id: 1
serial: 3749C127
slot: DIMM 2
size: 4GiB
width: 64 bits
clock: 1334MHz (0.7ns)





share|improve this answer
























  • 1





    Please include substance to answers. Don't just mention names of commands, but show their output.

    – slm
    Nov 11 '14 at 3:03











  • lshw (ran with root permission of course) didn't give me cache information. but lscpu and dmidecode tools gave me the results.

    – Shnd
    Mar 18 '16 at 12:04



















18


















lscpu



If you care only about the sizes, try lscpu from util-linux.



Example



$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 2
Core(s) per socket: 2
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 37
Model name: Intel(R) Core(TM) i5 CPU M 560 @ 2.67GHz
Stepping: 5
CPU MHz: 1199.000
BogoMIPS: 5319.88
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 3072K
NUMA node0 CPU(s): 0-3


x86info



There should be also package/command called x86info. Assuming you have i386/x86_64, x86info -c should provide more detailed information about caches.



Example



$ x86info -c
x86info v1.30. Dave Jones 2001-2011
Feedback to <davej@redhat.com>.

Found 4 identical CPUs
Extended Family: 0 Extended Model: 2 Family: 6 Model: 37 Stepping: 5
Type: 0 (Original OEM)
CPU Model (x86info's best guess): Core i7 (Nehalem) [Clarkdale/Arrandale]
Processor name string (BIOS programmed): Intel(R) Core(TM) i5 CPU M 560 @ 2.67GHz

Cache info
L1 Instruction cache: 32KB, 4-way associative. 64 byte line size.
L1 Data cache: 32KB, 8-way associative. 64 byte line size.
L2 (MLC): 256KB, 8-way associative. 64 byte line size.
TLB info
Instruction TLB: 2MB or 4MB pages, fully associative, 7 entries
Instruction TLB: 4K pages, 4-way associative, 64 entries.
Data TLB: 4KB or 4MB pages, fully associative, 32 entries.
Data TLB: 4KB pages, 4-way associative, 64 entries
Data TLB: 4K pages, 4-way associative, 512 entries.
Data TLB: 4KB or 4MB pages, fully associative, 32 entries.
Data TLB: 4KB pages, 4-way associative, 64 entries
64 byte prefetching.
Data TLB: 4K pages, 4-way associative, 512 entries.
Found unknown cache descriptors: dd
Total processor threads: 4
This system has 1 dual-core processor with hyper-threading (2 threads per core) running at an estimated 2.65GHz





share|improve this answer




































    3


















    You could try this command.



    $sudo dmidecode -t cache


    Example



    $ sudo dmidecode -t cache | grep -iE "leve|installed"
    Configuration: Enabled, Socketed, Level 1
    Installed Size: 32 kB
    Installed SRAM Type: Asynchronous
    Configuration: Enabled, Socketed, Level 2
    Installed Size: 256 kB
    Installed SRAM Type: Burst
    Configuration: Enabled, Socketed, Level 3
    Installed Size: 3072 kB
    Installed SRAM Type: Burst


    To see RAM simply add the additional switch -t memory.



    $ sudo dmidecode -t cache -t memory


    References




    • finding L2 cache size in Linux






    share|improve this answer




































      3


















      getconf



      getconf -a | grep CACHE


      gives:



      LEVEL1_ICACHE_SIZE                 32768
      LEVEL1_ICACHE_ASSOC 8
      LEVEL1_ICACHE_LINESIZE 64
      LEVEL1_DCACHE_SIZE 32768
      LEVEL1_DCACHE_ASSOC 8
      LEVEL1_DCACHE_LINESIZE 64
      LEVEL2_CACHE_SIZE 262144
      LEVEL2_CACHE_ASSOC 8
      LEVEL2_CACHE_LINESIZE 64
      LEVEL3_CACHE_SIZE 20971520
      LEVEL3_CACHE_ASSOC 20
      LEVEL3_CACHE_LINESIZE 64
      LEVEL4_CACHE_SIZE 0
      LEVEL4_CACHE_ASSOC 0
      LEVEL4_CACHE_LINESIZE 0


      Or for a single level:



      getconf LEVEL2_CACHE_SIZE


      The cool thing about this interface is that it is just a wrapper around the POSIX sysconf C function (cache arguments are non-POSIX extensions), and so it can be used from C code as well.



      Tested in Ubuntu 16.04.



      x86 CPUID instruction



      The CPUID x86 instruction also offers cache information, and can be directly accessed by userland: https://en.wikipedia.org/wiki/CPUID



      glibc seems to use that method for x86. I haven't confirmed by step debugging / instruction tracing, but the source for 2.28 sysdeps/x86/cacheinfo.c does that:



      __cpuid (2, eax, ebx, ecx, edx);


      TODO create a minimal C example, lazy now, asked at: https://stackoverflow.com/questions/14283171/how-to-receive-l1-l2-l3-cache-size-using-cpuid-instruction-in-x86



      ARM also has an architecture-defined mechanism to find cache sizes through registers such as the Cache Size ID Register (CCSIDR), see the ARMv8 Programmers' Manual 11.6 "Cache discovery" for an overview.






      share|improve this answer




































        2


















        There are special files exported to /sys sysfs Linux filesystem since 2008:



        https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-devices-system-cpu



        What:       /sys/devices/system/cpu/cpu*/cache/index*/<set_of_attributes_mentioned_below>
        Date: July 2014(documented, existed before August 2008)
        Description: Parameters for the CPU cache attributes

        allocation_policy:
        - WriteAllocate: allocate a memory location to a cache line
        on a cache miss because of a write
        - ReadAllocate: allocate a memory location to a cache line
        on a cache miss because of a read
        - ReadWriteAllocate: both writeallocate and readallocate

        coherency_line_size: the minimum amount of data in bytes that gets
        transferred from memory to cache

        level: the cache hierarchy in the multi-level cache configuration

        number_of_sets: total number of sets in the cache, a set is a
        collection of cache lines with the same cache index

        physical_line_partition: number of physical cache line per cache tag

        shared_cpu_list: the list of logical cpus sharing the cache

        shared_cpu_map: logical cpu mask containing the list of cpus sharing
        the cache

        size: the total cache size in kB

        type:
        - Instruction: cache that only holds instructions
        - Data: cache that only caches data
        - Unified: cache that holds both data and instructions

        ways_of_associativity: degree of freedom in placing a particular block
        of memory in the cache

        write_policy:
        - WriteThrough: data is written to both the cache line
        and to the block in the lower-level memory
        - WriteBack: data is written only to the cache line and
        the modified cache line is written to main
        memory only when it is replaced


        ID files:



        What:       /sys/devices/system/cpu/cpu*/cache/index*/id
        Date: September 2016
        Contact: Linux kernel mailing list <linux-kernel@vger.kernel.org>
        Description: Cache id

        The id provides a unique number for a specific instance of
        a cache of a particular type. E.g. there may be a level
        3 unified cache on each socket in a server and we may
        assign them ids 0, 1, 2, ...

        Note that id value can be non-contiguous. E.g. level 1
        caches typically exist per core, but there may not be a
        power of two cores on a socket, so these caches may be
        numbered 0, 1, 2, 3, 4, 5, 8, 9, 10, ...





        share|improve this answer



























        • I wonder why on my machine index0 and index1 both do level 1 on kernel v4.15, it is confusing. 0-index preventive coding? :-)

          – Ciro Santilli 新疆改造中心法轮功六四事件
          Feb 27 '18 at 11:58








        • 1





          @CiroSantilli华涌低端人口六四事件法轮功, (with the name to not pronounce), probably index0 is about L1 with type Data (L1 data cache) and index1 is about L1 with type Instruction (L1 instruction cache). Then index2 is of type Unified and level of 2 (L2 cache, can store both data and instruction)

          – osgx
          Feb 27 '18 at 14:33











        • ah, yes! I should be more patient to read docs :-)

          – Ciro Santilli 新疆改造中心法轮功六四事件
          Feb 27 '18 at 14:36



















        1


















        cpuid



        Another option is cpuid program. It uses CPUID instructions and does not require root. It also can work throught cpuid Linux kernel module.



        cache and TLB information (2):
        0x59: data TLB: 4K pages, 16 entries
        0xba: data TLB: 4K pages, 4-way, 64 entries
        0x4f: instruction TLB: 4K pages, 32 entries
        0xc0: data TLB: 4K & 4M pages, 4-way, 8 entries
        0x80: L2 cache: 512K, 8-way, 64 byte lines
        0x30: L1 cache: 32K, 8-way, 64 byte lines
        0x0e: L1 data cache: 24K, 6-way, 64 byte lines


        Note that on common consumer CPUs L1 and L2 caches are per core, while L3 cache is shared by all cores.






        share|improve this answer




































          0


















          if you only want the L3 then grep "cache size" < /proc/cpuinfo should be enough.



          However since the way L3 cache is shared among cpu archs differs, its value might need normalization






          share|improve this answer





























          • Perhaps you want to remove a useless use of cat.

            – maxschlepzig
            yesterday













          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });















          draft saved

          draft discarded
















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f167038%2fis-there-any-way-to-know-the-size-of-l1-l2-l3-cache-and-ram-in-linux%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown


























          7 Answers
          7






          active

          oldest

          votes








          7 Answers
          7






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          22


















          If you have lshw installed:



          $ sudo lshw -C memory


          Example



          $ sudo lshw -C memory
          ...
          *-cache:0
          description: L1 cache
          physical id: a
          slot: Internal L1 Cache
          size: 32KiB
          capacity: 32KiB
          capabilities: asynchronous internal write-through data
          *-cache:1
          description: L2 cache
          physical id: b
          slot: Internal L2 Cache
          size: 256KiB
          capacity: 256KiB
          capabilities: burst internal write-through unified
          *-cache:2
          description: L3 cache
          physical id: c
          slot: Internal L3 Cache
          size: 3MiB
          capacity: 8MiB
          capabilities: burst internal write-back
          *-memory
          description: System Memory
          physical id: 2a
          slot: System board or motherboard
          size: 8GiB
          *-bank:0
          description: SODIMM DDR3 Synchronous 1334 MHz (0.7 ns)
          product: M471B5273CH0-CH9
          vendor: Samsung
          physical id: 0
          serial: 67010644
          slot: DIMM 1
          size: 4GiB
          width: 64 bits
          clock: 1334MHz (0.7ns)
          *-bank:1
          description: SODIMM DDR3 Synchronous 1334 MHz (0.7 ns)
          product: 16JTF51264HZ-1G4H1
          vendor: Micron Technology
          physical id: 1
          serial: 3749C127
          slot: DIMM 2
          size: 4GiB
          width: 64 bits
          clock: 1334MHz (0.7ns)





          share|improve this answer
























          • 1





            Please include substance to answers. Don't just mention names of commands, but show their output.

            – slm
            Nov 11 '14 at 3:03











          • lshw (ran with root permission of course) didn't give me cache information. but lscpu and dmidecode tools gave me the results.

            – Shnd
            Mar 18 '16 at 12:04
















          22


















          If you have lshw installed:



          $ sudo lshw -C memory


          Example



          $ sudo lshw -C memory
          ...
          *-cache:0
          description: L1 cache
          physical id: a
          slot: Internal L1 Cache
          size: 32KiB
          capacity: 32KiB
          capabilities: asynchronous internal write-through data
          *-cache:1
          description: L2 cache
          physical id: b
          slot: Internal L2 Cache
          size: 256KiB
          capacity: 256KiB
          capabilities: burst internal write-through unified
          *-cache:2
          description: L3 cache
          physical id: c
          slot: Internal L3 Cache
          size: 3MiB
          capacity: 8MiB
          capabilities: burst internal write-back
          *-memory
          description: System Memory
          physical id: 2a
          slot: System board or motherboard
          size: 8GiB
          *-bank:0
          description: SODIMM DDR3 Synchronous 1334 MHz (0.7 ns)
          product: M471B5273CH0-CH9
          vendor: Samsung
          physical id: 0
          serial: 67010644
          slot: DIMM 1
          size: 4GiB
          width: 64 bits
          clock: 1334MHz (0.7ns)
          *-bank:1
          description: SODIMM DDR3 Synchronous 1334 MHz (0.7 ns)
          product: 16JTF51264HZ-1G4H1
          vendor: Micron Technology
          physical id: 1
          serial: 3749C127
          slot: DIMM 2
          size: 4GiB
          width: 64 bits
          clock: 1334MHz (0.7ns)





          share|improve this answer
























          • 1





            Please include substance to answers. Don't just mention names of commands, but show their output.

            – slm
            Nov 11 '14 at 3:03











          • lshw (ran with root permission of course) didn't give me cache information. but lscpu and dmidecode tools gave me the results.

            – Shnd
            Mar 18 '16 at 12:04














          22














          22










          22









          If you have lshw installed:



          $ sudo lshw -C memory


          Example



          $ sudo lshw -C memory
          ...
          *-cache:0
          description: L1 cache
          physical id: a
          slot: Internal L1 Cache
          size: 32KiB
          capacity: 32KiB
          capabilities: asynchronous internal write-through data
          *-cache:1
          description: L2 cache
          physical id: b
          slot: Internal L2 Cache
          size: 256KiB
          capacity: 256KiB
          capabilities: burst internal write-through unified
          *-cache:2
          description: L3 cache
          physical id: c
          slot: Internal L3 Cache
          size: 3MiB
          capacity: 8MiB
          capabilities: burst internal write-back
          *-memory
          description: System Memory
          physical id: 2a
          slot: System board or motherboard
          size: 8GiB
          *-bank:0
          description: SODIMM DDR3 Synchronous 1334 MHz (0.7 ns)
          product: M471B5273CH0-CH9
          vendor: Samsung
          physical id: 0
          serial: 67010644
          slot: DIMM 1
          size: 4GiB
          width: 64 bits
          clock: 1334MHz (0.7ns)
          *-bank:1
          description: SODIMM DDR3 Synchronous 1334 MHz (0.7 ns)
          product: 16JTF51264HZ-1G4H1
          vendor: Micron Technology
          physical id: 1
          serial: 3749C127
          slot: DIMM 2
          size: 4GiB
          width: 64 bits
          clock: 1334MHz (0.7ns)





          share|improve this answer
















          If you have lshw installed:



          $ sudo lshw -C memory


          Example



          $ sudo lshw -C memory
          ...
          *-cache:0
          description: L1 cache
          physical id: a
          slot: Internal L1 Cache
          size: 32KiB
          capacity: 32KiB
          capabilities: asynchronous internal write-through data
          *-cache:1
          description: L2 cache
          physical id: b
          slot: Internal L2 Cache
          size: 256KiB
          capacity: 256KiB
          capabilities: burst internal write-through unified
          *-cache:2
          description: L3 cache
          physical id: c
          slot: Internal L3 Cache
          size: 3MiB
          capacity: 8MiB
          capabilities: burst internal write-back
          *-memory
          description: System Memory
          physical id: 2a
          slot: System board or motherboard
          size: 8GiB
          *-bank:0
          description: SODIMM DDR3 Synchronous 1334 MHz (0.7 ns)
          product: M471B5273CH0-CH9
          vendor: Samsung
          physical id: 0
          serial: 67010644
          slot: DIMM 1
          size: 4GiB
          width: 64 bits
          clock: 1334MHz (0.7ns)
          *-bank:1
          description: SODIMM DDR3 Synchronous 1334 MHz (0.7 ns)
          product: 16JTF51264HZ-1G4H1
          vendor: Micron Technology
          physical id: 1
          serial: 3749C127
          slot: DIMM 2
          size: 4GiB
          width: 64 bits
          clock: 1334MHz (0.7ns)






          share|improve this answer















          share|improve this answer




          share|improve this answer



          share|improve this answer








          edited Nov 11 '14 at 2:59









          slm

          270k77 gold badges588 silver badges732 bronze badges




          270k77 gold badges588 silver badges732 bronze badges










          answered Nov 10 '14 at 10:19









          CostasCostas

          13k11 silver badges29 bronze badges




          13k11 silver badges29 bronze badges











          • 1





            Please include substance to answers. Don't just mention names of commands, but show their output.

            – slm
            Nov 11 '14 at 3:03











          • lshw (ran with root permission of course) didn't give me cache information. but lscpu and dmidecode tools gave me the results.

            – Shnd
            Mar 18 '16 at 12:04














          • 1





            Please include substance to answers. Don't just mention names of commands, but show their output.

            – slm
            Nov 11 '14 at 3:03











          • lshw (ran with root permission of course) didn't give me cache information. but lscpu and dmidecode tools gave me the results.

            – Shnd
            Mar 18 '16 at 12:04








          1




          1





          Please include substance to answers. Don't just mention names of commands, but show their output.

          – slm
          Nov 11 '14 at 3:03





          Please include substance to answers. Don't just mention names of commands, but show their output.

          – slm
          Nov 11 '14 at 3:03













          lshw (ran with root permission of course) didn't give me cache information. but lscpu and dmidecode tools gave me the results.

          – Shnd
          Mar 18 '16 at 12:04





          lshw (ran with root permission of course) didn't give me cache information. but lscpu and dmidecode tools gave me the results.

          – Shnd
          Mar 18 '16 at 12:04













          18


















          lscpu



          If you care only about the sizes, try lscpu from util-linux.



          Example



          $ lscpu
          Architecture: x86_64
          CPU op-mode(s): 32-bit, 64-bit
          Byte Order: Little Endian
          CPU(s): 4
          On-line CPU(s) list: 0-3
          Thread(s) per core: 2
          Core(s) per socket: 2
          Socket(s): 1
          NUMA node(s): 1
          Vendor ID: GenuineIntel
          CPU family: 6
          Model: 37
          Model name: Intel(R) Core(TM) i5 CPU M 560 @ 2.67GHz
          Stepping: 5
          CPU MHz: 1199.000
          BogoMIPS: 5319.88
          Virtualization: VT-x
          L1d cache: 32K
          L1i cache: 32K
          L2 cache: 256K
          L3 cache: 3072K
          NUMA node0 CPU(s): 0-3


          x86info



          There should be also package/command called x86info. Assuming you have i386/x86_64, x86info -c should provide more detailed information about caches.



          Example



          $ x86info -c
          x86info v1.30. Dave Jones 2001-2011
          Feedback to <davej@redhat.com>.

          Found 4 identical CPUs
          Extended Family: 0 Extended Model: 2 Family: 6 Model: 37 Stepping: 5
          Type: 0 (Original OEM)
          CPU Model (x86info's best guess): Core i7 (Nehalem) [Clarkdale/Arrandale]
          Processor name string (BIOS programmed): Intel(R) Core(TM) i5 CPU M 560 @ 2.67GHz

          Cache info
          L1 Instruction cache: 32KB, 4-way associative. 64 byte line size.
          L1 Data cache: 32KB, 8-way associative. 64 byte line size.
          L2 (MLC): 256KB, 8-way associative. 64 byte line size.
          TLB info
          Instruction TLB: 2MB or 4MB pages, fully associative, 7 entries
          Instruction TLB: 4K pages, 4-way associative, 64 entries.
          Data TLB: 4KB or 4MB pages, fully associative, 32 entries.
          Data TLB: 4KB pages, 4-way associative, 64 entries
          Data TLB: 4K pages, 4-way associative, 512 entries.
          Data TLB: 4KB or 4MB pages, fully associative, 32 entries.
          Data TLB: 4KB pages, 4-way associative, 64 entries
          64 byte prefetching.
          Data TLB: 4K pages, 4-way associative, 512 entries.
          Found unknown cache descriptors: dd
          Total processor threads: 4
          This system has 1 dual-core processor with hyper-threading (2 threads per core) running at an estimated 2.65GHz





          share|improve this answer

































            18


















            lscpu



            If you care only about the sizes, try lscpu from util-linux.



            Example



            $ lscpu
            Architecture: x86_64
            CPU op-mode(s): 32-bit, 64-bit
            Byte Order: Little Endian
            CPU(s): 4
            On-line CPU(s) list: 0-3
            Thread(s) per core: 2
            Core(s) per socket: 2
            Socket(s): 1
            NUMA node(s): 1
            Vendor ID: GenuineIntel
            CPU family: 6
            Model: 37
            Model name: Intel(R) Core(TM) i5 CPU M 560 @ 2.67GHz
            Stepping: 5
            CPU MHz: 1199.000
            BogoMIPS: 5319.88
            Virtualization: VT-x
            L1d cache: 32K
            L1i cache: 32K
            L2 cache: 256K
            L3 cache: 3072K
            NUMA node0 CPU(s): 0-3


            x86info



            There should be also package/command called x86info. Assuming you have i386/x86_64, x86info -c should provide more detailed information about caches.



            Example



            $ x86info -c
            x86info v1.30. Dave Jones 2001-2011
            Feedback to <davej@redhat.com>.

            Found 4 identical CPUs
            Extended Family: 0 Extended Model: 2 Family: 6 Model: 37 Stepping: 5
            Type: 0 (Original OEM)
            CPU Model (x86info's best guess): Core i7 (Nehalem) [Clarkdale/Arrandale]
            Processor name string (BIOS programmed): Intel(R) Core(TM) i5 CPU M 560 @ 2.67GHz

            Cache info
            L1 Instruction cache: 32KB, 4-way associative. 64 byte line size.
            L1 Data cache: 32KB, 8-way associative. 64 byte line size.
            L2 (MLC): 256KB, 8-way associative. 64 byte line size.
            TLB info
            Instruction TLB: 2MB or 4MB pages, fully associative, 7 entries
            Instruction TLB: 4K pages, 4-way associative, 64 entries.
            Data TLB: 4KB or 4MB pages, fully associative, 32 entries.
            Data TLB: 4KB pages, 4-way associative, 64 entries
            Data TLB: 4K pages, 4-way associative, 512 entries.
            Data TLB: 4KB or 4MB pages, fully associative, 32 entries.
            Data TLB: 4KB pages, 4-way associative, 64 entries
            64 byte prefetching.
            Data TLB: 4K pages, 4-way associative, 512 entries.
            Found unknown cache descriptors: dd
            Total processor threads: 4
            This system has 1 dual-core processor with hyper-threading (2 threads per core) running at an estimated 2.65GHz





            share|improve this answer































              18














              18










              18









              lscpu



              If you care only about the sizes, try lscpu from util-linux.



              Example



              $ lscpu
              Architecture: x86_64
              CPU op-mode(s): 32-bit, 64-bit
              Byte Order: Little Endian
              CPU(s): 4
              On-line CPU(s) list: 0-3
              Thread(s) per core: 2
              Core(s) per socket: 2
              Socket(s): 1
              NUMA node(s): 1
              Vendor ID: GenuineIntel
              CPU family: 6
              Model: 37
              Model name: Intel(R) Core(TM) i5 CPU M 560 @ 2.67GHz
              Stepping: 5
              CPU MHz: 1199.000
              BogoMIPS: 5319.88
              Virtualization: VT-x
              L1d cache: 32K
              L1i cache: 32K
              L2 cache: 256K
              L3 cache: 3072K
              NUMA node0 CPU(s): 0-3


              x86info



              There should be also package/command called x86info. Assuming you have i386/x86_64, x86info -c should provide more detailed information about caches.



              Example



              $ x86info -c
              x86info v1.30. Dave Jones 2001-2011
              Feedback to <davej@redhat.com>.

              Found 4 identical CPUs
              Extended Family: 0 Extended Model: 2 Family: 6 Model: 37 Stepping: 5
              Type: 0 (Original OEM)
              CPU Model (x86info's best guess): Core i7 (Nehalem) [Clarkdale/Arrandale]
              Processor name string (BIOS programmed): Intel(R) Core(TM) i5 CPU M 560 @ 2.67GHz

              Cache info
              L1 Instruction cache: 32KB, 4-way associative. 64 byte line size.
              L1 Data cache: 32KB, 8-way associative. 64 byte line size.
              L2 (MLC): 256KB, 8-way associative. 64 byte line size.
              TLB info
              Instruction TLB: 2MB or 4MB pages, fully associative, 7 entries
              Instruction TLB: 4K pages, 4-way associative, 64 entries.
              Data TLB: 4KB or 4MB pages, fully associative, 32 entries.
              Data TLB: 4KB pages, 4-way associative, 64 entries
              Data TLB: 4K pages, 4-way associative, 512 entries.
              Data TLB: 4KB or 4MB pages, fully associative, 32 entries.
              Data TLB: 4KB pages, 4-way associative, 64 entries
              64 byte prefetching.
              Data TLB: 4K pages, 4-way associative, 512 entries.
              Found unknown cache descriptors: dd
              Total processor threads: 4
              This system has 1 dual-core processor with hyper-threading (2 threads per core) running at an estimated 2.65GHz





              share|improve this answer
















              lscpu



              If you care only about the sizes, try lscpu from util-linux.



              Example



              $ lscpu
              Architecture: x86_64
              CPU op-mode(s): 32-bit, 64-bit
              Byte Order: Little Endian
              CPU(s): 4
              On-line CPU(s) list: 0-3
              Thread(s) per core: 2
              Core(s) per socket: 2
              Socket(s): 1
              NUMA node(s): 1
              Vendor ID: GenuineIntel
              CPU family: 6
              Model: 37
              Model name: Intel(R) Core(TM) i5 CPU M 560 @ 2.67GHz
              Stepping: 5
              CPU MHz: 1199.000
              BogoMIPS: 5319.88
              Virtualization: VT-x
              L1d cache: 32K
              L1i cache: 32K
              L2 cache: 256K
              L3 cache: 3072K
              NUMA node0 CPU(s): 0-3


              x86info



              There should be also package/command called x86info. Assuming you have i386/x86_64, x86info -c should provide more detailed information about caches.



              Example



              $ x86info -c
              x86info v1.30. Dave Jones 2001-2011
              Feedback to <davej@redhat.com>.

              Found 4 identical CPUs
              Extended Family: 0 Extended Model: 2 Family: 6 Model: 37 Stepping: 5
              Type: 0 (Original OEM)
              CPU Model (x86info's best guess): Core i7 (Nehalem) [Clarkdale/Arrandale]
              Processor name string (BIOS programmed): Intel(R) Core(TM) i5 CPU M 560 @ 2.67GHz

              Cache info
              L1 Instruction cache: 32KB, 4-way associative. 64 byte line size.
              L1 Data cache: 32KB, 8-way associative. 64 byte line size.
              L2 (MLC): 256KB, 8-way associative. 64 byte line size.
              TLB info
              Instruction TLB: 2MB or 4MB pages, fully associative, 7 entries
              Instruction TLB: 4K pages, 4-way associative, 64 entries.
              Data TLB: 4KB or 4MB pages, fully associative, 32 entries.
              Data TLB: 4KB pages, 4-way associative, 64 entries
              Data TLB: 4K pages, 4-way associative, 512 entries.
              Data TLB: 4KB or 4MB pages, fully associative, 32 entries.
              Data TLB: 4KB pages, 4-way associative, 64 entries
              64 byte prefetching.
              Data TLB: 4K pages, 4-way associative, 512 entries.
              Found unknown cache descriptors: dd
              Total processor threads: 4
              This system has 1 dual-core processor with hyper-threading (2 threads per core) running at an estimated 2.65GHz






              share|improve this answer















              share|improve this answer




              share|improve this answer



              share|improve this answer








              edited Nov 11 '14 at 3:01









              slm

              270k77 gold badges588 silver badges732 bronze badges




              270k77 gold badges588 silver badges732 bronze badges










              answered Nov 9 '14 at 23:54









              Miroslav FrancMiroslav Franc

              1,3911 gold badge9 silver badges14 bronze badges




              1,3911 gold badge9 silver badges14 bronze badges


























                  3


















                  You could try this command.



                  $sudo dmidecode -t cache


                  Example



                  $ sudo dmidecode -t cache | grep -iE "leve|installed"
                  Configuration: Enabled, Socketed, Level 1
                  Installed Size: 32 kB
                  Installed SRAM Type: Asynchronous
                  Configuration: Enabled, Socketed, Level 2
                  Installed Size: 256 kB
                  Installed SRAM Type: Burst
                  Configuration: Enabled, Socketed, Level 3
                  Installed Size: 3072 kB
                  Installed SRAM Type: Burst


                  To see RAM simply add the additional switch -t memory.



                  $ sudo dmidecode -t cache -t memory


                  References




                  • finding L2 cache size in Linux






                  share|improve this answer

































                    3


















                    You could try this command.



                    $sudo dmidecode -t cache


                    Example



                    $ sudo dmidecode -t cache | grep -iE "leve|installed"
                    Configuration: Enabled, Socketed, Level 1
                    Installed Size: 32 kB
                    Installed SRAM Type: Asynchronous
                    Configuration: Enabled, Socketed, Level 2
                    Installed Size: 256 kB
                    Installed SRAM Type: Burst
                    Configuration: Enabled, Socketed, Level 3
                    Installed Size: 3072 kB
                    Installed SRAM Type: Burst


                    To see RAM simply add the additional switch -t memory.



                    $ sudo dmidecode -t cache -t memory


                    References




                    • finding L2 cache size in Linux






                    share|improve this answer































                      3














                      3










                      3









                      You could try this command.



                      $sudo dmidecode -t cache


                      Example



                      $ sudo dmidecode -t cache | grep -iE "leve|installed"
                      Configuration: Enabled, Socketed, Level 1
                      Installed Size: 32 kB
                      Installed SRAM Type: Asynchronous
                      Configuration: Enabled, Socketed, Level 2
                      Installed Size: 256 kB
                      Installed SRAM Type: Burst
                      Configuration: Enabled, Socketed, Level 3
                      Installed Size: 3072 kB
                      Installed SRAM Type: Burst


                      To see RAM simply add the additional switch -t memory.



                      $ sudo dmidecode -t cache -t memory


                      References




                      • finding L2 cache size in Linux






                      share|improve this answer
















                      You could try this command.



                      $sudo dmidecode -t cache


                      Example



                      $ sudo dmidecode -t cache | grep -iE "leve|installed"
                      Configuration: Enabled, Socketed, Level 1
                      Installed Size: 32 kB
                      Installed SRAM Type: Asynchronous
                      Configuration: Enabled, Socketed, Level 2
                      Installed Size: 256 kB
                      Installed SRAM Type: Burst
                      Configuration: Enabled, Socketed, Level 3
                      Installed Size: 3072 kB
                      Installed SRAM Type: Burst


                      To see RAM simply add the additional switch -t memory.



                      $ sudo dmidecode -t cache -t memory


                      References




                      • finding L2 cache size in Linux







                      share|improve this answer















                      share|improve this answer




                      share|improve this answer



                      share|improve this answer








                      edited Mar 20 '17 at 10:18









                      Community

                      1




                      1










                      answered Nov 10 '14 at 1:44









                      RameshRamesh

                      25.6k37 gold badges108 silver badges191 bronze badges




                      25.6k37 gold badges108 silver badges191 bronze badges


























                          3


















                          getconf



                          getconf -a | grep CACHE


                          gives:



                          LEVEL1_ICACHE_SIZE                 32768
                          LEVEL1_ICACHE_ASSOC 8
                          LEVEL1_ICACHE_LINESIZE 64
                          LEVEL1_DCACHE_SIZE 32768
                          LEVEL1_DCACHE_ASSOC 8
                          LEVEL1_DCACHE_LINESIZE 64
                          LEVEL2_CACHE_SIZE 262144
                          LEVEL2_CACHE_ASSOC 8
                          LEVEL2_CACHE_LINESIZE 64
                          LEVEL3_CACHE_SIZE 20971520
                          LEVEL3_CACHE_ASSOC 20
                          LEVEL3_CACHE_LINESIZE 64
                          LEVEL4_CACHE_SIZE 0
                          LEVEL4_CACHE_ASSOC 0
                          LEVEL4_CACHE_LINESIZE 0


                          Or for a single level:



                          getconf LEVEL2_CACHE_SIZE


                          The cool thing about this interface is that it is just a wrapper around the POSIX sysconf C function (cache arguments are non-POSIX extensions), and so it can be used from C code as well.



                          Tested in Ubuntu 16.04.



                          x86 CPUID instruction



                          The CPUID x86 instruction also offers cache information, and can be directly accessed by userland: https://en.wikipedia.org/wiki/CPUID



                          glibc seems to use that method for x86. I haven't confirmed by step debugging / instruction tracing, but the source for 2.28 sysdeps/x86/cacheinfo.c does that:



                          __cpuid (2, eax, ebx, ecx, edx);


                          TODO create a minimal C example, lazy now, asked at: https://stackoverflow.com/questions/14283171/how-to-receive-l1-l2-l3-cache-size-using-cpuid-instruction-in-x86



                          ARM also has an architecture-defined mechanism to find cache sizes through registers such as the Cache Size ID Register (CCSIDR), see the ARMv8 Programmers' Manual 11.6 "Cache discovery" for an overview.






                          share|improve this answer

































                            3


















                            getconf



                            getconf -a | grep CACHE


                            gives:



                            LEVEL1_ICACHE_SIZE                 32768
                            LEVEL1_ICACHE_ASSOC 8
                            LEVEL1_ICACHE_LINESIZE 64
                            LEVEL1_DCACHE_SIZE 32768
                            LEVEL1_DCACHE_ASSOC 8
                            LEVEL1_DCACHE_LINESIZE 64
                            LEVEL2_CACHE_SIZE 262144
                            LEVEL2_CACHE_ASSOC 8
                            LEVEL2_CACHE_LINESIZE 64
                            LEVEL3_CACHE_SIZE 20971520
                            LEVEL3_CACHE_ASSOC 20
                            LEVEL3_CACHE_LINESIZE 64
                            LEVEL4_CACHE_SIZE 0
                            LEVEL4_CACHE_ASSOC 0
                            LEVEL4_CACHE_LINESIZE 0


                            Or for a single level:



                            getconf LEVEL2_CACHE_SIZE


                            The cool thing about this interface is that it is just a wrapper around the POSIX sysconf C function (cache arguments are non-POSIX extensions), and so it can be used from C code as well.



                            Tested in Ubuntu 16.04.



                            x86 CPUID instruction



                            The CPUID x86 instruction also offers cache information, and can be directly accessed by userland: https://en.wikipedia.org/wiki/CPUID



                            glibc seems to use that method for x86. I haven't confirmed by step debugging / instruction tracing, but the source for 2.28 sysdeps/x86/cacheinfo.c does that:



                            __cpuid (2, eax, ebx, ecx, edx);


                            TODO create a minimal C example, lazy now, asked at: https://stackoverflow.com/questions/14283171/how-to-receive-l1-l2-l3-cache-size-using-cpuid-instruction-in-x86



                            ARM also has an architecture-defined mechanism to find cache sizes through registers such as the Cache Size ID Register (CCSIDR), see the ARMv8 Programmers' Manual 11.6 "Cache discovery" for an overview.






                            share|improve this answer































                              3














                              3










                              3









                              getconf



                              getconf -a | grep CACHE


                              gives:



                              LEVEL1_ICACHE_SIZE                 32768
                              LEVEL1_ICACHE_ASSOC 8
                              LEVEL1_ICACHE_LINESIZE 64
                              LEVEL1_DCACHE_SIZE 32768
                              LEVEL1_DCACHE_ASSOC 8
                              LEVEL1_DCACHE_LINESIZE 64
                              LEVEL2_CACHE_SIZE 262144
                              LEVEL2_CACHE_ASSOC 8
                              LEVEL2_CACHE_LINESIZE 64
                              LEVEL3_CACHE_SIZE 20971520
                              LEVEL3_CACHE_ASSOC 20
                              LEVEL3_CACHE_LINESIZE 64
                              LEVEL4_CACHE_SIZE 0
                              LEVEL4_CACHE_ASSOC 0
                              LEVEL4_CACHE_LINESIZE 0


                              Or for a single level:



                              getconf LEVEL2_CACHE_SIZE


                              The cool thing about this interface is that it is just a wrapper around the POSIX sysconf C function (cache arguments are non-POSIX extensions), and so it can be used from C code as well.



                              Tested in Ubuntu 16.04.



                              x86 CPUID instruction



                              The CPUID x86 instruction also offers cache information, and can be directly accessed by userland: https://en.wikipedia.org/wiki/CPUID



                              glibc seems to use that method for x86. I haven't confirmed by step debugging / instruction tracing, but the source for 2.28 sysdeps/x86/cacheinfo.c does that:



                              __cpuid (2, eax, ebx, ecx, edx);


                              TODO create a minimal C example, lazy now, asked at: https://stackoverflow.com/questions/14283171/how-to-receive-l1-l2-l3-cache-size-using-cpuid-instruction-in-x86



                              ARM also has an architecture-defined mechanism to find cache sizes through registers such as the Cache Size ID Register (CCSIDR), see the ARMv8 Programmers' Manual 11.6 "Cache discovery" for an overview.






                              share|improve this answer
















                              getconf



                              getconf -a | grep CACHE


                              gives:



                              LEVEL1_ICACHE_SIZE                 32768
                              LEVEL1_ICACHE_ASSOC 8
                              LEVEL1_ICACHE_LINESIZE 64
                              LEVEL1_DCACHE_SIZE 32768
                              LEVEL1_DCACHE_ASSOC 8
                              LEVEL1_DCACHE_LINESIZE 64
                              LEVEL2_CACHE_SIZE 262144
                              LEVEL2_CACHE_ASSOC 8
                              LEVEL2_CACHE_LINESIZE 64
                              LEVEL3_CACHE_SIZE 20971520
                              LEVEL3_CACHE_ASSOC 20
                              LEVEL3_CACHE_LINESIZE 64
                              LEVEL4_CACHE_SIZE 0
                              LEVEL4_CACHE_ASSOC 0
                              LEVEL4_CACHE_LINESIZE 0


                              Or for a single level:



                              getconf LEVEL2_CACHE_SIZE


                              The cool thing about this interface is that it is just a wrapper around the POSIX sysconf C function (cache arguments are non-POSIX extensions), and so it can be used from C code as well.



                              Tested in Ubuntu 16.04.



                              x86 CPUID instruction



                              The CPUID x86 instruction also offers cache information, and can be directly accessed by userland: https://en.wikipedia.org/wiki/CPUID



                              glibc seems to use that method for x86. I haven't confirmed by step debugging / instruction tracing, but the source for 2.28 sysdeps/x86/cacheinfo.c does that:



                              __cpuid (2, eax, ebx, ecx, edx);


                              TODO create a minimal C example, lazy now, asked at: https://stackoverflow.com/questions/14283171/how-to-receive-l1-l2-l3-cache-size-using-cpuid-instruction-in-x86



                              ARM also has an architecture-defined mechanism to find cache sizes through registers such as the Cache Size ID Register (CCSIDR), see the ARMv8 Programmers' Manual 11.6 "Cache discovery" for an overview.







                              share|improve this answer















                              share|improve this answer




                              share|improve this answer



                              share|improve this answer








                              edited Jan 10 at 19:08

























                              answered Feb 27 '18 at 12:02









                              Ciro Santilli 新疆改造中心法轮功六四事件Ciro Santilli 新疆改造中心法轮功六四事件

                              6,8152 gold badges55 silver badges56 bronze badges




                              6,8152 gold badges55 silver badges56 bronze badges


























                                  2


















                                  There are special files exported to /sys sysfs Linux filesystem since 2008:



                                  https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-devices-system-cpu



                                  What:       /sys/devices/system/cpu/cpu*/cache/index*/<set_of_attributes_mentioned_below>
                                  Date: July 2014(documented, existed before August 2008)
                                  Description: Parameters for the CPU cache attributes

                                  allocation_policy:
                                  - WriteAllocate: allocate a memory location to a cache line
                                  on a cache miss because of a write
                                  - ReadAllocate: allocate a memory location to a cache line
                                  on a cache miss because of a read
                                  - ReadWriteAllocate: both writeallocate and readallocate

                                  coherency_line_size: the minimum amount of data in bytes that gets
                                  transferred from memory to cache

                                  level: the cache hierarchy in the multi-level cache configuration

                                  number_of_sets: total number of sets in the cache, a set is a
                                  collection of cache lines with the same cache index

                                  physical_line_partition: number of physical cache line per cache tag

                                  shared_cpu_list: the list of logical cpus sharing the cache

                                  shared_cpu_map: logical cpu mask containing the list of cpus sharing
                                  the cache

                                  size: the total cache size in kB

                                  type:
                                  - Instruction: cache that only holds instructions
                                  - Data: cache that only caches data
                                  - Unified: cache that holds both data and instructions

                                  ways_of_associativity: degree of freedom in placing a particular block
                                  of memory in the cache

                                  write_policy:
                                  - WriteThrough: data is written to both the cache line
                                  and to the block in the lower-level memory
                                  - WriteBack: data is written only to the cache line and
                                  the modified cache line is written to main
                                  memory only when it is replaced


                                  ID files:



                                  What:       /sys/devices/system/cpu/cpu*/cache/index*/id
                                  Date: September 2016
                                  Contact: Linux kernel mailing list <linux-kernel@vger.kernel.org>
                                  Description: Cache id

                                  The id provides a unique number for a specific instance of
                                  a cache of a particular type. E.g. there may be a level
                                  3 unified cache on each socket in a server and we may
                                  assign them ids 0, 1, 2, ...

                                  Note that id value can be non-contiguous. E.g. level 1
                                  caches typically exist per core, but there may not be a
                                  power of two cores on a socket, so these caches may be
                                  numbered 0, 1, 2, 3, 4, 5, 8, 9, 10, ...





                                  share|improve this answer



























                                  • I wonder why on my machine index0 and index1 both do level 1 on kernel v4.15, it is confusing. 0-index preventive coding? :-)

                                    – Ciro Santilli 新疆改造中心法轮功六四事件
                                    Feb 27 '18 at 11:58








                                  • 1





                                    @CiroSantilli华涌低端人口六四事件法轮功, (with the name to not pronounce), probably index0 is about L1 with type Data (L1 data cache) and index1 is about L1 with type Instruction (L1 instruction cache). Then index2 is of type Unified and level of 2 (L2 cache, can store both data and instruction)

                                    – osgx
                                    Feb 27 '18 at 14:33











                                  • ah, yes! I should be more patient to read docs :-)

                                    – Ciro Santilli 新疆改造中心法轮功六四事件
                                    Feb 27 '18 at 14:36
















                                  2


















                                  There are special files exported to /sys sysfs Linux filesystem since 2008:



                                  https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-devices-system-cpu



                                  What:       /sys/devices/system/cpu/cpu*/cache/index*/<set_of_attributes_mentioned_below>
                                  Date: July 2014(documented, existed before August 2008)
                                  Description: Parameters for the CPU cache attributes

                                  allocation_policy:
                                  - WriteAllocate: allocate a memory location to a cache line
                                  on a cache miss because of a write
                                  - ReadAllocate: allocate a memory location to a cache line
                                  on a cache miss because of a read
                                  - ReadWriteAllocate: both writeallocate and readallocate

                                  coherency_line_size: the minimum amount of data in bytes that gets
                                  transferred from memory to cache

                                  level: the cache hierarchy in the multi-level cache configuration

                                  number_of_sets: total number of sets in the cache, a set is a
                                  collection of cache lines with the same cache index

                                  physical_line_partition: number of physical cache line per cache tag

                                  shared_cpu_list: the list of logical cpus sharing the cache

                                  shared_cpu_map: logical cpu mask containing the list of cpus sharing
                                  the cache

                                  size: the total cache size in kB

                                  type:
                                  - Instruction: cache that only holds instructions
                                  - Data: cache that only caches data
                                  - Unified: cache that holds both data and instructions

                                  ways_of_associativity: degree of freedom in placing a particular block
                                  of memory in the cache

                                  write_policy:
                                  - WriteThrough: data is written to both the cache line
                                  and to the block in the lower-level memory
                                  - WriteBack: data is written only to the cache line and
                                  the modified cache line is written to main
                                  memory only when it is replaced


                                  ID files:



                                  What:       /sys/devices/system/cpu/cpu*/cache/index*/id
                                  Date: September 2016
                                  Contact: Linux kernel mailing list <linux-kernel@vger.kernel.org>
                                  Description: Cache id

                                  The id provides a unique number for a specific instance of
                                  a cache of a particular type. E.g. there may be a level
                                  3 unified cache on each socket in a server and we may
                                  assign them ids 0, 1, 2, ...

                                  Note that id value can be non-contiguous. E.g. level 1
                                  caches typically exist per core, but there may not be a
                                  power of two cores on a socket, so these caches may be
                                  numbered 0, 1, 2, 3, 4, 5, 8, 9, 10, ...





                                  share|improve this answer



























                                  • I wonder why on my machine index0 and index1 both do level 1 on kernel v4.15, it is confusing. 0-index preventive coding? :-)

                                    – Ciro Santilli 新疆改造中心法轮功六四事件
                                    Feb 27 '18 at 11:58








                                  • 1





                                    @CiroSantilli华涌低端人口六四事件法轮功, (with the name to not pronounce), probably index0 is about L1 with type Data (L1 data cache) and index1 is about L1 with type Instruction (L1 instruction cache). Then index2 is of type Unified and level of 2 (L2 cache, can store both data and instruction)

                                    – osgx
                                    Feb 27 '18 at 14:33











                                  • ah, yes! I should be more patient to read docs :-)

                                    – Ciro Santilli 新疆改造中心法轮功六四事件
                                    Feb 27 '18 at 14:36














                                  2














                                  2










                                  2









                                  There are special files exported to /sys sysfs Linux filesystem since 2008:



                                  https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-devices-system-cpu



                                  What:       /sys/devices/system/cpu/cpu*/cache/index*/<set_of_attributes_mentioned_below>
                                  Date: July 2014(documented, existed before August 2008)
                                  Description: Parameters for the CPU cache attributes

                                  allocation_policy:
                                  - WriteAllocate: allocate a memory location to a cache line
                                  on a cache miss because of a write
                                  - ReadAllocate: allocate a memory location to a cache line
                                  on a cache miss because of a read
                                  - ReadWriteAllocate: both writeallocate and readallocate

                                  coherency_line_size: the minimum amount of data in bytes that gets
                                  transferred from memory to cache

                                  level: the cache hierarchy in the multi-level cache configuration

                                  number_of_sets: total number of sets in the cache, a set is a
                                  collection of cache lines with the same cache index

                                  physical_line_partition: number of physical cache line per cache tag

                                  shared_cpu_list: the list of logical cpus sharing the cache

                                  shared_cpu_map: logical cpu mask containing the list of cpus sharing
                                  the cache

                                  size: the total cache size in kB

                                  type:
                                  - Instruction: cache that only holds instructions
                                  - Data: cache that only caches data
                                  - Unified: cache that holds both data and instructions

                                  ways_of_associativity: degree of freedom in placing a particular block
                                  of memory in the cache

                                  write_policy:
                                  - WriteThrough: data is written to both the cache line
                                  and to the block in the lower-level memory
                                  - WriteBack: data is written only to the cache line and
                                  the modified cache line is written to main
                                  memory only when it is replaced


                                  ID files:



                                  What:       /sys/devices/system/cpu/cpu*/cache/index*/id
                                  Date: September 2016
                                  Contact: Linux kernel mailing list <linux-kernel@vger.kernel.org>
                                  Description: Cache id

                                  The id provides a unique number for a specific instance of
                                  a cache of a particular type. E.g. there may be a level
                                  3 unified cache on each socket in a server and we may
                                  assign them ids 0, 1, 2, ...

                                  Note that id value can be non-contiguous. E.g. level 1
                                  caches typically exist per core, but there may not be a
                                  power of two cores on a socket, so these caches may be
                                  numbered 0, 1, 2, 3, 4, 5, 8, 9, 10, ...





                                  share|improve this answer














                                  There are special files exported to /sys sysfs Linux filesystem since 2008:



                                  https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-devices-system-cpu



                                  What:       /sys/devices/system/cpu/cpu*/cache/index*/<set_of_attributes_mentioned_below>
                                  Date: July 2014(documented, existed before August 2008)
                                  Description: Parameters for the CPU cache attributes

                                  allocation_policy:
                                  - WriteAllocate: allocate a memory location to a cache line
                                  on a cache miss because of a write
                                  - ReadAllocate: allocate a memory location to a cache line
                                  on a cache miss because of a read
                                  - ReadWriteAllocate: both writeallocate and readallocate

                                  coherency_line_size: the minimum amount of data in bytes that gets
                                  transferred from memory to cache

                                  level: the cache hierarchy in the multi-level cache configuration

                                  number_of_sets: total number of sets in the cache, a set is a
                                  collection of cache lines with the same cache index

                                  physical_line_partition: number of physical cache line per cache tag

                                  shared_cpu_list: the list of logical cpus sharing the cache

                                  shared_cpu_map: logical cpu mask containing the list of cpus sharing
                                  the cache

                                  size: the total cache size in kB

                                  type:
                                  - Instruction: cache that only holds instructions
                                  - Data: cache that only caches data
                                  - Unified: cache that holds both data and instructions

                                  ways_of_associativity: degree of freedom in placing a particular block
                                  of memory in the cache

                                  write_policy:
                                  - WriteThrough: data is written to both the cache line
                                  and to the block in the lower-level memory
                                  - WriteBack: data is written only to the cache line and
                                  the modified cache line is written to main
                                  memory only when it is replaced


                                  ID files:



                                  What:       /sys/devices/system/cpu/cpu*/cache/index*/id
                                  Date: September 2016
                                  Contact: Linux kernel mailing list <linux-kernel@vger.kernel.org>
                                  Description: Cache id

                                  The id provides a unique number for a specific instance of
                                  a cache of a particular type. E.g. there may be a level
                                  3 unified cache on each socket in a server and we may
                                  assign them ids 0, 1, 2, ...

                                  Note that id value can be non-contiguous. E.g. level 1
                                  caches typically exist per core, but there may not be a
                                  power of two cores on a socket, so these caches may be
                                  numbered 0, 1, 2, 3, 4, 5, 8, 9, 10, ...






                                  share|improve this answer













                                  share|improve this answer




                                  share|improve this answer



                                  share|improve this answer










                                  answered Jan 25 '18 at 18:26









                                  osgxosgx

                                  8107 silver badges10 bronze badges




                                  8107 silver badges10 bronze badges
















                                  • I wonder why on my machine index0 and index1 both do level 1 on kernel v4.15, it is confusing. 0-index preventive coding? :-)

                                    – Ciro Santilli 新疆改造中心法轮功六四事件
                                    Feb 27 '18 at 11:58








                                  • 1





                                    @CiroSantilli华涌低端人口六四事件法轮功, (with the name to not pronounce), probably index0 is about L1 with type Data (L1 data cache) and index1 is about L1 with type Instruction (L1 instruction cache). Then index2 is of type Unified and level of 2 (L2 cache, can store both data and instruction)

                                    – osgx
                                    Feb 27 '18 at 14:33











                                  • ah, yes! I should be more patient to read docs :-)

                                    – Ciro Santilli 新疆改造中心法轮功六四事件
                                    Feb 27 '18 at 14:36



















                                  • I wonder why on my machine index0 and index1 both do level 1 on kernel v4.15, it is confusing. 0-index preventive coding? :-)

                                    – Ciro Santilli 新疆改造中心法轮功六四事件
                                    Feb 27 '18 at 11:58








                                  • 1





                                    @CiroSantilli华涌低端人口六四事件法轮功, (with the name to not pronounce), probably index0 is about L1 with type Data (L1 data cache) and index1 is about L1 with type Instruction (L1 instruction cache). Then index2 is of type Unified and level of 2 (L2 cache, can store both data and instruction)

                                    – osgx
                                    Feb 27 '18 at 14:33











                                  • ah, yes! I should be more patient to read docs :-)

                                    – Ciro Santilli 新疆改造中心法轮功六四事件
                                    Feb 27 '18 at 14:36

















                                  I wonder why on my machine index0 and index1 both do level 1 on kernel v4.15, it is confusing. 0-index preventive coding? :-)

                                  – Ciro Santilli 新疆改造中心法轮功六四事件
                                  Feb 27 '18 at 11:58







                                  I wonder why on my machine index0 and index1 both do level 1 on kernel v4.15, it is confusing. 0-index preventive coding? :-)

                                  – Ciro Santilli 新疆改造中心法轮功六四事件
                                  Feb 27 '18 at 11:58






                                  1




                                  1





                                  @CiroSantilli华涌低端人口六四事件法轮功, (with the name to not pronounce), probably index0 is about L1 with type Data (L1 data cache) and index1 is about L1 with type Instruction (L1 instruction cache). Then index2 is of type Unified and level of 2 (L2 cache, can store both data and instruction)

                                  – osgx
                                  Feb 27 '18 at 14:33





                                  @CiroSantilli华涌低端人口六四事件法轮功, (with the name to not pronounce), probably index0 is about L1 with type Data (L1 data cache) and index1 is about L1 with type Instruction (L1 instruction cache). Then index2 is of type Unified and level of 2 (L2 cache, can store both data and instruction)

                                  – osgx
                                  Feb 27 '18 at 14:33













                                  ah, yes! I should be more patient to read docs :-)

                                  – Ciro Santilli 新疆改造中心法轮功六四事件
                                  Feb 27 '18 at 14:36





                                  ah, yes! I should be more patient to read docs :-)

                                  – Ciro Santilli 新疆改造中心法轮功六四事件
                                  Feb 27 '18 at 14:36











                                  1


















                                  cpuid



                                  Another option is cpuid program. It uses CPUID instructions and does not require root. It also can work throught cpuid Linux kernel module.



                                  cache and TLB information (2):
                                  0x59: data TLB: 4K pages, 16 entries
                                  0xba: data TLB: 4K pages, 4-way, 64 entries
                                  0x4f: instruction TLB: 4K pages, 32 entries
                                  0xc0: data TLB: 4K & 4M pages, 4-way, 8 entries
                                  0x80: L2 cache: 512K, 8-way, 64 byte lines
                                  0x30: L1 cache: 32K, 8-way, 64 byte lines
                                  0x0e: L1 data cache: 24K, 6-way, 64 byte lines


                                  Note that on common consumer CPUs L1 and L2 caches are per core, while L3 cache is shared by all cores.






                                  share|improve this answer

































                                    1


















                                    cpuid



                                    Another option is cpuid program. It uses CPUID instructions and does not require root. It also can work throught cpuid Linux kernel module.



                                    cache and TLB information (2):
                                    0x59: data TLB: 4K pages, 16 entries
                                    0xba: data TLB: 4K pages, 4-way, 64 entries
                                    0x4f: instruction TLB: 4K pages, 32 entries
                                    0xc0: data TLB: 4K & 4M pages, 4-way, 8 entries
                                    0x80: L2 cache: 512K, 8-way, 64 byte lines
                                    0x30: L1 cache: 32K, 8-way, 64 byte lines
                                    0x0e: L1 data cache: 24K, 6-way, 64 byte lines


                                    Note that on common consumer CPUs L1 and L2 caches are per core, while L3 cache is shared by all cores.






                                    share|improve this answer































                                      1














                                      1










                                      1









                                      cpuid



                                      Another option is cpuid program. It uses CPUID instructions and does not require root. It also can work throught cpuid Linux kernel module.



                                      cache and TLB information (2):
                                      0x59: data TLB: 4K pages, 16 entries
                                      0xba: data TLB: 4K pages, 4-way, 64 entries
                                      0x4f: instruction TLB: 4K pages, 32 entries
                                      0xc0: data TLB: 4K & 4M pages, 4-way, 8 entries
                                      0x80: L2 cache: 512K, 8-way, 64 byte lines
                                      0x30: L1 cache: 32K, 8-way, 64 byte lines
                                      0x0e: L1 data cache: 24K, 6-way, 64 byte lines


                                      Note that on common consumer CPUs L1 and L2 caches are per core, while L3 cache is shared by all cores.






                                      share|improve this answer
















                                      cpuid



                                      Another option is cpuid program. It uses CPUID instructions and does not require root. It also can work throught cpuid Linux kernel module.



                                      cache and TLB information (2):
                                      0x59: data TLB: 4K pages, 16 entries
                                      0xba: data TLB: 4K pages, 4-way, 64 entries
                                      0x4f: instruction TLB: 4K pages, 32 entries
                                      0xc0: data TLB: 4K & 4M pages, 4-way, 8 entries
                                      0x80: L2 cache: 512K, 8-way, 64 byte lines
                                      0x30: L1 cache: 32K, 8-way, 64 byte lines
                                      0x0e: L1 data cache: 24K, 6-way, 64 byte lines


                                      Note that on common consumer CPUs L1 and L2 caches are per core, while L3 cache is shared by all cores.







                                      share|improve this answer















                                      share|improve this answer




                                      share|improve this answer



                                      share|improve this answer








                                      answered Oct 1 '16 at 11:11


























                                      community wiki





                                      Anton Leontiev



























                                          0


















                                          if you only want the L3 then grep "cache size" < /proc/cpuinfo should be enough.



                                          However since the way L3 cache is shared among cpu archs differs, its value might need normalization






                                          share|improve this answer





























                                          • Perhaps you want to remove a useless use of cat.

                                            – maxschlepzig
                                            yesterday
















                                          0


















                                          if you only want the L3 then grep "cache size" < /proc/cpuinfo should be enough.



                                          However since the way L3 cache is shared among cpu archs differs, its value might need normalization






                                          share|improve this answer





























                                          • Perhaps you want to remove a useless use of cat.

                                            – maxschlepzig
                                            yesterday














                                          0














                                          0










                                          0









                                          if you only want the L3 then grep "cache size" < /proc/cpuinfo should be enough.



                                          However since the way L3 cache is shared among cpu archs differs, its value might need normalization






                                          share|improve this answer
















                                          if you only want the L3 then grep "cache size" < /proc/cpuinfo should be enough.



                                          However since the way L3 cache is shared among cpu archs differs, its value might need normalization







                                          share|improve this answer















                                          share|improve this answer




                                          share|improve this answer



                                          share|improve this answer








                                          edited 30 mins ago

























                                          answered Jan 28 '18 at 18:05









                                          untoreuntore

                                          1515 bronze badges




                                          1515 bronze badges
















                                          • Perhaps you want to remove a useless use of cat.

                                            – maxschlepzig
                                            yesterday



















                                          • Perhaps you want to remove a useless use of cat.

                                            – maxschlepzig
                                            yesterday

















                                          Perhaps you want to remove a useless use of cat.

                                          – maxschlepzig
                                          yesterday





                                          Perhaps you want to remove a useless use of cat.

                                          – maxschlepzig
                                          yesterday



















                                          draft saved

                                          draft discarded



















































                                          Thanks for contributing an answer to Unix & Linux Stack Exchange!


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f167038%2fis-there-any-way-to-know-the-size-of-l1-l2-l3-cache-and-ram-in-linux%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown









                                          Popular posts from this blog

                                          Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                                          Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

                                          Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...