All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: acme@ghostprotocols.net, linux-kernel@vger.kernel.org,
	Ingo Molnar <mingo@kernel.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Mike Galbraith <efault@gmx.de>, Jiri Olsa <jolsa@redhat.com>,
	Stephane Eranian <eranian@google.com>,
	Pekka Enberg <penberg@kernel.org>
Subject: Re: [PATCH 6/8] perf sched: Introduce timehist command
Date: Thu, 28 Nov 2013 09:01:00 -0700	[thread overview]
Message-ID: <529768BC.2090604@gmail.com> (raw)
In-Reply-To: <87siugq2hr.fsf@sejong.aot.lge.com>

On 11/28/13, 2:50 AM, Namhyung Kim wrote:
>> +static inline void printf_nsecs(unsigned long long nsecs, int width_sec)
>> >+{
>> >+	unsigned long secs;
>> >+	unsigned long usecs;
>> >+
>> >+	secs = nsecs / NSECS_PER_SEC;
>> >+	nsecs -= secs * NSECS_PER_SEC;
>> >+	usecs = nsecs / NSECS_PER_USEC;
>> >+	printf("%*lu.%06lu ", width_sec, secs, usecs);
>> >+}
> It seems very similar to what timehist_time_str() does.  Better to
> factor out?

yes and no. The above is used to dump time-based stats (time between 
sched-in events, scheduling delay, and run time).

What I really want for timehist_time_str is time-of-day. And in local 
variants of this code I have that. Until I can convince Peter, et al. 
about the real need to pull perf_clock into userspace this is a bit of a 
place holder so that local code and this version do not differ too much.

>
>
> [SNIP]
>> >+static unsigned int comm_width = 20;
>> >+
>> >+static char *timehist_get_commstr(struct thread *thread)
>> >+{
>> >+	static char str[32];
>> >+	const char *comm = thread__comm_str(thread);
>> >+	pid_t tid = thread->tid;
>> >+	pid_t pid = thread->pid_;
>> >+	unsigned int n;
>> >+
>> >+	if (pid == 0)
>> >+		scnprintf(str, sizeof(str), "%s", comm);
>> >+
>> >+	else if (tid != pid)
>> >+		scnprintf(str, sizeof(str), "%s[%d/%d]", comm, tid, pid);
>> >+
>> >+	else
>> >+		scnprintf(str, sizeof(str), "%s[%d]", comm, tid);
>> >+
>> >+	n = strlen(str);
> Why not just using return value of scnprintf()?

right. will do.

>
>
>> >+	if (n > comm_width)
>> >+		comm_width = n;
>> >+
>> >+	return str;
>> >+}
>> >+
>> >+static void timehist_header(struct perf_sched *sched)
>> >+{
>> >+	u32 max_cpus = sched->max_cpu;
>> >+	u32 i, j;
>> >+
>> >+	printf("%15s %-4s", "time", "cpu");
>> >+
>> >+	if (sched->show_cpu_visual && max_cpus) {
>> >+		printf(" ");
>> >+		for (i = 0, j = 0; i < max_cpus; ++i) {
>> >+			printf("%x", j++);
>> >+			if (j > 15)
>> >+				j = 0;
>> >+		}
>> >+		printf(" ");
>> >+	}
>> >+
>> >+	printf(" %-20s %9s %9s %9s",
>> >+		"task name[tid/pid]", "b/n time", "sch delay", "run time");
>> >+
>> >+	if (sched->show_wakeups)
>> >+		printf("  %-20s", "wakeup");
>> >+
>> >+	printf("\n");
>> >+
>> >+	printf("%15s %4s", "---------------", "----");
> You might want to use "%.15s" and graph_dotted_line.

did not know about that. will update.


>> >+static void timehist_print_sample(struct perf_sched *sched,
>> >+				  union perf_event *event,
>> >+				  struct perf_evsel *evsel,
>> >+				  struct perf_sample *sample,
>> >+				  struct thread *thread,
>> >+				  struct machine *machine)
>> >+{
>> >+	struct thread_runtime *tr = thread__priv(thread);
>> >+	char tstr[64];
>> >+	u32 max_cpus = sched->max_cpu;
>> >+
>> >+	printf("%15s ", timehist_time_str(tstr, sizeof(tstr), sample->time));
>> >+
>> >+	printf("[%02d] ", sample->cpu);
>> >+
>> >+	if (sched->show_cpu_visual && max_cpus) {
>> >+		u32 i;
>> >+		char c;
>> >+		for (i = 0; i < max_cpus; ++i) {
>> >+			if (i == sample->cpu)
>> >+				c = (thread->tid == 0) ? 'i' : 's';
> It'd better explaining what the 'i' and 's' mean..

visual aid: i = idle, s = sched-event. will add a comment.

>> >+static void free_idle_threads(void)
>> >+{
>> >+	int i;
>> >+
>> >+	if (idle_threads == NULL)
>> >+		return;
>> >+
>> >+	for (i = 0; i <= idle_max_cpu; ++i)
>> >+		free(idle_threads[i]);
> Doesn't it need to be thread__delete(idle_threads[i]) ?

yes. forgot to update this to the new api.

David


  reply	other threads:[~2013-11-28 16:01 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-18 20:32 [PATCH 0/8] perf: sched timehist command David Ahern
2013-11-18 20:32 ` [PATCH 1/8] perf tool: Skip ignored symbols while printing callchain David Ahern
2013-11-30 12:52   ` [tip:perf/core] perf evsel: " tip-bot for David Ahern
2013-11-18 20:32 ` [PATCH 2/8] perf symbols: Move idle syms check from top to generic function David Ahern
2013-11-28  8:36   ` Namhyung Kim
2013-11-30 15:58     ` David Ahern
2013-11-30 12:52   ` [tip:perf/core] " tip-bot for David Ahern
2013-11-18 20:32 ` [PATCH 3/8] perf symbol: Save vmlinux or kallsyms path loaded David Ahern
2013-11-22 18:44   ` Arnaldo Carvalho de Melo
2013-11-22 19:13     ` David Ahern
2013-11-22 19:40       ` Arnaldo Carvalho de Melo
2013-11-22 20:09         ` David Ahern
2013-11-18 20:32 ` [PATCH 4/8] perf thread: Move comm_list check into function David Ahern
2013-11-30 12:52   ` [tip:perf/core] " tip-bot for David Ahern
2013-11-18 20:32 ` [PATCH 5/8] perf tool: export setup_list David Ahern
2013-11-28  8:45   ` Namhyung Kim
2013-11-30 12:52   ` [tip:perf/core] perf tools: Export setup_list tip-bot for David Ahern
2013-11-18 20:32 ` [PATCH 6/8] perf sched: Introduce timehist command David Ahern
2013-11-28  9:50   ` Namhyung Kim
2013-11-28 16:01     ` David Ahern [this message]
2013-11-28 15:38   ` Namhyung Kim
2013-11-28 16:01     ` David Ahern
2013-11-29  0:48       ` Namhyung Kim
2013-11-29  1:58         ` David Ahern
2013-12-04  4:15           ` David Ahern
2013-11-18 20:32 ` [PATCH 7/8] perf sched timehist: Add support for context-switch event David Ahern
2013-11-18 20:32 ` [PATCH 8/8] perf sched : Add documentation for timehist options David Ahern
2013-11-28 15:42   ` Namhyung Kim

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=529768BC.2090604@gmail.com \
    --to=dsahern@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=efault@gmx.de \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=penberg@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.