diff -urNp --exclude CVS --exclude BitKeeper x-ref/arch/i386/config.in x/arch/i386/config.in --- x-ref/arch/i386/config.in 2003-07-17 11:15:53.000000000 +0200 +++ x/arch/i386/config.in 2003-07-17 11:15:56.000000000 +0200 @@ -282,6 +282,7 @@ endmenu mainmenu_option next_comment comment 'General setup' +bool 'Desktop Multimedia (please avoid benchmarks with this enabled)' CONFIG_DESKTOP bool 'Networking support' CONFIG_NET # Visual Workstation support is utterly broken. diff -urNp --exclude CVS --exclude BitKeeper x-ref/fs/proc/array.c x/fs/proc/array.c --- x-ref/fs/proc/array.c 2003-07-17 11:15:53.000000000 +0200 +++ x/fs/proc/array.c 2003-07-17 11:15:56.000000000 +0200 @@ -360,15 +360,15 @@ int proc_pid_stat(struct task_struct *ta task->cmin_flt, task->maj_flt, task->cmaj_flt, - task->times.tms_utime, - task->times.tms_stime, - task->times.tms_cutime, - task->times.tms_cstime, + jiffies_to_clock_t(task->times.tms_utime), + jiffies_to_clock_t(task->times.tms_stime), + jiffies_to_clock_t(task->times.tms_cutime), + jiffies_to_clock_t(task->times.tms_cstime), priority, nice, 0UL /* removed */, - task->it_real_value, - task->start_time, + jiffies_to_clock_t(task->it_real_value), + jiffies_to_clock_t(task->start_time), vsize, mm ? mm->rss : 0, /* you might want to shift this left 3 */ task->rlim[RLIMIT_RSS].rlim_cur, @@ -700,14 +700,14 @@ int proc_pid_cpu(struct task_struct *tas len = sprintf(buffer, "cpu %lu %lu\n", - task->times.tms_utime, - task->times.tms_stime); + jiffies_to_clock_t(task->times.tms_utime), + jiffies_to_clock_t(task->times.tms_stime)); for (i = 0 ; i < smp_num_cpus; i++) len += sprintf(buffer + len, "cpu%d %lu %lu\n", i, - task->per_cpu_utime[cpu_logical_map(i)], - task->per_cpu_stime[cpu_logical_map(i)]); + jiffies_to_clock_t(task->per_cpu_utime[cpu_logical_map(i)]), + jiffies_to_clock_t(task->per_cpu_stime[cpu_logical_map(i)])); return len; } diff -urNp --exclude CVS --exclude BitKeeper x-ref/fs/proc/proc_misc.c x/fs/proc/proc_misc.c --- x-ref/fs/proc/proc_misc.c 2003-07-17 11:15:52.000000000 +0200 +++ x/fs/proc/proc_misc.c 2003-07-17 11:15:56.000000000 +0200 @@ -405,16 +405,16 @@ static int kstat_read_proc(char *page, c { int i, len = 0; extern unsigned long total_forks; - unsigned long jif = jiffies; + unsigned long jif = jiffies_to_clock_t(jiffies); unsigned int sum = 0, user = 0, nice = 0, system = 0; int major, disk; for (i = 0 ; i < smp_num_cpus; i++) { int cpu = cpu_logical_map(i), j; - user += kstat.per_cpu_user[cpu]; - nice += kstat.per_cpu_nice[cpu]; - system += kstat.per_cpu_system[cpu]; + user += jiffies_to_clock_t(kstat.per_cpu_user[cpu]); + nice += jiffies_to_clock_t(kstat.per_cpu_nice[cpu]); + system += jiffies_to_clock_t(kstat.per_cpu_system[cpu]); #if !defined(CONFIG_ARCH_S390) for (j = 0 ; j < NR_IRQS ; j++) sum += kstat.irqs[cpu][j]; @@ -428,10 +428,10 @@ static int kstat_read_proc(char *page, c proc_sprintf(page, &off, &len, "cpu%d %u %u %u %lu\n", i, - kstat.per_cpu_user[cpu_logical_map(i)], - kstat.per_cpu_nice[cpu_logical_map(i)], - kstat.per_cpu_system[cpu_logical_map(i)], - jif - ( kstat.per_cpu_user[cpu_logical_map(i)] \ + jiffies_to_clock_t(kstat.per_cpu_user[cpu_logical_map(i)]), + jiffies_to_clock_t(kstat.per_cpu_nice[cpu_logical_map(i)]), + jiffies_to_clock_t(kstat.per_cpu_system[cpu_logical_map(i)]), + jif - jiffies_to_clock_t(kstat.per_cpu_user[cpu_logical_map(i)] \ + kstat.per_cpu_nice[cpu_logical_map(i)] \ + kstat.per_cpu_system[cpu_logical_map(i)])); proc_sprintf(page, &off, &len, diff -urNp --exclude CVS --exclude BitKeeper x-ref/include/asm-i386/param.h x/include/asm-i386/param.h --- x-ref/include/asm-i386/param.h 2003-03-15 03:25:10.000000000 +0100 +++ x/include/asm-i386/param.h 2003-07-17 11:15:56.000000000 +0200 @@ -1,8 +1,23 @@ #ifndef _ASMi386_PARAM_H #define _ASMi386_PARAM_H +#include + +#ifdef __KERNEL__ + +#ifndef CONFIG_DESKTOP +# define HZ 100 /* internal kernel timer frequency */ +#else +# define HZ 1000 +#endif + +# define USER_HZ 100 /* some user interfaces are in ticks */ +# define CLOCKS_PER_SEC (USER_HZ) /* like times() */ +# define jiffies_to_clock_t(x) ((x) / ((HZ) / (USER_HZ))) +#endif + #ifndef HZ -#define HZ 100 +#define HZ 100 /* if userspace cheats, give them 100 */ #endif #define EXEC_PAGESIZE 4096 @@ -17,8 +32,4 @@ #define MAXHOSTNAMELEN 64 /* max length of hostname */ -#ifdef __KERNEL__ -# define CLOCKS_PER_SEC 100 /* frequency at which times() counts */ -#endif - #endif diff -urNp --exclude CVS --exclude BitKeeper x-ref/include/linux/sched.h x/include/linux/sched.h --- x-ref/include/linux/sched.h 2003-07-17 11:15:52.000000000 +0200 +++ x/include/linux/sched.h 2003-07-17 11:19:31.000000000 +0200 @@ -614,6 +614,8 @@ extern unsigned int * prof_buffer; extern unsigned long prof_len; extern unsigned long prof_shift; +extern int MAX_TIMESLICE, MIN_TIMESLICE; + #define CURRENT_TIME (xtime.tv_sec) extern void FASTCALL(__wake_up(wait_queue_head_t *q, unsigned int mode, int nr)); diff -urNp --exclude CVS --exclude BitKeeper x-ref/include/linux/sysctl.h x/include/linux/sysctl.h --- x-ref/include/linux/sysctl.h 2003-07-17 11:15:53.000000000 +0200 +++ x/include/linux/sysctl.h 2003-07-17 11:16:54.000000000 +0200 @@ -130,6 +130,8 @@ enum KERN_PPC_L3CR=57, /* l3cr register on PPC */ KERN_EXCEPTION_TRACE=58, /* boolean: exception trace */ KERN_SHMBIGPAGESPERFILE=59, /* int: max bigpages per file */ + KERN_MAXTIMESLICE=60, /* int: nice -20 max timeslice */ + KERN_MINTIMESLICE=61, /* int: nice +19 min timeslice */ }; diff -urNp --exclude CVS --exclude BitKeeper x-ref/kernel/sched.c x/kernel/sched.c --- x-ref/kernel/sched.c 2003-07-17 11:15:52.000000000 +0200 +++ x/kernel/sched.c 2003-07-17 11:20:13.000000000 +0200 @@ -52,8 +52,13 @@ * maximum timeslice is 300 msecs. Timeslices get refilled after * they expire. */ -#define MIN_TIMESLICE ( 10 * HZ / 1000) -#define MAX_TIMESLICE (300 * HZ / 1000) +#ifndef CONFIG_DESKTOP +# define __MIN_TIMESLICE ( 10 * HZ / 1000) +# define __MAX_TIMESLICE (250 * HZ / 1000) +#else +# define __MIN_TIMESLICE ( 1 * HZ / 1000) +# define __MAX_TIMESLICE (25 * HZ / 1000) +#endif #define CHILD_PENALTY 50 #define PARENT_PENALTY 100 #define PRIO_BONUS_RATIO 25 @@ -61,6 +66,8 @@ #define MAX_SLEEP_AVG (2*HZ) #define STARVATION_LIMIT (2*HZ) +int MAX_TIMESLICE = __MAX_TIMESLICE, MIN_TIMESLICE = __MIN_TIMESLICE; + /* * If a task is 'interactive' then we reinsert it in the active * array after it has expired its current timeslice. (it will not diff -urNp --exclude CVS --exclude BitKeeper x-ref/kernel/signal.c x/kernel/signal.c --- x-ref/kernel/signal.c 2003-07-17 11:15:41.000000000 +0200 +++ x/kernel/signal.c 2003-07-17 11:15:56.000000000 +0200 @@ -13,7 +13,7 @@ #include #include #include - +#include #include /* @@ -761,8 +761,8 @@ void do_notify_parent(struct task_struct info.si_uid = tsk->uid; /* FIXME: find out whether or not this is supposed to be c*time. */ - info.si_utime = tsk->times.tms_utime; - info.si_stime = tsk->times.tms_stime; + info.si_utime = jiffies_to_clock_t(tsk->times.tms_utime); + info.si_stime = jiffies_to_clock_t(tsk->times.tms_stime); status = tsk->exit_code & 0x7f; why = SI_KERNEL; /* shouldn't happen */ diff -urNp --exclude CVS --exclude BitKeeper x-ref/kernel/sys.c x/kernel/sys.c --- x-ref/kernel/sys.c 2003-07-17 11:15:41.000000000 +0200 +++ x/kernel/sys.c 2003-07-17 11:15:56.000000000 +0200 @@ -14,7 +14,7 @@ #include #include #include - +#include #include #include @@ -810,16 +810,23 @@ asmlinkage long sys_setfsgid(gid_t gid) asmlinkage long sys_times(struct tms * tbuf) { + struct tms temp; + /* * In the SMP world we might just be unlucky and have one of * the times increment as we use it. Since the value is an * atomically safe type this is just fine. Conceptually its * as if the syscall took an instant longer to occur. */ - if (tbuf) - if (copy_to_user(tbuf, ¤t->times, sizeof(struct tms))) + if (tbuf) { + temp.tms_utime = jiffies_to_clock_t(current->times.tms_utime); + temp.tms_stime = jiffies_to_clock_t(current->times.tms_stime); + temp.tms_cutime = jiffies_to_clock_t(current->times.tms_cutime); + temp.tms_cstime = jiffies_to_clock_t(current->times.tms_cstime); + if (copy_to_user(tbuf, &temp, sizeof(struct tms))) return -EFAULT; - return jiffies; + } + return jiffies_to_clock_t(jiffies); } /* diff -urNp --exclude CVS --exclude BitKeeper x-ref/kernel/sysctl.c x/kernel/sysctl.c --- x-ref/kernel/sysctl.c 2003-07-17 11:15:53.000000000 +0200 +++ x/kernel/sysctl.c 2003-07-17 11:18:50.000000000 +0200 @@ -284,6 +284,10 @@ static ctl_table kern_table[] = { {KERN_EXCEPTION_TRACE,"exception-trace", &exception_trace,sizeof(int),0644,NULL,&proc_dointvec}, #endif + {KERN_MAXTIMESLICE, "max-timeslice", + &MAX_TIMESLICE,sizeof(int),0644,NULL,&proc_dointvec}, + {KERN_MINTIMESLICE, "min-timeslice", + &MIN_TIMESLICE,sizeof(int),0644,NULL,&proc_dointvec}, {0} };