Hi Steve, On Thu, 2019-02-14 at 18:11 -0500, Steven Rostedt wrote: > On Wed, 13 Feb 2019 17:42:45 -0600 > Tom Zanussi <zanussi@xxxxxxxxxx> wrote: > > > + > > +/** > > + * tracing_snapshot_cond_enable - enable conditional snapshot for > > an instance > > + * @tr: The tracing instance > > + * @cond_data: User data to associate with the snapshot > > + * @update: Implementation of the cond_snapshot update > > function > > + * > > + * Check whether the conditional snapshot for the given instance > > has > > + * already been enabled, or if the current tracer is already using > > a > > + * snapshot; if so, return -EBUSY, else create a cond_snapshot and > > + * save the cond_data and update function inside. > > + * > > + * Returns 0 if successful, error otherwise. > > + */ > > +int tracing_snapshot_cond_enable(struct trace_array *tr, void > > *cond_data, > > + cond_update_fn_t update) > > +{ > > + struct cond_snapshot *cond_snapshot; > > + int ret = 0; > > + > > + cond_snapshot = kzalloc(sizeof(*cond_snapshot), > > GFP_KERNEL); > > + if (!cond_snapshot) > > + return -ENOMEM; > > + > > + cond_snapshot->cond_data = cond_data; > > + cond_snapshot->update = update; > > + > > + mutex_lock(&trace_types_lock); > > + > > + ret = tracing_alloc_snapshot_instance(tr); > > + if (ret) > > + goto fail_unlock; > > + > > + if (tr->current_trace->use_max_tr) { > > + ret = -EBUSY; > > + goto fail_unlock; > > + } > > + > > + if (tr->cond_snapshot) { > > + ret = -EBUSY; > > + goto fail_unlock; > > + } > > + > > + arch_spin_lock(&tr->max_lock); > > + tr->cond_snapshot = cond_snapshot; > > + arch_spin_unlock(&tr->max_lock); > > + > > + mutex_unlock(&trace_types_lock); > > + > > + return ret; > > + > > + fail_unlock: > > + mutex_unlock(&trace_types_lock); > > + kfree(cond_snapshot); > > + return ret; > > Some whitespace damage here. No need to resend, I fixed it. > OK, thanks. > > > +} > > +EXPORT_SYMBOL_GPL(tracing_snapshot_cond_enable); > > + > > I also added this change on top of your series. > > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c > index 0460cc0f28fd..2cf3c747a357 100644 > --- a/kernel/trace/trace.c > +++ b/kernel/trace/trace.c > @@ -1116,6 +1116,14 @@ int tracing_snapshot_cond_enable(struct > trace_array *tr, void *cond_data, > goto fail_unlock; > } > > + /* > + * The cond_snapshot can only change to NULL without the > + * trace_types_lock. We don't care if we race with it going > + * to NULL, but we want to make sure that it's not set to > + * something other than NULL when we get here, which we can > + * do safely with only holding the trace_types_lock and not > + * having to take the max_lock. > + */ > if (tr->cond_snapshot) { > ret = -EBUSY; > goto fail_unlock; > Looks good, thanks for adding that back. Tom > I'll start testing your series now. > > Thanks! > > -- Steve >