Commit 5ad0c942 authored by Tim Schmielau's avatar Tim Schmielau Committed by Linus Torvalds

[PATCH] use 64 bit jiffies: 64-bit process start time

This prevents reporting processes as having started in the future, after
32 bit jiffies wrap.
parent 4143137c
......@@ -301,7 +301,7 @@ int proc_pid_stat(struct task_struct *task, char * buffer)
ppid = task->pid ? task->real_parent->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,
......@@ -324,7 +324,7 @@ int proc_pid_stat(struct task_struct *task, char * buffer)
nice,
0UL /* removed */,
jiffies_to_clock_t(task->it_real_value),
jiffies_to_clock_t(task->start_time),
(unsigned long long) jiffies_64_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,
......
......@@ -343,7 +343,7 @@ struct task_struct {
unsigned long it_real_incr, it_prof_incr, it_virt_incr;
struct timer_list real_timer;
unsigned long utime, stime, cutime, cstime;
unsigned long start_time;
u64 start_time;
/* 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;
/* process credentials */
......
......@@ -51,7 +51,9 @@
#include <linux/tty.h>
#include <linux/security.h>
#include <linux/vfs.h>
#include <linux/jiffies.h>
#include <asm/uaccess.h>
#include <asm/div64.h>
/*
* These constants control the amount of freespace that suspend and
......@@ -306,6 +308,7 @@ static void do_acct_process(long exitcode, struct file *file)
mm_segment_t fs;
unsigned long vsize;
unsigned long flim;
u64 elapsed;
/*
* First check to see if there is enough free_space to continue
......@@ -323,9 +326,11 @@ static void do_acct_process(long exitcode, struct file *file)
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 < (unsigned long) -1l ?
(unsigned long) elapsed : (unsigned long) -1l);
do_div(elapsed, HZ);
ac.ac_btime = xtime.tv_sec - elapsed;
ac.ac_utime = encode_comp_t(current->utime);
ac.ac_stime = encode_comp_t(current->stime);
ac.ac_uid = current->uid;
......
......@@ -26,6 +26,7 @@
#include <linux/mman.h>
#include <linux/fs.h>
#include <linux/security.h>
#include <linux/jiffies.h>
#include <linux/futex.h>
#include <linux/ptrace.h>
#include <linux/mount.h>
......@@ -814,7 +815,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
p->cutime = p->cstime = 0;
p->array = NULL;
p->lock_depth = -1; /* -1 = no lock */
p->start_time = jiffies;
p->start_time = get_jiffies_64();
p->security = NULL;
retval = -ENOMEM;
......
......@@ -19,6 +19,7 @@
#include <linux/sched.h>
#include <linux/swap.h>
#include <linux/timex.h>
#include <linux/jiffies.h>
/* #define DEBUG */
......@@ -68,11 +69,10 @@ static int badness(struct task_struct *p)
/*
* 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->utime + p->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));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment