git: c89319e9c7b0 - 2023Q1 - sysutils/turbostat: unbreak runtime on FreeBSD >= 13.1
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 19 Feb 2023 00:50:08 UTC
The branch 2023Q1 has been updated by jbeich: URL: https://cgit.FreeBSD.org/ports/commit/?id=c89319e9c7b0e184ebbd82549788279b04a9cf76 commit c89319e9c7b0e184ebbd82549788279b04a9cf76 Author: Jan Beich <jbeich@FreeBSD.org> AuthorDate: 2023-02-19 00:28:44 +0000 Commit: Jan Beich <jbeich@FreeBSD.org> CommitDate: 2023-02-19 00:49:22 +0000 sysutils/turbostat: unbreak runtime on FreeBSD >= 13.1 $ turbostat turbostat version 17.06.23 - Len Brown <lenb@kernel.org> Segmentation fault * thread #1, name = 'turbostat', stop reason = signal SIGSEGV: invalid address (fault address: 0x0) frame #0: 0x0000000000216992 turbostat`topology_probe at turbostat.c:4685:7 4682 * Validate that all cpus in cpu_subset are also in cpu_present_set 4683 */ 4684 for (i = 0; i < CPU_SUBSET_MAXCPUS; ++i) { -> 4685 if (CPU_ISSET_S(i, cpu_subset_size, cpu_subset)) 4686 if (!CPU_ISSET_S(i, cpu_present_setsize, cpu_present_set)) 4687 err(1, "cpu%d not present", i); 4688 } (lldb) bt * thread #1, name = 'turbostat', stop reason = signal SIGSEGV: invalid address (fault address: 0x0) * frame #0: 0x0000000000216992 turbostat`topology_probe at turbostat.c:4685:7 frame #1: 0x00000000002111c9 turbostat`setup_all_buffers at turbostat.c:4853:2 frame #2: 0x0000000000217909 turbostat`turbostat_init at turbostat.c:4888:2 frame #3: 0x0000000000218f3f turbostat`main(argc=1, argv=0x0000000820444710) at turbostat.c:5447:2 frame #4: 0x0000000000207160 turbostat`_start(ap=<unavailable>, cleanup=<unavailable>) at crt1_c.c:73:7 (lldb) p cpu_subset (cpu_set_t *) $0 = NULL PR: 262866 (cherry picked from commit b27279cba1cad5a4f00237ddfffe11789e1c2053) --- sysutils/turbostat/Makefile | 2 +- sysutils/turbostat/files/patch-turbostat.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/sysutils/turbostat/Makefile b/sysutils/turbostat/Makefile index b2784d3b2542..3815b4d3b8bd 100644 --- a/sysutils/turbostat/Makefile +++ b/sysutils/turbostat/Makefile @@ -1,6 +1,6 @@ PORTNAME= turbostat PORTVERSION= 4.17 # Turbostat itself has a version, but we don't bother -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= sysutils MASTER_SITES= https://raw.githubusercontent.com/torvalds/linux/v${PORTVERSION}/tools/power/x86/turbostat/ \ https://raw.githubusercontent.com/torvalds/linux/v${PORTVERSION}/arch/x86/include/asm/ diff --git a/sysutils/turbostat/files/patch-turbostat.c b/sysutils/turbostat/files/patch-turbostat.c index cbfdcb22ddda..ae33628083e8 100644 --- a/sysutils/turbostat/files/patch-turbostat.c +++ b/sysutils/turbostat/files/patch-turbostat.c @@ -23,7 +23,7 @@ +#define CPU_ALLOC(_ign) ({(cpuset_t*)malloc(sizeof(cpuset_t));}) +#define CPU_ALLOC_SIZE(_ign) sizeof(cpuset_t) +#define CPU_FREE free -+#define CPU_ISSET_S(cpu, _ign, set) (set && CPU_ISSET(cpu, set)) ++#define CPU_ISSET_S(cpu, _ign, set) CPU_ISSET(cpu, set) +#define CPU_SET_S(cpu, _ign, set) CPU_SET(cpu, set) +#define CPU_ZERO_S(_ign, set) CPU_ZERO(set) +#define sched_setaffinity(_x, _y, set) cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(cpuset_t), set) @@ -445,6 +445,15 @@ /* * NHM adds support for additional MSRs: +@@ -4343,7 +4682,7 @@ void topology_probe() + * Validate that all cpus in cpu_subset are also in cpu_present_set + */ + for (i = 0; i < CPU_SUBSET_MAXCPUS; ++i) { +- if (CPU_ISSET_S(i, cpu_subset_size, cpu_subset)) ++ if (cpu_subset && CPU_ISSET_S(i, cpu_subset_size, cpu_subset)) + if (!CPU_ISSET_S(i, cpu_present_setsize, cpu_present_set)) + err(1, "cpu%d not present", i); + } @@ -4520,8 +4852,21 @@ void setup_all_buffers(void) for_all_proc_cpus(initialize_counters); }