Jiffies_64 for 2.4.22-ac
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I took Tim Schmielau's jiffies_64 patch, and ported it to -ac
currently running on my machine here.
comments? did i screw up horribly?
- --
tabris
- -
We have art that we do not die of the truth.
-- Nietzsche
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQE/YU0PtTgrITXtL+8RAsiHAJ9j7y8qzFwrIiMCpTfyVR+CpDetWACgpWaQ hJQSYKqtVNYgc6tf6C5gFhU=
=yz0I
-----END PGP SIGNATURE-----
linux/fs/proc/array.c +2 -2
@@ -345,7 +345,7 @@ ppid = task->pid ? task->p_opptr->pid :0 ;read_unlock (&tasklist_lock); res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \ -%lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld %lu %lu %ld %lu %lu %lu %lu %lu \ +%lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld %llu %lu %ld %lu %lu %lu %lu %lu \ %lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %lu\n", task->pid, task->comm,
@@ -368,7 +368,7 @@ nice,0UL /* removed */ , task->it_real_value, - task->start_time, + (unsigned long long )(task->start_time), vsize, mm ? mm->rss :0 ,/* you might want to shift this left 3 */ task->rlim[RLIMIT_RSS].rlim_cur,
linux/fs/proc/proc_misc.c +124 -37
220 lines not on this page · raw message
linux/include/linux/kernel_stat.h +3 -3
@@ -16,9 +16,9 @@#define DK_MAX_DISK 16struct kernel_stat { -unsigned int per_cpu_user[NR_CPUS ], - per_cpu_nice[NR_CPUS ], - per_cpu_system[NR_CPUS ]; +unsigned long per_cpu_user[NR_CPUS ], + per_cpu_nice[NR_CPUS ], + per_cpu_system[NR_CPUS ];unsigned int dk_drive[DK_MAX_MAJOR ][DK_MAX_DISK ];unsigned int dk_drive_rio[DK_MAX_MAJOR ][DK_MAX_DISK ];unsigned int dk_drive_wio[DK_MAX_MAJOR ][DK_MAX_DISK ];
linux/include/linux/sched.h +13 -1
@@ -380,7 +380,7 @@unsigned long it_real_incr, it_prof_incr, it_virt_incr;struct timer_list real_timer;struct tms times; -unsigned long start_time; +u64 start_time;long per_cpu_utime[NR_CPUS ], per_cpu_stime[NR_CPUS ];/* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */ unsigned long min_flt, maj_flt, nswap, cmin_flt, cmaj_flt, cnswap;
@@ -590,6 +590,18 @@#include <asm/current.h> extern unsigned long volatile jiffies; +#if BITS_PER_LONG <48 +#define NEEDS_JIFFIES_64 +extern u64 get_jiffies_64 (void ); +#else +/* jiffies is wide enough to not wrap for 8716 years at HZ==1024 */ +static inline u64 get_jiffies_64 (void ) + { +return (u64 )jiffies; + } +#endif + +extern unsigned long itimer_ticks;extern unsigned long itimer_next;extern struct timeval xtime;
linux/kernel/acct.c +23 -10
@@ -57,6 +57,7 @@#include <linux/tty.h> #include <asm/uaccess.h> +#include <asm/div64.h> /* * These constants control the amount of freespace that suspend and
@@ -228,20 +229,24 @@* This routine has been adopted from the encode_comp_t() function in * the kern_acct.c file of the FreeBSD operating system. The encoding * is a 13-bit fraction with a 3-bit (base 8) exponent. +* +* Bumped up to encode 64 bit values. Unfortunately the result may +* overflow now. */ #define MANTSIZE 13/* 13 bit mantissa. */ -#define EXPSIZE 3/* Base 8 (3 bit) exponent. */ +#define EXPSIZE 3/* 3 bit exponent. */ +#define EXPBASE 3/* Base 8 (3 bit) exponent. */ #define MAXFRACT ((1 << MANTSIZE) - 1)/* Maximum fractional value. */ -static comp_t encode_comp_t (unsigned long value) +static comp_t encode_comp_t (u64 value) {int exp, rnd; exp = rnd =0 ;while (value >MAXFRACT ) { - rnd = value & (1 << (EXPSIZE -1 ));/* Round up? */ - value >>=EXPSIZE ;/* Base 8 exponent == 3 bit shift. */ + rnd = value & (1 << (EXPBASE -1 ));/* Round up? */ + value >>=EXPBASE ;/* Base 8 exponent == 3 bit shift. */ exp++; }
@@ -249,16 +254,21 @@* If we need to round up, do it (and handle overflow correctly). */ if (rnd && (++value >MAXFRACT )) { - value >>=EXPSIZE ; + value >>=EXPBASE ; exp++; }/* * Clean it up and polish it off. */ - exp <<=MANTSIZE ;/* Shift the exponent into place */ - exp += value;/* and add on the mantissa. */ -return exp; +if (exp >= (1 <<EXPSIZE )) { +/* Overflow. Return largest representable number instead. */ +return (1ul << (MANTSIZE +EXPSIZE )) -1 ; + }else { + exp <<=MANTSIZE ;/* Shift the exponent into place */ + exp += value;/* and add on the mantissa. */ +return exp; + } }/*
@@ -279,6 +289,7 @@mm_segment_t fs;unsigned long vsize;unsigned long flim; +u64 elapsed;/* * First check to see if there is enough free_space to continue
@@ -296,8 +307,10 @@strncpy (ac.ac_comm, current->comm,ACCT_COMM ); ac.ac_comm[ACCT_COMM -1 ] ='\0' ; - ac.ac_btime =CT_TO_SECS (current->start_time) + (xtime.tv_sec - (jiffies /HZ )); - ac.ac_etime =encode_comp_t (jiffies - current->start_time); + elapsed =get_jiffies_64 () - current->start_time; + ac.ac_etime =encode_comp_t (elapsed); +do_div (elapsed,HZ ); + ac.ac_btime = xtime.tv_sec - elapsed; ac.ac_utime =encode_comp_t (current->times.tms_utime); ac.ac_stime =encode_comp_t (current->times.tms_stime); ac.ac_uid =fs_high2lowuid (current->uid);
linux/kernel/fork.c +1 -1
@@ -746,7 +746,7 @@#endif p->array =NULL ; p->lock_depth =-1 ;/* -1 = no lock */ - p->start_time = jiffies; + p->start_time =get_jiffies_64 ();INIT_LIST_HEAD (&p->local_pages);
linux/kernel/info.c +5 -1
@@ -12,15 +12,19 @@#include <linux/smp_lock.h> #include <asm/uaccess.h> +#include <asm/div64.h> asmlinkage long sys_sysinfo (struct sysinfo *info) {struct sysinfo val; +u64 uptime;memset ((char *)&val,0 ,sizeof (struct sysinfo ));cli (); - val.uptime = jiffies /HZ ; + uptime =get_jiffies_64 (); +do_div (uptime,HZ ); + val.uptime = (unsigned long ) uptime; val.loads[0 ] = avenrun[0 ] << (SI_LOAD_SHIFT -FSHIFT ); val.loads[1 ] = avenrun[1 ] << (SI_LOAD_SHIFT -FSHIFT );
linux/kernel/timer.c +61 -0
85 lines not on this page · raw message
linux/mm/oom_kill.c +2 -3
@@ -73,11 +73,10 @@/* * CPU time is in seconds and run time is in minutes. There is no * particular reason for this other than that it turned out to work -* very well in practice. This is not safe against jiffie wraps -* but we don't care _that_ much... +* very well in practice. */ cpu_time = (p->times.tms_utime + p->times.tms_stime) >> (SHIFT_HZ +3 ); - run_time = (jiffies - p->start_time) >> (SHIFT_HZ +10 ); + run_time = (get_jiffies_64 () - p->start_time) >> (SHIFT_HZ +10 ); points /=int_sqrt (cpu_time); points /=int_sqrt (int_sqrt (run_time));
Quoted 4 lines · Tabris
I took Tim Schmielau's
jiffies_64patch, and ported it to -accurrently running on my machine here.
comments? did i screw up horribly?
see my comments below:
linux/fs/proc/proc_misc.c line 114
Quoted 4 lines
linux/fs/proc/proc_misc.c +4
-0+#define get_uidle_64 () get_64bits(&(init_tasks[0]->times.tms_utime),\ + &uidle_msb_flips) +#define get_sidle_64 () get_64bits(&(init_tasks[0]->times.tms_stime),\ + &sidle_msb_flips)
for -ac this needs to be
+#define get_uidle_64() get_64bits(&(init_task.times.tms_utime),\
+ &uidle_msb_flips)
+#define get_sidle_64() get_64bits(&(init_task.times.tms_stime),\
+ &sidle_msb_flips)
linux/fs/proc/proc_misc.c line 146
Quoted 2 lines
linux/fs/proc/proc_misc.c +2
-0+check_one (init_tasks[0 ]->times.tms_utime, &uidle_msb_flips); +check_one (init_tasks[0 ]->times.tms_stime, &sidle_msb_flips);
ditto
+#define get_uidle_64() (init_tasks[0]->times.tms_utime)
+#define get_sidle_64() (init_tasks[0]->times.tms_stime)
ditto
linux/fs/proc/proc_misc.c line 209
Quoted 4 lines
linux/fs/proc/proc_misc.c +1
-2-unsigned long uptime; -unsigned long idle; +u64 uptime, idle;int len;
the declaration
unsigned long uptime_remainder, idle_remainder;
is missing
linux/fs/proc/proc_misc.c line 221
Quoted 10 lines
#if HZ!=100
linux/fs/proc/proc_misc.c +4
-4len =sprintf (page,"%lu.%02lu %lu.%02lu\n" , - uptime /HZ , - (((uptime %HZ ) *100 ) /HZ ) %100 , - idle /HZ , - (((idle %HZ ) *100 ) /HZ ) %100 ); + (unsigned long ) uptime, + uptime_remainder, + (unsigned long ) idle /HZ , + idle_remainder);
since we're in the HZ!=100 branch, this needs to be
+ (uptime_remainder * 100) / HZ, + (unsigned long) idle, + (idle_remainder * 100) / HZ);
I wonder it actually compiled, but otherwise it looks good.
Tim
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 60 lines · Tim Schmielau
Quoted 4 lines · Tabris
I took Tim Schmielau's
jiffies_64patch, and ported it to -accurrently running on my machine here.
comments? did i screw up horribly?see my comments below:
Quoted 6 lines
+#define
get_uidle_64()
get_64bits(&(init_tasks[0]->times.tms_utime),\ +
&uidle_msb_flips)
+#defineget_sidle_64()
get_64bits(&(init_tasks[0]->times.tms_stime),\ +
&sidle_msb_flips)for -ac this needs to be
linux/fs/proc/proc_misc.c +4
-0+#define get_uidle_64 () get_64bits(&(init_task.times.tms_utime),\ + &uidle_msb_flips) +#define get_sidle_64 () get_64bits(&(init_task.times.tms_stime),\ + &sidle_msb_flips)linux/fs/proc/proc_misc.c line 146
Quoted 3 lines
linux/fs/proc/proc_misc.c +2
-0+check_one (init_tasks[0 ]->times.tms_utime, &uidle_msb_flips); +check_one (init_tasks[0 ]->times.tms_stime, &sidle_msb_flips);ditto
linux/fs/proc/proc_misc.c +2
-0+#define get_uidle_64 () (init_tasks[0]->times.tms_utime) +#define get_sidle_64 () (init_tasks[0]->times.tms_stime)ditto
linux/fs/proc/proc_misc.c line 209
Quoted 4 lines
linux/fs/proc/proc_misc.c +1
-2-unsigned long uptime; -unsigned long idle; +u64 uptime, idle;int len;the declaration
unsigned long uptime_remainder, idle_remainder;is missing
linux/fs/proc/proc_misc.c line 221
Quoted 10 lines
#if HZ!=100
linux/fs/proc/proc_misc.c +4
-4len =sprintf (page,"%lu.%02lu %lu.%02lu\n" , - uptime /HZ , - (((uptime %HZ ) *100 ) /HZ ) %100 , - idle /HZ , - (((idle %HZ ) *100 ) /HZ ) %100 ); + (unsigned long ) uptime, + uptime_remainder, + (unsigned long ) idle /HZ , + idle_remainder);since we're in the HZ!=100 branch, this needs to be
(quoted diff) +3
-0+ (uptime_remainder * 100) / HZ, + (unsigned long) idle, + (idle_remainder * 100) / HZ);
Quoted 4 lines
I wonder it actually compiled, but otherwise it looks good.
Tim
oops.
yeah, i merged it originally against a different tree... that patch didn't apply against 2.4.22-ac
and i forgot to compile test it since i was too tired.
updated/fixed patch later today.
- --
tabris
- -
"...A strange enigma is man!"
"Someone calls him a soul concealed in an animal," I suggested. "Winwood Reade is good upon the subject," said Holmes. "He remarked
that, while the individual man is an insoluble puzzle, in the aggregate he becomes a mathematical certainty. You can, for example, never foretell what any one man will do, but you can say with precision what an average number will be up to. Individuals vary, but percentages remain constant. So says the statistician."
-- Sherlock Holmes, "The Sign of Four"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQE/YeEYtTgrITXtL+8RAm6zAJ93ljgW0p70fgrrjvhu52Dod+fOawCcCLjc Ns6HWVXlCbIHWf8t2FB9BzI=
=ya6P
-----END PGP SIGNATURE-----
this one is changed as per my current running kernel, and compile tested. sorry about the last one... -ENOCAFFEINE
linux/fs/proc/array.c +2 -2
@@ -345,7 +345,7 @@ ppid = task->pid ? task->p_opptr->pid :0 ;read_unlock (&tasklist_lock); res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \ -%lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld %lu %lu %ld %lu %lu %lu %lu %lu \ +%lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld %llu %lu %ld %lu %lu %lu %lu %lu \ %lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %lu\n", task->pid, task->comm,
@@ -368,7 +368,7 @@ nice,0UL /* removed */ , task->it_real_value, - task->start_time, + (unsigned long long )(task->start_time), vsize, mm ? mm->rss :0 ,/* you might want to shift this left 3 */ task->rlim[RLIMIT_RSS].rlim_cur,
linux/fs/proc/proc_misc.c +125 -37
221 lines not on this page · raw message
linux/include/linux/kernel_stat.h +3 -3
@@ -16,9 +16,9 @@#define DK_MAX_DISK 16struct kernel_stat { -unsigned int per_cpu_user[NR_CPUS ], - per_cpu_nice[NR_CPUS ], - per_cpu_system[NR_CPUS ]; +unsigned long per_cpu_user[NR_CPUS ], + per_cpu_nice[NR_CPUS ], + per_cpu_system[NR_CPUS ];unsigned int dk_drive[DK_MAX_MAJOR ][DK_MAX_DISK ];unsigned int dk_drive_rio[DK_MAX_MAJOR ][DK_MAX_DISK ];unsigned int dk_drive_wio[DK_MAX_MAJOR ][DK_MAX_DISK ];
linux/include/linux/sched.h +13 -1
@@ -380,7 +380,7 @@unsigned long it_real_incr, it_prof_incr, it_virt_incr;struct timer_list real_timer;struct tms times; -unsigned long start_time; +u64 start_time;long per_cpu_utime[NR_CPUS ], per_cpu_stime[NR_CPUS ];/* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */ unsigned long min_flt, maj_flt, nswap, cmin_flt, cmaj_flt, cnswap;
@@ -590,6 +590,18 @@#include <asm/current.h> extern unsigned long volatile jiffies; +#if BITS_PER_LONG <48 +#define NEEDS_JIFFIES_64 +extern u64 get_jiffies_64 (void ); +#else +/* jiffies is wide enough to not wrap for 8716 years at HZ==1024 */ +static inline u64 get_jiffies_64 (void ) + { +return (u64 )jiffies; + } +#endif + +extern unsigned long itimer_ticks;extern unsigned long itimer_next;extern struct timeval xtime;
linux/kernel/acct.c +23 -10
@@ -57,6 +57,7 @@#include <linux/tty.h> #include <asm/uaccess.h> +#include <asm/div64.h> /* * These constants control the amount of freespace that suspend and
@@ -228,20 +229,24 @@* This routine has been adopted from the encode_comp_t() function in * the kern_acct.c file of the FreeBSD operating system. The encoding * is a 13-bit fraction with a 3-bit (base 8) exponent. +* +* Bumped up to encode 64 bit values. Unfortunately the result may +* overflow now. */ #define MANTSIZE 13/* 13 bit mantissa. */ -#define EXPSIZE 3/* Base 8 (3 bit) exponent. */ +#define EXPSIZE 3/* 3 bit exponent. */ +#define EXPBASE 3/* Base 8 (3 bit) exponent. */ #define MAXFRACT ((1 << MANTSIZE) - 1)/* Maximum fractional value. */ -static comp_t encode_comp_t (unsigned long value) +static comp_t encode_comp_t (u64 value) {int exp, rnd; exp = rnd =0 ;while (value >MAXFRACT ) { - rnd = value & (1 << (EXPSIZE -1 ));/* Round up? */ - value >>=EXPSIZE ;/* Base 8 exponent == 3 bit shift. */ + rnd = value & (1 << (EXPBASE -1 ));/* Round up? */ + value >>=EXPBASE ;/* Base 8 exponent == 3 bit shift. */ exp++; }
@@ -249,16 +254,21 @@* If we need to round up, do it (and handle overflow correctly). */ if (rnd && (++value >MAXFRACT )) { - value >>=EXPSIZE ; + value >>=EXPBASE ; exp++; }/* * Clean it up and polish it off. */ - exp <<=MANTSIZE ;/* Shift the exponent into place */ - exp += value;/* and add on the mantissa. */ -return exp; +if (exp >= (1 <<EXPSIZE )) { +/* Overflow. Return largest representable number instead. */ +return (1ul << (MANTSIZE +EXPSIZE )) -1 ; + }else { + exp <<=MANTSIZE ;/* Shift the exponent into place */ + exp += value;/* and add on the mantissa. */ +return exp; + } }/*
@@ -279,6 +289,7 @@mm_segment_t fs;unsigned long vsize;unsigned long flim; +u64 elapsed;/* * First check to see if there is enough free_space to continue
@@ -296,8 +307,10 @@strncpy (ac.ac_comm, current->comm,ACCT_COMM ); ac.ac_comm[ACCT_COMM -1 ] ='\0' ; - ac.ac_btime =CT_TO_SECS (current->start_time) + (xtime.tv_sec - (jiffies /HZ )); - ac.ac_etime =encode_comp_t (jiffies - current->start_time); + elapsed =get_jiffies_64 () - current->start_time; + ac.ac_etime =encode_comp_t (elapsed); +do_div (elapsed,HZ ); + ac.ac_btime = xtime.tv_sec - elapsed; ac.ac_utime =encode_comp_t (current->times.tms_utime); ac.ac_stime =encode_comp_t (current->times.tms_stime); ac.ac_uid =fs_high2lowuid (current->uid);
linux/kernel/fork.c +1 -1
@@ -746,7 +746,7 @@#endif p->array =NULL ; p->lock_depth =-1 ;/* -1 = no lock */ - p->start_time = jiffies; + p->start_time =get_jiffies_64 ();INIT_LIST_HEAD (&p->local_pages);
linux/kernel/info.c +5 -1
@@ -12,15 +12,19 @@#include <linux/smp_lock.h> #include <asm/uaccess.h> +#include <asm/div64.h> asmlinkage long sys_sysinfo (struct sysinfo *info) {struct sysinfo val; +u64 uptime;memset ((char *)&val,0 ,sizeof (struct sysinfo ));cli (); - val.uptime = jiffies /HZ ; + uptime =get_jiffies_64 (); +do_div (uptime,HZ ); + val.uptime = (unsigned long ) uptime; val.loads[0 ] = avenrun[0 ] << (SI_LOAD_SHIFT -FSHIFT ); val.loads[1 ] = avenrun[1 ] << (SI_LOAD_SHIFT -FSHIFT );
linux/kernel/timer.c +61 -0
85 lines not on this page · raw message
linux/mm/oom_kill.c +2 -3
@@ -73,11 +73,10 @@/* * CPU time is in seconds and run time is in minutes. There is no * particular reason for this other than that it turned out to work -* very well in practice. This is not safe against jiffie wraps -* but we don't care _that_ much... +* very well in practice. */ cpu_time = (p->times.tms_utime + p->times.tms_stime) >> (SHIFT_HZ +3 ); - run_time = (jiffies - p->start_time) >> (SHIFT_HZ +10 ); + run_time = (get_jiffies_64 () - p->start_time) >> (SHIFT_HZ +10 ); points /=int_sqrt (cpu_time); points /=int_sqrt (int_sqrt (run_time));
Quoted 2 lines · Tabris
this one is changed as per my current running kernel, and compile tested. sorry about the last one...
-ENOCAFFEINE
still one knit:
linux/fs/proc/proc_misc.c line 222
Quoted 10 lines
#if HZ!=100 len = sprintf(page,"%lu.%02lu %lu.%02lu\n",linux/fs/proc/proc_misc.c +4
-4- uptime /HZ , - (((uptime %HZ ) *100 ) /HZ ) %100 , - idle /HZ , - (((idle % HZ) * 100) / HZ) % 100); + (unsigned long ) uptime, + (uptime_remainder *100 ) /HZ , + (unsigned long ) idle /HZ , + (idle_remainder * 100) / HZ);
the last lines should read
+ (unsigned long) idle,
+ (idle_remainder * 100) / HZ);
since idle already got divided by HZ a couple of lines earlier.
Btw., the common convention used by kernel hackers is that you can do
Quoted 2 lines
cd linux-2.4.22-ac1
patch -p1 <../whatever.patch
while with your patches one has to use -p2.
Tim
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 5 lines · Tim Schmielau
Quoted 2 lines · Tabris
this one is changed as per my current running kernel, and compile tested. sorry about the last one...
-ENOCAFFEINEstill one knit:
<snip>
Quoted 7 lines
the last lines should read
(quoted diff) +2
-0+ (unsigned long) idle, + (idle_remainder * 100) / HZ);since idle already got divided by HZ a couple of lines earlier.
fixed.
Quoted 8 lines
Btw., the common convention used by kernel hackers is that you can do
Quoted 2 lines
cd linux-2.4.22-ac1
patch -p1 <../whatever.patchwhile with your patches one has to use -p2.
short of running sed on my patches or changing my own tree structure, I'm not sure how to change this.
FWIW, my current method is actually closer to how Linus used to do it... Marcelo changed it from $version/linux to linux-$version and when using old Linus 2.4 patches, one does a patch -p 1 from $version/ but Marcelo patches, i have to do it from linux/
Maybe I'm just being an old timer on this... but i think i liked Linus' old way better.
Quoted 1 line
Tim
- --
tabris
- -
A programmer from a very large computer company went to a software
conference and then returned to report to his manager, saying: "What sort of programmers work for other companies? They behaved badly and were unconcerned with appearances. Their hair was long and unkempt and their clothes were wrinkled and old. They crashed out hospitality suites and they made rude noises during my presentation."
The manager said: "I should have never sent you to the conference.
Those programmers live beyond the physical world. They consider life absurd, an accidental coincidence. They come and go without knowing limitations. Without a care, they live only for their programs. Why should they bother with social conventions?"
"They are alive within the Tao."
-- Geoffrey James, "The Tao of Programming"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQE/YgR4tTgrITXtL+8RAiHYAJsF/KGLO1rGySnkcbJ/XhQqAoDdpQCff4fJ omrBweDu942bMXDQp9J+3QA=
=gU7d
-----END PGP SIGNATURE-----
linux/fs/proc/array.c +2 -2
@@ -345,7 +345,7 @@ ppid = task->pid ? task->p_opptr->pid :0 ;read_unlock (&tasklist_lock); res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \ -%lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld %lu %lu %ld %lu %lu %lu %lu %lu \ +%lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld %llu %lu %ld %lu %lu %lu %lu %lu \ %lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %lu\n", task->pid, task->comm,
@@ -368,7 +368,7 @@ nice,0UL /* removed */ , task->it_real_value, - task->start_time, + (unsigned long long )(task->start_time), vsize, mm ? mm->rss :0 ,/* you might want to shift this left 3 */ task->rlim[RLIMIT_RSS].rlim_cur,
linux/fs/proc/proc_misc.c +125 -37
221 lines not on this page · raw message
linux/include/linux/kernel_stat.h +3 -3
@@ -16,9 +16,9 @@#define DK_MAX_DISK 16struct kernel_stat { -unsigned int per_cpu_user[NR_CPUS ], - per_cpu_nice[NR_CPUS ], - per_cpu_system[NR_CPUS ]; +unsigned long per_cpu_user[NR_CPUS ], + per_cpu_nice[NR_CPUS ], + per_cpu_system[NR_CPUS ];unsigned int dk_drive[DK_MAX_MAJOR ][DK_MAX_DISK ];unsigned int dk_drive_rio[DK_MAX_MAJOR ][DK_MAX_DISK ];unsigned int dk_drive_wio[DK_MAX_MAJOR ][DK_MAX_DISK ];
linux/include/linux/sched.h +13 -1
@@ -380,7 +380,7 @@unsigned long it_real_incr, it_prof_incr, it_virt_incr;struct timer_list real_timer;struct tms times; -unsigned long start_time; +u64 start_time;long per_cpu_utime[NR_CPUS ], per_cpu_stime[NR_CPUS ];/* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */ unsigned long min_flt, maj_flt, nswap, cmin_flt, cmaj_flt, cnswap;
@@ -590,6 +590,18 @@#include <asm/current.h> extern unsigned long volatile jiffies; +#if BITS_PER_LONG <48 +#define NEEDS_JIFFIES_64 +extern u64 get_jiffies_64 (void ); +#else +/* jiffies is wide enough to not wrap for 8716 years at HZ==1024 */ +static inline u64 get_jiffies_64 (void ) + { +return (u64 )jiffies; + } +#endif + +extern unsigned long itimer_ticks;extern unsigned long itimer_next;extern struct timeval xtime;
linux/kernel/acct.c +23 -10
@@ -57,6 +57,7 @@#include <linux/tty.h> #include <asm/uaccess.h> +#include <asm/div64.h> /* * These constants control the amount of freespace that suspend and
@@ -228,20 +229,24 @@* This routine has been adopted from the encode_comp_t() function in * the kern_acct.c file of the FreeBSD operating system. The encoding * is a 13-bit fraction with a 3-bit (base 8) exponent. +* +* Bumped up to encode 64 bit values. Unfortunately the result may +* overflow now. */ #define MANTSIZE 13/* 13 bit mantissa. */ -#define EXPSIZE 3/* Base 8 (3 bit) exponent. */ +#define EXPSIZE 3/* 3 bit exponent. */ +#define EXPBASE 3/* Base 8 (3 bit) exponent. */ #define MAXFRACT ((1 << MANTSIZE) - 1)/* Maximum fractional value. */ -static comp_t encode_comp_t (unsigned long value) +static comp_t encode_comp_t (u64 value) {int exp, rnd; exp = rnd =0 ;while (value >MAXFRACT ) { - rnd = value & (1 << (EXPSIZE -1 ));/* Round up? */ - value >>=EXPSIZE ;/* Base 8 exponent == 3 bit shift. */ + rnd = value & (1 << (EXPBASE -1 ));/* Round up? */ + value >>=EXPBASE ;/* Base 8 exponent == 3 bit shift. */ exp++; }
@@ -249,16 +254,21 @@* If we need to round up, do it (and handle overflow correctly). */ if (rnd && (++value >MAXFRACT )) { - value >>=EXPSIZE ; + value >>=EXPBASE ; exp++; }/* * Clean it up and polish it off. */ - exp <<=MANTSIZE ;/* Shift the exponent into place */ - exp += value;/* and add on the mantissa. */ -return exp; +if (exp >= (1 <<EXPSIZE )) { +/* Overflow. Return largest representable number instead. */ +return (1ul << (MANTSIZE +EXPSIZE )) -1 ; + }else { + exp <<=MANTSIZE ;/* Shift the exponent into place */ + exp += value;/* and add on the mantissa. */ +return exp; + } }/*
@@ -279,6 +289,7 @@mm_segment_t fs;unsigned long vsize;unsigned long flim; +u64 elapsed;/* * First check to see if there is enough free_space to continue
@@ -296,8 +307,10 @@strncpy (ac.ac_comm, current->comm,ACCT_COMM ); ac.ac_comm[ACCT_COMM -1 ] ='\0' ; - ac.ac_btime =CT_TO_SECS (current->start_time) + (xtime.tv_sec - (jiffies /HZ )); - ac.ac_etime =encode_comp_t (jiffies - current->start_time); + elapsed =get_jiffies_64 () - current->start_time; + ac.ac_etime =encode_comp_t (elapsed); +do_div (elapsed,HZ ); + ac.ac_btime = xtime.tv_sec - elapsed; ac.ac_utime =encode_comp_t (current->times.tms_utime); ac.ac_stime =encode_comp_t (current->times.tms_stime); ac.ac_uid =fs_high2lowuid (current->uid);
linux/kernel/fork.c +1 -1
@@ -746,7 +746,7 @@#endif p->array =NULL ; p->lock_depth =-1 ;/* -1 = no lock */ - p->start_time = jiffies; + p->start_time =get_jiffies_64 ();INIT_LIST_HEAD (&p->local_pages);
linux/kernel/info.c +5 -1
@@ -12,15 +12,19 @@#include <linux/smp_lock.h> #include <asm/uaccess.h> +#include <asm/div64.h> asmlinkage long sys_sysinfo (struct sysinfo *info) {struct sysinfo val; +u64 uptime;memset ((char *)&val,0 ,sizeof (struct sysinfo ));cli (); - val.uptime = jiffies /HZ ; + uptime =get_jiffies_64 (); +do_div (uptime,HZ ); + val.uptime = (unsigned long ) uptime; val.loads[0 ] = avenrun[0 ] << (SI_LOAD_SHIFT -FSHIFT ); val.loads[1 ] = avenrun[1 ] << (SI_LOAD_SHIFT -FSHIFT );
linux/kernel/timer.c +61 -0
85 lines not on this page · raw message
linux/mm/oom_kill.c +2 -3
@@ -73,11 +73,10 @@/* * CPU time is in seconds and run time is in minutes. There is no * particular reason for this other than that it turned out to work -* very well in practice. This is not safe against jiffie wraps -* but we don't care _that_ much... +* very well in practice. */ cpu_time = (p->times.tms_utime + p->times.tms_stime) >> (SHIFT_HZ +3 ); - run_time = (jiffies - p->start_time) >> (SHIFT_HZ +10 ); + run_time = (get_jiffies_64 () - p->start_time) >> (SHIFT_HZ +10 ); points /=int_sqrt (cpu_time); points /=int_sqrt (int_sqrt (run_time));
Quoted 4 lines
Quoted 2 lines
while with your patches one has to use -p2.
short of running sed on my patches or changing my own tree structure, I'm not sure how to change this.
sed is one option, links are another.
Quoted 3 lines
Marcelo changed it from $version/linux to linux-$version and when using old Linus 2.4 patches, one does a patch -p 1 from $version/ but Marcelo patches, i have to do it from linux/
Linus' 2.4 patches used $version/linux/ for the old tree and linux/ for the new one, so they worked with -p1 from inside linux/ as well.
Anyways, I don't bother too much. It's just a short moment of irritation when the first filename isn't found.
Tim