View | Details | Raw Unified | Return to bug 251113
Collapse All | Expand All

(-)b/sysutils/turbostat/Makefile (-10 / +24 lines)
Lines 1-12 Link Here
1
# $FreeBSD$
1
# $FreeBSD$
2
2
3
PORTNAME=	turbostat
3
PORTNAME=	turbostat
4
PORTVERSION=	4.17 # Turbostat itself has a version, but we don't bother
4
PORTVERSION=	5.3  # Turbostat itself has a version, but we don't bother
5
PORTREVISION=	1
6
CATEGORIES=	sysutils
5
CATEGORIES=	sysutils
7
MASTER_SITES=	https://raw.githubusercontent.com/torvalds/linux/v${PORTVERSION}/tools/power/x86/turbostat/ \
6
MASTER_SITES=	https://raw.githubusercontent.com/torvalds/linux/v${PORTVERSION}/ 
8
		https://raw.githubusercontent.com/torvalds/linux/v${PORTVERSION}/arch/x86/include/asm/
7
9
DISTFILES=	${PORTNAME}.c ${PORTNAME}.8 msr-index.h intel-family.h
8
TURBOSTAT_DIR= tools/power/x86/turbostat/
9
ASM_DIR= arch/x86/include/asm/
10
X86ASM_DIR= tools/arch/x86/include/uapi/asm/
11
GENERICASM_DIR= tools/include/uapi/asm-generic/
12
DISTFILES=	${TURBOSTAT_DIR}${PORTNAME}.c \
13
			${TURBOSTAT_DIR}${PORTNAME}.8 \
14
			${ASM_DIR}intel-family.h \
15
			${ASM_DIR}msr-index.h \
16
			tools/include/linux/bits.h \
17
			${X86ASM_DIR}bitsperlong.h \
18
            ${GENERICASM_DIR}bitsperlong.h
19
10
DIST_SUBDIR=	${PORTNAME}-${PORTVERSION}
20
DIST_SUBDIR=	${PORTNAME}-${PORTVERSION}
11
21
12
MAINTAINER=	d.scott.phillips@intel.com
22
MAINTAINER=	d.scott.phillips@intel.com
Lines 22-32 PLIST_FILES= sbin/turbostat man/man8/turbostat.8.gz Link Here
22
post-extract:
32
post-extract:
23
33
24
do-extract:
34
do-extract:
25
	@${MKDIR} ${WRKSRC}
35
	@${MKDIR} ${WRKSRC}/linux/asm/asm-generic
26
	${CP} ${_DISTDIR}/${PORTNAME}.c ${WRKSRC}
36
	${CP} ${_DISTDIR}/${TURBOSTAT_DIR}${PORTNAME}.c ${WRKSRC}
27
	${CP} ${_DISTDIR}/${PORTNAME}.8 ${WRKSRC}
37
	${CP} ${_DISTDIR}/${TURBOSTAT_DIR}${PORTNAME}.8 ${WRKSRC}
28
	${CP} ${_DISTDIR}/msr-index.h ${WRKSRC}
38
	${CP} ${_DISTDIR}/tools/include/linux/bits.h ${WRKSRC}/linux
29
	${CP} ${_DISTDIR}/intel-family.h ${WRKSRC}
39
	${CP} ${_DISTDIR}/${X86ASM_DIR}bitsperlong.h ${WRKSRC}/linux/asm
40
	${CP} ${_DISTDIR}/${ASM_DIR}intel-family.h ${WRKSRC}
41
	${CP} ${_DISTDIR}/${ASM_DIR}msr-index.h ${WRKSRC}
42
	${CP} ${_DISTDIR}/${GENERICASM_DIR}bitsperlong.h ${WRKSRC}/linux/asm/asm-generic
43
30
44
31
do-build:
45
do-build:
32
	cd ${WRKSRC} && ${CC} ${CFLAGS} -DMSRHEADER='"msr-index.h"' -DINTEL_FAMILY_HEADER='"intel-family.h"' -o ${PORTNAME} ${PORTNAME}.c -lutil
46
	cd ${WRKSRC} && ${CC} ${CFLAGS} -DMSRHEADER='"msr-index.h"' -DINTEL_FAMILY_HEADER='"intel-family.h"' -o ${PORTNAME} ${PORTNAME}.c -lutil
(-)b/sysutils/turbostat/distinfo (-9 / +15 lines)
Lines 1-9 Link Here
1
TIMESTAMP = 1531331060
1
TIMESTAMP = 1574260829
2
SHA256 (turbostat-4.17/turbostat.c) = 23bc86ba086b0b18bfb92619eb66e0c482f7d6c20f5a00d9c333ac2a1c212660
2
SHA256 (turbostat-5.3/tools/power/x86/turbostat/turbostat.c) = d37950aa03c9fc719b53f416edcf9b361806e11b00be3520acf0b502c27054cb
3
SIZE (turbostat-4.17/turbostat.c) = 135407
3
SIZE (turbostat-5.3/tools/power/x86/turbostat/turbostat.c) = 153590
4
SHA256 (turbostat-4.17/turbostat.8) = b58eddff29a33ada502627a457021dd70191a4e4bb96b17ff44b1623158b3ed4
4
SHA256 (turbostat-5.3/tools/power/x86/turbostat/turbostat.8) = fa255211daee4d3a504c9b9e38bdbb9e7c7e739a60a9a2648dbac0edb4cd774f
5
SIZE (turbostat-4.17/turbostat.8) = 18201
5
SIZE (turbostat-5.3/tools/power/x86/turbostat/turbostat.8) = 20239
6
SHA256 (turbostat-4.17/msr-index.h) = f984e5737423ed1e5beea2d543f2f263321f43b74abc31d728f306489279e4cf
6
SHA256 (turbostat-5.3/arch/x86/include/asm/intel-family.h) = a6354dd96e09d000df29fdcff3adb4bdc595b662ff0894dbc07451f65253efb5
7
SIZE (turbostat-4.17/msr-index.h) = 29422
7
SIZE (turbostat-5.3/arch/x86/include/asm/intel-family.h) = 3993
8
SHA256 (turbostat-4.17/intel-family.h) = c3b888feb0e1a73c0aa6817908c2e71313b1dc2d6c834700d1f983746cc49258
8
SHA256 (turbostat-5.3/arch/x86/include/asm/msr-index.h) = d21fa6a86adb98a51f68ecc7d9074120291dd435522bbbe25895b6098b236920
9
SIZE (turbostat-4.17/intel-family.h) = 2629
9
SIZE (turbostat-5.3/arch/x86/include/asm/msr-index.h) = 32543
10
SHA256 (turbostat-5.3/tools/include/linux/bits.h) = 8121345ae3a14048a93d016664adf7155c3cd772b1b9536a27e5b91bd862fb07
11
SIZE (turbostat-5.3/tools/include/linux/bits.h) = 833
12
SHA256 (turbostat-5.3/tools/arch/x86/include/uapi/asm/bitsperlong.h) = 8897a5a9ea04d1f99bc7512542468983ca71808c7cf1d8ddfb23fb91654cad14
13
SIZE (turbostat-5.3/tools/arch/x86/include/uapi/asm/bitsperlong.h) = 320
14
SHA256 (turbostat-5.3/tools/include/uapi/asm-generic/bitsperlong.h) = 7168fc12586f612d643dc2b1157413a6af8fd5c37f04b2252bbb7668581bd4ab
15
SIZE (turbostat-5.3/tools/include/uapi/asm-generic/bitsperlong.h) = 516
(-)b/sysutils/turbostat/files/patch-linux_asm_bitsperlong.h (+10 lines)
Added Link Here
1
--- linux/asm/bitsperlong.h.orig	2019-11-20 21:11:45 UTC
2
+++ linux/asm/bitsperlong.h
3
@@ -8,6 +8,6 @@
4
 # define __BITS_PER_LONG 32
5
 #endif
6
 
7
-#include <asm-generic/bitsperlong.h>
8
+#include "asm-generic/bitsperlong.h"
9
 
10
 #endif /* __ASM_X86_BITSPERLONG_H */
(-)b/sysutils/turbostat/files/patch-linux_bits.h (+11 lines)
Added Link Here
1
--- linux/bits.h.orig	2019-11-20 21:11:33 UTC
2
+++ linux/bits.h
3
@@ -1,7 +1,7 @@
4
 /* SPDX-License-Identifier: GPL-2.0 */
5
 #ifndef __LINUX_BITS_H
6
 #define __LINUX_BITS_H
7
-#include <asm/bitsperlong.h>
8
+#include "asm/bitsperlong.h"
9
 
10
 #define BIT(nr)			(1UL << (nr))
11
 #define BIT_ULL(nr)		(1ULL << (nr))
(-)b/sysutils/turbostat/files/patch-msr-index.h (+11 lines)
Added Link Here
1
--- msr-index.h.orig	2019-11-20 21:11:54 UTC
2
+++ msr-index.h
3
@@ -2,7 +2,7 @@
4
 #ifndef _ASM_X86_MSR_INDEX_H
5
 #define _ASM_X86_MSR_INDEX_H
6
 
7
-#include <linux/bits.h>
8
+#include "linux/bits.h"
9
 
10
 /*
11
  * CPU model specific register (MSR) numbers.
(-)b/sysutils/turbostat/files/patch-turbostat.c (-35 / +309 lines)
Lines 1-6 Link Here
1
--- turbostat.c.orig	2018-07-31 20:42:12 UTC
1
--- turbostat.c.orig	2019-12-16 20:14:20 UTC
2
+++ turbostat.c
2
+++ turbostat.c
3
@@ -41,7 +41,31 @@
3
@@ -30,7 +30,31 @@
4
 #include <sched.h>
4
 #include <sched.h>
5
 #include <time.h>
5
 #include <time.h>
6
 #include <cpuid.h>
6
 #include <cpuid.h>
Lines 30-40 Link Here
30
 #include <linux/capability.h>
30
 #include <linux/capability.h>
31
+#endif
31
+#endif
32
 #include <errno.h>
32
 #include <errno.h>
33
 #include <math.h>
33
 
34
 
34
 char *proc_stat = "/proc/stat";
35
@@ -145,7 +169,9 @@ int ignore_stdin;
35
@@ -132,7 +156,9 @@ unsigned int has_misc_feature_control;
36
 #define MSR_CORE_ENERGY_STAT	0xc001029a
36
 #define RAPL_CORES (RAPL_CORES_ENERGY_STATUS | RAPL_CORES_POWER_LIMIT)
37
 #define MSR_PKG_ENERGY_STAT	0xc001029b
37
 #define	TJMAX_DEFAULT	100
38
 
38
 
39
+#ifndef __FreeBSD__
39
+#ifndef __FreeBSD__
40
 #define MAX(a, b) ((a) > (b) ? (a) : (b))
40
 #define MAX(a, b) ((a) > (b) ? (a) : (b))
Lines 42-48 Link Here
42
 
42
 
43
 /*
43
 /*
44
  * buffer size used by sscanf() for added column names
44
  * buffer size used by sscanf() for added column names
45
@@ -309,6 +335,7 @@ int cpu_migrate(int cpu)
45
@@ -357,6 +383,7 @@ int cpu_migrate(int cpu)
46
 	else
46
 	else
47
 		return 0;
47
 		return 0;
48
 }
48
 }
Lines 50-56 Link Here
50
 int get_msr_fd(int cpu)
50
 int get_msr_fd(int cpu)
51
 {
51
 {
52
 	char pathname[32];
52
 	char pathname[32];
53
@@ -319,18 +346,39 @@ int get_msr_fd(int cpu)
53
@@ -367,18 +394,39 @@ int get_msr_fd(int cpu)
54
 	if (fd)
54
 	if (fd)
55
 		return fd;
55
 		return fd;
56
 
56
 
Lines 91-110 Link Here
91
 	ssize_t retval;
91
 	ssize_t retval;
92
 
92
 
93
 	retval = pread(get_msr_fd(cpu), msr, sizeof(*msr), offset);
93
 	retval = pread(get_msr_fd(cpu), msr, sizeof(*msr), offset);
94
@@ -340,6 +388,7 @@ int get_msr(int cpu, off_t offset, unsigned long long 
94
@@ -388,6 +436,7 @@ int get_msr(int cpu, off_t offset, unsigned long long 
95
 
95
 
96
 	return 0;
96
 	return 0;
97
 }
97
 }
98
+#endif
98
+#endif
99
 
99
 
100
 /*
100
 /*
101
  * Each string in this array is compared in --show and --hide cmdline.
101
  * This list matches the column headers, except
102
@@ -2239,6 +2288,173 @@ int parse_int_file(const char *fmt, ...)
102
@@ -2018,7 +2067,308 @@ done:
103
 	return value;
103
 	return 0;
104
 }
104
 }
105
 
105
 
106
+#ifdef __FreeBSD__
106
+#ifdef __FreeBSD__
107
+static int ncpus;
107
+static int ncpus;
108
+static int maxcpu;
108
+struct cpuset_list {
109
+struct cpuset_list {
109
+	cpuset_t	*sets;
110
+	cpuset_t	*sets;
110
+	size_t		len;
111
+	size_t		len;
Lines 150-162 Link Here
150
+
151
+
151
+static void read_topology_spec(void)
152
+static void read_topology_spec(void)
152
+{
153
+{
153
+	char spec[16384];
154
+	char *spec, *i;
154
+	size_t sz = sizeof(spec) - 1;
155
+	size_t sz = 0;
155
+	char *i;
156
+
156
+
157
+	if (sysctlbyname("kern.sched.topology_spec", NULL, &sz, NULL, 0) != ENOMEM)
158
+		err(1, "sysctl: kern.sched.topology_spec: failed");
159
+	spec = malloc(sz + 1);
160
+	if (spec == NULL)
161
+		err(1, "malloc: failed");
157
+	if (sysctlbyname("kern.sched.topology_spec", spec, &sz, NULL, 0))
162
+	if (sysctlbyname("kern.sched.topology_spec", spec, &sz, NULL, 0))
158
+		err(1, "sysctl: kern.sched.topology_spec: failed");
163
+		err(1, "sysctl: kern.sched.topology_spec: failed");
159
+	spec[sizeof(spec) - 1] = '\0';
160
+
164
+
161
+	/* Skip the entire system entry. */
165
+	/* Skip the entire system entry. */
162
+	i = strstr(spec, "<cpu");
166
+	i = strstr(spec, "<cpu");
Lines 166-171 Link Here
166
+	cpuset_t last;
170
+	cpuset_t last;
167
+	CPU_ZERO(&last);
171
+	CPU_ZERO(&last);
168
+
172
+
173
+    char spectok[sizeof(spec)];
174
+	strcpy(spectok,spec);
175
+
176
+
169
+	while ((i = strstr(i + 1, "<cpu")) != NULL) {
177
+	while ((i = strstr(i + 1, "<cpu")) != NULL) {
170
+		cpuset_t set = parse_cpu_mask(i);
178
+		cpuset_t set = parse_cpu_mask(i);
171
+
179
+
Lines 196-202 Link Here
196
+		ncpus += CPU_COUNT(packages.sets + i);
204
+		ncpus += CPU_COUNT(packages.sets + i);
197
+}
205
+}
198
+
206
+
199
+static int get_physical_package_id(int cpu)
207
+int get_physical_package_id(int cpu)
200
+{
208
+{
201
+	for (int i = 0; i < packages.len; i++) {
209
+	for (int i = 0; i < packages.len; i++) {
202
+		if (!CPU_ISSET(cpu, packages.sets + i))
210
+		if (!CPU_ISSET(cpu, packages.sets + i))
Lines 207-213 Link Here
207
+	return -1;
215
+	return -1;
208
+}
216
+}
209
+
217
+
210
+static int get_core_id(int cpu)
218
+int get_core_id(int cpu)
211
+{
219
+{
212
+	int package_id = get_physical_package_id(cpu);
220
+	int package_id = get_physical_package_id(cpu);
213
+	if (package_id < 0)
221
+	if (package_id < 0)
Lines 260-266 Link Here
260
+	return 1;
268
+	return 1;
261
+}
269
+}
262
+
270
+
263
+static int cpu_is_first_core_in_package(int cpu)
271
+int cpu_is_first_core_in_package(int cpu)
264
+{
272
+{
265
+	int package = get_physical_package_id(cpu);
273
+	int package = get_physical_package_id(cpu);
266
+	if (package < 0)
274
+	if (package < 0)
Lines 268-287 Link Here
268
+
276
+
269
+	return CPU_FFS(packages.sets + package) - 1 == cpu;
277
+	return CPU_FFS(packages.sets + package) - 1 == cpu;
270
+}
278
+}
279
+/* TODO: Report Actual Die info */
280
+int get_die_id(int cpu)
281
+{
282
+	return -1;
283
+}
284
+
285
+int get_physical_node_id(struct cpu_topology *thiscpu)
286
+{
287
+    return -1;
288
+}
289
+
290
+int get_thread_siblings(struct cpu_topology *thiscpu)
291
+{
292
+	return -1;
293
+}
294
+
295
+void set_max_cpu_num(void)
296
+{
297
+		printf("set_mac_cpu_num");
298
+}
299
+
271
+
300
+
272
+#else
301
+#else
273
 /*
302
 /*
274
  * get_cpu_position_in_core(cpu)
303
+ * cpu_is_first_core_in_package(cpu)
275
  * return the position of the CPU among its HT siblings in the core
304
+ * return 1 if given CPU is 1st core in package
276
@@ -2326,6 +2542,7 @@ int get_num_ht_siblings(int cpu)
305
+ */
277
 	fclose(filep);
306
+int cpu_is_first_core_in_package(int cpu)
278
 	return matches+1;
307
+{
279
 }
308
+	return cpu == parse_int_file("/sys/devices/system/cpu/cpu%d/topology/core_siblings_list", cpu);
309
+}
310
+
311
+int get_physical_package_id(int cpu)
312
+{
313
+	return parse_int_file("/sys/devices/system/cpu/cpu%d/topology/physical_package_id", cpu);
314
+}
315
+
316
+int get_die_id(int cpu)
317
+{
318
+	return parse_int_file("/sys/devices/system/cpu/cpu%d/topology/die_id", cpu);
319
+}
320
+
321
+int get_core_id(int cpu)
322
+{
323
+	return parse_int_file("/sys/devices/system/cpu/cpu%d/topology/core_id", cpu);
324
+}
325
+
326
+int get_physical_node_id(struct cpu_topology *thiscpu)
327
+{
328
+	char path[80];
329
+	FILE *filep;
330
+	int i;
331
+	int cpu = thiscpu->logical_cpu_id;
332
+
333
+	for (i = 0; i <= topo.max_cpu_num; i++) {
334
+		sprintf(path, "/sys/devices/system/cpu/cpu%d/node%i/cpulist",
335
+			cpu, i);
336
+		filep = fopen(path, "r");
337
+		if (!filep)
338
+			continue;
339
+		fclose(filep);
340
+		return i;
341
+	}
342
+	return -1;
343
+}
344
+
345
+int get_thread_siblings(struct cpu_topology *thiscpu)
346
+{
347
+	char path[80], character;
348
+	FILE *filep;
349
+	unsigned long map;
350
+	int so, shift, sib_core;
351
+	int cpu = thiscpu->logical_cpu_id;
352
+	int offset = topo.max_cpu_num + 1;
353
+	size_t size;
354
+	int thread_id = 0;
355
+
356
+	thiscpu->put_ids = CPU_ALLOC((topo.max_cpu_num + 1));
357
+	if (thiscpu->thread_id < 0)
358
+		thiscpu->thread_id = thread_id++;
359
+	if (!thiscpu->put_ids)
360
+		return -1;
361
+
362
+	size = CPU_ALLOC_SIZE((topo.max_cpu_num + 1));
363
+	CPU_ZERO_S(size, thiscpu->put_ids);
364
+
365
+	sprintf(path,
366
+		"/sys/devices/system/cpu/cpu%d/topology/thread_siblings", cpu);
367
+	filep = fopen_or_die(path, "r");
368
+	do {
369
+		offset -= BITMASK_SIZE;
370
+		if (fscanf(filep, "%lx%c", &map, &character) != 2)
371
+			err(1, "%s: failed to parse file", path);
372
+		for (shift = 0; shift < BITMASK_SIZE; shift++) {
373
+			if ((map >> shift) & 0x1) {
374
+				so = shift + offset;
375
+				sib_core = get_core_id(so);
376
+				if (sib_core == thiscpu->physical_core_id) {
377
+					CPU_SET_S(so, size, thiscpu->put_ids);
378
+					if ((so != cpu) &&
379
+					    (cpus[so].thread_id < 0))
380
+						cpus[so].thread_id =
381
+								    thread_id++;
382
+				}
383
+			}
384
+		}
385
+	} while (!strncmp(&character, ",", 1));
386
+	fclose(filep);
387
+
388
+	return CPU_COUNT_S(size, thiscpu->put_ids);
389
+}
390
+
391
+void set_max_cpu_num(void)
392
+{
393
+	FILE *filep;
394
+	unsigned long dummy;
395
+
396
+	topo.max_cpu_num = 0;
397
+	filep = fopen_or_die(
398
+			"/sys/devices/system/cpu/cpu0/topology/thread_siblings",
399
+			"r");
400
+	while (fscanf(filep, "%lx,", &dummy) == 1)
401
+		topo.max_cpu_num += BITMASK_SIZE;
402
+	fclose(filep);
403
+	topo.max_cpu_num--; /* 0 based */
404
+}
405
+
280
+#endif
406
+#endif
407
+/*
408
  * MSR_PKG_CST_CONFIG_CONTROL decoding for pkg_cstate_limit:
409
  * If you change the values, note they are used both in comparisons
410
  * (>= PCL__7) and to index pkg_cstate_limit_strings[].
411
@@ -2540,30 +2890,7 @@ int parse_int_file(const char *fmt, ...)
412
 	return value;
413
 }
414
 
415
-/*
416
- * cpu_is_first_core_in_package(cpu)
417
- * return 1 if given CPU is 1st core in package
418
- */
419
-int cpu_is_first_core_in_package(int cpu)
420
-{
421
-	return cpu == parse_int_file("/sys/devices/system/cpu/cpu%d/topology/core_siblings_list", cpu);
422
-}
423
 
424
-int get_physical_package_id(int cpu)
425
-{
426
-	return parse_int_file("/sys/devices/system/cpu/cpu%d/topology/physical_package_id", cpu);
427
-}
428
-
429
-int get_die_id(int cpu)
430
-{
431
-	return parse_int_file("/sys/devices/system/cpu/cpu%d/topology/die_id", cpu);
432
-}
433
-
434
-int get_core_id(int cpu)
435
-{
436
-	return parse_int_file("/sys/devices/system/cpu/cpu%d/topology/core_id", cpu);
437
-}
438
-
439
 void set_node_data(void)
440
 {
441
 	int pkg, node, lnode, cpu, cpux;
442
@@ -2605,71 +2932,8 @@ void set_node_data(void)
443
 	}
444
 }
445
 
446
-int get_physical_node_id(struct cpu_topology *thiscpu)
447
-{
448
-	char path[80];
449
-	FILE *filep;
450
-	int i;
451
-	int cpu = thiscpu->logical_cpu_id;
452
 
453
-	for (i = 0; i <= topo.max_cpu_num; i++) {
454
-		sprintf(path, "/sys/devices/system/cpu/cpu%d/node%i/cpulist",
455
-			cpu, i);
456
-		filep = fopen(path, "r");
457
-		if (!filep)
458
-			continue;
459
-		fclose(filep);
460
-		return i;
461
-	}
462
-	return -1;
463
-}
281
 
464
 
465
-int get_thread_siblings(struct cpu_topology *thiscpu)
466
-{
467
-	char path[80], character;
468
-	FILE *filep;
469
-	unsigned long map;
470
-	int so, shift, sib_core;
471
-	int cpu = thiscpu->logical_cpu_id;
472
-	int offset = topo.max_cpu_num + 1;
473
-	size_t size;
474
-	int thread_id = 0;
475
-
476
-	thiscpu->put_ids = CPU_ALLOC((topo.max_cpu_num + 1));
477
-	if (thiscpu->thread_id < 0)
478
-		thiscpu->thread_id = thread_id++;
479
-	if (!thiscpu->put_ids)
480
-		return -1;
481
-
482
-	size = CPU_ALLOC_SIZE((topo.max_cpu_num + 1));
483
-	CPU_ZERO_S(size, thiscpu->put_ids);
484
-
485
-	sprintf(path,
486
-		"/sys/devices/system/cpu/cpu%d/topology/thread_siblings", cpu);
487
-	filep = fopen_or_die(path, "r");
488
-	do {
489
-		offset -= BITMASK_SIZE;
490
-		if (fscanf(filep, "%lx%c", &map, &character) != 2)
491
-			err(1, "%s: failed to parse file", path);
492
-		for (shift = 0; shift < BITMASK_SIZE; shift++) {
493
-			if ((map >> shift) & 0x1) {
494
-				so = shift + offset;
495
-				sib_core = get_core_id(so);
496
-				if (sib_core == thiscpu->physical_core_id) {
497
-					CPU_SET_S(so, size, thiscpu->put_ids);
498
-					if ((so != cpu) &&
499
-					    (cpus[so].thread_id < 0))
500
-						cpus[so].thread_id =
501
-								    thread_id++;
502
-				}
503
-			}
504
-		}
505
-	} while (!strncmp(&character, ",", 1));
506
-	fclose(filep);
507
-
508
-	return CPU_COUNT_S(size, thiscpu->put_ids);
509
-}
510
-
282
 /*
511
 /*
283
  * run func(thread, core, package) in topology order
512
  * run func(thread, core, package) in topology order
284
@@ -2371,6 +2588,22 @@ int for_all_cpus_2(int (func)(struct thread_data *, st
513
  * skip non-present cpus
514
@@ -2724,6 +2988,22 @@ int for_all_cpus_2(int (func)(struct thread_data *, st
285
 	return 0;
515
 	return 0;
286
 }
516
 }
287
 
517
 
Lines 304-310 Link Here
304
 /*
534
 /*
305
  * run func(cpu) on every cpu in /proc/stat
535
  * run func(cpu) on every cpu in /proc/stat
306
  * return max_cpu number
536
  * return max_cpu number
307
@@ -2401,6 +2634,7 @@ int for_all_proc_cpus(int (func)(int))
537
@@ -2754,6 +3034,7 @@ int for_all_proc_cpus(int (func)(int))
308
 	fclose(fp);
538
 	fclose(fp);
309
 	return 0;
539
 	return 0;
310
 }
540
 }
Lines 312-318 Link Here
312
 
542
 
313
 void re_initialize(void)
543
 void re_initialize(void)
314
 {
544
 {
315
@@ -2428,6 +2662,85 @@ int mark_cpu_present(int cpu)
545
@@ -2762,21 +3043,7 @@ void re_initialize(void)
546
 	printf("turbostat: re-initialized with num_cpus %d\n", topo.num_cpus);
547
 }
548
 
549
-void set_max_cpu_num(void)
550
-{
551
-	FILE *filep;
552
-	unsigned long dummy;
553
 
554
-	topo.max_cpu_num = 0;
555
-	filep = fopen_or_die(
556
-			"/sys/devices/system/cpu/cpu0/topology/thread_siblings",
557
-			"r");
558
-	while (fscanf(filep, "%lx,", &dummy) == 1)
559
-		topo.max_cpu_num += BITMASK_SIZE;
560
-	fclose(filep);
561
-	topo.max_cpu_num--; /* 0 based */
562
-}
563
-
564
 /*
565
  * count_cpus()
566
  * remember the last one seen, it will be the max
567
@@ -2798,6 +3065,89 @@ int init_thread_id(int cpu)
316
 	return 0;
568
 	return 0;
317
 }
569
 }
318
 
570
 
Lines 375-381 Link Here
375
+	}
627
+	}
376
+}
628
+}
377
+
629
+
378
+static int snapshot_proc_interrupts(void)
630
+int snapshot_proc_interrupts(void)
379
+{
631
+{
380
+	if (!intr_map)
632
+	if (!intr_map)
381
+		init_intr_map();
633
+		init_intr_map();
Lines 394-413 Link Here
394
+
646
+
395
+	return 0;
647
+	return 0;
396
+}
648
+}
649
+int snapshot_proc_sysfs_files(void)
650
+{
651
+		return 0;
652
+}
397
+#else
653
+#else
398
 /*
654
 /*
399
  * snapshot_proc_interrupts()
655
  * snapshot_proc_interrupts()
400
  *
656
  *
401
@@ -2491,6 +2804,8 @@ int snapshot_proc_interrupts(void)
657
@@ -2861,6 +3211,7 @@ int snapshot_proc_interrupts(void)
402
 	}
658
 	}
403
 	return 0;
659
 	return 0;
404
 }
660
 }
405
+#endif
406
+
661
+
407
 /*
662
 /*
408
  * snapshot_gfx_rc6_ms()
663
  * snapshot_gfx_rc6_ms()
409
  *
664
  *
410
@@ -2629,6 +2944,18 @@ restart:
665
@@ -2989,6 +3340,7 @@ int snapshot_proc_sysfs_files(void)
666
 
667
 	return 0;
668
 }
669
+#endif
670
 
671
 int exit_requested;
672
 
673
@@ -3140,6 +3492,18 @@ restart:
411
 	}
674
 	}
412
 }
675
 }
413
 
676
 
Lines 426-432 Link Here
426
 void check_dev_msr()
689
 void check_dev_msr()
427
 {
690
 {
428
 	struct stat sb;
691
 	struct stat sb;
429
@@ -2677,6 +3004,7 @@ void check_permissions()
692
@@ -3188,6 +3552,7 @@ void check_permissions()
430
 	if (do_exit)
693
 	if (do_exit)
431
 		exit(-6);
694
 		exit(-6);
432
 }
695
 }
Lines 434-440 Link Here
434
 
697
 
435
 /*
698
 /*
436
  * NHM adds support for additional MSRs:
699
  * NHM adds support for additional MSRs:
437
@@ -4520,8 +4848,21 @@ void setup_all_buffers(void)
700
@@ -5192,8 +5557,21 @@ void setup_all_buffers(void)
438
 	for_all_proc_cpus(initialize_counters);
701
 	for_all_proc_cpus(initialize_counters);
439
 }
702
 }
440
 
703
 
Lines 456-462 Link Here
456
 	base_cpu = sched_getcpu();
719
 	base_cpu = sched_getcpu();
457
 	if (base_cpu < 0)
720
 	if (base_cpu < 0)
458
 		err(-ENODEV, "No valid cpus found");
721
 		err(-ENODEV, "No valid cpus found");
459
@@ -4529,6 +4870,7 @@ void set_base_cpu(void)
722
@@ -5201,6 +5579,7 @@ void set_base_cpu(void)
460
 	if (debug > 1)
723
 	if (debug > 1)
461
 		fprintf(outf, "base_cpu = %d\n", base_cpu);
724
 		fprintf(outf, "base_cpu = %d\n", base_cpu);
462
 }
725
 }
Lines 464-466 Link Here
464
 
727
 
465
 void turbostat_init()
728
 void turbostat_init()
466
 {
729
 {
730
@@ -5769,7 +6148,9 @@ int main(int argc, char **argv)
731
 	if (!quiet)
732
 		print_version();
733
 
734
-	probe_sysfs();
735
+    #ifndef __FreeBSD__
736
+		probe_sysfs();
737
+    #endif
738
 
739
 	turbostat_init();
740
 

Return to bug 251113