Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753345AbbETMMe (ORCPT ); Wed, 20 May 2015 08:12:34 -0400 Received: from mail-wi0-f176.google.com ([209.85.212.176]:33866 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752103AbbETMMc (ORCPT ); Wed, 20 May 2015 08:12:32 -0400 Date: Wed, 20 May 2015 14:12:26 +0200 From: Ingo Molnar To: Robert Bragg Cc: intel-gfx@lists.freedesktop.org, Daniel Vetter , Jani Nikula , David Airlie , Peter Zijlstra , Paul Mackerras , Ingo Molnar , Arnaldo Carvalho de Melo , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-api@vger.kernel.org, Chris Wilson Subject: Re: [RFC PATCH v2] perf: Add PERF_EVENT_IOC_FLUSH ioctl Message-ID: <20150520121226.GA11195@gmail.com> References: <20150507142009.GX22099@nuc-i3427.alporthouse.com> <1431969919-32233-1-git-send-email-robert@sixbynine.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1431969919-32233-1-git-send-email-robert@sixbynine.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2716 Lines: 80 * Robert Bragg wrote: > To allow for pmus that may have internal buffering (e.g. the hardware > itself writes out data to its own circular buffer which is only > periodically forwarded to userspace via perf) this ioctl enables > userspace to explicitly ensure it has received all samples before a > point in time. > > v2: return int error status > > Signed-off-by: Robert Bragg > --- > include/linux/perf_event.h | 7 +++++++ > include/uapi/linux/perf_event.h | 1 + > kernel/events/core.c | 5 +++++ > 3 files changed, 13 insertions(+) > > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h > index cf1d096..0c591eb 100644 > --- a/include/linux/perf_event.h > +++ b/include/linux/perf_event.h > @@ -305,6 +305,13 @@ struct pmu { > * Free pmu-private AUX data structures > */ > void (*free_aux) (void *aux); /* optional */ > + > + /* > + * Flush buffered samples (E.g. for pmu hardware that writes samples to > + * some intermediate buffer) userspace may need to explicitly ensure > + * such samples have been forwarded to perf. > + */ > + int (*flush) (struct perf_event *event); /*optional */ > }; > > /** > diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h > index 309211b..cbf1b80 100644 > --- a/include/uapi/linux/perf_event.h > +++ b/include/uapi/linux/perf_event.h > @@ -389,6 +389,7 @@ struct perf_event_attr { > #define PERF_EVENT_IOC_SET_FILTER _IOW('$', 6, char *) > #define PERF_EVENT_IOC_ID _IOR('$', 7, __u64 *) > #define PERF_EVENT_IOC_SET_BPF _IOW('$', 8, __u32) > +#define PERF_EVENT_IOC_FLUSH _IO ('$', 9) > > enum perf_event_ioc_flags { > PERF_IOC_FLAG_GROUP = 1U << 0, > diff --git a/kernel/events/core.c b/kernel/events/core.c > index 3fe532a..72daee6 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -4079,6 +4079,11 @@ static long _perf_ioctl(struct perf_event *event, unsigned int cmd, unsigned lon > case PERF_EVENT_IOC_SET_BPF: > return perf_event_set_bpf_prog(event, arg); > > + case PERF_EVENT_IOC_FLUSH: > + if (event->pmu->flush) > + return event->pmu->flush(event); > + return 0; > + > default: > return -ENOTTY; > } So 'struct file_operations' has a callback for: int (*fsync) (struct file *, loff_t, loff_t, int datasync); Could we use that perhaps, instead of an ioctl()? Not sure how it all integrates with the VFS though. Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/