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:	Tue, 22 Apr 2014 16:25:17 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Jean Pihet <jean.pihet@...aro.org>
Cc:	Borislav Petkov <bp@...en8.de>, Ingo Molnar <mingo@...nel.org>,
	Arnaldo Carvalho de Melo <acme@...radead.org>,
	Jiri Olsa <jolsa@...hat.com>, linux-kernel@...r.kernel.org,
	Robert Richter <rric@...nel.org>,
	Robert Richter <robert.richter@...aro.org>
Subject: Re: [PATCH 03/16] perf, mmap: Factor out perf_alloc/free_rb()

On Mon, Apr 07, 2014 at 05:04:25PM +0200, Jean Pihet wrote:
> From: Robert Richter <robert.richter@...aro.org>
> 
> Factor out code to allocate and deallocate ringbuffers. We need this
> later to setup the sampling buffer for persistent events.
> 
> While at this, replacing get_current_user() with get_uid(user).
> 
> Signed-off-by: Robert Richter <robert.richter@...aro.org>
> Signed-off-by: Robert Richter <rric@...nel.org>
> Signed-off-by: Jean Pihet <jean.pihet@...aro.org>
> ---
>  kernel/events/core.c     | 77 +++++++++++++++++++++++++++++-------------------
>  kernel/events/internal.h |  3 ++
>  2 files changed, 50 insertions(+), 30 deletions(-)
> 
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 5eaba42..22ec8f0 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -3193,7 +3193,45 @@ static void free_event_rcu(struct rcu_head *head)
>  }
>  
>  static void ring_buffer_put(struct ring_buffer *rb);
> +static void ring_buffer_attach(struct perf_event *event, struct ring_buffer *rb);
>  static void ring_buffer_detach(struct perf_event *event, struct ring_buffer *rb);
> +static void perf_event_init_userpage(struct perf_event *event);
> +
> +/*
> + * Must be called with &event->mmap_mutex held. event->rb must be
> + * NULL. perf_alloc_rb() requires &event->mmap_count to be incremented
> + * on success which corresponds to &rb->mmap_count that is initialized
> + * with 1.
> + */
> +int perf_alloc_rb(struct perf_event *event, int nr_pages, int flags)
> +{
> +	struct ring_buffer *rb;

	lockdep_assert_held(&event->mmap_mutex);
	WARN_ON(event->rb);

> +
> +	rb = rb_alloc(nr_pages,
> +		event->attr.watermark ? event->attr.wakeup_watermark : 0,
> +		event->cpu, flags);
> +	if (!rb)
> +		return -ENOMEM;
> +
> +	atomic_set(&rb->mmap_count, 1);
> +	ring_buffer_attach(event, rb);
> +	rcu_assign_pointer(event->rb, rb);
> +
> +	perf_event_init_userpage(event);
> +	perf_event_update_userpage(event);
> +
> +	return 0;
> +}
> +
> +/* Must be called with &event->mmap_mutex held. event->rb must be set. */
> +void perf_free_rb(struct perf_event *event)
> +{
> +	struct ring_buffer *rb = event->rb;

	lockdep_assert_held(&event->mmap_mutex);

> +	rcu_assign_pointer(event->rb, NULL);
> +	ring_buffer_detach(event, rb);
> +	ring_buffer_put(rb);
> +}
--
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