From: Mathieu Desnoyers Date: Wed, 22 May 2019 01:15:44 +0000 (-0400) Subject: Prepare callstack common code for stackwalk X-Git-Tag: v2.12.0-pre~43 X-Git-Url: http://git.liburcu.org/?p=lttng-modules.git;a=commitdiff_plain;h=b5a89a3f5421fb3ad06911300df2e2fdf29a5ace Prepare callstack common code for stackwalk Prepare the callstack common code for stackwalk implementation, moving more legacy code to the legacy implementation header. Signed-off-by: Mathieu Desnoyers --- diff --git a/lttng-context-callstack-legacy-impl.h b/lttng-context-callstack-legacy-impl.h index a68e8a18..6b4f0627 100644 --- a/lttng-context-callstack-legacy-impl.h +++ b/lttng-context-callstack-legacy-impl.h @@ -53,6 +53,12 @@ static struct lttng_cs_type cs_types[] = { }, }; +static +const char *lttng_cs_ctx_mode_name(enum lttng_cs_ctx_modes mode) +{ + return cs_types[mode].name; +} + static int init_type(enum lttng_cs_ctx_modes mode) { @@ -70,6 +76,25 @@ int init_type(enum lttng_cs_ctx_modes mode) return 0; } +static +void lttng_cs_set_init(struct lttng_cs __percpu *cs_set) +{ + int cpu, i; + + for_each_possible_cpu(cpu) { + struct lttng_cs *cs; + + cs = per_cpu_ptr(cs_set, cpu); + for (i = 0; i < RING_BUFFER_MAX_NESTING; i++) { + struct lttng_cs_dispatch *dispatch; + + dispatch = &cs->dispatch[i]; + dispatch->stack_trace.entries = dispatch->entries; + dispatch->stack_trace.max_entries = MAX_ENTRIES; + } + } +} + /* Keep track of nesting inside userspace callstack context code */ DEFINE_PER_CPU(int, callstack_user_nesting); diff --git a/lttng-context-callstack.c b/lttng-context-callstack.c index 3fccfcf2..4a440040 100644 --- a/lttng-context-callstack.c +++ b/lttng-context-callstack.c @@ -63,7 +63,6 @@ void field_data_free(struct field_data *fdata) static struct field_data __percpu *field_data_create(enum lttng_cs_ctx_modes mode) { - int cpu, i; struct lttng_cs __percpu *cs_set; struct field_data *fdata; @@ -73,20 +72,8 @@ struct field_data __percpu *field_data_create(enum lttng_cs_ctx_modes mode) cs_set = alloc_percpu(struct lttng_cs); if (!cs_set) goto error_alloc; - + lttng_cs_set_init(cs_set); fdata->cs_percpu = cs_set; - for_each_possible_cpu(cpu) { - struct lttng_cs *cs; - - cs = per_cpu_ptr(cs_set, cpu); - for (i = 0; i < RING_BUFFER_MAX_NESTING; i++) { - struct lttng_cs_dispatch *dispatch; - - dispatch = &cs->dispatch[i]; - dispatch->stack_trace.entries = dispatch->entries; - dispatch->stack_trace.max_entries = MAX_ENTRIES; - } - } fdata->mode = mode; return fdata; @@ -107,7 +94,7 @@ static int __lttng_add_callstack_generic(struct lttng_ctx **ctx, enum lttng_cs_ctx_modes mode) { - const char *ctx_name = cs_types[mode].name; + const char *ctx_name = lttng_cs_ctx_mode_name(mode); struct lttng_ctx_field *field; struct field_data *fdata; int ret;