All of lore.kernel.org
 help / color / mirror / Atom feed
* Bad patch to schedule()
@ 2005-03-09 12:02 Andi Kleen
  2005-03-13  5:18 ` Roland McGrath
  0 siblings, 1 reply; 2+ messages in thread
From: Andi Kleen @ 2005-03-09 12:02 UTC (permalink / raw)
  To: torvalds, roland, akpm; +Cc: linux-kernel


I just see that this patch went into mainline.

[PATCH] posix-timers: high-resolution CPU clocks for POSIX clock_* syscalls

This patch provides support for thread and process CPU time clocks in the
....

 /*
+ * This is called on clock ticks and on context switches.
+ * Bank in p->sched_time the ns elapsed since the last tick or switch.
+ */
+static inline void update_cpu_clock(task_t *p, runqueue_t *rq,
+				    unsigned long long now)
+{
+	unsigned long long last = max(p->timestamp, rq->timestamp_last_tick);
+	p->sched_time += now - last;
+}
+

called from schedule(). The problem with this is that it completely
messes up the register allocation for i386 schedule() because it 
does long long arithmetic. This causes gcc to spill everything
else because it needs four registers, and i386 only has 6 usable
ones.

I think a critical path like the scheduler needs a little bit more
care.  Also it is totally unclear if this obscure POSIX feature
is really worth making schedule() slower. I think not.

In case it is kept it should be done in a way that doesn't impact
i386 unduly e.g. by avoiding long long arithmetic here and 
making sure fast paths stay fast.

I would propose to back this patch out again until this is resolved.

-Andi



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bad patch to schedule()
  2005-03-09 12:02 Bad patch to schedule() Andi Kleen
@ 2005-03-13  5:18 ` Roland McGrath
  0 siblings, 0 replies; 2+ messages in thread
From: Roland McGrath @ 2005-03-13  5:18 UTC (permalink / raw)
  To: Andi Kleen; +Cc: torvalds, akpm, linux-kernel

> called from schedule(). The problem with this is that it completely
> messes up the register allocation for i386 schedule() because it 
> does long long arithmetic. This causes gcc to spill everything
> else because it needs four registers, and i386 only has 6 usable
> ones.

The generated code I've seen does not bear out this claim.  If you are
using ancient compilers and they produce poor code, then it is time to move
on.  If you are using some recent gcc, then you'll have to show the
concrete details since they don't match what I see.


Thanks,
Roland

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-03-13  5:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-09 12:02 Bad patch to schedule() Andi Kleen
2005-03-13  5:18 ` Roland McGrath

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.