linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sched: smpnice -- apply review suggestions
@ 2006-02-23  1:15 Peter Williams
  2006-02-24  0:59 ` Con Kolivas
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Williams @ 2006-02-23  1:15 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Linux Kernel Mailing List, Con Kolivas, Ingo Molnar, npiggin,
	Siddha, Suresh B, Chen, Kenneth W, John Hawkes

[-- Attachment #1: Type: text/plain, Size: 651 bytes --]

This patch applies the suggestions made by Con Kolivas for improving the 
smpnice code.

The non cosmetic part of the patch addresses the fact the mapping from 
nice values to task load weights for negative nice values does not match 
the implied CPU allocations in the function task_timeslice().  As 
suggested by Con the mapping function now uses the time slice 
information directly (via a slightly modified interface).

Signed-off-by: Peter Williams <pwil3058@bigpond.com.au>

Peter
-- 
Peter Williams                                   pwil3058@bigpond.net.au

"Learning, n. The kind of ignorance distinguishing the studious."
  -- Ambrose Bierce

[-- Attachment #2: smpnice-apply-review-comments --]
[-- Type: text/plain, Size: 3134 bytes --]

Index: MM-2.6.X/include/linux/sched.h
===================================================================
--- MM-2.6.X.orig/include/linux/sched.h	2006-02-23 11:23:42.000000000 +1100
+++ MM-2.6.X/include/linux/sched.h	2006-02-23 12:02:16.000000000 +1100
@@ -699,13 +699,13 @@ struct task_struct {
 
 	int lock_depth;		/* BKL lock depth */
 
-#if defined(CONFIG_SMP) && defined(__ARCH_WANT_UNLOCKED_CTXSW)
+#ifdef CONFIG_SMP
+#ifdef __ARCH_WANT_UNLOCKED_CTXSW
 	int oncpu;
 #endif
-	int prio, static_prio;
-#ifdef CONFIG_SMP
 	int load_weight;	/* for load balancing purposes */
 #endif
+	int prio, static_prio;
 	struct list_head run_list;
 	prio_array_t *array;
 
Index: MM-2.6.X/kernel/sched.c
===================================================================
--- MM-2.6.X.orig/kernel/sched.c	2006-02-23 11:23:42.000000000 +1100
+++ MM-2.6.X/kernel/sched.c	2006-02-23 11:55:37.000000000 +1100
@@ -170,13 +170,19 @@
 #define SCALE_PRIO(x, prio) \
 	max(x * (MAX_PRIO - prio) / (MAX_USER_PRIO/2), MIN_TIMESLICE)
 
-static unsigned int task_timeslice(task_t *p)
+static unsigned int static_prio_timeslice(int static_prio)
 {
-	if (p->static_prio < NICE_TO_PRIO(0))
-		return SCALE_PRIO(DEF_TIMESLICE*4, p->static_prio);
+	if (static_prio < NICE_TO_PRIO(0))
+		return SCALE_PRIO(DEF_TIMESLICE*4, static_prio);
 	else
-		return SCALE_PRIO(DEF_TIMESLICE, p->static_prio);
+		return SCALE_PRIO(DEF_TIMESLICE, static_prio);
 }
+
+static inline unsigned int task_timeslice(task_t *p)
+{
+	return static_prio_timeslice(p->static_prio);
+}
+
 #define task_hot(p, now, sd) ((long long) ((now) - (p)->last_ran)	\
 				< (long long) (sd)->cache_hot_time)
 
@@ -676,21 +682,23 @@ static int effective_prio(task_t *p)
  * To aid in avoiding the subversion of "niceness" due to uneven distribution
  * of tasks with abnormal "nice" values across CPUs the contribution that
  * each task makes to its run queue's load is weighted according to its
- * scheduling class and "nice" value.
+ * scheduling class and "nice" value.  For SCHED_NORMAL tasks this is just a
+ * scaled version of the new time slice allocation that they receive on time
+ * slice expiry etc.
  */
 
 /*
- * Priority weight for load balancing ranges from 1/20 (nice==19) to 459/20 (RT
- * priority of 100).
+ * Assume: static_prio_timeslice(NICE_TO_PRIO(0)) == DEF_TIMESLICE
+ * If static_prio_timeslice() is ever changed to break this assumption then
+ * this code will need modification
  */
-#define NICE_TO_LOAD_PRIO(nice) \
-	((nice >= 0) ? (20 - (nice)) : (20 + (nice) * (nice)))
+#define TIME_SLICE_NICE_ZERO DEF_TIMESLICE
 #define LOAD_WEIGHT(lp) \
-	(((lp) * SCHED_LOAD_SCALE) / NICE_TO_LOAD_PRIO(0))
-#define NICE_TO_LOAD_WEIGHT(nice)	LOAD_WEIGHT(NICE_TO_LOAD_PRIO(nice))
-#define PRIO_TO_LOAD_WEIGHT(prio)	NICE_TO_LOAD_WEIGHT(PRIO_TO_NICE(prio))
+	(((lp) * SCHED_LOAD_SCALE) / TIME_SLICE_NICE_ZERO)
+#define PRIO_TO_LOAD_WEIGHT(prio) \
+	LOAD_WEIGHT(static_prio_timeslice(prio))
 #define RTPRIO_TO_LOAD_WEIGHT(rp) \
-	LOAD_WEIGHT(NICE_TO_LOAD_PRIO(-20) + (rp))
+	(PRIO_TO_LOAD_WEIGHT(MAX_RT_PRIO) + LOAD_WEIGHT(rp))
 
 static inline void set_load_weight(task_t *p)
 {

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

* Re: [PATCH] sched: smpnice -- apply review suggestions
  2006-02-23  1:15 [PATCH] sched: smpnice -- apply review suggestions Peter Williams
@ 2006-02-24  0:59 ` Con Kolivas
  0 siblings, 0 replies; 2+ messages in thread
From: Con Kolivas @ 2006-02-24  0:59 UTC (permalink / raw)
  To: Peter Williams
  Cc: Andrew Morton, Linux Kernel Mailing List, Ingo Molnar, npiggin,
	Siddha, Suresh B, Chen, Kenneth W, John Hawkes

On Thursday 23 February 2006 12:15, Peter Williams wrote:
> This patch applies the suggestions made by Con Kolivas for improving the
> smpnice code.
>
> The non cosmetic part of the patch addresses the fact the mapping from
> nice values to task load weights for negative nice values does not match
> the implied CPU allocations in the function task_timeslice().  As
> suggested by Con the mapping function now uses the time slice
> information directly (via a slightly modified interface).

Looks good to me.

> Signed-off-by: Peter Williams <pwil3058@bigpond.com.au>
Signed-off-by: Con Kolivas <kernel@kolivas.org>

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

end of thread, other threads:[~2006-02-24  1:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-23  1:15 [PATCH] sched: smpnice -- apply review suggestions Peter Williams
2006-02-24  0:59 ` Con Kolivas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).