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 May 2010 10:38:18 +0200
From:	Ingo Molnar <mingo@...e.hu>
To:	Lin Ming <ming.m.lin@...el.com>
Cc:	greg@...ah.com, Peter Zijlstra <peterz@...radead.org>,
	Corey Ashford <cjashfor@...ux.vnet.ibm.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	"eranian@...il.com" <eranian@...il.com>,
	"Gary.Mohr@...l.com" <Gary.Mohr@...l.com>,
	"arjan@...ux.intel.com" <arjan@...ux.intel.com>,
	"Zhang, Yanmin" <yanmin_zhang@...ux.intel.com>,
	Paul Mackerras <paulus@...ba.org>,
	"David S. Miller" <davem@...emloft.net>,
	Russell King <rmk+kernel@....linux.org.uk>,
	Paul Mundt <lethal@...ux-sh.org>,
	lkml <linux-kernel@...r.kernel.org>,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	Will Deacon <will.deacon@....com>,
	Maynard Johnson <mpjohn@...ibm.com>,
	Carl Love <carll@...ibm.com>
Subject: Re: [RFC][PATCH 3/9] perf: export registerred pmus via sysfs


* Lin Ming <ming.m.lin@...el.com> wrote:

> On Tue, 2010-05-11 at 17:18 +0800, Ingo Molnar wrote:
> > * Peter Zijlstra <peterz@...radead.org> wrote:
> > 
> > > The new PMUs will use a dynamic range that starts at PERF_TYPE_MAX.
> > 
> > I dont think we should use a dynamic range of event sources - it's a 
> > completely useless indirection that has no meaning to humans.
> > 
> > As far as machine interfaces go a much cleaner approach would be to allow an 
> > open fd to a sysfs file to be passed to sys_perf_event_open() - this would 
> > identify the event source. This needs a small extension of the ABI but we 
> > could thus get rid of the 'type' enumeration altogether and express _all_ 
> > event sources via fds to sysfs files.
> 
> I still don't understand this sys_fd -> pmu lookup, would you please
> explain it more detail?
> 
> struct pmu {
> 	kobject kobj;
> 	...
> };
> 
> What I can imagine is,
> 
> 1. In userspace, sys_fd =
> open("/sys/devices/system/cpu/event_source", ..), then sys_fd is passed
> to sys_perf_event_open()

Yes, open() an event_source - or rather an event itself. For raw events there 
has to be a separate event entry that can be opened.

I.e. we'd have a layout like:

 /sys/devices/system/cpu/events/cycles/id
 /sys/devices/system/cpu/events/instructions/id
 /sys/devices/system/cpu/events/raw/id

By making each event category a directory we gain the flexibility of 
integrating tracepoints as well, for example:

 /sys/kernel/sched/events/wakeup/id
 /sys/kernel/sched/events/wakeup/format

Where 'format' describes the event record layout:

 # cat /debug/tracing/events/sched/sched_wakeup/format 
 name: sched_wakeup
 ID: 59
 format:
	field:unsigned short common_type;	offset:0;	size:2;	signed:0;
	field:unsigned char common_flags;	offset:2;	size:1;	signed:0;
	field:unsigned char common_preempt_count;	offset:3;	size:1;	signed:0;
	field:int common_pid;	offset:4;	size:4;	signed:1;
	field:int common_lock_depth;	offset:8;	size:4;	signed:1;

	field:char comm[TASK_COMM_LEN];	offset:12;	size:16;	signed:1;
	field:pid_t pid;	offset:28;	size:4;	signed:1;
	field:int prio;	offset:32;	size:4;	signed:1;
	field:int success;	offset:36;	size:4;	signed:1;
	field:int target_cpu;	offset:40;	size:4;	signed:1;

 print fmt: "comm=%s pid=%d prio=%d success=%d target_cpu=%03d", REC->comm, REC->pid, REC->prio, REC->success, REC->target_cpu

> 2. In kernel, sys_file = <find the sys file structure with sys_fd>
> 
> 3. kobject = <retrieve the kobject from sys_file>
> 
> 4. pmu = container_of(kobject, struct pmu, kobj)
> 
> If my understanding is correct, then step 3 above seems strange. It's
> not the typical usage of sys file.

I dont think it's stange - we demux from the generic sysfs object to the more 
specific perf events related object. This is similar how driver specific sysfs 
functionality does the demux as well.

	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