mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH][plugsched additions 1/2] Add optional functions to set_task_cpu
@ 2004-11-01  3:58 Con Kolivas
  2004-11-01  5:48 ` Matt Heler
  0 siblings, 1 reply; 3+ messages in thread
From: Con Kolivas @ 2004-11-01  3:58 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andrew Morton, Peter Williams

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

Add optional functions to set_task_cpu



[-- Attachment #2: Add optional functions to set_task_cpu --]
[-- Type: text/plain, Size: 5460 bytes --]

Some cpu schedulers may want to do work when set task_cpu is called. For
completeness, Add a common version of task_cpu and set_task_cpu to
scheduler.c and make it privatised.

Add support to ingosched and staircase.

Signed-off-by: Con Kolivas <kernel@kolivas.org>


Index: linux-2.6.10-rc1-mm2-plugsched1/include/linux/sched.h
===================================================================
--- linux-2.6.10-rc1-mm2-plugsched1.orig/include/linux/sched.h	2004-10-30 22:00:40.000000000 +1000
+++ linux-2.6.10-rc1-mm2-plugsched1/include/linux/sched.h	2004-10-31 22:16:59.186092025 +1100
@@ -1076,33 +1076,8 @@ extern void recalc_sigpending(void);
 
 extern void signal_wake_up(struct task_struct *t, int resume_stopped);
 
-/*
- * Wrappers for p->thread_info->cpu access. No-op on UP.
- */
-#ifdef CONFIG_SMP
-
-static inline unsigned int task_cpu(const struct task_struct *p)
-{
-	return p->thread_info->cpu;
-}
-
-static inline void set_task_cpu(struct task_struct *p, unsigned int cpu)
-{
-	p->thread_info->cpu = cpu;
-}
-
-#else
-
-static inline unsigned int task_cpu(const struct task_struct *p)
-{
-	return 0;
-}
-
-static inline void set_task_cpu(struct task_struct *p, unsigned int cpu)
-{
-}
-
-#endif /* CONFIG_SMP */
+extern unsigned int task_cpu(const struct task_struct *p);
+extern void set_task_cpu(struct task_struct *p, unsigned int cpu);
 
 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
 extern void arch_pick_mmap_layout(struct mm_struct *mm);
Index: linux-2.6.10-rc1-mm2-plugsched1/include/linux/scheduler.h
===================================================================
--- linux-2.6.10-rc1-mm2-plugsched1.orig/include/linux/scheduler.h	2004-10-30 22:00:40.000000000 +1000
+++ linux-2.6.10-rc1-mm2-plugsched1/include/linux/scheduler.h	2004-10-31 22:17:25.920994749 +1100
@@ -10,6 +10,8 @@
  */
 struct sched_drv
 {
+	unsigned int (*task_cpu)(const struct task_struct *);
+	void (*set_task_cpu)(struct task_struct *, unsigned int);
 	void (*init_sched_domain_sysctl)(void);
 	void (*destroy_sched_domain_sysctl)(void);
 	void (*account_steal_time)(struct task_struct *, cputime_t);
@@ -57,6 +59,12 @@ struct sched_drv
 };
 
 /*
+ * List functions that have common variants that many schedulers use.
+ */
+extern unsigned int common_task_cpu(const struct task_struct *p);
+extern void common_set_task_cpu(struct task_struct *p, unsigned int cpu);
+
+/*
  * All private per-scheduler entries in task_struct are defined here as
  * separate structs placed into the cpusched union in task_struct.
  */
Index: linux-2.6.10-rc1-mm2-plugsched1/kernel/sched.c
===================================================================
--- linux-2.6.10-rc1-mm2-plugsched1.orig/kernel/sched.c	2004-10-30 22:00:40.000000000 +1000
+++ linux-2.6.10-rc1-mm2-plugsched1/kernel/sched.c	2004-10-31 22:09:06.263548556 +1100
@@ -4085,6 +4085,8 @@ static void ingo_destroy_sched_domain_sy
 #endif
 
 struct sched_drv ingo_sched_drv = {
+	.task_cpu		= common_task_cpu,
+	.set_task_cpu		= common_set_task_cpu,
 	.init_sched_domain_sysctl = ingo_init_sched_domain_sysctl,
 	.destroy_sched_domain_sysctl = ingo_destroy_sched_domain_sysctl,
 	.account_steal_time	= ingo_account_steal_time,
Index: linux-2.6.10-rc1-mm2-plugsched1/kernel/scheduler.c
===================================================================
--- linux-2.6.10-rc1-mm2-plugsched1.orig/kernel/scheduler.c	2004-10-30 22:00:40.000000000 +1000
+++ linux-2.6.10-rc1-mm2-plugsched1/kernel/scheduler.c	2004-10-31 22:17:43.240340395 +1100
@@ -44,6 +44,10 @@
 DEFINE_PER_CPU(struct kernel_stat, kstat);
 EXPORT_PER_CPU_SYMBOL(kstat);
 
+unsigned int task_cpu(const struct task_struct *p);
+
+void set_task_cpu(struct task_struct *p, unsigned int cpu);
+
 #ifdef CONFIG_SMP
 /***
  * kick_process - kick a running thread to enter/exit the kernel
@@ -62,7 +66,31 @@ void kick_process(task_t *p)
 		smp_send_reschedule(cpu);
 	preempt_enable();
 }
-#endif
+
+/*
+ * Wrappers for p->thread_info->cpu access. No-op on UP.
+ */
+unsigned int common_task_cpu(const struct task_struct *p)
+{
+	return p->thread_info->cpu;
+}
+
+void common_set_task_cpu(struct task_struct *p, unsigned int cpu)
+{
+	p->thread_info->cpu = cpu;
+}
+
+#else
+
+unsigned int common_task_cpu(const struct task_struct *p)
+{
+	return 0;
+}
+
+void common_set_task_cpu(struct task_struct *p, unsigned int cpu)
+{
+}
+#endif /* CONFIG_SMP */
 
 #ifdef CONFIG_PREEMPT
 #ifdef CONFIG_DEBUG_PREEMPT
@@ -1000,6 +1028,16 @@ static int __init scheduler_setup(char *
 
 __setup ("cpusched=", scheduler_setup);
 
+unsigned int task_cpu(const struct task_struct *p)
+{
+	return scheduler->task_cpu(p);
+}
+
+void set_task_cpu(struct task_struct *p, unsigned int cpu)
+{
+	scheduler->set_task_cpu(p, cpu);
+}
+
 void init_sched_domain_sysctl(void)
 {
 	scheduler->init_sched_domain_sysctl();
Index: linux-2.6.10-rc1-mm2-plugsched1/kernel/staircase.c
===================================================================
--- linux-2.6.10-rc1-mm2-plugsched1.orig/kernel/staircase.c	2004-10-30 22:00:40.000000000 +1000
+++ linux-2.6.10-rc1-mm2-plugsched1/kernel/staircase.c	2004-10-31 22:09:18.226716200 +1100
@@ -3817,6 +3817,8 @@ static void sc_destroy_sched_domain_sysc
 #endif
 
 struct sched_drv sc_sched_drv = {
+	.task_cpu		= common_task_cpu,
+	.set_task_cpu		= common_set_task_cpu,
 	.init_sched_domain_sysctl = sc_init_sched_domain_sysctl,
 	.destroy_sched_domain_sysctl = sc_destroy_sched_domain_sysctl,
 	.account_steal_time	= sc_account_steal_time,

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

end of thread, other threads:[~2004-11-01  6:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-01  3:58 [PATCH][plugsched additions 1/2] Add optional functions to set_task_cpu Con Kolivas
2004-11-01  5:48 ` Matt Heler
2004-11-01  6:32   ` Con Kolivas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome