linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Wang Nan <wangnan0@huawei.com>
Subject: [PATCH 03/35] perf sched: Use linux/time64.h
Date: Tue, 23 Aug 2016 18:03:04 -0300	[thread overview]
Message-ID: <1471986216-18390-4-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1471986216-18390-1-git-send-email-acme@kernel.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

Probably the next step is to introduce linux/time.h and use
timespec_to_ns(), etc.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-4nqhskn27fn93cz3ukbc8drf@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-sched.c | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 0dfe8df2ab9b..f5503ca22e1c 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -26,6 +26,7 @@
 #include <pthread.h>
 #include <math.h>
 #include <api/fs/fs.h>
+#include <linux/time64.h>
 
 #define PR_SET_NAME		15               /* Set process name */
 #define MAX_CPUS		4096
@@ -199,7 +200,7 @@ static u64 get_nsecs(void)
 
 	clock_gettime(CLOCK_MONOTONIC, &ts);
 
-	return ts.tv_sec * 1000000000ULL + ts.tv_nsec;
+	return ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec;
 }
 
 static void burn_nsecs(struct perf_sched *sched, u64 nsecs)
@@ -223,7 +224,7 @@ static void sleep_nsecs(u64 nsecs)
 
 static void calibrate_run_measurement_overhead(struct perf_sched *sched)
 {
-	u64 T0, T1, delta, min_delta = 1000000000ULL;
+	u64 T0, T1, delta, min_delta = NSEC_PER_SEC;
 	int i;
 
 	for (i = 0; i < 10; i++) {
@@ -240,7 +241,7 @@ static void calibrate_run_measurement_overhead(struct perf_sched *sched)
 
 static void calibrate_sleep_measurement_overhead(struct perf_sched *sched)
 {
-	u64 T0, T1, delta, min_delta = 1000000000ULL;
+	u64 T0, T1, delta, min_delta = NSEC_PER_SEC;
 	int i;
 
 	for (i = 0; i < 10; i++) {
@@ -452,8 +453,8 @@ static u64 get_cpu_usage_nsec_parent(void)
 	err = getrusage(RUSAGE_SELF, &ru);
 	BUG_ON(err);
 
-	sum =  ru.ru_utime.tv_sec*1e9 + ru.ru_utime.tv_usec*1e3;
-	sum += ru.ru_stime.tv_sec*1e9 + ru.ru_stime.tv_usec*1e3;
+	sum =  ru.ru_utime.tv_sec * NSEC_PER_SEC + ru.ru_utime.tv_usec * NSEC_PER_USEC;
+	sum += ru.ru_stime.tv_sec * NSEC_PER_SEC + ru.ru_stime.tv_usec * NSEC_PER_USEC;
 
 	return sum;
 }
@@ -667,12 +668,12 @@ static void run_one_test(struct perf_sched *sched)
 		sched->run_avg = delta;
 	sched->run_avg = (sched->run_avg * (sched->replay_repeat - 1) + delta) / sched->replay_repeat;
 
-	printf("#%-3ld: %0.3f, ", sched->nr_runs, (double)delta / 1000000.0);
+	printf("#%-3ld: %0.3f, ", sched->nr_runs, (double)delta / NSEC_PER_MSEC);
 
-	printf("ravg: %0.2f, ", (double)sched->run_avg / 1e6);
+	printf("ravg: %0.2f, ", (double)sched->run_avg / NSEC_PER_MSEC);
 
 	printf("cpu: %0.2f / %0.2f",
-		(double)sched->cpu_usage / 1e6, (double)sched->runavg_cpu_usage / 1e6);
+		(double)sched->cpu_usage / NSEC_PER_MSEC, (double)sched->runavg_cpu_usage / NSEC_PER_MSEC);
 
 #if 0
 	/*
@@ -680,8 +681,8 @@ static void run_one_test(struct perf_sched *sched)
 	 * accurate than the sched->sum_exec_runtime based statistics:
 	 */
 	printf(" [%0.2f / %0.2f]",
-		(double)sched->parent_cpu_usage/1e6,
-		(double)sched->runavg_parent_cpu_usage/1e6);
+		(double)sched->parent_cpu_usage / NSEC_PER_MSEC,
+		(double)sched->runavg_parent_cpu_usage / NSEC_PER_MSEC);
 #endif
 
 	printf("\n");
@@ -696,13 +697,13 @@ static void test_calibrations(struct perf_sched *sched)
 	u64 T0, T1;
 
 	T0 = get_nsecs();
-	burn_nsecs(sched, 1e6);
+	burn_nsecs(sched, NSEC_PER_MSEC);
 	T1 = get_nsecs();
 
 	printf("the run test took %" PRIu64 " nsecs\n", T1 - T0);
 
 	T0 = get_nsecs();
-	sleep_nsecs(1e6);
+	sleep_nsecs(NSEC_PER_MSEC);
 	T1 = get_nsecs();
 
 	printf("the sleep test took %" PRIu64 " nsecs\n", T1 - T0);
@@ -1213,10 +1214,10 @@ static void output_lat_thread(struct perf_sched *sched, struct work_atoms *work_
 	avg = work_list->total_lat / work_list->nb_atoms;
 
 	printf("|%11.3f ms |%9" PRIu64 " | avg:%9.3f ms | max:%9.3f ms | max at: %13.6f s\n",
-	      (double)work_list->total_runtime / 1e6,
-		 work_list->nb_atoms, (double)avg / 1e6,
-		 (double)work_list->max_lat / 1e6,
-		 (double)work_list->max_lat_at / 1e9);
+	      (double)work_list->total_runtime / NSEC_PER_MSEC,
+		 work_list->nb_atoms, (double)avg / NSEC_PER_MSEC,
+		 (double)work_list->max_lat / NSEC_PER_MSEC,
+		 (double)work_list->max_lat_at / NSEC_PER_SEC);
 }
 
 static int pid_cmp(struct work_atoms *l, struct work_atoms *r)
@@ -1491,7 +1492,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,
 	if (sched->map.cpus && !cpu_map__has(sched->map.cpus, this_cpu))
 		goto out;
 
-	color_fprintf(stdout, color, "  %12.6f secs ", (double)timestamp/1e9);
+	color_fprintf(stdout, color, "  %12.6f secs ", (double)timestamp / NSEC_PER_SEC);
 	if (new_shortname) {
 		const char *pid_color = color;
 
@@ -1753,7 +1754,7 @@ static int perf_sched__lat(struct perf_sched *sched)
 
 	printf(" -----------------------------------------------------------------------------------------------------------------\n");
 	printf("  TOTAL:                |%11.3f ms |%9" PRIu64 " |\n",
-		(double)sched->all_runtime / 1e6, sched->all_count);
+		(double)sched->all_runtime / NSEC_PER_MSEC, sched->all_count);
 
 	printf(" ---------------------------------------------------\n");
 
-- 
2.7.4

  parent reply	other threads:[~2016-08-23 22:53 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-23 21:03 [GIT PULL 00/35] perf/core improvements and fixes Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 01/35] tools: Introduce tools/include/linux/time64.h for *SEC_PER_*SEC macros Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 02/35] perf bench numa: Use NSEC_PER_U?SEC Arnaldo Carvalho de Melo
2016-08-23 21:03 ` Arnaldo Carvalho de Melo [this message]
2016-08-23 21:03 ` [PATCH 04/35] perf timechart: " Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 05/35] perf bench sched-pipe: Use linux/time64.h, USEC_PER_SEC Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 06/35] perf stat: Use *SEC_PER_*SEC macros Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 07/35] perf bench mem: Use USEC_PER_SEC Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 08/35] perf bench sched-messaging: Use USEC_PER_MSEC Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 09/35] perf record: " Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 10/35] perf kvm: Use NSEC_PER_USEC Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 11/35] perf bench futex: " Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 12/35] perf top: Use MSEC_PER_SEC Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 13/35] perf hists: Introduce nr_header_lines into struct perf_hpp_list Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 14/35] perf hists: Add line argument into perf_hpp_fmt's header callback Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 15/35] perf tools tui: Display multiple header lines Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 16/35] perf tools stdio: " Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 17/35] perf hists: Add support for header span Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 18/35] perf disassemble: Move check for kallsyms + !kcore Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 19/35] perf disassemble: Simplify logic for picking the filename to disassemble Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 20/35] perf disassemble: Extract logic to find file to pass to objdump to a separate function Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 21/35] tools: Copy coresight-pmu.h header file needed by perf tools Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 22/35] perf report: Allow configuring the default sort order in ~/.perfconfig Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 23/35] perf tools: Use __weak definition from linux/compiler.h Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 24/35] perf tools: Skip running the feature tests for 'make install-doc' Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 25/35] perf hists browser: Remove superfluous null check on map Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 26/35] ftrace: kprobe: uprobe: Add x8/x16/x32/x64 for hexadecimal types Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 27/35] ftrace: probe: Add README entries for k/uprobe-events Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 28/35] perf probe: Add supported for type casting by the running kernel Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 29/35] perf probe: Support hexadecimal casting Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 30/35] perf probe: Use hexadecimal type by default if possible Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 31/35] ftrace: kprobe: uprobe: Show u8/u16/u32/u64 types in decimal Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 32/35] perf tools: Fix typo: "ehough" -> "enough" Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 33/35] perf test bpf: " Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 34/35] perf " Arnaldo Carvalho de Melo
2016-08-23 21:03 ` [PATCH 35/35] perf record: Fix spelling mistake "Finshed" -> "Finished" Arnaldo Carvalho de Melo
2016-08-24  9:09 ` [GIT PULL 00/35] perf/core improvements and fixes Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1471986216-18390-4-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=wangnan0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).