lkml.org 
[lkml]   [2010]   [Oct]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 3/6] Refactor account_system_time separating id and actual update
    Date
    Refactor account_system_time, to separate out the logic of
    identifying the update needed and code that does actual updating.

    This is used by following patch for IRQ_TIME_ACCOUNTING,
    which has different identification logic and same update logic.

    Signed-off-by: Venkatesh Pallipadi <venki@google.com>
    ---
    kernel/sched.c | 46 +++++++++++++++++++++++++++++++---------------
    1 files changed, 31 insertions(+), 15 deletions(-)

    diff --git a/kernel/sched.c b/kernel/sched.c
    index 5d4afe9..8b97958 100644
    --- a/kernel/sched.c
    +++ b/kernel/sched.c
    @@ -3501,6 +3501,32 @@ static void account_guest_time(struct task_struct *p, cputime_t cputime,
    }

    /*
    + * Account system cpu time to a process and desired cpustat field
    + * @p: the process that the cpu time gets accounted to
    + * @cputime: the cpu time spent in kernel space since the last update
    + * @cputime_scaled: cputime scaled by cpu frequency
    + * @target_cputime64: pointer to cpustat field that needs updating
    + */
    +static inline
    +void __account_system_time(struct task_struct *p, cputime_t cputime,
    + cputime_t cputime_scaled, cputime64_t *target_cputime64)
    +{
    + cputime64_t tmp = cputime_to_cputime64(cputime);
    +
    + /* Add system time to process. */
    + p->stime = cputime_add(p->stime, cputime);
    + p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
    + account_group_system_time(p, cputime);
    +
    + /* Add system time to cpustat. */
    + *target_cputime64 = cputime64_add(*target_cputime64, tmp);
    + cpuacct_update_stats(p, CPUACCT_STAT_SYSTEM, cputime);
    +
    + /* Account for system time used */
    + acct_update_integrals(p);
    +}
    +
    +/*
    * Account system cpu time to a process.
    * @p: the process that the cpu time gets accounted to
    * @hardirq_offset: the offset to subtract from hardirq_count()
    @@ -3511,31 +3537,21 @@ void account_system_time(struct task_struct *p, int hardirq_offset,
    cputime_t cputime, cputime_t cputime_scaled)
    {
    struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
    - cputime64_t tmp;
    + cputime64_t *target_cputime64;

    if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
    account_guest_time(p, cputime, cputime_scaled);
    return;
    }

    - /* Add system time to process. */
    - p->stime = cputime_add(p->stime, cputime);
    - p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
    - account_group_system_time(p, cputime);
    -
    - /* Add system time to cpustat. */
    - tmp = cputime_to_cputime64(cputime);
    if (hardirq_count() - hardirq_offset)
    - cpustat->irq = cputime64_add(cpustat->irq, tmp);
    + target_cputime64 = &cpustat->irq;
    else if (in_serving_softirq())
    - cpustat->softirq = cputime64_add(cpustat->softirq, tmp);
    + target_cputime64 = &cpustat->softirq;
    else
    - cpustat->system = cputime64_add(cpustat->system, tmp);
    + target_cputime64 = &cpustat->system;

    - cpuacct_update_stats(p, CPUACCT_STAT_SYSTEM, cputime);
    -
    - /* Account for system time used */
    - acct_update_integrals(p);
    + __account_system_time(p, cputime, cputime_scaled, target_cputime64);
    }

    /*
    --
    1.7.1


    \
     
     \ /
      Last update: 2010-10-21 00:53    [W:0.027 / U:30.988 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site