sched/fair: make capacity_margin __read_mostly
Subsystems (2)
PATCH v2 1/2 sched/fair: make capacity_margin __read_mostly
Variable 'capacity_margin' is used with read operation for most cases to calculate the capacity margin, put it into __read_mostly section.
--- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
@@ -129,7 +129,7 @@ unsigned int sysctl_sched_cfs_bandwidth_slice = 5000UL;* * (default: ~20%) */ -unsigned int capacity_margin =1280 ; +unsigned int capacity_margin__read_mostly =1280 ;static inline void update_load_add (struct load_weight *lw,unsigned long inc) {
Signature · 1 line
2.7.4
PATCH v2 2/2 cpufreq: schedutil: consolidate capacity margin calculation
Scheduler CFS class has variable 'capacity_margin' to calculate the capacity margin, and schedutil governor also needs to compensate the same margin for frequency tipping point. Below are formulas used in CFS class and schedutil governor separately:
CFS: U` = U * capacity_margin / 1024 = U * 1.25 Schedutil: U` = U + U >> 2 = U + U * 0.25 = U * 1.25
This patch consolidates the capacity margin calculation so let schedutil to use same formula with CFS class. As result this can avoid the mismatch issue between schedutil and CFS class after change 'capacity_margin' to other values.
--- kernel/sched/cpufreq_schedutil.c | 6 ++++-- kernel/sched/sched.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-)
kernel/sched/cpufreq_schedutil.c +4 -2
@@ -155,7 +155,8 @@ static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time,* * next_freq = C * curr_freq * util_raw / max * -* Take C = 1.25 for the frequency tipping point at (util / max) = 0.8. +* Take C = capacity_margin / 1024 = 1.25, so it's for the frequency tipping +* point at (util / max) = 0.8. * * The lowest driver-supported frequency which is equal or greater than the raw * next_freq (as calculated above) is returned, subject to policy min/max and
@@ -168,7 +169,8 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy,unsigned int freq =arch_scale_freq_invariant () ? policy->cpuinfo.max_freq : policy->cur; - freq = (freq + (freq >>2 )) * util / max; + freq = freq * capacity_margin >>SCHED_CAPACITY_SHIFT ; + freq = freq * util / max;if (freq == sg_policy->cached_raw_freq && sg_policy->next_freq !=UINT_MAX )return sg_policy->next_freq;
kernel/sched/sched.h +1 -0
@@ -52,6 +52,7 @@ struct cpuidle_state;#define TASK_ON_RQ_MIGRATING 2extern __read_mostly int scheduler_running; +extern unsigned int capacity_margin__read_mostly ;extern unsigned long calc_load_update;extern atomic_long_t calc_load_tasks;
Signature · 1 line
2.7.4
Re: [PATCH v2 2/2] cpufreq: schedutil: consolidate capacity margin calculation
Hi Leo,
Quoted 1 line · Leo Yan
Scheduler CFS class has variable '
capacity_margin' to calculate the
s/calculate/represent/ ?
Quoted 5 lines
capacity margin, and schedutil governor also needs to compensate the same margin for frequency tipping point. Below are formulas used in CFS class and schedutil governor separately:
CFS: U` = U *
capacity_margin/ 1024 = U * 1.25
You should mention in the commit message, at the moment capacity_margin is 1280 which makes U` = 1.25.
Quoted 4 lines
Schedutil: U` = U + U >> 2 = U + U * 0.25 = U * 1.25
This patch consolidates the capacity margin calculation so let schedutil to use same formula with CFS class. As result this can avoid
As a result.
Quoted 2 lines
the mismatch issue between schedutil and CFS class after change '
capacity_margin' to other values.
This didn't make sense to me. May be you meant:
This patch consolidates the usage of the capacity margin value and lets schedutil use the same formula as the CFS class. Thus we can avoid the mismatch between schedutil and CFS class if 'capacity_margin' is changed to other values in the future.
Quoted 18 lines
Cc Dietmar Eggemann <[email protected]>Cc Morten Rasmussen <[email protected]>Cc Chris Redpath <[email protected]>Cc Joel Fernandes <[email protected]>Cc Vincent Guittot <[email protected]>Cc Patrick Bellasi <[email protected]>Cc Rafael J. Wysocki <[email protected]>Signed-off-by Leo Yan <[email protected]>--- kernel/sched/cpufreq_schedutil.c | 6 ++++-- kernel/sched/sched.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-)kernel/sched/cpufreq_schedutil.c +0
-0
kernel/sched/cpufreq_schedutil.c static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time, · line 159
Quoted 6 lines
kernel/sched/cpufreq_schedutil.c +2
-1@@ -155,7 +155,8 @@ static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time,* * next_freq = C * curr_freq * util_raw / max * -* Take C = 1.25 for the frequency tipping point at (util / max) = 0.8. +* Take C = capacity_margin / 1024 = 1.25, so it's for the frequency tipping +* point at (util / max) = 0.8.
The above comment assumes capacity_margin is 1280. If for any reason the capacity_margin is changed to something else, then the comment wont make sense anymore.
thanks,
- Joel
Re: [PATCH v2 2/2] cpufreq: schedutil: consolidate capacity margin calculation
Hi Joel,
Quoted 26 lines · Joel Fernandes
Hi Leo,
Quoted 1 line · Leo Yan
Scheduler CFS class has variable '
capacity_margin' to calculate thes/calculate/represent/ ?
Quoted 5 lines
capacity margin, and schedutil governor also needs to compensate the same margin for frequency tipping point. Below are formulas used in CFS class and schedutil governor separately:
CFS: U` = U *
capacity_margin/ 1024 = U * 1.25You should mention in the commit message, at the moment
capacity_marginis 1280 which makes U` = 1.25.Quoted 4 lines
Schedutil: U` = U + U >> 2 = U + U * 0.25 = U * 1.25
This patch consolidates the capacity margin calculation so let schedutil to use same formula with CFS class. As result this can avoid
As a result.
Quoted 2 lines
the mismatch issue between schedutil and CFS class after change '
capacity_margin' to other values.
Quoted 6 lines
This didn't make sense to me. May be you meant:
This patch consolidates the usage of the capacity margin value and lets schedutil use the same formula as the CFS class. Thus we can avoid the mismatch between schedutil and CFS class if '
capacity_margin' is changed to other values in the future.
Yeah, thanks for the suggestion. And accept all upper comment. Will refine for new patch.
Thanks,
Leo Yan
Quoted 32 lines
Quoted 18 lines
Cc Dietmar Eggemann <[email protected]>Cc Morten Rasmussen <[email protected]>Cc Chris Redpath <[email protected]>Cc Joel Fernandes <[email protected]>Cc Vincent Guittot <[email protected]>Cc Patrick Bellasi <[email protected]>Cc Rafael J. Wysocki <[email protected]>Signed-off-by Leo Yan <[email protected]>--- kernel/sched/cpufreq_schedutil.c | 6 ++++-- kernel/sched/sched.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-)kernel/sched/cpufreq_schedutil.c +0
-0kernel/sched/cpufreq_schedutil.c static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time, · line 159
Quoted 6 lines
kernel/sched/cpufreq_schedutil.c +2
-1@@ -155,7 +155,8 @@ static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time,* * next_freq = C * curr_freq * util_raw / max * -* Take C = 1.25 for the frequency tipping point at (util / max) = 0.8. +* Take C = capacity_margin / 1024 = 1.25, so it's for the frequency tipping +* point at (util / max) = 0.8. The above comment assumes
capacity_marginis 1280. If for any reason thecapacity_marginis changed to something else, then the comment wont make sense anymore.thanks,
- Joel