public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: /proc/cpuinfo: Always print topology info Date: Mon, 16 Jan 2023 13:30:26 +0000 (GMT) [thread overview] Message-ID: <20230116133026.DF87D3858C27@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=75c375e86df31fefc85a54a060283fe7389c8c6b commit 75c375e86df31fefc85a54a060283fe7389c8c6b Author: Corinna Vinschen <corinna@vinschen.de> AuthorDate: Mon Jan 16 14:23:38 2023 +0100 Commit: Corinna Vinschen <corinna@vinschen.de> CommitDate: Mon Jan 16 14:23:38 2023 +0100 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> Diff: --- winsup/cygwin/fhandler/proc.cc | 18 +++++++++++++++--- winsup/cygwin/release/3.4.4 | 3 +++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/fhandler/proc.cc b/winsup/cygwin/fhandler/proc.cc index 181652a0867a..b7f29b23d5ee 100644 --- a/winsup/cygwin/fhandler/proc.cc +++ b/winsup/cygwin/fhandler/proc.cc @@ -671,7 +671,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 @@ -950,8 +951,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); @@ -961,6 +961,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; diff --git a/winsup/cygwin/release/3.4.4 b/winsup/cygwin/release/3.4.4 index 35d746ba08fd..2c93cd0663c2 100644 --- a/winsup/cygwin/release/3.4.4 +++ b/winsup/cygwin/release/3.4.4 @@ -13,3 +13,6 @@ Bug Fixes - Avoid hangs when reading /proc/<PID>/status. Addresses: https://cygwin.com/pipermail/cygwin/2022-December/252756.html + +- Fix vmstat(1) printing an error message on single core CPUs. + Addresses: https://cygwin.com/pipermail/cygwin/2023-January/252857.html
reply other threads:[~2023-01-16 13:30 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230116133026.DF87D3858C27@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).