Commit ccbf62d8 authored by Thomas Gleixner's avatar Thomas Gleixner Committed by John Stultz

sched: Make task->start_time nanoseconds based

Simplify the timespec to nsec/usec conversions.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
parent 57e0be04
...@@ -1367,7 +1367,7 @@ struct task_struct { ...@@ -1367,7 +1367,7 @@ struct task_struct {
} vtime_snap_whence; } vtime_snap_whence;
#endif #endif
unsigned long nvcsw, nivcsw; /* context switch counts */ unsigned long nvcsw, nivcsw; /* context switch counts */
struct timespec start_time; /* monotonic time */ u64 start_time; /* monotonic time in nsec */
u64 real_start_time; /* boot based time in nsec */ u64 real_start_time; /* boot based time in nsec */
/* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */ /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
unsigned long min_flt, maj_flt; unsigned long min_flt, maj_flt;
......
...@@ -458,9 +458,7 @@ static void do_acct_process(struct bsd_acct_struct *acct, ...@@ -458,9 +458,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
acct_t ac; acct_t ac;
mm_segment_t fs; mm_segment_t fs;
unsigned long flim; unsigned long flim;
u64 elapsed; u64 elapsed, run_time;
u64 run_time;
struct timespec uptime;
struct tty_struct *tty; struct tty_struct *tty;
const struct cred *orig_cred; const struct cred *orig_cred;
...@@ -484,10 +482,8 @@ static void do_acct_process(struct bsd_acct_struct *acct, ...@@ -484,10 +482,8 @@ static void do_acct_process(struct bsd_acct_struct *acct,
strlcpy(ac.ac_comm, current->comm, sizeof(ac.ac_comm)); strlcpy(ac.ac_comm, current->comm, sizeof(ac.ac_comm));
/* calculate run_time in nsec*/ /* calculate run_time in nsec*/
ktime_get_ts(&uptime); run_time = ktime_get_ns();
run_time = (u64)uptime.tv_sec*NSEC_PER_SEC + uptime.tv_nsec; run_time -= current->group_leader->start_time;
run_time -= (u64)current->group_leader->start_time.tv_sec * NSEC_PER_SEC
+ current->group_leader->start_time.tv_nsec;
/* convert nsec -> AHZ */ /* convert nsec -> AHZ */
elapsed = nsec_to_AHZ(run_time); elapsed = nsec_to_AHZ(run_time);
#if ACCT_VERSION==3 #if ACCT_VERSION==3
......
...@@ -1262,7 +1262,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, ...@@ -1262,7 +1262,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
posix_cpu_timers_init(p); posix_cpu_timers_init(p);
ktime_get_ts(&p->start_time); p->start_time = ktime_get_ns();
p->real_start_time = ktime_get_boot_ns(); p->real_start_time = ktime_get_boot_ns();
p->io_context = NULL; p->io_context = NULL;
p->audit_context = NULL; p->audit_context = NULL;
......
...@@ -31,20 +31,19 @@ void bacct_add_tsk(struct user_namespace *user_ns, ...@@ -31,20 +31,19 @@ void bacct_add_tsk(struct user_namespace *user_ns,
struct taskstats *stats, struct task_struct *tsk) struct taskstats *stats, struct task_struct *tsk)
{ {
const struct cred *tcred; const struct cred *tcred;
struct timespec uptime, ts;
cputime_t utime, stime, utimescaled, stimescaled; cputime_t utime, stime, utimescaled, stimescaled;
u64 ac_etime; u64 delta;
BUILD_BUG_ON(TS_COMM_LEN < TASK_COMM_LEN); BUILD_BUG_ON(TS_COMM_LEN < TASK_COMM_LEN);
/* calculate task elapsed time in timespec */ /* calculate task elapsed time in nsec */
ktime_get_ts(&uptime); delta = ktime_get_ns() - tsk->start_time;
ts = timespec_sub(uptime, tsk->start_time); /* Convert to micro seconds */
/* rebase elapsed time to usec (should never be negative) */ do_div(delta, NSEC_PER_USEC);
ac_etime = timespec_to_ns(&ts); stats->ac_etime = delta;
do_div(ac_etime, NSEC_PER_USEC); /* Convert to seconds for btime */
stats->ac_etime = ac_etime; do_div(delta, USEC_PER_SEC);
stats->ac_btime = get_seconds() - ts.tv_sec; stats->ac_btime = get_seconds() - delta;
if (thread_group_leader(tsk)) { if (thread_group_leader(tsk)) {
stats->ac_exitcode = tsk->exit_code; stats->ac_exitcode = tsk->exit_code;
if (tsk->flags & PF_FORKNOEXEC) if (tsk->flags & PF_FORKNOEXEC)
......
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