From: Eric Dumazet <dada1@cosmosbay.com>
To: "Björn Steinbrink" <B.Steinbrink@gmx.de>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Michal Piotrowski <michal.k.k.piotrowski@gmail.com>,
Ian Kumlien <iank@bredband.net>,
Linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
Arjan van de Ven <arjan@infradead.org>
Subject: Re: [BUG] Something goes wrong with timer statistics.
Date: Wed, 30 May 2007 14:44:49 +0200 [thread overview]
Message-ID: <20070530144449.36811a4d.dada1@cosmosbay.com> (raw)
In-Reply-To: <20070530113825.GA5203@atjola.homenet>
On Wed, 30 May 2007 13:38:25 +0200
Björn Steinbrink <B.Steinbrink@gmx.de> wrote:
> On 2007.05.30 00:38:08 +0200, Thomas Gleixner wrote:
> > On Wed, 2007-05-30 at 00:24 +0200, Michal Piotrowski wrote:
> > > Hi Ian,
> > >
> > > (Thomas "The Wizard of Time" added to CC :))
> >
> > Added more wizards :)
> >
> > > On 29/05/07, Ian Kumlien <iank@bredband.net> wrote:
> > > > Hi,
> > > >
> > > > As the daystar sets, i try to play some with my new would be
> > > > firewall/server, but since this will be running for quite some time i
> > > > have been experimenting with powertop to find out what i can do to limit
> > > > it's power usage.
> > > >
> > > > But, if i run powertop for too long or a few times to many... this
> > > > happens:
> > > > http://pomac.netswarm.net/pics/kernel_panic.jpg
> >
> > This was reported before. It's incredibly hard to reproduce.
>
> OK, second try, this time with a patch. In timer_stats_update_stats,
> input is allocated on the stack, so it is uninitialized, in particular
> the "next" field is random. Now in tstat_lookup, the new entry "curr" is
> initialized with the values from "input" (passed as "entry") and "next"
> is set to NULL _after_ it is added to the list, so if a second CPU is
> running the fastpath lookup while we're inserting the new element, it
> might get the garbage value in "next". The patch below fixes that.
>
> Björn
>
>
>
> Initialize the "next" field of a timer stats entry before it is inserted
> into the list to avoid a race with the fastpath lookup.
>
> Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
> ---
> diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
> index 868f1bc..5bc8f91 100644
> --- a/kernel/time/timer_stats.c
> +++ b/kernel/time/timer_stats.c
> @@ -202,12 +202,12 @@ static struct entry *tstat_lookup(struct entry *entry, char *comm)
> if (curr) {
> *curr = *entry;
> curr->count = 0;
> + curr->next = NULL;
> memcpy(curr->comm, comm, TASK_COMM_LEN);
> if (prev)
> prev->next = curr;
> else
> *head = curr;
> - curr->next = NULL;
> }
> out_unlock:
> spin_unlock(&table_lock);
>
Your analysis might be right, not the fix.
You *cannot* assume curr->next = NULL will be done before insert.
You probably also need a memory barrier.
curr->next = NULL;
memcpy(curr->comm, comm, TASK_COMM_LEN);
smp_mb(); /* commit all writes to curr before insert */
if (prev)
prev->next = curr;
else
*head = curr;
next prev parent reply other threads:[~2007-05-30 12:44 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-29 21:38 Ian Kumlien
2007-05-29 22:37 ` David Miller
2007-05-29 22:42 ` Thomas Gleixner
2007-05-29 22:44 ` David Miller
2007-05-29 22:53 ` Thomas Gleixner
[not found] ` <6bffcb0e0705291541q7e6d6faen5cd6345074c4c92a@mail.gmail.com>
2007-05-29 22:44 ` David Miller
2007-05-29 22:51 ` Ian Kumlien
2007-05-29 23:03 ` David Miller
2007-05-30 0:04 ` Ian Kumlien
[not found] ` <6bffcb0e0705291524y2752d646p94b0bf6ca87af68f@mail.gmail.com>
2007-05-29 22:35 ` Ian Kumlien
2007-05-29 22:38 ` Thomas Gleixner
2007-05-29 22:50 ` Ian Kumlien
2007-05-30 6:52 ` Björn Steinbrink
2007-05-30 7:10 ` Björn Steinbrink
2007-05-30 11:38 ` Björn Steinbrink
2007-05-30 12:44 ` Eric Dumazet [this message]
2007-05-30 13:14 ` Björn Steinbrink
[not found] ` <20070531102047.GG19272@pomac.netswarm.net>
2007-05-31 14:25 ` Björn Steinbrink
2007-05-31 15:10 ` Eric Dumazet
2007-05-31 15:27 ` Björn Steinbrink
2007-05-31 22:59 ` Ian Kumlien
2007-05-31 23:09 ` Björn Steinbrink
2007-06-01 6:21 ` Ingo Molnar
2007-05-30 0:13 ` Stephane Casset
2007-05-31 23:53 ` Björn Steinbrink
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=20070530144449.36811a4d.dada1@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=B.Steinbrink@gmx.de \
--cc=Linux-kernel@vger.kernel.org \
--cc=arjan@infradead.org \
--cc=iank@bredband.net \
--cc=michal.k.k.piotrowski@gmail.com \
--cc=mingo@elte.hu \
--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
all inboxes | Powered by JetHome®