This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cpuinfo cache size

On Jun 23 15:39, Marco Atzeri wrote:
> Hi Corinna,
> for a porting of a math lib to cygwin we are trying to obtain
> the same information of
> sysconf(_SC_LEVEL2_CACHE_SIZE)
> sysconf(_SC_LEVEL3_CACHE_SIZE)
> sysconf(_SC_LEVEL4_CACHE_SIZE)
> but of course none of them is implemented in cygwin.
> The /proc/cpuinfo contains :
> ------------------------------------------------------------------
> [...]
> cache size      : 256 KB
> [...]
> ------------------------------------------------------------------
> Looking on the code it seems that for
>   maxe >= 0x80000006
> cache_size reported on cpuinfo is calculated using L1
> and immediately after overwritten with L2 value.

This seems to be right, at least partially.  Linux /proc/cpuinfo
appears to report only the size of the outmost available cache.
So if you have L1 and L2 caches, Linux reports the L2 cache size.

The problem is that the L2 cache isn't the outmost available
cache anymore these days.  On my CPU Cygwin reports 256K, which
is the size of the per-core L2 caches.  However, the shared L3 cache
has a size of 15Megs, and that's what Linux reports:

  $ grep 'cache size' /proc/cpuinfo | head -1
  cache size	: 15360 KB

Cygwin is lacking the code to fetch L3 caches and afaics, it's not
overly simple.  At least calling cpuid as for L1 and L2 caches is not
sufficient, apparently.

> Should be possible to have both info available ?
> Any idea how to obtain the other cache infos ?

Not completely.  You have to use different cpuid codes for AMD and Intel
CPUs, and you have to call cpuid multiple times to get the full info
for all L3 caches of the system's CPUs, but I'm fuzzy on the details.

Patches are certainly welcome.


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: pgpG45Ok3zT5O.pgp
Description: PGP signature

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]