mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-27 00:51:35 +00:00
sched/cputime: Rename vtime fields
The current "snapshot" based naming on vtime fields suggests we record some past event but that's a low level picture of their actual purpose which comes out blurry. The real point of these fields is to run a basic state machine that tracks down cputime entry while switching between contexts. So lets reflect that with more meaningful names. Tested-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Rik van Riel <riel@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Wanpeng Li <kernellwp@gmail.com> Link: http://lkml.kernel.org/r/1498756511-11714-4-git-send-email-fweisbec@gmail.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
parent
9fa57cf5a5
commit
60a9ce57e7
4 changed files with 21 additions and 21 deletions
|
@ -171,8 +171,8 @@ extern struct cred init_cred;
|
||||||
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
|
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
|
||||||
# define INIT_VTIME(tsk) \
|
# define INIT_VTIME(tsk) \
|
||||||
.vtime_seqcount = SEQCNT_ZERO(tsk.vtime_seqcount), \
|
.vtime_seqcount = SEQCNT_ZERO(tsk.vtime_seqcount), \
|
||||||
.vtime_snap = 0, \
|
.vtime_starttime = 0, \
|
||||||
.vtime_snap_whence = VTIME_SYS,
|
.vtime_state = VTIME_SYS,
|
||||||
#else
|
#else
|
||||||
# define INIT_VTIME(tsk)
|
# define INIT_VTIME(tsk)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -689,7 +689,7 @@ struct task_struct {
|
||||||
struct prev_cputime prev_cputime;
|
struct prev_cputime prev_cputime;
|
||||||
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
|
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
|
||||||
seqcount_t vtime_seqcount;
|
seqcount_t vtime_seqcount;
|
||||||
unsigned long long vtime_snap;
|
unsigned long long vtime_starttime;
|
||||||
enum {
|
enum {
|
||||||
/* Task is sleeping or running in a CPU with VTIME inactive: */
|
/* Task is sleeping or running in a CPU with VTIME inactive: */
|
||||||
VTIME_INACTIVE = 0,
|
VTIME_INACTIVE = 0,
|
||||||
|
@ -697,7 +697,7 @@ struct task_struct {
|
||||||
VTIME_USER,
|
VTIME_USER,
|
||||||
/* Task runs in kernelspace in a CPU with VTIME active: */
|
/* Task runs in kernelspace in a CPU with VTIME active: */
|
||||||
VTIME_SYS,
|
VTIME_SYS,
|
||||||
} vtime_snap_whence;
|
} vtime_state;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_NO_HZ_FULL
|
#ifdef CONFIG_NO_HZ_FULL
|
||||||
|
|
|
@ -1638,8 +1638,8 @@ static __latent_entropy struct task_struct *copy_process(
|
||||||
|
|
||||||
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
|
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
|
||||||
seqcount_init(&p->vtime_seqcount);
|
seqcount_init(&p->vtime_seqcount);
|
||||||
p->vtime_snap = 0;
|
p->vtime_starttime = 0;
|
||||||
p->vtime_snap_whence = VTIME_INACTIVE;
|
p->vtime_state = VTIME_INACTIVE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SPLIT_RSS_COUNTING)
|
#if defined(SPLIT_RSS_COUNTING)
|
||||||
|
|
|
@ -683,10 +683,10 @@ static u64 vtime_delta(struct task_struct *tsk)
|
||||||
{
|
{
|
||||||
unsigned long now = READ_ONCE(jiffies);
|
unsigned long now = READ_ONCE(jiffies);
|
||||||
|
|
||||||
if (time_before(now, (unsigned long)tsk->vtime_snap))
|
if (time_before(now, (unsigned long)tsk->vtime_starttime))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return jiffies_to_nsecs(now - tsk->vtime_snap);
|
return jiffies_to_nsecs(now - tsk->vtime_starttime);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u64 get_vtime_delta(struct task_struct *tsk)
|
static u64 get_vtime_delta(struct task_struct *tsk)
|
||||||
|
@ -701,10 +701,10 @@ static u64 get_vtime_delta(struct task_struct *tsk)
|
||||||
* elapsed time. Limit account_other_time to prevent rounding
|
* elapsed time. Limit account_other_time to prevent rounding
|
||||||
* errors from causing elapsed vtime to go negative.
|
* errors from causing elapsed vtime to go negative.
|
||||||
*/
|
*/
|
||||||
delta = jiffies_to_nsecs(now - tsk->vtime_snap);
|
delta = jiffies_to_nsecs(now - tsk->vtime_starttime);
|
||||||
other = account_other_time(delta);
|
other = account_other_time(delta);
|
||||||
WARN_ON_ONCE(tsk->vtime_snap_whence == VTIME_INACTIVE);
|
WARN_ON_ONCE(tsk->vtime_state == VTIME_INACTIVE);
|
||||||
tsk->vtime_snap = now;
|
tsk->vtime_starttime = now;
|
||||||
|
|
||||||
return delta - other;
|
return delta - other;
|
||||||
}
|
}
|
||||||
|
@ -746,7 +746,7 @@ void vtime_guest_enter(struct task_struct *tsk)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* The flags must be updated under the lock with
|
* The flags must be updated under the lock with
|
||||||
* the vtime_snap flush and update.
|
* the vtime_starttime flush and update.
|
||||||
* That enforces a right ordering and update sequence
|
* That enforces a right ordering and update sequence
|
||||||
* synchronization against the reader (task_gtime())
|
* synchronization against the reader (task_gtime())
|
||||||
* that can thus safely catch up with a tickless delta.
|
* that can thus safely catch up with a tickless delta.
|
||||||
|
@ -776,12 +776,12 @@ void vtime_account_idle(struct task_struct *tsk)
|
||||||
void arch_vtime_task_switch(struct task_struct *prev)
|
void arch_vtime_task_switch(struct task_struct *prev)
|
||||||
{
|
{
|
||||||
write_seqcount_begin(&prev->vtime_seqcount);
|
write_seqcount_begin(&prev->vtime_seqcount);
|
||||||
prev->vtime_snap_whence = VTIME_INACTIVE;
|
prev->vtime_state = VTIME_INACTIVE;
|
||||||
write_seqcount_end(&prev->vtime_seqcount);
|
write_seqcount_end(&prev->vtime_seqcount);
|
||||||
|
|
||||||
write_seqcount_begin(¤t->vtime_seqcount);
|
write_seqcount_begin(¤t->vtime_seqcount);
|
||||||
current->vtime_snap_whence = VTIME_SYS;
|
current->vtime_state = VTIME_SYS;
|
||||||
current->vtime_snap = jiffies;
|
current->vtime_starttime = jiffies;
|
||||||
write_seqcount_end(¤t->vtime_seqcount);
|
write_seqcount_end(¤t->vtime_seqcount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -791,8 +791,8 @@ void vtime_init_idle(struct task_struct *t, int cpu)
|
||||||
|
|
||||||
local_irq_save(flags);
|
local_irq_save(flags);
|
||||||
write_seqcount_begin(&t->vtime_seqcount);
|
write_seqcount_begin(&t->vtime_seqcount);
|
||||||
t->vtime_snap_whence = VTIME_SYS;
|
t->vtime_state = VTIME_SYS;
|
||||||
t->vtime_snap = jiffies;
|
t->vtime_starttime = jiffies;
|
||||||
write_seqcount_end(&t->vtime_seqcount);
|
write_seqcount_end(&t->vtime_seqcount);
|
||||||
local_irq_restore(flags);
|
local_irq_restore(flags);
|
||||||
}
|
}
|
||||||
|
@ -809,7 +809,7 @@ u64 task_gtime(struct task_struct *t)
|
||||||
seq = read_seqcount_begin(&t->vtime_seqcount);
|
seq = read_seqcount_begin(&t->vtime_seqcount);
|
||||||
|
|
||||||
gtime = t->gtime;
|
gtime = t->gtime;
|
||||||
if (t->vtime_snap_whence == VTIME_SYS && t->flags & PF_VCPU)
|
if (t->vtime_state == VTIME_SYS && t->flags & PF_VCPU)
|
||||||
gtime += vtime_delta(t);
|
gtime += vtime_delta(t);
|
||||||
|
|
||||||
} while (read_seqcount_retry(&t->vtime_seqcount, seq));
|
} while (read_seqcount_retry(&t->vtime_seqcount, seq));
|
||||||
|
@ -840,7 +840,7 @@ void task_cputime(struct task_struct *t, u64 *utime, u64 *stime)
|
||||||
*stime = t->stime;
|
*stime = t->stime;
|
||||||
|
|
||||||
/* Task is sleeping, nothing to add */
|
/* Task is sleeping, nothing to add */
|
||||||
if (t->vtime_snap_whence == VTIME_INACTIVE || is_idle_task(t))
|
if (t->vtime_state == VTIME_INACTIVE || is_idle_task(t))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
delta = vtime_delta(t);
|
delta = vtime_delta(t);
|
||||||
|
@ -849,9 +849,9 @@ void task_cputime(struct task_struct *t, u64 *utime, u64 *stime)
|
||||||
* Task runs either in user or kernel space, add pending nohz time to
|
* Task runs either in user or kernel space, add pending nohz time to
|
||||||
* the right place.
|
* the right place.
|
||||||
*/
|
*/
|
||||||
if (t->vtime_snap_whence == VTIME_USER || t->flags & PF_VCPU)
|
if (t->vtime_state == VTIME_USER || t->flags & PF_VCPU)
|
||||||
*utime += delta;
|
*utime += delta;
|
||||||
else if (t->vtime_snap_whence == VTIME_SYS)
|
else if (t->vtime_state == VTIME_SYS)
|
||||||
*stime += delta;
|
*stime += delta;
|
||||||
} while (read_seqcount_retry(&t->vtime_seqcount, seq));
|
} while (read_seqcount_retry(&t->vtime_seqcount, seq));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue