From: Mathieu Desnoyers Date: Thu, 11 Jun 2015 15:39:16 +0000 (+0200) Subject: Implement cpu_id context for filtering X-Git-Tag: v2.7.0-rc1~7 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=b3699d90c5a746caeade87f86c371d2ed195147c;p=lttng-modules.git Implement cpu_id context for filtering cpu_id context can now be used for filtering, e.g.: lttng enable-event -k sched_switch --filter '$ctx.cpu_id==1' Signed-off-by: Mathieu Desnoyers --- diff --git a/Makefile b/Makefile index b1bc6b95..f233e660 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,8 @@ lttng-tracer-objs := lttng-events.o lttng-abi.o \ lttng-context-prio.o lttng-context-nice.o \ lttng-context-vpid.o lttng-context-tid.o \ lttng-context-vtid.o lttng-context-ppid.o \ - lttng-context-vppid.o lttng-calibrate.o \ + lttng-context-vppid.o lttng-context-cpu-id.o \ + lttng-calibrate.o \ lttng-context-hostname.o wrapper/random.o \ probes/lttng.o wrapper/trace-clock.o \ wrapper/page_alloc.o \ diff --git a/lttng-abi.c b/lttng-abi.c index d4c5ea0f..93cdce3e 100644 --- a/lttng-abi.c +++ b/lttng-abi.c @@ -240,6 +240,8 @@ long lttng_abi_add_context(struct file *file, return lttng_add_procname_to_ctx(ctx); case LTTNG_KERNEL_CONTEXT_HOSTNAME: return lttng_add_hostname_to_ctx(ctx); + case LTTNG_KERNEL_CONTEXT_CPU_ID: + return lttng_add_cpu_id_to_ctx(ctx); default: return -EINVAL; } diff --git a/lttng-abi.h b/lttng-abi.h index 06eae785..ab54cf8d 100644 --- a/lttng-abi.h +++ b/lttng-abi.h @@ -141,6 +141,7 @@ enum lttng_kernel_context_type { LTTNG_KERNEL_CONTEXT_PPID = 8, LTTNG_KERNEL_CONTEXT_VPPID = 9, LTTNG_KERNEL_CONTEXT_HOSTNAME = 10, + LTTNG_KERNEL_CONTEXT_CPU_ID = 11, }; struct lttng_kernel_perf_counter_ctx { diff --git a/lttng-context.c b/lttng-context.c index d8ce9770..eca58ce1 100644 --- a/lttng-context.c +++ b/lttng-context.c @@ -264,6 +264,10 @@ int lttng_context_init(void) if (ret) { printk(KERN_WARNING "Cannot add context lttng_add_vpid_to_ctx"); } + ret = lttng_add_cpu_id_to_ctx(<tng_static_ctx); + if (ret) { + printk(KERN_WARNING "Cannot add context lttng_add_cpu_id_to_ctx"); + } /* TODO: perf counters for filtering */ return 0; } diff --git a/lttng-events.h b/lttng-events.h index 4d1b54f9..4d9bdfd0 100644 --- a/lttng-events.h +++ b/lttng-events.h @@ -605,6 +605,7 @@ void lttng_remove_context_field(struct lttng_ctx **ctx, struct lttng_ctx_field *field); void lttng_destroy_context(struct lttng_ctx *ctx); int lttng_add_pid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_cpu_id_to_ctx(struct lttng_ctx **ctx); int lttng_add_procname_to_ctx(struct lttng_ctx **ctx); int lttng_add_prio_to_ctx(struct lttng_ctx **ctx); int lttng_add_nice_to_ctx(struct lttng_ctx **ctx);