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]
Date:	Thu, 13 Nov 2014 17:08:33 -0300
From:	Arnaldo Carvalho de Melo <acme@...nel.org>
To:	Andi Kleen <andi@...stfloor.org>
Cc:	jolsa@...hat.com, linux-kernel@...r.kernel.org,
	namhyung@...nel.org, Andi Kleen <ak@...ux.intel.com>
Subject: Re: [PATCH 02/10] perf, tools: Support handling complete branch
 stacks as histograms

Em Thu, Nov 13, 2014 at 08:52:08PM +0100, Andi Kleen escreveu:
> On Thu, Nov 13, 2014 at 04:14:17PM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Wed, Nov 12, 2014 at 06:05:20PM -0800, Andi Kleen escreveu:
> > > +static int remove_loops(struct branch_entry *l, int nr)
> > > +{
> > > +	int i, j, off;
> > > +	unsigned char chash[CHASHSZ];
> > > +
> > > +	memset(chash, NO_ENTRY, sizeof(chash));
> > > +
> > > +	BUG_ON(nr >= 256);
> > 
> > What is wrong with return -1 and propagating the error, so that the user
> > is informed if the data being processed is bogus, stop processing with a
> > warning or continue processing if finding the next valid record is
> > possible?
> 
> The error doesn't depend on the record. There is a check for the record
> being < 127 in front of this. This is merely to catch that 
> if someone increases PERF_MAX_BRANCH_DEPTH to below 255 they need
> to increase the type of the hash table from u8.

Ok, so this would be better as a BUILD_BUG_ON? 

Like:

#define CHASHSZ 127
#define CHASHBITS 7
#define NO_ENTRY 0xff

#define PERF_MAX_BRANCH_DEPTH 127

/* Remove loops. */
static int remove_loops(struct branch_entry *l, int nr)
{
	int i, j, off;
	unsigned char chash[CHASHSZ];

	memset(chash, NO_ENTRY, sizeof(chash));

	/* Change the type of the chash table, u8 is not enough now */
	BUILD_BUG_ON(PERF_MAX_BRANCH_DEPTH >= 256);
	for (i = 0; i < nr; i++) {
		int h = hash_64(l[i].from, CHASHBITS) % CHASHSZ;

-------------------------------------

- Arnaldo
--
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