public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: William Lee Irwin III <wli@holomorphy.com>
To: Andrea Arcangeli <andrea@novell.com>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>,
	Ingo Molnar <mingo@elte.hu>, Andrew Morton <akpm@osdl.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [patch] sched: fix scheduling latencies for !PREEMPT kernels
Date: Tue, 14 Sep 2004 09:31:06 -0700	[thread overview]
Message-ID: <20040914163106.GS9106@holomorphy.com> (raw)
In-Reply-To: <20040914140905.GM4180@dualathlon.random>

On Tue, Sep 14, 2004 at 04:09:05PM +0200, Andrea Arcangeli wrote:
> 1) cond_resched should become a noop if CONFIG_PREEMPT=y
>    (cond_resched_lock of course should still unlock/relock if
>     need_resched() is set, but not __cond_resched).
> 2) all Ingo's new and old might_sleep should be converted to
>    cond_resched (or optionally to cond_resched_costly, see point 5).
> 3) might_sleep should return a debug statement.
> 4) cond_resched should call might_sleep if need_resched is not set if
>    CONFIG_PREEMPT=n is disabled, and it should _only_ call might_sleep
>    if CONFIG_PREEMPT=y after we implement point 1.
> 5) no further config option should exist (if we really add an option
>    it should be called CONFIG_COND_RESCHED_COSTLY of similar to 
>    differentiate scheduling points in fast paths (like spinlock places
>    with CONFIG_PREEMPT=n) (so you can choose between cond_resched() and
>    cond_resched_costly())
> I recommended point 2,3,4,5 already (a few of them twice), point 1 (your
> point) looks lower prio (CONFIG_PREEMPT=y already does an overkill of
> implicit need_resched() checks anyways).

The might_sleep() in cond_resched() sounds particularly useful to pick
up misapplications of cond_resched().


On Tue, Sep 14, 2004 at 11:33:48PM +1000, Nick Piggin wrote:
>> Why would someone who really cares about latency not enable preempt?
>> cond_rescheds everywhere? Isn't this now the worst of both worlds?

On Tue, Sep 14, 2004 at 04:09:05PM +0200, Andrea Arcangeli wrote:
> to avoid lots of worthless cond_resched in all spin_unlock and to avoid
> kernel crashes if some driver is not preempt complaint?
> I've a better question for you, why would someone ever disable
> CONFIG_PREEMPT_VOLUNTARY? That config option is a nosense as far as I
> can tell. If something it should be renamed to
> "CONFIG_I_DON_T_WANT_TO_RUN_THE_OLD_KERNEL_CODE" ;)

Well, thankfully we've taken the whole of the preempt-related code in
spin_unlock() and all the other locking primitives out of line for the
CONFIG_PREEMPT case (and potentially more, though that would be at the
expense of x86(-64)).

preempt_schedule() is actually what's used in preempt_check_resched(),
not cond_resched(), and this inspired me to take a look at that. What
on earth are people smoking with all these loops done up with gotos?
I suppose this isn't even the half of it, but it's what I looked at.


-- wli

Nuke some superfluous gotos in preempt_schedule().

Index: mm5-2.6.9-rc1/kernel/sched.c
===================================================================
--- mm5-2.6.9-rc1.orig/kernel/sched.c	2004-09-13 16:27:46.998672328 -0700
+++ mm5-2.6.9-rc1/kernel/sched.c	2004-09-14 09:01:46.514087864 -0700
@@ -2464,18 +2464,19 @@
 	 * If there is a non-zero preempt_count or interrupts are disabled,
 	 * we do not want to preempt the current task.  Just return..
 	 */
-	if (unlikely(ti->preempt_count || irqs_disabled()))
-		return;
-
-need_resched:
-	ti->preempt_count = PREEMPT_ACTIVE;
-	schedule();
-	ti->preempt_count = 0;
+	if (likely(!ti->preempt_count && !irqs_disabled())) {
+		do {
+			ti->preempt_count = PREEMPT_ACTIVE;
+			schedule();
+			ti->preempt_count = 0;
 
-	/* we could miss a preemption opportunity between schedule and now */
-	barrier();
-	if (unlikely(test_thread_flag(TIF_NEED_RESCHED)))
-		goto need_resched;
+			/*
+			 * Without this barrier, we could miss a
+			 * preemption opportunity between schedule and now
+			 */
+			barrier();
+		} while (unlikely(test_thread_flag(TIF_NEED_RESCHED)));
+	}
 }
 
 EXPORT_SYMBOL(preempt_schedule);

  parent reply	other threads:[~2004-09-14 16:43 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-14  9:15 [patch] preempt-cleanup.patch, 2.6.9-rc2 Ingo Molnar
2004-09-14  9:34 ` [printk] make console_conditional_schedule() __sched and use cond_resched() William Lee Irwin III
2004-09-14  9:38 ` [patch] preempt-lock-need-resched.patch, 2.6.9-rc2 Ingo Molnar
2004-09-14  9:51   ` [patch] sched: add cond_resched_softirq() Ingo Molnar
2004-09-14  9:57     ` [patch] sched: fix latency in random driver Ingo Molnar
2004-09-14 10:06       ` [patch] sched, ext3: fix scheduling latencies in ext3 Ingo Molnar
2004-09-14 10:13         ` [patch] sched, vfs: fix scheduling latencies in invalidate_inodes() Ingo Molnar
2004-09-14 10:19         ` [patch] sched, vfs: fix scheduling latencies in prune_dcache() and select_parent() Ingo Molnar
2004-09-14 10:25           ` [patch] sched, net: fix scheduling latencies in netstat Ingo Molnar
2004-09-14 10:44             ` [patch] sched, net: fix scheduling latencies in __release_sock Ingo Molnar
2004-09-14 10:50               ` [patch] sched, mm: fix scheduling latencies in copy_page_range() Ingo Molnar
2004-09-14 10:56                 ` [patch] sched, mm: fix scheduling latencies in unmap_vmas() Ingo Molnar
2004-09-14 10:59                 ` [patch] sched, mm: fix scheduling latencies in get_user_pages() Ingo Molnar
2004-09-14 11:02                   ` [patch] sched, mm: fix scheduling latencies in filemap_sync() Ingo Molnar
2004-09-14 11:06                     ` [patch] sched, tty: fix scheduling latencies in tty_io.c Ingo Molnar
2004-09-14 10:53                       ` Alan Cox
2004-09-14 12:00                         ` Ingo Molnar
2004-09-14 11:18                           ` Alan Cox
2004-09-14 12:27                             ` Ingo Molnar
2004-09-14 12:11                               ` Alan Cox
2004-09-14 11:08                       ` [patch] sched, pty: fix scheduling latencies in pty.c Ingo Molnar
2004-09-14 11:12                         ` [patch] might_sleep() additions to fs-writeback.c Ingo Molnar
2004-09-14 11:25                         ` [patch] fix keventd execution dependency Ingo Molnar
2004-09-15 22:18                           ` Rusty Russell
2004-09-14 11:28                       ` [patch] sched: fix scheduling latencies in mttr.c Ingo Molnar
2004-09-14 11:32                         ` [patch] sched: fix scheduling latencies in vgacon.c Ingo Molnar
2004-09-14 11:35                         ` [patch] sched: fix scheduling latencies in NTFS mount Ingo Molnar
2004-09-14 13:31                           ` Anton Altaparmakov
2004-09-14 11:42                         ` [patch] sched: fix scheduling latencies for !PREEMPT kernels Ingo Molnar
2004-09-14 12:55                           ` Nick Piggin
2004-09-14 13:22                             ` Ingo Molnar
2004-09-14 13:33                               ` Nick Piggin
2004-09-14 14:09                                 ` Andrea Arcangeli
2004-09-14 14:28                                   ` Nick Piggin
2004-09-14 15:03                                     ` Andrea Arcangeli
2004-09-14 18:05                                       ` Robert Love
2004-09-14 18:52                                         ` William Lee Irwin III
2004-09-14 19:02                                           ` Robert Love
2004-09-14 19:21                                             ` William Lee Irwin III
2004-09-14 19:19                                               ` Alan Cox
2004-09-15  0:22                                                 ` Lee Revell
2004-09-15  1:46                                                   ` William Lee Irwin III
2004-09-15  2:00                                                     ` Lee Revell
2004-09-15  2:36                                                       ` William Lee Irwin III
2004-09-15  2:59                                                         ` Lee Revell
2004-09-15 13:36                                                         ` Hans Reiser
2004-09-15 20:40                                                           ` William Lee Irwin III
2004-09-15  1:18                                                 ` William Lee Irwin III
2004-09-14 19:26                                               ` Robert Love
2004-09-14 21:06                                               ` William Lee Irwin III
2004-09-14 19:25                                             ` Andrea Arcangeli
2004-09-14 19:29                                               ` Robert Love
2004-09-14 19:34                                               ` William Lee Irwin III
2004-09-15  1:02                                       ` Lee Revell
2004-09-15  1:39                                         ` William Lee Irwin III
2004-09-15  2:11                                           ` Lee Revell
2004-09-15 11:17                                             ` Ingo Molnar
2004-09-15  9:56                                           ` Ingo Molnar
2004-09-15  9:57                                             ` William Lee Irwin III
2004-09-15 10:12                                               ` Ingo Molnar
2004-09-14 16:31                                   ` William Lee Irwin III [this message]
2004-09-14 16:39                                     ` Andrea Arcangeli
2004-09-14 14:54                                 ` Ingo Molnar
2004-09-14 22:55                                   ` Nick Piggin
2004-09-15  6:19                                     ` Ingo Molnar
2004-09-15  8:23                                       ` Nick Piggin
2004-09-15  8:43                                         ` Ingo Molnar
2004-09-15 10:09                                           ` William Lee Irwin III
2004-09-15 10:21                                             ` Ingo Molnar
2004-09-16  1:03                                           ` Nick Piggin
2004-09-16  6:14                                             ` Ingo Molnar
2004-09-15  0:35                                   ` Lee Revell
2004-09-14 13:25                         ` [patch] sched: fix scheduling latencies in mtrr.c Ingo Molnar
2004-09-14 13:15                           ` Alan Cox
2004-09-14 15:00                             ` Ingo Molnar
2004-09-14 18:22                           ` Zwane Mwaikambo

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=20040914163106.GS9106@holomorphy.com \
    --to=wli@holomorphy.com \
    --cc=akpm@osdl.org \
    --cc=andrea@novell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=nickpiggin@yahoo.com.au \
    /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