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:	Mon, 2 Nov 2009 14:00:16 +0100
From:	Frederic Weisbecker <fweisbec@...il.com>
To:	Paul Mackerras <paulus@...ba.org>
Cc:	Arjan van de Ven <arjan@...radead.org>,
	Ingo Molnar <mingo@...e.hu>,
	LKML <linux-kernel@...r.kernel.org>,
	Arjan van de Ven <arjan@...ux.intel.com>,
	"K.Prasad" <prasad@...ux.vnet.ibm.com>,
	Alan Stern <stern@...land.harvard.edu>,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	Steven Rostedt <rostedt@...dmis.org>,
	Jan Kiszka <jan.kiszka@...mens.com>,
	Jiri Slaby <jirislaby@...il.com>,
	Li Zefan <lizf@...fujitsu.com>, Avi Kivity <avi@...hat.com>,
	Mike Galbraith <efault@....de>,
	Masami Hiramatsu <mhiramat@...hat.com>,
	Paul Mundt <lethal@...ux-sh.org>,
	Jan Kiszka <jan.kiszka@....de>
Subject: Re: [PATCH 1/6] perf/core: Provide a kernel-internal interface to
	get to performance counters

On Mon, Nov 02, 2009 at 09:47:49PM +1100, Paul Mackerras wrote:
> Arjan van de Ven writes:
> 
> > On Mon, 2 Nov 2009 14:46:55 +1100
> > Paul Mackerras <paulus@...ba.org> wrote:
> > 
> > > Frederic Weisbecker writes:
> > > 
> > > >  /*
> > > > + * perf_event_create_kernel_counter
> > > > + * MUST be called from a kernel thread.
> > > 
> > > Why?  The reason for this requirement isn't obvious to me.  It would
> > > be good to have the reason documented in the comment for the sake of
> > > people modifying the code in future.
> > 
> > because if you call it from another context it will attach to that
> > context... and go away when that context goes away...
> 
> I don't think that's right.  When a task exits, that doesn't
> automatically kill all the perf_events it created.  The perf_events
> each have a reference to their owner's task_struct, so the task_struct
> will hang around until all of the perf_events get released.  Normally
> top-level perf_events have an associated filp and we use its reference
> count to control the perf_event lifetime, but with these new kernel
> perf_events there is no filp, so the caller will have to do any
> refcounting required.
> 
> Bottom line is that a perf_event created by
> perf_event_create_kernel_counter will exist until someone calls
> perf_event_release_kernel on it, whether or not the owner task exits
> (and whether or not that task is a kernel thread or a usermode
> process).  So I see no need to prohibit creating kernel perf_events in
> the context of a user task, though callers need to be aware that doing
> so could potentially mean the user task's task_struct has to hang
> around for a long time after the task exits.
> 
> Paul.


Yeah. For example while creating a breakpoint through ptrace,
the owner of an event created by perf_event_create_kernel_counter
is the user task that does the ptrace call.

But we need to explicitly release some disabled/pending ptrace
breakpoints using perf_event_release_kernel when the task exits.
I should simplify this part in the future.

That said, it's all fine to set the owner as a user task like in this
example.

Should I remove this comment?

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