From: Andrew Morton <akpm@osdl.org>
To: Mikael Pettersson <mikpe@csd.uu.se>
Cc: linux-kernel@vger.kernel.org, Manfred Spraul <manfred@colorfullife.com>
Subject: Re: [RFC][2.6.8-rc1-mm1] perfctr inheritance locking issue
Date: Mon, 26 Jul 2004 16:57:54 -0700 [thread overview]
Message-ID: <20040726165754.1a4eda43.akpm@osdl.org> (raw)
In-Reply-To: <200407201122.i6KBMbPR021614@harpo.it.uu.se>
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?
> My options seem to boil down to one of the following:
> 1. Forget task_lock(), always take the tasklist_lock.
> This should work but would lock the task list briefly at
> operations like set_cpus_allowed(), and creating/deleting
> a task's perfctr state object. I don't like that.
> 2. Add a 'spinlock_t perfctr_lock;' to the thread_struct,
> next to the perfctr state pointer. This is much cleaner,
> but increases the size of the thread struct slightly.
>
> I think I prefer option #2. Any objections to that?
Would be better to just sort out the locking, then take task_lock() inside
tasklist_lock. That was allegedly the rule in 2.4.
next prev parent reply other threads:[~2004-07-26 23:59 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 [this message]
2004-07-27 16:25 ` Manfred Spraul
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=20040726165754.1a4eda43.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=manfred@colorfullife.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox