perf thread: Adopt get_main_thread from db-export.c
[deliverable/linux.git] / include / linux / perf_event.h
index dbd18246b36e6f01c8299f5e73ad4793e4e80a3e..6b87be908790f10be32fb48e943f487a75745a75 100644 (file)
@@ -64,6 +64,9 @@ struct perf_callchain_entry {
 struct perf_callchain_entry_ctx {
        struct perf_callchain_entry *entry;
        u32                         max_stack;
+       u32                         nr;
+       short                       contexts;
+       bool                        contexts_maxed;
 };
 
 struct perf_raw_record {
@@ -1077,12 +1080,27 @@ extern int get_callchain_buffers(void);
 extern void put_callchain_buffers(void);
 
 extern int sysctl_perf_event_max_stack;
+extern int sysctl_perf_event_max_contexts_per_stack;
+
+static inline int perf_callchain_store_context(struct perf_callchain_entry_ctx *ctx, u64 ip)
+{
+       if (ctx->contexts < sysctl_perf_event_max_contexts_per_stack) {
+               struct perf_callchain_entry *entry = ctx->entry;
+               entry->ip[entry->nr++] = ip;
+               ++ctx->contexts;
+               return 0;
+       } else {
+               ctx->contexts_maxed = true;
+               return -1; /* no more room, stop walking the stack */
+       }
+}
 
 static inline int perf_callchain_store(struct perf_callchain_entry_ctx *ctx, u64 ip)
 {
-       struct perf_callchain_entry *entry = ctx->entry;
-       if (entry->nr < ctx->max_stack) {
+       if (ctx->nr < ctx->max_stack && !ctx->contexts_maxed) {
+               struct perf_callchain_entry *entry = ctx->entry;
                entry->ip[entry->nr++] = ip;
+               ++ctx->nr;
                return 0;
        } else {
                return -1; /* no more room, stop walking the stack */
This page took 0.042537 seconds and 5 git commands to generate.