X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=lttng-abi.c;h=8f63ad94c8fb053d9178aa91aa71d14d317f4e1b;hb=92d9f5e6df0f72842b28ccd303569c88e183325a;hp=eaa2f63f5af57991e2f5ab67460d93e2e60b7dc4;hpb=3c9970797850893aaf1b9019d21868d73580e17d;p=lttng-modules.git diff --git a/lttng-abi.c b/lttng-abi.c index eaa2f63f..8f63ad94 100644 --- a/lttng-abi.c +++ b/lttng-abi.c @@ -144,6 +144,51 @@ fd_error: return ret; } +#ifndef CONFIG_HAVE_SYSCALL_TRACEPOINTS +static inline +int lttng_abi_syscall_list(void) +{ + return -ENOSYS; +} +#else +static +int lttng_abi_syscall_list(void) +{ + struct file *syscall_list_file; + int file_fd, ret; + + file_fd = lttng_get_unused_fd(); + if (file_fd < 0) { + ret = file_fd; + goto fd_error; + } + + syscall_list_file = anon_inode_getfile("[lttng_syscall_list]", + <tng_syscall_list_fops, + NULL, O_RDWR); + if (IS_ERR(syscall_list_file)) { + ret = PTR_ERR(syscall_list_file); + goto file_error; + } + ret = lttng_syscall_list_fops.open(NULL, syscall_list_file); + if (ret < 0) + goto open_error; + fd_install(file_fd, syscall_list_file); + if (file_fd < 0) { + ret = file_fd; + goto fd_error; + } + return file_fd; + +open_error: + fput(syscall_list_file); +file_error: + put_unused_fd(file_fd); +fd_error: + return ret; +} +#endif + static void lttng_abi_tracer_version(struct lttng_kernel_tracer_version *v) { @@ -195,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; } @@ -575,9 +622,11 @@ unsigned int lttng_metadata_ring_buffer_poll(struct file *filp, if (finalized) mask |= POLLHUP; + mutex_lock(&stream->metadata_cache->lock); if (stream->metadata_cache->metadata_written > stream->metadata_out) mask |= POLLIN; + mutex_unlock(&stream->metadata_cache->lock); } return mask; @@ -875,7 +924,6 @@ int lttng_abi_open_metadata_stream(struct file *channel_file) metadata_stream->priv = buf; stream_priv = metadata_stream; metadata_stream->transport = channel->transport; - mutex_init(&metadata_stream->lock); /* * Since life-time of metadata cache differs from that of @@ -929,74 +977,51 @@ int lttng_abi_create_event(struct file *channel_file, default: break; } - switch (event_param->instrumentation) { - default: - event_fd = lttng_get_unused_fd(); - if (event_fd < 0) { - ret = event_fd; - goto fd_error; - } - event_file = anon_inode_getfile("[lttng_event]", - <tng_event_fops, - NULL, O_RDWR); - if (IS_ERR(event_file)) { - ret = PTR_ERR(event_file); - goto file_error; - } - if (event_param->instrumentation == LTTNG_KERNEL_TRACEPOINT) { - struct lttng_enabler *enabler; - - if (event_param->name[strlen(event_param->name) - 1] == '*') { - enabler = lttng_enabler_create(LTTNG_ENABLER_WILDCARD, - event_param, channel); - } else { - enabler = lttng_enabler_create(LTTNG_ENABLER_NAME, - event_param, channel); - } - priv = enabler; + event_fd = lttng_get_unused_fd(); + if (event_fd < 0) { + ret = event_fd; + goto fd_error; + } + event_file = anon_inode_getfile("[lttng_event]", + <tng_event_fops, + NULL, O_RDWR); + if (IS_ERR(event_file)) { + ret = PTR_ERR(event_file); + goto file_error; + } + if (event_param->instrumentation == LTTNG_KERNEL_TRACEPOINT + || event_param->instrumentation == LTTNG_KERNEL_SYSCALL) { + struct lttng_enabler *enabler; + + if (event_param->name[strlen(event_param->name) - 1] == '*') { + enabler = lttng_enabler_create(LTTNG_ENABLER_WILDCARD, + event_param, channel); } else { - struct lttng_event *event; - - /* - * We tolerate no failure path after event creation. It - * will stay invariant for the rest of the session. - */ - event = lttng_event_create(channel, event_param, - NULL, NULL, - event_param->instrumentation); - WARN_ON_ONCE(!event); - if (IS_ERR(event)) { - ret = PTR_ERR(event); - goto event_error; - } - priv = event; + enabler = lttng_enabler_create(LTTNG_ENABLER_NAME, + event_param, channel); } - event_file->private_data = priv; - fd_install(event_fd, event_file); - /* The event holds a reference on the channel */ - atomic_long_inc(&channel_file->f_count); - break; - case LTTNG_KERNEL_SYSCALL: - ret = lttng_syscalls_register(channel, NULL); - if (ret) - goto fd_error; - event_fd = 0; - if (event_param->u.syscall.enable) { - ret = lttng_syscall_filter_enable(channel, - !strcmp(event_param->name, "*") ? - NULL : event_param->name); - if (ret) - goto fd_error; + priv = enabler; + } else { + struct lttng_event *event; - } else { - ret = lttng_syscall_filter_disable(channel, - !strcmp(event_param->name, "*") ? - NULL : event_param->name); - if (ret) - goto fd_error; + /* + * We tolerate no failure path after event creation. It + * will stay invariant for the rest of the session. + */ + event = lttng_event_create(channel, event_param, + NULL, NULL, + event_param->instrumentation); + WARN_ON_ONCE(!event); + if (IS_ERR(event)) { + ret = PTR_ERR(event); + goto event_error; } - break; + priv = event; } + event_file->private_data = priv; + fd_install(event_fd, event_file); + /* The event holds a reference on the channel */ + atomic_long_inc(&channel_file->f_count); return event_fd; event_error: @@ -1346,6 +1371,18 @@ long lttng_event_ioctl(struct file *file, unsigned int cmd, unsigned long arg) WARN_ON_ONCE(1); return -ENOSYS; } + case LTTNG_KERNEL_FILTER: + switch (*evtype) { + case LTTNG_TYPE_EVENT: + return -EINVAL; + case LTTNG_TYPE_ENABLER: + { + enabler = file->private_data; + return lttng_enabler_attach_bytecode(enabler, + (struct lttng_kernel_filter_bytecode __user *) arg); + } + + } default: return -ENOIOCTLCMD; }