Skip to contentSkip to conversation

Make unique task_struct variables private

PATCH In review Con Kolivas 1 participant 1 message Oct 30, 2004 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 17/28 Make unique task_struct variables private

Make unique task_struct variables private

The task_struct needs to be flexible enough to have private entries unique to each cpu scheduler design. Remove the variables that are likely to differ between designs and put them in a separate per-scheduler struct enclosed within a common union.

Remove the private data from INIT_TASK and place it into sched_init().

Update all entries in sched.c to reflect the new task_struct design.

include/linux/init_task.h +0 -5
Index: linux-2.6.10-rc1-mm2-plugsched1/include/linux/init_task.h
===================================================================
@@ -72,14 +72,10 @@ extern struct group_info init_groups;
 	.usage		= ATOMIC_INIT(2),				\
 	.flags		= 0,						\
 	.lock_depth	= -1,						\
-	.prio		= MAX_PRIO-20,					\
-	.static_prio	= MAX_PRIO-20,					\
 	.policy		= SCHED_NORMAL,					\
 	.cpus_allowed	= CPU_MASK_ALL,					\
 	.mm		= NULL,						\
 	.active_mm	= &init_mm,					\
-	.run_list	= LIST_HEAD_INIT(tsk.run_list),			\
-	.time_slice	= HZ,						\
 	.tasks		= LIST_HEAD_INIT(tsk.tasks),			\
 	.ptrace_children= LIST_HEAD_INIT(tsk.ptrace_children),		\
 	.ptrace_list	= LIST_HEAD_INIT(tsk.ptrace_list),		\
@@ -115,5 +111,4 @@ extern struct group_info init_groups;
 	.private_pages	= LIST_HEAD_INIT(tsk.private_pages),		\
 	.private_pages_count = 0,					\
 }
-
 #endif
include/linux/sched.h +4 -9
Index: linux-2.6.10-rc1-mm2-plugsched1/include/linux/sched.h
===================================================================
@@ -524,18 +524,13 @@ struct task_struct {
 
 	int lock_depth;		/* Lock depth */
 
-	int prio, static_prio;
-	struct list_head run_list;
-	prio_array_t *array;
-
-	unsigned long sleep_avg;
-	long interactive_credit;
-	unsigned long long timestamp, last_ran;
-	int activated;
+	int static_prio;	/* A commonality between cpu schedulers */
+	union {
+		struct cpusched_ingo ingosched;
+	} u;
 
 	unsigned long policy;
 	cpumask_t cpus_allowed;
-	unsigned int time_slice, first_time_slice;
 
 #ifdef CONFIG_SCHEDSTATS
 	struct sched_info sched_info;
include/linux/scheduler.h +13 -0
Index: linux-2.6.10-rc1-mm2-plugsched1/include/linux/scheduler.h
===================================================================
@@ -36,3 +36,16 @@ struct sched_drv
 	void (*cpu_attach_domain)(struct sched_domain *, int);
 #endif
 };
+
+struct cpusched_ingo {
+	int prio;
+	struct list_head run_list;
+	prio_array_t *array;
+	unsigned int time_slice;
+	unsigned int first_time_slice;
+	unsigned long sleep_avg;
+	long interactive_credit;
+	unsigned long timestamp;
+	unsigned long long last_ran;
+	int activated;
+};
kernel/sched.c +129 -122

647 lines not on this page · raw message