[PATCH 2/2] perf tools: use *SEC_PER_*SEC macros

From: Emmanouil Maroudas
Date: Sun Jun 28 2020 - 19:44:08 EST


builtin-stat.c: typecast macro to u64
see commit ea9eb1f456a0 ("perf stat: Fix duration_time value for higher intervals")

No functional change intended.

Signed-off-by: Emmanouil Maroudas <emmanouil.maroudas@xxxxxxxxx>
---
tools/perf/builtin-record.c | 2 +-
tools/perf/builtin-stat.c | 4 ++--
tools/perf/builtin-trace.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index e108d90ae2ed..c3c7823966bc 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -249,7 +249,7 @@ static int record__aio_sync(struct mmap *md, bool sync_all)
{
struct aiocb **aiocb = md->aio.aiocb;
struct aiocb *cblocks = md->aio.cblocks;
- struct timespec timeout = { 0, 1000 * 1000 * 1 }; /* 1ms */
+ struct timespec timeout = { 0, NSEC_PER_MSEC * 1 }; /* 1ms */
int i, do_suspend;

do {
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 6aa866e2d512..2f4fe1aee865 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -305,7 +305,7 @@ static int read_single_counter(struct evsel *counter, int cpu,
int thread, struct timespec *rs)
{
if (counter->tool_event == PERF_TOOL_DURATION_TIME) {
- u64 val = rs->tv_nsec + rs->tv_sec*1000000000ULL;
+ u64 val = rs->tv_nsec + rs->tv_sec*(u64)NSEC_PER_SEC;
struct perf_counts_values *count =
perf_counts(counter->counts, cpu, thread);
count->ena = count->run = val;
@@ -471,7 +471,7 @@ static void process_interval(void)
}

init_stats(&walltime_nsecs_stats);
- update_stats(&walltime_nsecs_stats, stat_config.interval * 1000000ULL);
+ update_stats(&walltime_nsecs_stats, stat_config.interval * (u64)NSEC_PER_MSEC);
print_counters(&rs, 0, NULL);
}

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 4cbb64edc998..db0a2369e2f2 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -4043,7 +4043,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
perf_evlist__start_workload(evlist);

if (trace->opts.initial_delay) {
- usleep(trace->opts.initial_delay * 1000);
+ usleep(trace->opts.initial_delay * USEC_PER_MSEC);
evlist__enable(evlist);
}

--
2.17.1