[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080511142222.GU19219@parisc-linux.org>
Date: Sun, 11 May 2008 08:22:23 -0600
From: Matthew Wilcox <matthew@....cx>
To: Ingo Molnar <mingo@...e.hu>
Cc: Sven Wegener <sven.wegener@...aler.net>,
Linus Torvalds <torvalds@...ux-foundation.org>,
"Zhang, Yanmin" <yanmin_zhang@...ux.intel.com>,
Andi Kleen <andi@...stfloor.org>,
LKML <linux-kernel@...r.kernel.org>,
Alexander Viro <viro@....linux.org.uk>,
Andrew Morton <akpm@...ux-foundation.org>,
Thomas Gleixner <tglx@...utronix.de>,
"H. Peter Anvin" <hpa@...or.com>
Subject: Re: [git pull] scheduler fixes
On Sun, May 11, 2008 at 03:54:14PM +0200, Ingo Molnar wrote:
> the gain is rather obvious: two parallel up()s (or just up()s which come
> close enough after each other) will wake up two tasks in parallel. With
> your patch, the first guy wakes up and then it wakes up the second guy.
> I.e. your patch serializes the wakeup chain, mine keeps it parallel.
Yup. I explained why that's actually beneficial in an earlier email.
> the cache line dirtying is rather secondary to any solution - the first
> goal for any locking primitive is to get scheduling precise: to not wake
> up more tasks than optimal and to not wake up less tasks than optimal.
That's a laudable goal, but ultimately it's secondary to performance (or
this thread wouldn't exist).
> i.e. can you see any conceptual hole in the patch below?
No conceptual holes, just a performance one.
Either we want your patch below or mine; definitely not both.
diff --git a/kernel/semaphore.c b/kernel/semaphore.c
index 5e41217..e520ad4 100644
--- a/kernel/semaphore.c
+++ b/kernel/semaphore.c
@@ -229,6 +229,11 @@ static inline int __sched __down_common(struct semaphore *sem, long state,
}
list_del(&waiter.list);
+
+ /* It's possible we need to wake up the next task on the list too */
+ if (unlikely(sem->count > 1) && !list_empty(&sem->wait_list))
+ __up(sem);
+
return ret;
}
> Ingo
>
> ---
> kernel/semaphore.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> Index: linux/kernel/semaphore.c
> ===================================================================
> --- linux.orig/kernel/semaphore.c
> +++ linux/kernel/semaphore.c
> @@ -258,5 +258,11 @@ static noinline void __sched __up(struct
> {
> struct semaphore_waiter *waiter = list_first_entry(&sem->wait_list,
> struct semaphore_waiter, list);
> + /*
> + * Rotate sleepers - to make sure all of them get woken in case
> + * of parallel up()s:
> + */
> + list_move_tail(&waiter->list, &sem->wait_list);
> +
> wake_up_process(waiter->task);
> }
--
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists