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: <20110726044257.GB27720@suse.de>
Date:	Mon, 25 Jul 2011 21:42:57 -0700
From:	Greg KH <gregkh@...e.de>
To:	Lin Ming <ming.m.lin@...el.com>
Cc:	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Ingo Molnar <mingo@...e.hu>, Andi Kleen <andi@...stfloor.org>,
	Stephane Eranian <eranian@...gle.com>,
	Arnaldo Carvalho de Melo <acme@...stprotocols.net>,
	linux-kernel <linux-kernel@...r.kernel.org>,
	Kay Sievers <kay.sievers@...y.org>
Subject: Re: [PATCH v2 1/6] perf: Add interface to add general events to sysfs

On Tue, Jul 26, 2011 at 09:06:07AM +0800, Lin Ming wrote:
> On Mon, 2011-07-25 at 23:20 +0800, Greg KH wrote:
> > On Mon, Jul 25, 2011 at 10:32:03AM +0200, Peter Zijlstra wrote:
> > > On Mon, 2011-07-25 at 16:11 +0800, Lin Ming wrote:
> > > > It's strange that I didn't find a way to check if a directory is present
> > > > in sysfs. Any hint?
> > > 
> > > sysfs is voodoo for me, best I can come up with is, ask the sysfs
> > > folks ;-)
> > > 
> > > Kay, Greg?
> > 
> > What are you trying to do here specifically?
> 
> Now there are perf event source devices in sysfs.

As of what kernel release?

> $ tree /sys/bus/event_source/devices/
> /sys/bus/event_source/devices/
> |-- breakpoint
> |-- cpu
> |-- software
> `-- tracepoint
> 
> I want to create a "events" directory to hold the most useful events
> under the event_source.

Then use the attribute group for that.

> $ tree /sys/bus/event_source/devices/cpu
> | -- events
> 
> Then add one event each time to the "events" dir.
> 
> Add "event1"
> $ tree /sys/bus/event_source/devices/cpu
> | -- events
>      | -- event1
> 
> Add "event2"
> $ tree /sys/bus/event_source/devices/cpu
> | -- events
>      | -- event1
>      | -- event2
> 
> So at the first time to add a event I need to check if the "events"
> directory is present. If not, create it.
> 
> Like below pseudo code,
> 
> int perf_pmu_add_event(struct pmu *pmu, const char *name, ....)
> {
> 	if there is no "events" dir under pmu->dev->kobj
> 		then create "events" dir
> 
> 	add event "name" to "events"
> 
> 	return ....
> }
> 
> So the problem is, for example, how to check if there is a "events" dir
> under /sys/bus/event_source/devices/cpu in kernel.

Just use the proper attribute group and you will be fine.  That will
create the directory automatically.

And I really don't think sysfs is good for this, as you don't have a
bus, and your devices aren't on that bus, and the subdirs you are
creating are not "normal" for sysfs.

Why not create your own filesystem?

greg k-h
--
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