lkml.org 
[lkml]   [2013]   [Jun]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v2 03/14] perf: Add persistent event facilities
Date
Hi Robert and Boris,

On Tue, 11 Jun 2013 18:42:29 +0200, Robert Richter wrote:
> From: Borislav Petkov <bp@alien8.de>
>
> Add a barebones implementation for registering persistent events with
> perf. For that, we don't destroy the buffers when they're unmapped;
> also, we map them read-only so that multiple agents can access them.
>
> Also, we allocate the event buffers at event init time and not at mmap
> time so that we can log samples into them regardless of whether there
> are readers in userspace or not.
>
> Changes made by Robert Richter <robert.richter@linaro.org>:
>
> * Fixing wrongly determined attribute size.
>
> * The default buffer size used to setup event buffers with perf tools
> is 512k. Using the same buffer size for persistent events. This also
> avoids failed mmap calls due to different buffer sizes.
>
> * Improve error reporting.
>
> * Returning -ENODEV if no file descriptor is found. An error code of
> -1 (-EPERM) is misleading in this case.
>
> * Adding cpu check to perf_get_persistent_event_fd()
>
> [ make percpu variable static ]
> Reported-by: Fengguang Wu <fengguang.wu@intel.com>
> Signed-off-by: Borislav Petkov <bp@suse.de>
> [ Fix attr size ]
> [ Setting default buffer size to 512k as in perf tools ]
> [ Print error code on failure when adding events ]
> [ Return resonable error code ]
> [ Adding cpu check to perf_get_persistent_event_fd() ]
> Reported-by: Jiri Olsa <jolsa@redhat.com>
> Signed-off-by: Robert Richter <robert.richter@linaro.org>
> Signed-off-by: Robert Richter <rric@kernel.org>
[SNIP]
> +int perf_add_persistent_event_by_id(int id)
> +{
> + struct perf_event_attr *attr;
> +
> + attr = kzalloc(sizeof(*attr), GFP_KERNEL);
> + if (!attr)
> + return -ENOMEM;
> +
> + attr->sample_period = 1;
> + attr->wakeup_events = 1;
> + attr->sample_type = PERF_SAMPLE_RAW;
> + attr->persistent = 1;
> + attr->config = id;
> + attr->type = PERF_TYPE_TRACEPOINT;
> + attr->size = sizeof(*attr);
> +
> + return perf_add_persistent_event(attr, CPU_BUFFER_NR_PAGES);
> +}
> +
> +int perf_get_persistent_event_fd(unsigned cpu, struct perf_event_attr *attr)
> +{
> + struct pers_event_desc *desc;
> +
> + if (cpu >= (unsigned)nr_cpu_ids)
> + return -EINVAL;
> +
> + list_for_each_entry(desc, &per_cpu(pers_events, cpu), plist)
> + if (desc->attr->config == attr->config)
> + return __alloc_persistent_event_fd(desc);
> +

So it only supports tracepoint events. Don't we need to add other types
of event?

Thanks,
Namhyung


> + return -ENODEV;
> +}
> +
> +
> +void __init persistent_events_init(void)
> +{
> + int i;
> +
> + for_each_possible_cpu(i)
> + INIT_LIST_HEAD(&per_cpu(pers_events, i));
> +}


\
 
 \ /
  Last update: 2013-06-14 04:21    [W:0.269 / U:0.428 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site