Skip to content

Commit 5685e0f

Browse files
Jiri Olsaacmel
authored andcommitted
perf: Add perf_output_skip function to skip bytes in sample
Introducing perf_output_skip function to be able to skip data within the perf ring buffer. When writing data into perf ring buffer we first reserve needed place in ring buffer and then copy the actual data. There's a possibility we won't be able to fill all the reserved size with data, so we need a way to skip the remaining bytes. This is going to be useful when storing the user stack dump, where we might end up with less data than we originally requested. Signed-off-by: Jiri Olsa <jolsa@redhat.com> Acked-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: "Frank Ch. Eigler" <fche@redhat.com> Cc: Arun Sharma <asharma@fb.com> Cc: Benjamin Redelings <benjamin.redelings@nescent.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Cyrill Gorcunov <gorcunov@openvz.org> Cc: Frank Ch. Eigler <fche@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Robert Richter <robert.richter@amd.com> Cc: Stephane Eranian <eranian@google.com> Cc: Tom Zanussi <tzanussi@gmail.com> Cc: Ulrich Drepper <drepper@gmail.com> Link: http://lkml.kernel.org/r/1344345647-11536-5-git-send-email-jolsa@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 91d7753 commit 5685e0f

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎include/linux/perf_event.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,6 +1321,8 @@ extern int perf_output_begin(struct perf_output_handle *handle,
13211321
extern void perf_output_end(struct perf_output_handle *handle);
13221322
extern unsigned int perf_output_copy(struct perf_output_handle *handle,
13231323
const void *buf, unsigned int len);
1324+
extern unsigned int perf_output_skip(struct perf_output_handle *handle,
1325+
unsigned int len);
13241326
extern int perf_swevent_get_recursion_context(void);
13251327
extern void perf_swevent_put_recursion_context(int rctx);
13261328
extern void perf_event_enable(struct perf_event *event);

‎kernel/events/internal.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
114114

115115
DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
116116

117+
#define MEMCPY_SKIP(dst, src, n) (n)
118+
119+
DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
120+
117121
#ifndef arch_perf_out_copy_user
118122
#define arch_perf_out_copy_user __copy_from_user_inatomic
119123
#endif

‎kernel/events/ring_buffer.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ unsigned int perf_output_copy(struct perf_output_handle *handle,
188188
return __output_copy(handle, buf, len);
189189
}
190190

191+
unsigned int perf_output_skip(struct perf_output_handle *handle,
192+
unsigned int len)
193+
{
194+
return __output_skip(handle, NULL, len);
195+
}
196+
191197
void perf_output_end(struct perf_output_handle *handle)
192198
{
193199
perf_output_put_handle(handle);

0 commit comments

Comments
 (0)