From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 6D2EC3858C2F; Mon, 16 Jan 2023 13:30:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D2EC3858C2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673875805; bh=fOy3msXe3P2qrufo7F2l+7SOl0cuRaQUw9B1s3lWmnc=; h=From:To:Subject:Date:From; b=UYgZZSARVjMAcHePRXJcx3+mfd8LMIFlo94I+vAOOrr/5o0/BO1B32XsrIybe4Lwn 2/6ElmtwV34+xoGu7oZUZOA1nmqxK3dq0/dV5Jo6IV8v3zkS9hx9EsB5H3DNWp8iAw dVHk1CISPhP/+SX7FnrAPAr7ykVBxonJ2lWzDihY= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/cygwin-3_4-branch] Cygwin: /proc/cpuinfo: Always print topology info X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/cygwin-3_4-branch X-Git-Oldrev: 1069eab80aa6e9f195e8bf1f04e49f9d23d41bc5 X-Git-Newrev: 7c870ee90f7c0f8264b58cf43616fa754993b9d1 Message-Id: <20230116133005.6D2EC3858C2F@sourceware.org> Date: Mon, 16 Jan 2023 13:30:05 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D7c870ee90f7= c0f8264b58cf43616fa754993b9d1 commit 7c870ee90f7c0f8264b58cf43616fa754993b9d1 Author: Corinna Vinschen AuthorDate: Mon Jan 16 14:23:38 2023 +0100 Commit: Corinna Vinschen CommitDate: Mon Jan 16 14:23:50 2023 +0100 Cygwin: /proc/cpuinfo: Always print topology info =20 vmstat from proc-ps-4.0.x prints "Unable to create system stat structur= e" 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). =20 Fix that by printing topology info all the time, even for single-core CPUs. =20 Fixes: e0d48debedfa ("Fix /proc/cpuinfo topology and cache size info") Signed-off-by: Corinna Vinschen 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 24067f68751d..66272125cb20 100644 --- a/winsup/cygwin/fhandler/proc.cc +++ b/winsup/cygwin/fhandler/proc.cc @@ -672,7 +672,8 @@ format_proc_cpuinfo (void *, char *&destbuf) =20 if (!SetThreadGroupAffinity (GetCurrentThread (), &affinity, &orig_group_affinity)) - system_printf ("SetThreadGroupAffinity(%x,%d (%x/%d)) failed %E", cpu_mas= k, 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 =3D 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 =3D (initial_apic_id & ((1 << logical_bits) - 1)) >> ht_bits; =20 bufptr +=3D __small_sprintf (bufptr, "physical id\t: %d\n", phys_id); - if (siblings > 0) - bufptr +=3D __small_sprintf (bufptr, "siblings\t: %u\n", siblings); + bufptr +=3D __small_sprintf (bufptr, "siblings\t: %u\n", siblings); bufptr +=3D __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); =20 } + else + { + /* Linux prints all this info depending on CONFIG_SMP. There's no + check if the CPU is actually a multicore CPU. */ + bufptr +=3D __small_sprintf (bufptr, "physical id\t: %d\n", cpu_number); + bufptr +=3D __small_sprintf (bufptr, "siblings\t: 1\n"); + bufptr +=3D __small_sprintf (bufptr, "core id\t\t: 0\n" + "cpu cores\t: 1\n"); + bufptr +=3D __small_sprintf (bufptr, "apicid\t\t: %d\n" + "initial apicid\t: %d\n", + apic_id, apic_id); + } =20 /* level is number of non-zero leafs exc. sub-leafs */ int level =3D 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 =20 - Avoid hangs when reading /proc//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