]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
perf_counter: per event wakeups
authorPeter Zijlstra <a.p.zijlstra@chello.nl>
Thu, 2 Apr 2009 09:12:01 +0000 (11:12 +0200)
committerIngo Molnar <mingo@elte.hu>
Mon, 6 Apr 2009 07:30:45 +0000 (09:30 +0200)
By request, provide a way to request a wakeup every 'n' events instead
of every page of output.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Orig-LKML-Reference: <20090402091319.323309784@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
include/linux/perf_counter.h
kernel/perf_counter.c

index 06a6fba9f53184ea9c2bce427f13c0500e68dcd8..5428ba120d78cfd917a9be7ff1f90bc48d9b4307 100644 (file)
@@ -145,7 +145,7 @@ struct perf_counter_hw_event {
                                __reserved_1   : 53;
 
        __u32                   extra_config_len;
-       __u32                   __reserved_4;
+       __u32                   wakeup_events;  /* wakeup every n events */
 
        __u64                   __reserved_2;
        __u64                   __reserved_3;
@@ -321,6 +321,7 @@ struct perf_mmap_data {
        int                             nr_pages;
        atomic_t                        wakeup;
        atomic_t                        head;
+       atomic_t                        events;
        struct perf_counter_mmap_page   *user_page;
        void                            *data_pages[0];
 };
index 995063df910fc1054c5b582faa1d313c22965ef5..9bcab10e735dfa476b124e64bad9835a923d7587 100644 (file)
@@ -1760,7 +1760,15 @@ static void perf_output_copy(struct perf_output_handle *handle,
 
 static void perf_output_end(struct perf_output_handle *handle)
 {
-       if (handle->wakeup)
+       int wakeup_events = handle->counter->hw_event.wakeup_events;
+
+       if (wakeup_events) {
+               int events = atomic_inc_return(&handle->data->events);
+               if (events >= wakeup_events) {
+                       atomic_sub(wakeup_events, &handle->data->events);
+                       __perf_output_wakeup(handle);
+               }
+       } else if (handle->wakeup)
                __perf_output_wakeup(handle);
        rcu_read_unlock();
 }