Skip to content

Commit 36e674a

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-core-for-mingo-20160823' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo: User visible changes: . Allow configuring the default 'perf report -s' sort order in ~/.perfconfig, for instance, "sym,dso" may be more fitting for kernel developers. (Arnaldo Carvalho de Melo) - Support x8/x16/x32/x64 hexadecimal "types" in ftrace and 'perf probe' (Masami Hiramatsu) Infrastructure changes: - Skip running the feature tests for 'make install-doc' (Rui Teng) - Introduce tools/include/linux/time64.h with *SEC_PER_*SEC macros to use in all of tools/ (Arnaldo Carvalho de Melo) - Break down symbol__disassemble() into multiple functions, to ease future work on better reporting the errors that may take place in the various steps it performs (possibly decompressing kernel module files, getting build-id keyed files, calling objdump, parsing its output, etc) (Arnaldo Carvalho de Melo) - Typo fixes in various places (Colin Ian King) - Remove superfluous NULL check in the TUI code (Colin Ian King) - Allow displaying multiple header lines in the TUI browser, prep work for the 'perf c2c' browser (Jiri Olsa) - Copy coresight-pmu.h header file needed by perf tools (Mathieu Poirier) - Use __weak definition from linux/compiler.h (Rui Teng) Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2 parents b6a32f0 + 5e30d55 commit 36e674a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+474
-232
lines changed

Documentation/trace/kprobetrace.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ Synopsis of kprobe_events
4444
+|-offs(FETCHARG) : Fetch memory at FETCHARG +|- offs address.(**)
4545
NAME=FETCHARG : Set NAME as the argument name of FETCHARG.
4646
FETCHARG:TYPE : Set TYPE as the type of FETCHARG. Currently, basic types
47-
(u8/u16/u32/u64/s8/s16/s32/s64), "string" and bitfield
48-
are supported.
47+
(u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal types
48+
(x8/x16/x32/x64), "string" and bitfield are supported.
4949

5050
(*) only for return probe.
5151
(**) this is useful for fetching a field of data structures.
@@ -54,7 +54,10 @@ Types
5454
-----
5555
Several types are supported for fetch-args. Kprobe tracer will access memory
5656
by given type. Prefix 's' and 'u' means those types are signed and unsigned
57-
respectively. Traced arguments are shown in decimal (signed) or hex (unsigned).
57+
respectively. 'x' prefix implies it is unsigned. Traced arguments are shown
58+
in decimal ('s' and 'u') or hexadecimal ('x'). Without type casting, 'x32'
59+
or 'x64' is used depends on the architecture (e.g. x86-32 uses x32, and
60+
x86-64 uses x64).
5861
String type is a special type, which fetches a "null-terminated" string from
5962
kernel space. This means it will fail and store NULL if the string container
6063
has been paged out.

Documentation/trace/uprobetracer.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ Synopsis of uprobe_tracer
4040
+|-offs(FETCHARG) : Fetch memory at FETCHARG +|- offs address.(**)
4141
NAME=FETCHARG : Set NAME as the argument name of FETCHARG.
4242
FETCHARG:TYPE : Set TYPE as the type of FETCHARG. Currently, basic types
43-
(u8/u16/u32/u64/s8/s16/s32/s64), "string" and bitfield
44-
are supported.
43+
(u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal types
44+
(x8/x16/x32/x64), "string" and bitfield are supported.
4545

4646
(*) only for return probe.
4747
(**) this is useful for fetching a field of data structures.
@@ -50,7 +50,10 @@ Types
5050
-----
5151
Several types are supported for fetch-args. Uprobe tracer will access memory
5252
by given type. Prefix 's' and 'u' means those types are signed and unsigned
53-
respectively. Traced arguments are shown in decimal (signed) or hex (unsigned).
53+
respectively. 'x' prefix implies it is unsigned. Traced arguments are shown
54+
in decimal ('s' and 'u') or hexadecimal ('x'). Without type casting, 'x32'
55+
or 'x64' is used depends on the architecture (e.g. x86-32 uses x32, and
56+
x86-64 uses x64).
5457
String type is a special type, which fetches a "null-terminated" string from
5558
user space.
5659
Bitfield is another special type, which takes 3 parameters, bit-width, bit-

kernel/trace/trace.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4123,6 +4123,30 @@ static const char readme_msg[] =
41234123
"\t\t\t traces\n"
41244124
#endif
41254125
#endif /* CONFIG_STACK_TRACER */
4126+
#ifdef CONFIG_KPROBE_EVENT
4127+
" kprobe_events\t\t- Add/remove/show the kernel dynamic events\n"
4128+
"\t\t\t Write into this file to define/undefine new trace events.\n"
4129+
#endif
4130+
#ifdef CONFIG_UPROBE_EVENT
4131+
" uprobe_events\t\t- Add/remove/show the userspace dynamic events\n"
4132+
"\t\t\t Write into this file to define/undefine new trace events.\n"
4133+
#endif
4134+
#if defined(CONFIG_KPROBE_EVENT) || defined(CONFIG_UPROBE_EVENT)
4135+
"\t accepts: event-definitions (one definition per line)\n"
4136+
"\t Format: p|r[:[<group>/]<event>] <place> [<args>]\n"
4137+
"\t -:[<group>/]<event>\n"
4138+
#ifdef CONFIG_KPROBE_EVENT
4139+
"\t place: [<module>:]<symbol>[+<offset>]|<memaddr>\n"
4140+
#endif
4141+
#ifdef CONFIG_UPROBE_EVENT
4142+
"\t place: <path>:<offset>\n"
4143+
#endif
4144+
"\t args: <name>=fetcharg[:type]\n"
4145+
"\t fetcharg: %<register>, @<address>, @<symbol>[+|-<offset>],\n"
4146+
"\t $stack<index>, $stack, $retval, $comm\n"
4147+
"\t type: s8/16/32/64, u8/16/32/64, x8/16/32/64, string,\n"
4148+
"\t b<bit-width>@<bit-offset>/<container-size>\n"
4149+
#endif
41264150
" events/\t\t- Directory containing all trace event subsystems:\n"
41274151
" enable\t\t- Write 0/1 to enable/disable tracing of all events\n"
41284152
" events/<system>/\t- Directory containing all trace events for <system>:\n"

kernel/trace/trace_kprobe.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ static const struct fetch_type kprobes_fetch_type_table[] = {
253253
ASSIGN_FETCH_TYPE(s16, u16, 1),
254254
ASSIGN_FETCH_TYPE(s32, u32, 1),
255255
ASSIGN_FETCH_TYPE(s64, u64, 1),
256+
ASSIGN_FETCH_TYPE_ALIAS(x8, u8, u8, 0),
257+
ASSIGN_FETCH_TYPE_ALIAS(x16, u16, u16, 0),
258+
ASSIGN_FETCH_TYPE_ALIAS(x32, u32, u32, 0),
259+
ASSIGN_FETCH_TYPE_ALIAS(x64, u64, u64, 0),
256260

257261
ASSIGN_FETCH_TYPE_END
258262
};

kernel/trace/trace_probe.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,28 @@ const char *reserved_field_names[] = {
3636
};
3737

3838
/* Printing in basic type function template */
39-
#define DEFINE_BASIC_PRINT_TYPE_FUNC(type, fmt) \
40-
int PRINT_TYPE_FUNC_NAME(type)(struct trace_seq *s, const char *name, \
39+
#define DEFINE_BASIC_PRINT_TYPE_FUNC(tname, type, fmt) \
40+
int PRINT_TYPE_FUNC_NAME(tname)(struct trace_seq *s, const char *name, \
4141
void *data, void *ent) \
4242
{ \
4343
trace_seq_printf(s, " %s=" fmt, name, *(type *)data); \
4444
return !trace_seq_has_overflowed(s); \
4545
} \
46-
const char PRINT_TYPE_FMT_NAME(type)[] = fmt; \
47-
NOKPROBE_SYMBOL(PRINT_TYPE_FUNC_NAME(type));
48-
49-
DEFINE_BASIC_PRINT_TYPE_FUNC(u8 , "0x%x")
50-
DEFINE_BASIC_PRINT_TYPE_FUNC(u16, "0x%x")
51-
DEFINE_BASIC_PRINT_TYPE_FUNC(u32, "0x%x")
52-
DEFINE_BASIC_PRINT_TYPE_FUNC(u64, "0x%Lx")
53-
DEFINE_BASIC_PRINT_TYPE_FUNC(s8, "%d")
54-
DEFINE_BASIC_PRINT_TYPE_FUNC(s16, "%d")
55-
DEFINE_BASIC_PRINT_TYPE_FUNC(s32, "%d")
56-
DEFINE_BASIC_PRINT_TYPE_FUNC(s64, "%Ld")
46+
const char PRINT_TYPE_FMT_NAME(tname)[] = fmt; \
47+
NOKPROBE_SYMBOL(PRINT_TYPE_FUNC_NAME(tname));
48+
49+
DEFINE_BASIC_PRINT_TYPE_FUNC(u8, u8, "%u")
50+
DEFINE_BASIC_PRINT_TYPE_FUNC(u16, u16, "%u")
51+
DEFINE_BASIC_PRINT_TYPE_FUNC(u32, u32, "%u")
52+
DEFINE_BASIC_PRINT_TYPE_FUNC(u64, u64, "%Lu")
53+
DEFINE_BASIC_PRINT_TYPE_FUNC(s8, s8, "%d")
54+
DEFINE_BASIC_PRINT_TYPE_FUNC(s16, s16, "%d")
55+
DEFINE_BASIC_PRINT_TYPE_FUNC(s32, s32, "%d")
56+
DEFINE_BASIC_PRINT_TYPE_FUNC(s64, s64, "%Ld")
57+
DEFINE_BASIC_PRINT_TYPE_FUNC(x8, u8, "0x%x")
58+
DEFINE_BASIC_PRINT_TYPE_FUNC(x16, u16, "0x%x")
59+
DEFINE_BASIC_PRINT_TYPE_FUNC(x32, u32, "0x%x")
60+
DEFINE_BASIC_PRINT_TYPE_FUNC(x64, u64, "0x%Lx")
5761

5862
/* Print type function for string type */
5963
int PRINT_TYPE_FUNC_NAME(string)(struct trace_seq *s, const char *name,

kernel/trace/trace_probe.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ DECLARE_BASIC_PRINT_TYPE_FUNC(s8);
149149
DECLARE_BASIC_PRINT_TYPE_FUNC(s16);
150150
DECLARE_BASIC_PRINT_TYPE_FUNC(s32);
151151
DECLARE_BASIC_PRINT_TYPE_FUNC(s64);
152+
DECLARE_BASIC_PRINT_TYPE_FUNC(x8);
153+
DECLARE_BASIC_PRINT_TYPE_FUNC(x16);
154+
DECLARE_BASIC_PRINT_TYPE_FUNC(x32);
155+
DECLARE_BASIC_PRINT_TYPE_FUNC(x64);
156+
152157
DECLARE_BASIC_PRINT_TYPE_FUNC(string);
153158

154159
#define FETCH_FUNC_NAME(method, type) fetch_##method##_##type
@@ -203,7 +208,7 @@ DEFINE_FETCH_##method(u32) \
203208
DEFINE_FETCH_##method(u64)
204209

205210
/* Default (unsigned long) fetch type */
206-
#define __DEFAULT_FETCH_TYPE(t) u##t
211+
#define __DEFAULT_FETCH_TYPE(t) x##t
207212
#define _DEFAULT_FETCH_TYPE(t) __DEFAULT_FETCH_TYPE(t)
208213
#define DEFAULT_FETCH_TYPE _DEFAULT_FETCH_TYPE(BITS_PER_LONG)
209214
#define DEFAULT_FETCH_TYPE_STR __stringify(DEFAULT_FETCH_TYPE)
@@ -234,6 +239,10 @@ ASSIGN_FETCH_FUNC(file_offset, ftype), \
234239
#define ASSIGN_FETCH_TYPE(ptype, ftype, sign) \
235240
__ASSIGN_FETCH_TYPE(#ptype, ptype, ftype, sizeof(ftype), sign, #ptype)
236241

242+
/* If ptype is an alias of atype, use this macro (show atype in format) */
243+
#define ASSIGN_FETCH_TYPE_ALIAS(ptype, atype, ftype, sign) \
244+
__ASSIGN_FETCH_TYPE(#ptype, ptype, ftype, sizeof(ftype), sign, #atype)
245+
237246
#define ASSIGN_FETCH_TYPE_END {}
238247

239248
#define FETCH_TYPE_STRING 0

kernel/trace/trace_uprobe.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ static const struct fetch_type uprobes_fetch_type_table[] = {
211211
ASSIGN_FETCH_TYPE(s16, u16, 1),
212212
ASSIGN_FETCH_TYPE(s32, u32, 1),
213213
ASSIGN_FETCH_TYPE(s64, u64, 1),
214+
ASSIGN_FETCH_TYPE_ALIAS(x8, u8, u8, 0),
215+
ASSIGN_FETCH_TYPE_ALIAS(x16, u16, u16, 0),
216+
ASSIGN_FETCH_TYPE_ALIAS(x32, u32, u32, 0),
217+
ASSIGN_FETCH_TYPE_ALIAS(x64, u64, u64, 0),
214218

215219
ASSIGN_FETCH_TYPE_END
216220
};

tools/include/linux/coresight-pmu.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright(C) 2015 Linaro Limited. All rights reserved.
3+
* Author: Mathieu Poirier <[email protected]>
4+
*
5+
* This program is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 as published by
7+
* the Free Software Foundation.
8+
*
9+
* This program is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12+
* more details.
13+
*
14+
* You should have received a copy of the GNU General Public License along with
15+
* this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
#ifndef _LINUX_CORESIGHT_PMU_H
19+
#define _LINUX_CORESIGHT_PMU_H
20+
21+
#define CORESIGHT_ETM_PMU_NAME "cs_etm"
22+
#define CORESIGHT_ETM_PMU_SEED 0x10
23+
24+
/* ETMv3.5/PTM's ETMCR config bit */
25+
#define ETM_OPT_CYCACC 12
26+
#define ETM_OPT_TS 28
27+
28+
static inline int coresight_get_trace_id(int cpu)
29+
{
30+
/*
31+
* A trace ID of value 0 is invalid, so let's start at some
32+
* random value that fits in 7 bits and go from there. Since
33+
* the common convention is to have data trace IDs be I(N) + 1,
34+
* set instruction trace IDs as a function of the CPU number.
35+
*/
36+
return (CORESIGHT_ETM_PMU_SEED + (cpu * 2));
37+
}
38+
39+
#endif

tools/include/linux/string.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ void *memdup(const void *src, size_t len);
88

99
int strtobool(const char *s, bool *res);
1010

11-
#ifdef __GLIBC__
11+
/*
12+
* glibc based builds needs the extern while uClibc doesn't.
13+
* However uClibc headers also define __GLIBC__ hence the hack below
14+
*/
15+
#if defined(__GLIBC__) && !defined(__UCLIBC__)
1216
extern size_t strlcpy(char *dest, const char *src, size_t size);
1317
#endif
1418

tools/include/linux/time64.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef _TOOLS_LINUX_TIME64_H
2+
#define _TOOLS_LINUX_TIME64_H
3+
4+
#define MSEC_PER_SEC 1000L
5+
#define USEC_PER_MSEC 1000L
6+
#define NSEC_PER_USEC 1000L
7+
#define NSEC_PER_MSEC 1000000L
8+
#define USEC_PER_SEC 1000000L
9+
#define NSEC_PER_SEC 1000000000L
10+
#define FSEC_PER_SEC 1000000000000000LL
11+
12+
#endif /* _LINUX_TIME64_H */

tools/perf/Documentation/perf-config.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,10 @@ call-graph.*::
382382
histogram entry. Default is 0 which means no limitation.
383383

384384
report.*::
385+
report.sort_order::
386+
Allows changing the default sort order from "comm,dso,symbol" to
387+
some other default, for instance "sym,dso" may be more fitting for
388+
kernel developers.
385389
report.percent-limit::
386390
This one is mostly the same as call-graph.threshold but works for
387391
histogram entries. Entries having an overhead lower than this

tools/perf/Documentation/perf-probe.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,12 @@ Each probe argument follows below syntax.
176176

177177
'NAME' specifies the name of this argument (optional). You can use the name of local variable, local data structure member (e.g. var->field, var.field2), local array with fixed index (e.g. array[1], var->array[0], var->pointer[2]), or kprobe-tracer argument format (e.g. $retval, %ax, etc). Note that the name of this argument will be set as the last member name if you specify a local data structure member (e.g. field2 for 'var->field1.field2'.)
178178
'$vars' and '$params' special arguments are also available for NAME, '$vars' is expanded to the local variables (including function parameters) which can access at given probe point. '$params' is expanded to only the function parameters.
179-
'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. Currently, basic types (u8/u16/u32/u64/s8/s16/s32/s64), signedness casting (u/s), "string" and bitfield are supported. (see TYPES for detail)
180-
179+
'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo (*). Currently, basic types (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal integers (x/x8/x16/x32/x64), signedness casting (u/s), "string" and bitfield are supported. (see TYPES for detail)
181180
On x86 systems %REG is always the short form of the register: for example %AX. %RAX or %EAX is not valid.
182181

183182
TYPES
184183
-----
185-
Basic types (u8/u16/u32/u64/s8/s16/s32/s64) are integer types. Prefix 's' and 'u' means those types are signed and unsigned respectively. Traced arguments are shown in decimal (signed) or hex (unsigned). You can also use 's' or 'u' to specify only signedness and leave its size auto-detected by perf probe.
184+
Basic types (u8/u16/u32/u64/s8/s16/s32/s64) and hexadecimal integers (x8/x16/x32/x64) are integer types. Prefix 's' and 'u' means those types are signed and unsigned respectively, and 'x' means that is shown in hexadecimal format. Traced arguments are shown in decimal (sNN/uNN) or hex (xNN). You can also use 's' or 'u' to specify only signedness and leave its size auto-detected by perf probe. Moreover, you can use 'x' to explicitly specify to be shown in hexadecimal (the size is also auto-detected).
186185
String type is a special type, which fetches a "null-terminated" string from kernel space. This means it will fail and store NULL if the string container has been paged out. You can specify 'string' type only for the local variable or structure member which is an array of or a pointer to 'char' or 'unsigned char' type.
187186
Bitfield is another special type, which takes 3 parameters, bit-width, bit-offset, and container-size (usually 32). The syntax is;
188187

tools/perf/MANIFEST

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ tools/include/asm-generic/bitops.h
6060
tools/include/linux/atomic.h
6161
tools/include/linux/bitops.h
6262
tools/include/linux/compiler.h
63+
tools/include/linux/coresight-pmu.h
6364
tools/include/linux/filter.h
6465
tools/include/linux/hash.h
6566
tools/include/linux/kernel.h
@@ -77,4 +78,5 @@ tools/include/linux/stringify.h
7778
tools/include/linux/types.h
7879
tools/include/linux/err.h
7980
tools/include/linux/bitmap.h
81+
tools/include/linux/time64.h
8082
tools/arch/*/include/uapi/asm/perf_regs.h

tools/perf/Makefile.perf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ SUBCMD_DIR = $(srctree)/tools/lib/subcmd/
165165
# non-config cases
166166
config := 1
167167

168-
NON_CONFIG_TARGETS := clean TAGS tags cscope help
168+
NON_CONFIG_TARGETS := clean TAGS tags cscope help install-doc
169169

170170
ifdef MAKECMDGOALS
171171
ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),)
@@ -429,6 +429,9 @@ $(PERF_IN): prepare FORCE
429429
@(test -f ../../include/asm-generic/bitops/fls64.h && ( \
430430
(diff -B ../include/asm-generic/bitops/fls64.h ../../include/asm-generic/bitops/fls64.h >/dev/null) \
431431
|| echo "Warning: tools/include/asm-generic/bitops/fls64.h differs from kernel" >&2 )) || true
432+
@(test -f ../../include/linux/coresight-pmu.h && ( \
433+
(diff -B ../include/linux/coresight-pmu.h ../../include/linux/coresight-pmu.h >/dev/null) \
434+
|| echo "Warning: tools/include/linux/coresight-pmu.h differs from kernel" >&2 )) || true
432435
$(Q)$(MAKE) $(build)=perf
433436

434437
$(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(LIBTRACEEVENT_DYNAMIC_LIST)

tools/perf/bench/futex-requeue.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <subcmd/parse-options.h>
1717
#include <linux/compiler.h>
1818
#include <linux/kernel.h>
19+
#include <linux/time64.h>
1920
#include <errno.h>
2021
#include "bench.h"
2122
#include "futex.h"
@@ -62,7 +63,7 @@ static void print_summary(void)
6263
printf("Requeued %d of %d threads in %.4f ms (+-%.2f%%)\n",
6364
requeued_avg,
6465
nthreads,
65-
requeuetime_avg/1e3,
66+
requeuetime_avg / USEC_PER_MSEC,
6667
rel_stddev_stats(requeuetime_stddev, requeuetime_avg));
6768
}
6869

@@ -184,7 +185,7 @@ int bench_futex_requeue(int argc, const char **argv,
184185

185186
if (!silent) {
186187
printf("[Run %d]: Requeued %d of %d threads in %.4f ms\n",
187-
j + 1, nrequeued, nthreads, runtime.tv_usec/1e3);
188+
j + 1, nrequeued, nthreads, runtime.tv_usec / (double)USEC_PER_MSEC);
188189
}
189190

190191
/* everybody should be blocked on futex2, wake'em up */

tools/perf/bench/futex-wake-parallel.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <subcmd/parse-options.h>
1616
#include <linux/compiler.h>
1717
#include <linux/kernel.h>
18+
#include <linux/time64.h>
1819
#include <errno.h>
1920
#include "bench.h"
2021
#include "futex.h"
@@ -156,7 +157,7 @@ static void print_run(struct thread_data *waking_worker, unsigned int run_num)
156157

157158
printf("[Run %d]: Avg per-thread latency (waking %d/%d threads) "
158159
"in %.4f ms (+-%.2f%%)\n", run_num + 1, wakeup_avg,
159-
nblocked_threads, waketime_avg/1e3,
160+
nblocked_threads, waketime_avg / USEC_PER_MSEC,
160161
rel_stddev_stats(waketime_stddev, waketime_avg));
161162
}
162163

@@ -172,7 +173,7 @@ static void print_summary(void)
172173
printf("Avg per-thread latency (waking %d/%d threads) in %.4f ms (+-%.2f%%)\n",
173174
wakeup_avg,
174175
nblocked_threads,
175-
waketime_avg/1e3,
176+
waketime_avg / USEC_PER_MSEC,
176177
rel_stddev_stats(waketime_stddev, waketime_avg));
177178
}
178179

tools/perf/bench/futex-wake.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <subcmd/parse-options.h>
1717
#include <linux/compiler.h>
1818
#include <linux/kernel.h>
19+
#include <linux/time64.h>
1920
#include <errno.h>
2021
#include "bench.h"
2122
#include "futex.h"
@@ -81,7 +82,7 @@ static void print_summary(void)
8182
printf("Wokeup %d of %d threads in %.4f ms (+-%.2f%%)\n",
8283
wakeup_avg,
8384
nthreads,
84-
waketime_avg/1e3,
85+
waketime_avg / USEC_PER_MSEC,
8586
rel_stddev_stats(waketime_stddev, waketime_avg));
8687
}
8788

@@ -182,7 +183,7 @@ int bench_futex_wake(int argc, const char **argv,
182183

183184
if (!silent) {
184185
printf("[Run %d]: Wokeup %d of %d threads in %.4f ms\n",
185-
j + 1, nwoken, nthreads, runtime.tv_usec/1e3);
186+
j + 1, nwoken, nthreads, runtime.tv_usec / (double)USEC_PER_MSEC);
186187
}
187188

188189
for (i = 0; i < nthreads; i++) {

tools/perf/bench/mem-functions.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <string.h>
2222
#include <sys/time.h>
2323
#include <errno.h>
24+
#include <linux/time64.h>
2425

2526
#define K 1024
2627

@@ -89,7 +90,7 @@ static u64 get_cycles(void)
8990

9091
static double timeval2double(struct timeval *ts)
9192
{
92-
return (double)ts->tv_sec + (double)ts->tv_usec / (double)1000000;
93+
return (double)ts->tv_sec + (double)ts->tv_usec / (double)USEC_PER_SEC;
9394
}
9495

9596
#define print_bps(x) do { \

0 commit comments

Comments
 (0)