#include "comm.h" #include "util.h" #include #include #include struct comm_str { char *str; struct rb_node rb_node; atomic_t refcnt; }; /* Should perhaps be moved to struct machine */ static struct rb_root comm_str_root; static struct comm_str *comm_str__get(struct comm_str *cs) { if (cs) atomic_inc(&cs->refcnt); return cs; } static void comm_str__put(struct comm_str *cs) { if (cs && atomic_dec_and_test(&cs->refcnt)) { rb_erase(&cs->rb_node, &comm_str_root); zfree(&cs->str); free(cs); } } static struct comm_str *comm_str__alloc(const char *str) { struct comm_str *cs; cs = zalloc(sizeof(*cs)); if (!cs) return NULL; cs->str = strdup(str); if (!cs->str) { free(cs); return NULL; } atomic_set(&cs->refcnt, 0); return cs; } static struct comm_str *comm_str__findnew(const char *str, struct rb_root *root) { struct rb_node **p = &root->rb_node; struct rb_node *parent = NULL; struct comm_str *iter, *new; int cmp; while (*p != NULL) { parent = *p; iter = rb_entry(parent, struct comm_str, rb_node); cmp = strcmp(str, iter->str); if (!cmp) return iter; if (cmp < 0) p = &(*p)->rb_left; else p = &(*p)->rb_right; } new = comm_str__alloc(str); if (!new) return NULL; rb_link_node(&new->rb_node, parent, p); rb_insert_color(&new->rb_node, root); return new; } struct comm *comm__new(const char *str, u64 timestamp, bool exec) { struct comm *comm = zalloc(sizeof(*comm)); if (!comm) return NULL; comm->start = timestamp; comm->exec = exec; comm->comm_str = comm_str__findnew(str, &comm_str_root); if (!comm->comm_str) { free(comm); return NULL; } comm_str__get(comm->comm_str); return comm; } int comm__override(struct comm *comm, const char *str, u64 timestamp, bool exec) { struct comm_str *new, *old = comm->comm_str; new = comm_str__findnew(str, &comm_str_root); if (!new) return -ENOMEM; comm_str__get(new); comm_str__put(old); comm->comm_str = new; comm->start = timestamp; if (exec) comm->exec = true; return 0; } void comm__free(struct comm *comm) { comm_str__put(comm->comm_str); free(comm); } const char *comm__str(const struct comm *comm) { return comm->comm_str->str; } f448c8b79c321e4a1f31f98194e4f6b6cae7'/>
diff options
context:
space:
mode:
authorSteven Rostedt (VMware) <rostedt@goodmis.org>2017-01-30 19:27:10 -0500
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2017-01-31 09:13:49 -0500
commit79c6f448c8b79c321e4a1f31f98194e4f6b6cae7 (patch)
tree370efda701f03cccf21e02bb1fdd3b852547d75c /sound/usb/misc
parent0c744ea4f77d72b3dcebb7a8f2684633ec79be88 (diff)
tracing: Fix hwlat kthread migration
The hwlat tracer creates a kernel thread at start of the tracer. It is pinned to a single CPU and will move to the next CPU after each period of running. If the user modifies the migration thread's affinity, it will not change after that happens. The original code created the thread at the first instance it was called, but later was changed to destroy the thread after the tracer was finished, and would not be created until the next instance of the tracer was established. The code that initialized the affinity was only called on the initial instantiation of the tracer. After that, it was not initialized, and the previous affinity did not match the current newly created one, making it appear that the user modified the thread's affinity when it did not, and the thread failed to migrate again. Cc: stable@vger.kernel.org Fixes: 0330f7aa8ee6 ("tracing: Have hwlat trace migrate across tracing_cpumask CPUs") Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Diffstat (limited to 'sound/usb/misc')