mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Con Kolivas <kernel@kolivas.org>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@osdl.org>, Peter Williams <pwil3058@bigpond.net.au>
Subject: [PATCH][plugsched additions 1/2] Add optional functions to set_task_cpu
Date: Mon, 01 Nov 2004 14:58:06 +1100	[thread overview]
Message-ID: <cone.1099281486.16793.26204.502@pc.kolivas.org> (raw)

[-- 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,

             reply	other threads:[~2004-11-01  3:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-01  3:58 Con Kolivas [this message]
2004-11-01  5:48 ` Matt Heler
2004-11-01  6:32   ` Con Kolivas

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=cone.1099281486.16793.26204.502@pc.kolivas.org \
    --to=kernel@kolivas.org \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pwil3058@bigpond.net.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

all inboxes | Powered by JetHome®