From: Manfred Spraul <manfred@colorfullife.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Mikael Pettersson <mikpe@csd.uu.se>, linux-kernel@vger.kernel.org
Subject: Re: [RFC][2.6.8-rc1-mm1] perfctr inheritance locking issue
Date: Tue, 27 Jul 2004 18:25:00 +0200 [thread overview]
Message-ID: <410681DC.7030706@colorfullife.com> (raw)
In-Reply-To: <20040726165754.1a4eda43.akpm@osdl.org>
Andrew Morton wrote:
>Mikael Pettersson <mikpe@csd.uu.se> wrote:
>
>
>>Andrew,
>>
>>There is another locking problem with the per-process
>>performance counter inheritance changes I sent you.
>>
>>I currently use task_lock(tsk) to synchronise accesses
>>to tsk->thread.perfctr, when that pointer could change.
>>
>>The write_lock_irq(&tasklist_lock) in release_task() is
>>needed to prevent ->parent from changing while releasing the
>>child, but the parent's ->thread.perfctr must also be locked.
>>However, sched.h explicitly forbids holding task_lock()
>>simultaneously with write_lock_irq(&tasklist_lock). Ouch.
>>
>>
>
>That's ghastly.
>
> * Nests both inside and outside of read_lock(&tasklist_lock).
> * It must not be nested with write_lock_irq(&tasklist_lock),
> * neither inside nor outside.
>
>Manfred, where did you discover the offending code?
>
>
>
Think about interrupts: they are permitted to acquire the tasklist_lock
for read.
Someone does
read_lock(&tasklist_lock);
task_lock(tsk);
One example is __do_SAK in tty_io.c, but I think there are further examples.
Now add a softirq that tries to deliver a signal: kill_something_info()
contains a
read_lock(&tasklist_lock);
This sequence doesn't deadlock - rw spinlocks starve writers.
But it means that both
task_lock();
write_lock_irq(&tasklist_lock);
and
write_lock_irq(&tasklist_lock);
task_lock();
can deadlock with the read_lock()/task_lock()/read_lock() sequence.
>Would be better to just sort out the locking, then take task_lock() inside
>tasklist_lock. That was allegedly the rule in 2.4.
>
>
It probably works by chance in 2.4.
--
Manfred
prev parent reply other threads:[~2004-07-27 16:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-20 11:22 [RFC][2.6.8-rc1-mm1] perfctr inheritance locking issue Mikael Pettersson
2004-07-26 23:57 ` Andrew Morton
2004-07-27 16:25 ` Manfred Spraul [this message]
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=410681DC.7030706@colorfullife.com \
--to=manfred@colorfullife.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mikpe@csd.uu.se \
/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.