public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>, Mike Galbraith <efault@gmx.de>,
	Paul Mackerras <paulus@samba.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Steven Rostedt <rostedt@goodmis.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH tip 1/1] perf_counter tools: Add locking to perf top
Date: Fri, 29 May 2009 22:22:17 +0200	[thread overview]
Message-ID: <1243628537.6645.106.camel@laptop> (raw)
In-Reply-To: <20090529200307.GR4747@ghostprotocols.net>

On Fri, 2009-05-29 at 17:03 -0300, Arnaldo Carvalho de Melo wrote:
>         /* Sort the active symbols */
> -       list_for_each_entry_safe(syme, n, &active_symbols, node) {
> -               if (syme->count[0] != 0) {
> +       pthread_mutex_lock(&active_symbols_lock);
> +       syme = list_entry(active_symbols.next, struct sym_entry, node);
> +       pthread_mutex_unlock(&active_symbols_lock);
> +
> +       list_for_each_entry_safe_from(syme, n, &active_symbols, node) {
> +               syme->snap_count = syme->count[0];
> +               if (syme->snap_count != 0) {
> +                       syme->weight = sym_weight(syme);

That looks wrong, you basically do a fancy cast while holding the lock,
then you overwrite the variable doing a list iteration without holding
the lock.

If list_add and list_del are under a lock, the iteration should be too.


  reply	other threads:[~2009-05-29 20:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-29 20:03 [PATCH tip 1/1] perf_counter tools: Add locking to perf top Arnaldo Carvalho de Melo
2009-05-29 20:22 ` Peter Zijlstra [this message]
2009-05-29 20:33   ` Arnaldo Carvalho de Melo
2009-05-30  9:33     ` Ingo Molnar
2009-05-30 10:31     ` Peter Zijlstra
2009-05-30  9:48 ` [tip:perfcounters/core] " tip-bot for Arnaldo Carvalho de Melo

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=1243628537.6645.106.camel@laptop \
    --to=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=efault@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /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