2003-05-19 08:13:18

by Ingo Molnar

[permalink] [raw]
Subject: [patch] sched-cleanup-2.5.69-A0


the attached scheduler cleanup (against BK-curr) removes the unused
requeueing code. Compiles & boots.

Ingo

--- linux/kernel/sched.c.orig
+++ linux/kernel/sched.c
@@ -340,10 +340,9 @@ static inline void __activate_task(task_
* Update all the scheduling statistics stuff. (sleep average
* calculation, priority modifiers, etc.)
*/
-static inline int activate_task(task_t *p, runqueue_t *rq)
+static inline void activate_task(task_t *p, runqueue_t *rq)
{
long sleep_time = jiffies - p->last_run - 1;
- int requeue_waker = 0;

if (sleep_time > 0) {
int sleep_avg;
@@ -372,8 +371,6 @@ static inline int activate_task(task_t *
}
}
__activate_task(p, rq);
-
- return requeue_waker;
}

/*
@@ -471,8 +468,8 @@ repeat:
*/
static int try_to_wake_up(task_t * p, unsigned int state, int sync, int kick)
{
- int success = 0, requeue_waker = 0;
unsigned long flags;
+ int success = 0;
long old_state;
runqueue_t *rq;

@@ -498,7 +495,7 @@ repeat_lock_task:
if (sync)
__activate_task(p, rq);
else {
- requeue_waker = activate_task(p, rq);
+ activate_task(p, rq);
if (p->prio < rq->curr->prio)
resched_task(rq->curr);
}
@@ -510,21 +507,6 @@ repeat_lock_task:
}
task_rq_unlock(rq, &flags);

- /*
- * We have to do this outside the other spinlock, the two
- * runqueues might be different:
- */
- if (requeue_waker) {
- prio_array_t *array;
-
- rq = task_rq_lock(current, &flags);
- array = current->array;
- dequeue_task(current, array);
- current->prio = effective_prio(current);
- enqueue_task(current, array);
- task_rq_unlock(rq, &flags);
- }
-
return success;
}



2003-05-19 15:01:02

by Werner Almesberger

[permalink] [raw]
Subject: Re: [patch] sched-cleanup-2.5.69-A0

Ingo Molnar wrote:
> the attached scheduler cleanup (against BK-curr) removes the unused
> requeueing code. Compiles & boots.

Ah, what a sweet way of getting rid of my nemesis :-)

The requeuing code troubled me quite a bit with umlsim, which
makes all kinds of calls from the idle task, including calls to
try_to_wake_up, or functions that eventually call it. Naturally,
whenever the requeuing was used, it tripped over current->array.
(And even with a fake array, it would have had ill effects.)

So the requeuing didn't do anything for processes other than the
idle task ?

- Werner

--
_________________________________________________________________________
/ Werner Almesberger, Buenos Aires, Argentina [email protected] /
/_http://www.almesberger.net/____________________________________________/

2003-05-19 15:57:19

by Ingo Molnar

[permalink] [raw]
Subject: Re: [patch] sched-cleanup-2.5.69-A0


On Mon, 19 May 2003, Werner Almesberger wrote:

> > the attached scheduler cleanup (against BK-curr) removes the unused
> > requeueing code. Compiles & boots.
>
> Ah, what a sweet way of getting rid of my nemesis :-)
>
> The requeuing code troubled me quite a bit with umlsim, which makes all
> kinds of calls from the idle task, including calls to try_to_wake_up, or
> functions that eventually call it. Naturally, whenever the requeuing was
> used, it tripped over current->array. (And even with a fake array, it
> would have had ill effects.)
>
> So the requeuing didn't do anything for processes other than the idle
> task ?

hm, it should in fact have been dead code from 2.5.68 on and upwards.
Before that it was called quite often.

but doing stuff out of the idle thread is not nice i think, there's a fair
amount of code that does not work out of the idle task. Any reason you
dont start some really-low-prio thread instead? (i could suggest
SCHED_BATCH but the scheduler doesnt have it :-)

Ingo

2003-05-19 16:39:10

by Werner Almesberger

[permalink] [raw]
Subject: Re: [patch] sched-cleanup-2.5.69-A0

Ingo Molnar wrote:
> hm, it should in fact have been dead code from 2.5.68 on and upwards.
> Before that it was called quite often.

Ah, that makes sense: I hit it in 2.5.66 and haven't tried more
recent kernels yet.

> but doing stuff out of the idle thread is not nice i think, there's a fair
> amount of code that does not work out of the idle task.

Yes, that's what I'm a bit worried about. Not calling anything
that may sleep sounds fair enough to me. At least networking
(that is, ARP and TCP) seems to be okay (I'm calling netif_rx,
plus a few simple helper functions, such as flow control, and
dev_alloc_skb), but it would of course be nice to avoid future
pitfalls.

A bit of background: umlsim (http://umlsim.sourceforge.net/)
turns UML into an event-driven simulator. It sits in the idle
thread to handle timeouts (simulation time doesn't move while
there is any pending work). All this is controlled by a master
process that works as a script-driven debugger. What those
scripts do is up to the user, but there's a (currently very
small) set of "library" functions that handle some of the more
common tasks, such as moving packets from one UML to the next.

> Any reason you
> dont start some really-low-prio thread instead? (i could suggest
> SCHED_BATCH but the scheduler doesnt have it :-)

Yes, I could do that, as long as this thread gets only run if there
is really nothing else left to do, but then only this thread runs.
Which is, of course, exactly what the idle thread does.

I could make it yield if anything else is runnable (I already check
for this, but just to panic). I suppose if I just set p->static_prio
to MAX_PRIO-1, this thread that would give me only very few
activations while other processes are runnable ?

Thanks,
- Werner

--
_________________________________________________________________________
/ Werner Almesberger, Buenos Aires, Argentina [email protected] /
/_http://www.almesberger.net/____________________________________________/

2003-05-19 16:53:07

by Ingo Molnar

[permalink] [raw]
Subject: Re: [patch] sched-cleanup-2.5.69-A0


On Mon, 19 May 2003, Werner Almesberger wrote:

> I could make it yield if anything else is runnable (I already check for
> this, but just to panic). I suppose if I just set p->static_prio to
> MAX_PRIO-1, this thread that would give me only very few activations
> while other processes are runnable ?

so you really want to run every time there's idle time, but you also want
to sleep until the event that causes some other thread to run, right?

Ingo

2003-05-19 17:33:32

by Werner Almesberger

[permalink] [raw]
Subject: Re: [patch] sched-cleanup-2.5.69-A0

Ingo Molnar wrote:
> so you really want to run every time there's idle time, but you also want
> to sleep until the event that causes some other thread to run, right?

Basically yes. When my idle thread has decided that the system
is really idle (i.e. if there are pending softirqs, it generates
an interrupt and yields), it contacts the simulator process
(outside the UML system), and puts the entire UML system to
sleep.

The simulator can then mess with the UML system through ptrace.
When it's done, it may advance the time, and let the UML system
run again. If the time has changed, the UML system will
fast-forward jiffies, and possibly generate a timer interrupt.
Then it yields its timeslice, and the cycle begins anew.

There are no "outside" interrupts, so ultimately, the event
causing other threads to run also comes from my idle thread.

- Werner

--
_________________________________________________________________________
/ Werner Almesberger, Buenos Aires, Argentina [email protected] /
/_http://www.almesberger.net/____________________________________________/