lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110721081531.GI9216@elte.hu>
Date:	Thu, 21 Jul 2011 10:15:31 +0200
From:	Ingo Molnar <mingo@...e.hu>
To:	Cyrill Gorcunov <gorcunov@...il.com>
Cc:	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Don Zickus <dzickus@...hat.com>,
	LKML <linux-kernel@...r.kernel.org>,
	Stephane Eranian <eranian@...gle.com>,
	Lin Ming <ming.m.lin@...el.com>,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Steven Rostedt <rostedt@...dmis.org>
Subject: Re: [PATCH -tip/perf/core] perf, x86: P4 PMU - Introduce event alias
 feature


* Cyrill Gorcunov <gorcunov@...il.com> wrote:

> On Thu, Jul 21, 2011 at 09:52:01AM +0200, Ingo Molnar wrote:
> > 
> > * Cyrill Gorcunov <gorcunov@...il.com> wrote:
> > 
> > > > > +static u64 p4_get_alias_event(u64 config)
> > > > > +{
> > > > > +	u64 config_match;
> > > > > +	int i;
> > > > > +
> > > > > +	/*
> > > > > +	 * Probably we're lucky and don't have to do
> > > > > +	 * matching over all config bits.
> > > > > +	 */
> > > > > +	if (!(config & P4_CONFIG_ALIASABLE))
> > > > > +		return 0;
> > > > 
> > > > 'all' config bits? There's a single alias mapping in 
> > > > p4_event_aliases[] right now which makes the comment rather 
> > > > misleading ...
> > > 
> > > no, the cycle below does check for all bits in config, and test
> > > for single bit might help us to return early.
> > 
> > The loop below? AFAICS it does:
> > 
> > > > > +	 */
> > > > > +	for (i = 0; i < ARRAY_SIZE(p4_event_aliases); i++) {
> > > > > +		if (config_match == p4_event_aliases[i].orig) {
> > > > > +			config_match = p4_event_aliases[i].alter;
> > > > > +			break;
> > > > > +		} else if (config_match == p4_event_aliases[i].alter) {
> > > > > +			config_match = p4_event_aliases[i].orig;
> > > > > +			break;
> > > > > +		}
> > > > > +	}
> > 
> > and p4_event_aliases[] is a single-entry array, so ARRAY_SIZE() is 1 
> > and this loop iterates once.
> 
> I know, but Ingo, I can't guarantee that we'll never bring some new
> alias(es) later ;) [...]

in which 'later' case that check and the comment can be added or 
updated ...

Right now it looks both somewhat pointless *and* the comment is 
somewhat misleading. You could fix the comment, pointing out that 
right now it's only a single entry but it's still a 
micro-optimization.

and if there's more entries in the future the comment can be updated.

> > > > Since this .c file is P4 specific and p4_event_aliases[] is a 
> > > > file-scope array, is the p4_ prefix even needed?
> > > 
> > > I prefer them to be distinguished this way, since the .c file in 
> > > real is included into another (perf_event.c) file.
> > 
> > That should probably be fixed btw. - but yeah, until the PMU drivers 
> > are separated out better the prefix is fine.
> 
> I thought about adding some additional Kconfig where we would 
> choose which PMU to compile in, not sure though where is the best 
> place for it (under which menu section I mean).

No need for any additional Kconfig for that, we could just build them 
as separate .o's.

Thanks,

	Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ