diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2023-01-16 16:23:38 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2023-01-16 16:23:50 +0300 |
commit | 7c870ee90f7c0f8264b58cf43616fa754993b9d1 (patch) | |
tree | b5e438524ecc6fcf3dc9d2624b07bd138d9e9de7 /winsup/cygwin/fhandler/proc.cc | |
parent | 1069eab80aa6e9f195e8bf1f04e49f9d23d41bc5 (diff) |
Cygwin: /proc/cpuinfo: Always print topology info
vmstat from proc-ps-4.0.x prints "Unable to create system stat structure"
if the /proc/cpuinfo output fails to contain topology info. While
Linux always prints topology info if the kernel has been built with
CONFIG_SMP, Cygwin only prints topology info if the CPU is known to
be multi-core (i. e., the HT feature flag is set).
Fix that by printing topology info all the time, even for single-core
CPUs.
Fixes: e0d48debedfa ("Fix /proc/cpuinfo topology and cache size info")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin/fhandler/proc.cc')
-rw-r--r-- | winsup/cygwin/fhandler/proc.cc | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/winsup/cygwin/fhandler/proc.cc b/winsup/cygwin/fhandler/proc.cc index 24067f687..66272125c 100644 --- a/winsup/cygwin/fhandler/proc.cc +++ b/winsup/cygwin/fhandler/proc.cc @@ -672,7 +672,8 @@ format_proc_cpuinfo (void *, char *&destbuf) if (!SetThreadGroupAffinity (GetCurrentThread (), &affinity, &orig_group_affinity)) - system_printf ("SetThreadGroupAffinity(%x,%d (%x/%d)) failed %E", cpu_mask, cpu_group, cpu_number, cpu_number); + system_printf ("SetThreadGroupAffinity(%x,%d (%x/%d)) failed %E", + cpu_mask, cpu_group, cpu_number, cpu_number); orig_affinity_mask = 1; /* Just mark success. */ /* I'm not sure whether the thread changes processor immediately and I'm not sure whether this function will cause the thread @@ -951,8 +952,7 @@ format_proc_cpuinfo (void *, char *&destbuf) core_id = (initial_apic_id & ((1 << logical_bits) - 1)) >> ht_bits; bufptr += __small_sprintf (bufptr, "physical id\t: %d\n", phys_id); - if (siblings > 0) - bufptr += __small_sprintf (bufptr, "siblings\t: %u\n", siblings); + bufptr += __small_sprintf (bufptr, "siblings\t: %u\n", siblings); bufptr += __small_sprintf (bufptr, "core id\t\t: %d\n" "cpu cores\t: %d\n", core_id, cpu_cores); @@ -962,6 +962,18 @@ format_proc_cpuinfo (void *, char *&destbuf) apic_id, initial_apic_id); } + else + { + /* Linux prints all this info depending on CONFIG_SMP. There's no + check if the CPU is actually a multicore CPU. */ + bufptr += __small_sprintf (bufptr, "physical id\t: %d\n", cpu_number); + bufptr += __small_sprintf (bufptr, "siblings\t: 1\n"); + bufptr += __small_sprintf (bufptr, "core id\t\t: 0\n" + "cpu cores\t: 1\n"); + bufptr += __small_sprintf (bufptr, "apicid\t\t: %d\n" + "initial apicid\t: %d\n", + apic_id, apic_id); + } /* level is number of non-zero leafs exc. sub-leafs */ int level = maxf + 1 + (maxe & 0x7fffffff) + 1; |