public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Robert Richter <robert.richter@amd.com>
To: Matt Fleming <matt@console-pimps.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Will Deacon <will.deacon@arm.com>,
	Paul Mundt <lethal@linux-sh.org>,
	Russell King <linux@arm.linux.org.uk>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"linux-sh@vger.kernel.org" <linux-sh@vger.kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@elte.hu>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>
Subject: Re: [PATCH V2 4/4] sh: Use the perf-events backend for oprofile
Date: Tue, 31 Aug 2010 15:26:51 +0200	[thread overview]
Message-ID: <20100831132651.GG22783@erda.amd.com> (raw)
In-Reply-To: <20100831122343.GB27532@console-pimps.org>

On 31.08.10 08:23:43, Matt Fleming wrote:
> > > > > -static int op_sh_start(void)
> > > > > +static char *op_name_from_perf_name(const char *name)
> > > > >  {
> > > > > -	/* Enable performance monitoring for all counters.  */
> > > > > -	on_each_cpu(model->cpu_start, NULL, 1);
> > > > > +	if (!strcmp(name, "SH-4A"))
> > > > > +		return "sh/sh4a";
> > > > > +	if (!strcmp(name, "SH7750"))
> > > > > +		return "sh/sh7750";
> > > > 
> > > > With that implementation we always have to touch the code for new
> > > > cpus. Maybe we derive it from the perf name, e.g. making all lowercase
> > > > and removing dashes?
> > > 
> > > Is this code really that bad that we need to start playing string
> > > manipulation games?
> > 
> > No, but with that implementation we always have to update the cpu
> > string with each new cpu though nothing else changes. We may keep this
> > code. But, shouldn't we return a default string "sh/<name>" for all
> > other cases? We will then need to update only the oprofile userland
> > with new cpus.
> 
> These names are actually the names of types of performance counters,
> not a specific cpu. All SH-4 cpus that have performance counters have
> 7750-style performance counters and all SH-4A cpus have SH-4A-style
> counters.
> 
> It's unlikely we'd have to update this code in the near future. Paul,
> correct me if I'm wrong here.

Ok, this shouldn't block this patch series, we still can make a patch
if there is a use case.

> > > > > +	ops->setup		= oprofile_perf_setup;
> > > > > +	ops->create_files	= oprofile_perf_create_files;
> > > > > +	ops->start		= oprofile_perf_start;
> > > > > +	ops->stop		= oprofile_perf_stop;
> > > > > +	ops->cpu_type		= op_name_from_perf_name(sh_pmu_name());
> > > > >  
> > > > > -	model = lmodel;
> > > > > +	oprofile_perf_set_num_counters(sh_pmu_num_events());
> > > > >  
> > > > > -	ops->setup		= op_sh_setup;
> > > > > -	ops->create_files	= op_sh_create_files;
> > > > > -	ops->start		= op_sh_start;
> > > > > -	ops->stop		= op_sh_stop;
> > > > > -	ops->cpu_type		= lmodel->cpu_type;
> > > > > +	ret = oprofile_perf_init();
> > > > 
> > > > Instead of exporting all the functions above implement something like:
> > > > 
> > > > 	name = op_name_from_perf_name(sh_pmu_name());
> > > > 	num_events = sh_pmu_num_events();
> > > > 	ret = oprofile_perf_init(ops, name, num_events);
> > > > 
> > > > We will then have only oprofile_perf_init() and oprofile_perf_exit()
> > > > as interface which is much cleaner.
> > > 
> > > Well, the reason that I left it this way is so that architectures can
> > > choose to implement wrappers around the oprofile_perf_* functions. I
> > > don't think ARM or SH actually need wrappers (the only extra thing that
> > > ARM does is locking which SH should probably do too) but I assumed there
> > > was a reason that these functions pointers were exposed originally. I
> > > haven't look at what other architectures would do. I'll take a look at
> > > that.
> > 
> > I am not sure if we need such wrappers, and if so we could implement
> > it anyway, e.g.:
> > 
> >  oprofile_perf_init(perf_ops, name, num_events);
> > 
> >  op_sh_setup():
> > 
> > 	/* setup something */
> > 	...
> > 
> > 	perf_ops->setup();
> > 
> > 	/* setup more */
> > 	...
> > 
> > But I don't think we need this. And the above makes the interface much
> > cleaner.
> 
> OK, seeing as the two architectures that will use this initially don't
> require wrappers I've no problem doing it your way. It can always be
> extended later if necessary. And more importantly, with a proper
> usecase we'll be able to see exactly _how_ it needs to be extended.

Yes, right. So I am looking forward to your new version.

Thanks,

-Robert

-- 
Advanced Micro Devices, Inc.
Operating System Research Center


  reply	other threads:[~2010-08-31 13:33 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-26 19:09 [PATCH V2 0/4] Generalise ARM perf-events backend for oprofile Matt Fleming
2010-08-26 19:09 ` [PATCH 1/4] oprofile: Handle initialisation failure more gracefully Matt Fleming
2010-08-27 12:43   ` Robert Richter
2010-08-27 15:15     ` Will Deacon
2010-08-27 16:38       ` Robert Richter
2010-08-27 18:06         ` Will Deacon
2010-08-27 19:47           ` Robert Richter
2010-08-26 19:09 ` [PATCH 2/4] sh: Accessor functions for the sh_pmu state Matt Fleming
2010-08-27 13:43   ` Robert Richter
2010-08-27 19:17     ` Matt Fleming
2010-08-30 12:41       ` Robert Richter
2010-08-26 19:09 ` [PATCH V2 3/4] oprofile: Abstract the perf-events backend Matt Fleming
2010-08-27 10:41   ` Will Deacon
2010-08-27 12:44     ` Matt Fleming
2010-08-27 12:59   ` Robert Richter
2010-08-27 14:31   ` Robert Richter
2010-08-26 19:09 ` [PATCH V2 4/4] sh: Use the perf-events backend for oprofile Matt Fleming
2010-08-27 14:59   ` Robert Richter
2010-08-27 20:19     ` Matt Fleming
2010-08-31 11:28       ` Robert Richter
2010-08-31 12:23         ` Matt Fleming
2010-08-31 13:26           ` Robert Richter [this message]
2010-08-31 11:05 ` [PATCH V2 0/4] Generalise ARM " Robert Richter
2010-08-31 11:25   ` Matt Fleming

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=20100831132651.GG22783@erda.amd.com \
    --to=robert.richter@amd.com \
    --cc=acme@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=lethal@linux-sh.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=matt@console-pimps.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=will.deacon@arm.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