mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Du, Changbin" <changbin.du@intel.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>,
	"Du, Changbin" <changbin.du@intel.com>,
	acme@kernel.org, peterz@infradead.org, mingo@redhat.com,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	kernel-team@lge.com
Subject: Re: [RESEND PATCH] perf sched map: re-annotate shortname if thread comm changed
Date: Mon, 5 Mar 2018 15:11:36 +0800	[thread overview]
Message-ID: <20180305071136.qs3lsoh432mzbizw@intel.com> (raw)
In-Reply-To: <20180302144732.GA2471@danjae.aot.lge.com>

Hi,
On Fri, Mar 02, 2018 at 11:47:32PM +0900, Namhyung Kim wrote:
> Hi,
> 
> On Fri, Mar 02, 2018 at 12:38:45PM +0100, Jiri Olsa wrote:
> > On Fri, Mar 02, 2018 at 06:52:54PM +0800, Du, Changbin wrote:
> > > Hello, any comment?
> > 
> > sry, overlooked this one
> > 
> > SNIP
> > 
> > > > diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
> > > > index 68b65b1..c660fe6 100644
> > > > --- a/tools/perf/util/thread.c
> > > > +++ b/tools/perf/util/thread.c
> > > > @@ -212,6 +212,7 @@ static int ____thread__set_comm(struct thread *thread, const char *str,
> > > >  			unwind__flush_access(thread);
> > > >  	}
> > > >  
> > > > +	thread->comm_changed = true;
> > > >  	thread->comm_set = true;
> > > >  
> > > >  	return 0;
> > > > diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
> > > > index 40cfa36..b9a328b 100644
> > > > --- a/tools/perf/util/thread.h
> > > > +++ b/tools/perf/util/thread.h
> > > > @@ -27,6 +27,7 @@ struct thread {
> > > >  	int			cpu;
> > > >  	refcount_t		refcnt;
> > > >  	char			shortname[3];
> > > > +	bool			comm_changed;
> > 
> > I don't like that it's in struct thread and set by generic function,
> > and just one command (sched) checks/sets it back.. I'd rather see it
> > in thread::priv area..
> 
> 100% agreed.
> 
> 
> > on the other hand it's simple enough and looks
> > like generic solution would be more tricky
> 
> What about adding perf_sched__process_comm() to set it in the
> thread::priv?
>
I can be done, then thread->comm_changed moves to thread_runtime->comm_changed.
Draft code as below. It is also a little tricky.

+int perf_sched__process_comm(struct perf_tool *tool __maybe_unused,
+                            union perf_event *event,
+                            struct perf_sample *sample,
+                            struct machine *machine)
+{
+       struct thread *thread;
+       struct thread_runtime *r;
+
+       perf_event__process_comm(tool, event, sample, machine);
+
+       thread = machine__findnew_thread(machine, pid, tid);
+       if (thread) {
+               r = thread__priv(thread);
+               if (r)
+                       r->comm_changed = true;
+               thread__put(thread);
+       }
+}
+
 static int perf_sched__read_events(struct perf_sched *sched)
 {
        const struct perf_evsel_str_handler handlers[] = {
@@ -3291,7 +3311,7 @@ int cmd_sched(int argc, const char **argv)
        struct perf_sched sched = {
                .tool = {
                        .sample          = perf_sched__process_tracepoint_sample,
-                       .comm            = perf_event__process_comm,
+                       .comm            = perf_sched__process_comm,


But I'd keep 'comm_changed' where 'shortname' is defined. I think they should appears
togother. And 'shortname' is only used by sched command, too.

So I still prefer my privous simpler change. Thanks!

> Thanks,
> Namhyung

-- 
Thanks,
Changbin Du

  reply	other threads:[~2018-03-05  7:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-23 11:40 changbin.du
2018-03-02 10:52 ` Du, Changbin
2018-03-02 11:38   ` Jiri Olsa
2018-03-02 14:47     ` Namhyung Kim
2018-03-05  7:11       ` Du, Changbin [this message]
2018-03-05 22:37         ` Jiri Olsa
2018-03-05 23:16           ` Namhyung Kim
2018-03-06  3:33           ` Du, Changbin
2018-03-02 14:43 ` Arnaldo Carvalho de Melo
2018-03-05  7:14   ` Du, Changbin

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=20180305071136.qs3lsoh432mzbizw@intel.com \
    --to=changbin.du@intel.com \
    --cc=acme@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=kernel-team@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome