linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>, LKML <linux-kernel@vger.kernel.org>,
	Krister Johansen <kjlx@templeofstupid.com>,
	Hari Bathini <hbathini@linux.vnet.ibm.com>
Subject: Re: [PATCH 1/3] perf tools: Protect reading thread's namespace
Date: Thu, 23 May 2019 11:36:38 +0900	[thread overview]
Message-ID: <20190523023636.GA196218@google.com> (raw)
In-Reply-To: <20190522131832.GB30271@kernel.org>

Hi Arnaldo,

On Wed, May 22, 2019 at 10:18:32AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, May 22, 2019 at 02:32:48PM +0900, Namhyung Kim escreveu:
> > It seems that the current code lacks holding the namespace lock in
> > thread__namespaces().  Otherwise it can see inconsistent results.
> > 
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > ---
> >  tools/perf/util/thread.c | 15 +++++++++++++--
> >  1 file changed, 13 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
> > index 403045a2bbea..b413ba5b9835 100644
> > --- a/tools/perf/util/thread.c
> > +++ b/tools/perf/util/thread.c
> > @@ -133,7 +133,7 @@ void thread__put(struct thread *thread)
> >  	}
> >  }
> >  
> > -struct namespaces *thread__namespaces(const struct thread *thread)
> > +static struct namespaces *__thread__namespaces(const struct thread *thread)
> >  {
> >  	if (list_empty(&thread->namespaces_list))
> >  		return NULL;
> > @@ -141,10 +141,21 @@ struct namespaces *thread__namespaces(const struct thread *thread)
> >  	return list_first_entry(&thread->namespaces_list, struct namespaces, list);
> >  }
> >  
> > +struct namespaces *thread__namespaces(const struct thread *thread)
> > +{
> > +	struct namespaces *ns;
> > +
> > +	down_read((struct rw_semaphore *)&thread->namespaces_lock);
> > +	ns = __thread__namespaces(thread);
> > +	up_read((struct rw_semaphore *)&thread->namespaces_lock);
> > +
> 
> Humm, so we need to change thread__namespaces() to remove that const
> instead of throwing it away with that cast, right?

Yes, that's possible too.  Note that thread__comm_str() has the same issue
as well.

Thanks,
Namhyung

  reply	other threads:[~2019-05-23  2:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22  5:32 [PATCH 0/3] perf tools: Assorted fixes and cleanups for namespace events Namhyung Kim
2019-05-22  5:32 ` [PATCH 1/3] perf tools: Protect reading thread's namespace Namhyung Kim
2019-05-22 13:18   ` Arnaldo Carvalho de Melo
2019-05-23  2:36     ` Namhyung Kim [this message]
2019-05-27  6:11       ` [PATCH 4/3] perf tools: Remove const from thread read accessors Namhyung Kim
2019-05-27 14:15         ` Arnaldo Carvalho de Melo
2019-05-30  8:07         ` [tip:perf/core] " tip-bot for Namhyung Kim
2019-05-28 21:27   ` [tip:perf/urgent] perf namespace: Protect reading thread's namespace tip-bot for Namhyung Kim
2019-05-22  5:32 ` [PATCH 2/3] perf tools: Add missing swap ops for namespace events Namhyung Kim
2019-05-22 13:23   ` Arnaldo Carvalho de Melo
2019-05-28 21:28   ` [tip:perf/urgent] perf session: " tip-bot for Namhyung Kim
2019-05-22  5:32 ` [PATCH 3/3] perf top: Enable --namespaces option Namhyung Kim
2019-05-22 13:24   ` Arnaldo Carvalho de Melo
2019-05-23  2:42     ` Namhyung Kim
2019-05-30  8:06   ` [tip:perf/core] perf top: Add " tip-bot for Namhyung Kim

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=20190523023636.GA196218@google.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=hbathini@linux.vnet.ibm.com \
    --cc=jolsa@redhat.com \
    --cc=kjlx@templeofstupid.com \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).