[Linux-hls-cvs] hls/patches gensched2-2.6.8-1.patch,NONE,1.1
Status: Pre-Alpha
Brought to you by:
lucabe
|
From: Luca A. <lu...@us...> - 2005-01-22 12:06:35
|
Update of /cvsroot/linux-hls/hls/patches In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4892/patches Added Files: gensched2-2.6.8-1.patch Log Message: 2.6 backend update... Still doesn't work, but it looks better ;-) --- NEW FILE: gensched2-2.6.8-1.patch --- diff -urp kernel-source-2.6.8/Makefile gensched/kernel-source-2.6.8/Makefile --- kernel-source-2.6.8/Makefile 2004-09-13 05:28:07.000000000 +0200 +++ gensched/kernel-source-2.6.8/Makefile 2004-09-30 15:02:53.000000000 +0200 @@ -1,7 +1,7 @@ VERSION = 2 PATCHLEVEL = 6 SUBLEVEL = 8 -EXTRAVERSION = +EXTRAVERSION = -gensched NAME=Zonked Quokka # *DOCUMENTATION* diff -urp kernel-source-2.6.8/arch/i386/Kconfig gensched/kernel-source-2.6.8/arch/i386/Kconfig --- kernel-source-2.6.8/arch/i386/Kconfig 2004-09-13 05:28:07.000000000 +0200 +++ gensched/kernel-source-2.6.8/arch/i386/Kconfig 2004-09-30 15:02:33.000000000 +0200 @@ -540,6 +540,13 @@ config PREEMPT Say Y here if you are building a kernel for a desktop, embedded or real-time system. Say N if you are unsure. +#Added by Luca +config GENERIC_SCHEDULER + bool 'Generic Scheduler' + help + Gensched hooks, for implementing generic scheduling strategies in + modules... + config X86_UP_APIC bool "Local APIC support on uniprocessors" if !SMP depends on !(X86_VISWS || X86_VOYAGER) diff -urp kernel-source-2.6.8/arch/ppc/Kconfig gensched/kernel-source-2.6.8/arch/ppc/Kconfig --- kernel-source-2.6.8/arch/ppc/Kconfig 2004-08-14 07:38:08.000000000 +0200 +++ gensched/kernel-source-2.6.8/arch/ppc/Kconfig 2004-09-30 15:02:34.000000000 +0200 @@ -808,6 +808,13 @@ config PREEMPT Say Y here if you are building a kernel for a desktop, embedded or real-time system. Say N if you are unsure. +#Added by Luca +config GENERIC_SCHEDULER + bool 'Generic Scheduler' + help + Gensched hooks, for implementing generic scheduling strategies in + modules... + config HIGHMEM bool "High memory support" diff -urp kernel-source-2.6.8/include/linux/init_task.h gensched/kernel-source-2.6.8/include/linux/init_task.h --- kernel-source-2.6.8/include/linux/init_task.h 2004-08-14 07:36:16.000000000 +0200 +++ gensched/kernel-source-2.6.8/include/linux/init_task.h 2004-09-30 15:02:34.000000000 +0200 @@ -64,6 +64,12 @@ extern struct group_info init_groups; * INIT_TASK is used to set up the first task table, touch at * your own risk!. Base=0, limit=0x1fffff (=2MB) */ +#ifdef CONFIG_GENERIC_SCHEDULER +#define DATA_INIT .private_data = NULL, +#else +#define DATA_INIT +#endif /* CONFIG_GENERIC_SCHEDULER */ + #define INIT_TASK(tsk) \ { \ .state = 0, \ @@ -112,6 +118,7 @@ extern struct group_info init_groups; .proc_lock = SPIN_LOCK_UNLOCKED, \ .switch_lock = SPIN_LOCK_UNLOCKED, \ .journal_info = NULL, \ + DATA_INIT \ } diff -urp kernel-source-2.6.8/include/linux/sched.h gensched/kernel-source-2.6.8/include/linux/sched.h --- kernel-source-2.6.8/include/linux/sched.h 2004-08-14 07:36:16.000000000 +0200 +++ gensched/kernel-source-2.6.8/include/linux/sched.h 2004-10-04 22:01:48.000000000 +0200 @@ -527,6 +527,9 @@ struct task_struct { struct mempolicy *mempolicy; short il_next; /* could be shared with used_math */ #endif +#ifdef CONFIG_GENERIC_SCHEDULER + void *private_data; +#endif /* CONFIG_GENERIC_SCHEDULER */ }; static inline pid_t process_group(struct task_struct *tsk) @@ -1060,6 +1063,20 @@ extern void recalc_sigpending(void); extern void signal_wake_up(struct task_struct *t, int resume_stopped); +#ifdef CONFIG_GENERIC_SCHEDULER +extern void (*block_hook)(struct task_struct *tsk); +extern void (*unblock_hook)(struct task_struct *tsk); +extern void (*fork_hook)(struct task_struct *tsk); +extern void (*cleanup_hook)(struct task_struct *tsk); +extern int (*setsched_hook)(pid_t pid, int policy, struct sched_param *param); +extern int (*getsched_hook)(pid_t pid, struct sched_param *param); +void gensched_dispatch(struct task_struct *p, int state); +#define GENSCHED_ENABLE 0x10 +#define GENSCHED_DISABLE 0x20 +#define DISPATCH_PRIORITY (MAX_RT_PRIO - 1) +#define INACTIVE_PRIORITY 0 +#endif /* CONFIG_GENERIC_SCHEDULER */ + /* * Wrappers for p->thread_info->cpu access. No-op on UP. */ diff -urp kernel-source-2.6.8/kernel/exit.c gensched/kernel-source-2.6.8/kernel/exit.c --- kernel-source-2.6.8/kernel/exit.c 2004-08-14 07:37:40.000000000 +0200 +++ gensched/kernel-source-2.6.8/kernel/exit.c 2004-09-30 15:04:01.000000000 +0200 @@ -32,6 +32,11 @@ extern void sem_exit (void); extern struct task_struct *child_reaper; +#ifdef CONFIG_GENERIC_SCHEDULER +static void (*cleanup_hook)(struct task_struct *tsk); +EXPORT_SYMBOL_GPL(cleanup_hook); +#endif /* CONFIG_GENERIC_SCHEDULER */ + int getrusage(struct task_struct *, int, struct rusage __user *); static void __unhash_process(struct task_struct *p) @@ -821,6 +826,14 @@ asmlinkage NORET_TYPE void do_exit(long } acct_process(code); + +#ifdef CONFIG_GENERIC_SCHEDULER + /* Is this the correct place for this hook? */ + if (cleanup_hook != NULL) { + cleanup_hook(tsk); + } +#endif + __exit_mm(tsk); exit_sem(tsk); diff -urp kernel-source-2.6.8/kernel/fork.c gensched/kernel-source-2.6.8/kernel/fork.c --- kernel-source-2.6.8/kernel/fork.c 2004-08-14 07:36:16.000000000 +0200 +++ gensched/kernel-source-2.6.8/kernel/fork.c 2004-10-21 21:36:08.000000000 +0200 @@ -44,6 +44,12 @@ #include <asm/cacheflush.h> #include <asm/tlbflush.h> + +#ifdef CONFIG_GENERIC_SCHEDULER +static void (*fork_hook)(struct task_struct *tsk); +EXPORT_SYMBOL_GPL(fork_hook); +#endif /* CONFIG_GENERIC_SCHEDULER */ + /* The idle threads do not count.. * Protected by write_lock_irq(&tasklist_lock) */ @@ -1194,7 +1200,6 @@ long do_fork(unsigned long clone_flags, p->vfork_done = &vfork; init_completion(&vfork); } - if ((p->ptrace & PT_PTRACED) || (clone_flags & CLONE_STOPPED)) { /* * We'll start up with an immediate SIGSTOP. @@ -1229,6 +1234,13 @@ long do_fork(unsigned long clone_flags, put_cpu(); } ++total_forks; +#ifdef CONFIG_GENERIC_SCHEDULER + /*FIXME: Is this the right place? */ + p->private_data = NULL; + if (fork_hook != NULL) { + fork_hook(p); + } +#endif /* CONFIG_GENERIC_SCHEDULER */ if (unlikely (trace)) { current->ptrace_message = pid; diff -urp kernel-source-2.6.8/kernel/sched.c gensched/kernel-source-2.6.8/kernel/sched.c --- kernel-source-2.6.8/kernel/sched.c 2004-08-14 07:37:38.000000000 +0200 +++ gensched/kernel-source-2.6.8/kernel/sched.c 2005-01-10 23:21:58.000000000 +0100 @@ -44,6 +44,17 @@ #include <asm/unistd.h> +#ifdef CONFIG_GENERIC_SCHEDULER +static void (*block_hook)(struct task_struct *tsk); +static void (*unblock_hook)(struct task_struct *tsk); +static int (*setsched_hook)(pid_t pid, int policy, struct sched_param *param); +static int (*getsched_hook)(pid_t pid, struct sched_param *param); +EXPORT_SYMBOL_GPL(block_hook); +EXPORT_SYMBOL_GPL(unblock_hook); +EXPORT_SYMBOL_GPL(setsched_hook); +EXPORT_SYMBOL_GPL(getsched_hook); +#endif /* CONFIG_GENERIC_SCHEDULER */ + #ifdef CONFIG_NUMA #define cpu_to_node_mask(cpu) node_to_cpumask(cpu_to_node(cpu)) #else @@ -512,6 +523,11 @@ static void deactivate_task(struct task_ rq->nr_uninterruptible++; dequeue_task(p, p->array); p->array = NULL; +#ifdef CONFIG_GENERIC_SCHEDULER + if ((block_hook != NULL) && (p->private_data != NULL)) { + block_hook(p); + } +#endif /* CONFIG_GENERIC_SCHEDULER */ } /* @@ -844,6 +860,12 @@ out_activate: } success = 1; +#ifdef CONFIG_GENERIC_SCHEDULER + p->state = TASK_RUNNING; + if ((unblock_hook != NULL) && (p->private_data != NULL)) { + unblock_hook(p); + } +#endif /* CONFIG_GENERIC_SCHEDULER */ out_running: p->state = TASK_RUNNING; out: @@ -2812,6 +2834,17 @@ out_nounlock: asmlinkage long sys_sched_setscheduler(pid_t pid, int policy, struct sched_param __user *param) { +#ifdef CONFIG_GENERIC_SCHEDULER + /* FIXME: Move in setsched!!! */ + if (setsched_hook != NULL) { + int res; + + res = setsched_hook(pid, policy, param); + if (res <= 0) { + return res; + } + } +#endif return setscheduler(pid, policy, param); } @@ -2822,6 +2855,16 @@ asmlinkage long sys_sched_setscheduler(p */ asmlinkage long sys_sched_setparam(pid_t pid, struct sched_param __user *param) { +#ifdef CONFIG_GENERIC_SCHEDULER + if (setsched_hook != NULL) { + int res; + + res = setsched_hook(pid, -1, param); + if (res <= 0) { + return res; + } + } +#endif return setscheduler(pid, -1, param); } @@ -2862,6 +2905,17 @@ asmlinkage long sys_sched_getparam(pid_t int retval = -EINVAL; task_t *p; +#ifdef CONFIG_GENERIC_SCHEDULER + /* FIXME: Move down, and pass p, not pid!!! */ + if (getsched_hook != NULL) { + int res; + + res = getsched_hook(pid, param); + if (res <= 0) { + return res; + } + } +#endif if (!param || pid < 0) goto out_nounlock; @@ -3976,6 +4030,71 @@ void __init sched_init(void) enter_lazy_tlb(&init_mm, current); } +#ifdef CONFIG_GENERIC_SCHEDULER +void gensched_dispatch(struct task_struct *p, int state) +{ +/* runqueue_t *rq; */ + prio_array_t *array; + unsigned long flags; + int oldprio; + + read_lock_irqsave(&tasklist_lock, flags); +/* rq = task_rq_lock(p, &flags); */ + + array = p->array; + if (array) { + /* deactivate_task(p, task_rq(p));*/ + /* We cannot directly call deactivate_task, because it would call the deactivation hook... */ + /*nr_running_dec(task_rq(p));*/ + task_rq(p)->nr_running--; + if (p->state == TASK_UNINTERRUPTIBLE) + task_rq(p)->nr_uninterruptible++; + dequeue_task(p, p->array); + p->array = NULL; + } else if (state == GENSCHED_ENABLE) { + printk("ERROR!!! Trying to dispatch a non-active task?\n"); + BUG(); + } + oldprio = p->prio; + if (state == GENSCHED_ENABLE) { + if (p->rt_priority != INACTIVE_PRIORITY) { + printk("ERROR!!! Trying to dispatch a task with oldprio = %lu != %d?\n", + p->rt_priority, INACTIVE_PRIORITY); + BUG(); + } + __setscheduler(p, SCHED_FIFO, DISPATCH_PRIORITY); + } else { + p->static_prio = MAX_PRIO; + __setscheduler(p, SCHED_NORMAL /*SCHED_FIFO*/, INACTIVE_PRIORITY); + } + if (array) { + /* __activate_task(p, task_rq(p)); */ + enqueue_task(p, task_rq(p)->active); + /*nr_running_inc(task_rq(p));*/ + task_rq(p)->nr_running++; + if (task_running(task_rq(p), p)) { + if (p->prio > oldprio) { + resched_task(task_rq(p)->curr); + } else { +#if 0 + printk("ERROR!!! %d < %d?\n", p->prio, oldprio); + BUG(); /* Comment the BUG out... Can happen in convert_tasks() */ +#endif + } + } else if (p->prio < task_rq(p)->curr->prio) { +#if 0 + printk("ERROR [1]!!! %d < %d?\n", p->prio, task_rq(p)->curr->prio); +#endif + resched_task(task_rq(p)->curr); + } + } + +/* task_rq_unlock(rq, &flags); */ + read_unlock_irqrestore(&tasklist_lock, flags); +} +EXPORT_SYMBOL_GPL(gensched_dispatch); +#endif /* CONFIG_GENERIC_SCHEDULER */ + #ifdef CONFIG_DEBUG_SPINLOCK_SLEEP void __might_sleep(char *file, int line) { |