From: "Paul E. McKenney" <paulmck@us.ibm.com>
To: Wu Fengguang <wfg@mail.ustc.edu.cn>,
linux-kernel@vger.kernel.org, Andrew Morton <akpm@osdl.org>
Cc: mingo@elte.hu, levon@movementarian.org
Subject: Re: BUG: spinlock recursion on 2.6.14-mm2 when oprofiling
Date: Fri, 25 Nov 2005 15:28:29 -0800 [thread overview]
Message-ID: <20051125232829.GA2405@us.ibm.com> (raw)
In-Reply-To: <20051125220117.GA1836@us.ibm.com>
On Fri, Nov 25, 2005 at 02:01:17PM -0800, Paul E. McKenney wrote:
> One concern on the attached patch is the possible effect on latency.
>
> John, any reason why the dead_tasks list cannot be spliced onto a
> local list, then freed outside of the task_mortuary lock? Any reason
> why the dying_tasks list cannot be spliced onto the dead_tasks list
> (an O(1) operation)?
And here is an alternative patch that assumes that the answer to both
questions above is "no". It is shorter, though mostly due to use of
the list_splice_init() and list_for_each_entry_safe() primitives.
Thanx, Paul
Signed-off-by: <paulmck@us.ibm.com>
buffer_sync.c | 28 +++++++++++++---------------
1 files changed, 13 insertions(+), 15 deletions(-)
diff -urpNa -X dontdiff linux-2.6.14-mm2/drivers/oprofile/buffer_sync.c linux-2.6.14-mm2-fixmortuary/drivers/oprofile/buffer_sync.c
--- linux-2.6.14-mm2/drivers/oprofile/buffer_sync.c 2005-10-27 17:02:08.000000000 -0700
+++ linux-2.6.14-mm2-fixmortuary/drivers/oprofile/buffer_sync.c 2005-11-25 14:51:26.000000000 -0800
@@ -46,10 +46,11 @@ static void process_task_mortuary(void);
*/
static int task_free_notify(struct notifier_block * self, unsigned long val, void * data)
{
+ unsigned long flags;
struct task_struct * task = data;
- spin_lock(&task_mortuary);
+ spin_lock_irqsave(&task_mortuary, flags);
list_add(&task->tasks, &dying_tasks);
- spin_unlock(&task_mortuary);
+ spin_unlock_irqrestore(&task_mortuary, flags);
return NOTIFY_OK;
}
@@ -431,25 +432,22 @@ static void increment_tail(struct oprofi
*/
static void process_task_mortuary(void)
{
- struct list_head * pos;
- struct list_head * pos2;
+ unsigned long flags;
+ LIST_HEAD(local_dead_tasks);
struct task_struct * task;
+ struct task_struct * ttask;
- spin_lock(&task_mortuary);
+ spin_lock_irqsave(&task_mortuary, flags);
- list_for_each_safe(pos, pos2, &dead_tasks) {
- task = list_entry(pos, struct task_struct, tasks);
- list_del(&task->tasks);
- free_task(task);
- }
+ list_splice_init(&dead_tasks, &local_dead_tasks);
+ list_splice_init(&dying_tasks, &dead_tasks);
- list_for_each_safe(pos, pos2, &dying_tasks) {
- task = list_entry(pos, struct task_struct, tasks);
+ spin_unlock_irqrestore(&task_mortuary, flags);
+
+ list_for_each_entry_safe(task, ttask, &local_dead_tasks, tasks) {
list_del(&task->tasks);
- list_add_tail(&task->tasks, &dead_tasks);
+ free_task(task);
}
-
- spin_unlock(&task_mortuary);
}
next prev parent reply other threads:[~2005-11-25 23:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-18 15:21 BUG: spinlock recursion on 2.6.14-mm2 when oprofiling Wu Fengguang
2005-11-25 22:01 ` Paul E. McKenney
2005-11-25 23:28 ` Paul E. McKenney [this message]
2005-11-26 3:39 ` Wu Fengguang
2005-11-26 5:14 ` Paul E. McKenney
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=20051125232829.GA2405@us.ibm.com \
--to=paulmck@us.ibm.com \
--cc=akpm@osdl.org \
--cc=levon@movementarian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=wfg@mail.ustc.edu.cn \
/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