From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [for-next][PATCH 2/5] tracing: Add set_event_pid directory for future use
Date: Tue, 1 Dec 2015 10:12:37 -0800 [thread overview]
Message-ID: <20151201181237.GQ26643@linux.vnet.ibm.com> (raw)
In-Reply-To: <20151119231726.5362295f@grimm.local.home>
On Thu, Nov 19, 2015 at 11:17:26PM -0500, Steven Rostedt wrote:
> On Thu, 19 Nov 2015 15:24:27 -0800
> "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> wrote:
>
> > > +static void *p_start(struct seq_file *m, loff_t *pos)
> > > +{
> > > + struct trace_pid_list *pid_list;
> > > + struct trace_array *tr = m->private;
> > > +
> > > + /*
> > > + * Grab the mutex, to keep calls to p_next() having the same
> > > + * tr->filtered_pids as p_start() has.
> > > + * If we just passed the tr->filtered_pids around, then RCU would
> > > + * have been enough, but doing that makes things more complex.
> > > + */
> > > + mutex_lock(&event_mutex);
> > > + rcu_read_lock_sched();
> >
> > This looks interesting... You hold the mutex, which I am guessing
> > blocks changes. Then why the need for rcu_read_lock_sched()?
>
> Technically you are correct. It's not needed. But I added it more for
> documentation :-)
>
> Ideally, we wouldn't need the mutex here. But then we need to pass
> around the pid_list which makes it a bit more complex in the seq_file
> code than to pass around the tr (where we get pid_list from
> tr->filtered_pids).
>
> And we do multiple rcu_dereference_sched()s, and for this code to work
> properly (give consistent output), the result should be the same.
> Hence, we grab the mutex, to keep the tr->filtered_pids to be
> consistent between the rcu_dereference_sched() calls, but since we are
> not modifying tr->filtered_pids(), and if we changed this code to do a
> single rcu_dereference_sched() and pass around the result, then we
> wouldn't need to grab the mutex, and the rcu_read_lock_sched() would be
> enough.
>
> I could remove it and change the code to do rcu_dereferenced_lock() but
> to me that makes it sound like this code is an update path, which it is
> not.
>
> Does this make sense in a crazy way?
Ummm... Pretty crazy. ;-)
For me, it was mostly confusing, as I could not figure out how the
rcu_read_lock_sched() was helping. But of course, others' mileage
might vary.
Thanx, Paul
> -- Steve
>
>
> >
> > Thanx, Paul
> >
> > > +
> > > + pid_list = rcu_dereference_sched(tr->filtered_pids);
> > > +
> > > + if (!pid_list || *pos >= pid_list->nr_pids)
> > > + return NULL;
> > > +
> > > + return (void *)&pid_list->pids[*pos];
> > > +}
> > > +
> > > +static void p_stop(struct seq_file *m, void *p)
> > > +{
> > > + rcu_read_unlock_sched();
> > > + mutex_unlock(&event_mutex);
> > > +}
> > > +
> > > +static void *
> > > +p_next(struct seq_file *m, void *v, loff_t *pos)
> > > +{
> > > + struct trace_array *tr = m->private;
> > > + struct trace_pid_list *pid_list = rcu_dereference_sched(tr->filtered_pids);
> > > +
> > > + (*pos)++;
> > > +
> > > + if (*pos >= pid_list->nr_pids)
> > > + return NULL;
> > > +
> > > + return (void *)&pid_list->pids[*pos];
> > > +}
> > > +
> > > +static int p_show(struct seq_file *m, void *v)
> > > +{
> > > + pid_t *pid = v;
> > > +
> > > + seq_printf(m, "%d\n", *pid);
> > > + return 0;
> > > +}
>
next prev parent reply other threads:[~2015-12-01 18:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-29 7:07 [for-next][PATCH 0/5] tracing: Addition of set_event_pid Steven Rostedt
2015-10-29 7:07 ` [for-next][PATCH 1/5] tracepoint: Give priority to probes of tracepoints Steven Rostedt
2015-10-29 17:52 ` Mathieu Desnoyers
2015-10-30 20:25 ` Steven Rostedt
2015-10-30 20:49 ` Mathieu Desnoyers
2015-10-29 7:07 ` [for-next][PATCH 2/5] tracing: Add set_event_pid directory for future use Steven Rostedt
2015-11-19 23:24 ` Paul E. McKenney
2015-11-20 4:17 ` Steven Rostedt
2015-12-01 18:12 ` Paul E. McKenney [this message]
2015-10-29 7:07 ` [for-next][PATCH 3/5] tracing: Implement event pid filtering Steven Rostedt
2015-10-29 7:07 ` [for-next][PATCH 4/5] tracing: Check all tasks on each CPU when filtering pids Steven Rostedt
2015-10-30 6:16 ` Jiaxing Wang
2015-10-30 20:28 ` Steven Rostedt
2015-10-29 7:07 ` [for-next][PATCH 5/5] tracing: Fix sparse RCU warning Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151201181237.GQ26643@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.