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: <20071113225848.GK5747@frankl.hpl.hp.com>
Date:	Tue, 13 Nov 2007 14:58:48 -0800
From:	Stephane Eranian <eranian@....hp.com>
To:	Andi Kleen <andi@...stfloor.org>
Cc:	akpm@...l.org, Robert Richter <robert.richter@....com>,
	gregkh@...e.de, linux-kernel@...r.kernel.org,
	perfmon@...ali.hpl.hp.com, William Cohen <wcohen@...hat.com>,
	perfmon2-devel@...ts.sourceforge.net
Subject: Re: [perfmon] Re: [perfmon2] perfmon2 merge news

Andi,

On Tue, Nov 13, 2007 at 11:25:34PM +0100, Andi Kleen wrote:
> On Tue, Nov 13, 2007 at 02:22:34PM -0800, Stephane Eranian wrote:
> > Andi,
> > On Tue, Nov 13, 2007 at 10:50:56PM +0100, Andi Kleen wrote:
> > > > Yes, horribly more complicated because of locking issues within perfmon.
> > > > As soon as you expose a file descriptor, you need some locking to prevent
> > > > multiple user threads (malicious or not) to compete to access the PMU state.
> > > 
> > > Why do you need the file descriptor? 
> > > 
> > 
> > To identify your monitoring session be it system-wide (i.e., per-cpu) or per-thread.
> > file descriptor allows you to use close, read, select, poll and you leverage the
> 
> Surely that could be done with a flag for each call too? Keeping file descriptors
> to pass essentially a boolean seems overkill.
> 

I don't understand this.

Let's take the simplest possible example (self-monitoring per-thread)
counting one event in one data register.

int
main(int argc, char **argv)
{
	int ctx_fd;
	pfarg_pmd_t pd[1];
	pfarg_pmc_t pc[1];
	pfarg_ctx_t ctx;
	pfarg_load_t load_args;

	memset(&ctx, 0, sizeof(ctx));
	memset(pc, 0, sizeof(pc));
	memset(pd, 0, sizeof(pd));

	/* create session (context) and get file descriptor back (identifier) */
	ctx_fd = pfm_create_context(&ctx, NULL, NULL, 0);

	/* setup one config register (PMC0) */
	pc[0].reg_num   = 0
	pc[0].reg_value = 0x1234;

	/* setup one data register (PMD0) */
	pd[0].reg_num = 0;
	pd[0].reg_value = 0;

	/* program the registers */
	pfm_write_pmcs(ctx_fd, pc, 1);
	pfm_write_pmds(ctx_fd, pd, 1);

	/* attach the context to self */
	load_args.load_pid = getpid();
	pfm_load_context(ctx_fd, &load_args);

	/* activate monitoring */
	pfm_start(ctx_fd, NULL);

	/*
	 * run code to measure
	 */

	/* stop monitoring */
	pfm_stop(ctx_fd);

	/* read data register */
	pfm_read_pmds(ctx_fd, pd, 1);

	printf("PMD0 %llu\n", pd[0].reg_value);

	/* destroy session */
	close(ctx_fd);

	return 0;
}

-- 

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