Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 182519
b: refs/heads/master
c: fa535a7
h: refs/heads/master
i:
  182517: 9974d5d
  182515: 54c9bb6
  182511: ce7ff1d
v: v3
  • Loading branch information
Anton Blanchard authored and Ingo Molnar committed Feb 8, 2010
1 parent 112e7fc commit 7be6961
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0c9cf2efd74dbc90354e2ccc7dbd6bad68ec6c4d
refs/heads/master: fa535a77bd3fa32b9215ba375d6a202fe73e1dd6
20 changes: 19 additions & 1 deletion trunk/kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -8997,13 +8997,31 @@ static void cpuacct_charge(struct task_struct *tsk, u64 cputime)
rcu_read_unlock();
}

/*
* When CONFIG_VIRT_CPU_ACCOUNTING is enabled one jiffy can be very large
* in cputime_t units. As a result, cpuacct_update_stats calls
* percpu_counter_add with values large enough to always overflow the
* per cpu batch limit causing bad SMP scalability.
*
* To fix this we scale percpu_counter_batch by cputime_one_jiffy so we
* batch the same amount of time with CONFIG_VIRT_CPU_ACCOUNTING disabled
* and enabled. We cap it at INT_MAX which is the largest allowed batch value.
*/
#ifdef CONFIG_SMP
#define CPUACCT_BATCH \
min_t(long, percpu_counter_batch * cputime_one_jiffy, INT_MAX)
#else
#define CPUACCT_BATCH 0
#endif

/*
* Charge the system/user time to the task's accounting group.
*/
static void cpuacct_update_stats(struct task_struct *tsk,
enum cpuacct_stat_index idx, cputime_t val)
{
struct cpuacct *ca;
int batch = CPUACCT_BATCH;

if (unlikely(!cpuacct_subsys.active))
return;
Expand All @@ -9012,7 +9030,7 @@ static void cpuacct_update_stats(struct task_struct *tsk,
ca = task_ca(tsk);

do {
percpu_counter_add(&ca->cpustat[idx], val);
__percpu_counter_add(&ca->cpustat[idx], val, batch);
ca = ca->parent;
} while (ca);
rcu_read_unlock();
Expand Down

0 comments on commit 7be6961

Please sign in to comment.