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: <1258457333.7816.186.camel@laptop>
Date:	Tue, 17 Nov 2009 12:28:53 +0100
From:	Peter Zijlstra <peterz@...radead.org>
To:	Frederic Weisbecker <fweisbec@...il.com>
Cc:	Ingo Molnar <mingo@...e.hu>, LKML <linux-kernel@...r.kernel.org>,
	Li Zefan <lizf@...fujitsu.com>,
	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@....de>,
	Jiri Slaby <jirislaby@...il.com>, Avi Kivity <avi@...hat.com>,
	Paul Mackerras <paulus@...ba.org>,
	Mike Galbraith <efault@....de>,
	Masami Hiramatsu <mhiramat@...hat.com>,
	Paul Mundt <lethal@...ux-sh.org>,
	Arjan van de Ven <arjan@...ux.intel.com>
Subject: Re: [PATCH 3/7 v6] perf/core: Add a callback to perf events

On Sun, 2009-11-08 at 16:28 +0100, Frederic Weisbecker wrote:
> A simple callback in a perf event can be used for multiple purposes.
> For example it is useful for triggered based events like hardware
> breakpoints that need a callback to dispatch a triggered breakpoint
> event.
> 
> v2: Simplify a bit the callback attribution as suggested by Paul
>     Mackerras

Yuck! So we add an opaque callback without semantics nor usage.

> ---
>  include/linux/perf_event.h |    7 ++++++-
>  kernel/perf_event.c        |   14 ++++++++++----
>  2 files changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
> index fa151d4..8d54e6d 100644
> --- a/include/linux/perf_event.h
> +++ b/include/linux/perf_event.h
> @@ -544,6 +544,8 @@ struct perf_pending_entry {
>  	void (*func)(struct perf_pending_entry *);
>  };
>  
> +typedef void (*perf_callback_t)(struct perf_event *, void *);
> +
>  /**
>   * struct perf_event - performance event kernel representation:
>   */
> @@ -639,6 +641,8 @@ struct perf_event {
>  	struct event_filter		*filter;
>  #endif
>  
> +	perf_callback_t			callback;
> +
>  #endif /* CONFIG_PERF_EVENTS */
>  };
>  
> @@ -748,7 +752,8 @@ extern int perf_event_release_kernel(struct perf_event *event);
>  extern struct perf_event *
>  perf_event_create_kernel_counter(struct perf_event_attr *attr,
>  				int cpu,
> -				pid_t pid);
> +				pid_t pid,
> +				perf_callback_t callback);
>  extern u64 perf_event_read_value(struct perf_event *event);
>  
>  struct perf_sample_data {
> diff --git a/kernel/perf_event.c b/kernel/perf_event.c
> index 02d4ff0..5087125 100644
> --- a/kernel/perf_event.c
> +++ b/kernel/perf_event.c
> @@ -4293,6 +4293,7 @@ perf_event_alloc(struct perf_event_attr *attr,
>  		   struct perf_event_context *ctx,
>  		   struct perf_event *group_leader,
>  		   struct perf_event *parent_event,
> +		   perf_callback_t callback,
>  		   gfp_t gfpflags)
>  {
>  	const struct pmu *pmu;
> @@ -4335,6 +4336,11 @@ perf_event_alloc(struct perf_event_attr *attr,
>  
>  	event->state		= PERF_EVENT_STATE_INACTIVE;
>  
> +	if (!callback && parent_event)
> +		callback = parent_event->callback;
> +	
> +	event->callback	= callback;
> +
>  	if (attr->disabled)
>  		event->state = PERF_EVENT_STATE_OFF;
>  
> @@ -4611,7 +4617,7 @@ SYSCALL_DEFINE5(perf_event_open,
>  	}
>  
>  	event = perf_event_alloc(&attr, cpu, ctx, group_leader,
> -				     NULL, GFP_KERNEL);
> +				     NULL, NULL, GFP_KERNEL);
>  	err = PTR_ERR(event);
>  	if (IS_ERR(event))
>  		goto err_put_context;
> @@ -4668,7 +4674,7 @@ err_put_context:
>   */
>  struct perf_event *
>  perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
> -				 pid_t pid)
> +				 pid_t pid, perf_callback_t callback)
>  {
>  	struct perf_event *event;
>  	struct perf_event_context *ctx;
> @@ -4683,7 +4689,7 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
>  		return NULL ;
>  
>  	event = perf_event_alloc(attr, cpu, ctx, NULL,
> -				     NULL, GFP_KERNEL);
> +				     NULL, callback, GFP_KERNEL);
>  	err = PTR_ERR(event);
>  	if (IS_ERR(event))
>  		goto err_put_context;
> @@ -4736,7 +4742,7 @@ inherit_event(struct perf_event *parent_event,
>  	child_event = perf_event_alloc(&parent_event->attr,
>  					   parent_event->cpu, child_ctx,
>  					   group_leader, parent_event,
> -					   GFP_KERNEL);
> +					   NULL, GFP_KERNEL);
>  	if (IS_ERR(child_event))
>  		return child_event;
>  	get_ctx(child_ctx);


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