sched: move content out of core files for load calculations
v2 cover sched: move content out of core files for load calculations
Recent activity has had a focus on moving functionally related blocks of stuff out of sched/core.c into stand-alone files. The code relating to load calculations has grown significantly enough recently to warrant placing it in a separate file.
Here we do that, and in doing so, we shed ~20k of code from sched/core.c (~10%).
A couple small static functions in the core sched.h header were also localized to their singular user in sched/fair.c at the same time, with the goal to also reduce the amount of "broadcast" content in that sched.h file.
Paul.
---
v2 changes:
1) rebase from tip's sched/core (v3.9-rc1-38-gb329fd5) to today's
tip master (v3.9-rc6-2031-g27f8b76).
2) rename file from load_avg.c to proc.c
---
The following changes since commit 27f8b769cba5a97ffcbaae92fd4c0ed84f00e214:
manual merge of tools/kvm (2013-04-19 13:05:17 +0200)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux.git for-ingo
for you to fetch changes up to dac25445169ff97142ae4f7174e3d94ce7036ad3:
sched: move update_load_[add/sub/set] from sched.h to fair.c (2013-04-19 14:38:11 -0400)
----------------------------------------------------------------
Paul Gortmaker (2):
sched: fork load calculation code from sched/core --> sched/proc
sched: move update_load_[add/sub/set] from sched.h to fair.c
kernel/sched/Makefile | 2 +- kernel/sched/core.c | 569 ------------------------------------------------- kernel/sched/fair.c | 18 ++ kernel/sched/proc.c | 578 ++++++++++++++++++++++++++++++++++++++++++++++++++ kernel/sched/sched.h | 26 +-- 5 files changed, 605 insertions(+), 588 deletions(-) create mode 100644 kernel/sched/proc.c
PATCH v2 1/2 sched: fork load calculation code from sched/core --> sched/proc
This large chunk of load calculation code can be easily divorced from the main core.c scheduler file, with only a couple prototypes and externs added to a kernel/sched header.
Some recent commits expanded the code and the documentation of it, making it large enough to warrant separation. For example, see:
556061b, "sched/nohz: Fix rq->cpu_load[] calculations" 5aaa0b7, "sched/nohz: Fix rq->cpu_load calculations some more" 5167e8d, "sched/nohz: Rewrite and fix load-avg computation -- again"
More importantly, it helps reduce the size of the main sched/core.c by yet another significant amount (~600 lines).
--- kernel/sched/Makefile | 2 +- kernel/sched/core.c | 569 ------------------------------------------------- kernel/sched/proc.c | 578 ++++++++++++++++++++++++++++++++++++++++++++++++++ kernel/sched/sched.h | 8 + 4 files changed, 587 insertions(+), 570 deletions(-) create mode 100644 kernel/sched/proc.c
kernel/sched/Makefile +1 -1
@@ -11,7 +11,7 @@ ifneq ($(CONFIG_SCHED_OMIT_FRAME_POINTER),y) CFLAGS_core.o := $(PROFILING) -fno-omit-frame-pointer endif -obj-y += core.o clock.o cputime.o idle_task.o fair.o rt.o stop_task.o +obj-y += core.o proc.o clock.o cputime.o idle_task.o fair.o rt.o stop_task.o obj-$(CONFIG_SMP) += cpupri.o obj-$(CONFIG_SCHED_AUTOGROUP) += auto_group.o obj-$(CONFIG_SCHEDSTATS) += stats.o
kernel/sched/core.c +0 -569
575 lines not on this page · raw message
kernel/sched/proc.c new file +578 -0
578 lines not on this page · raw message
kernel/sched/sched.h +8 -0
@@ -9,8 +9,16 @@#include "cpupri.h" #include "cpuacct.h" +struct rq ; +extern __read_mostly int scheduler_running; +extern unsigned long calc_load_update; +extern atomic_long_t calc_load_tasks; + +extern long calc_load_fold_active (struct rq *this_rq); +extern void update_cpu_load_active (struct rq *this_rq); +/* * Convert user-nice values [ -20 ... 0 ... 19 ] * to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ],
Signature · 1 line
1.8.1.2
tip-bot for Paul Gortmaker
merge bot[tip:sched/urgent] sched: Factor out load calculation code from sched/core.c --> sched/proc.c
sched: Factor out load calculation code from sched/core.c --> sched/proc.c
Commit-ID: 45ceebf77653975815d82fcf7cec0a164215ae11 Gitweb: http://git.kernel.org/tip/45ceebf77653975815d82fcf7cec0a164215ae11 Author: Paul Gortmaker <[email protected]> AuthorDate: Fri, 19 Apr 2013 15:10:49 -0400 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 7 May 2013 13:14:50 +0200
sched: Factor out load calculation code from sched/core.c --> sched/proc.c
This large chunk of load calculation code can be easily divorced from the main core.c scheduler file, with only a couple prototypes and externs added to a kernel/sched header.
Some recent commits expanded the code and the documentation of it, making it large enough to warrant separation. For example, see:
556061b, "sched/nohz: Fix rq->cpu_load[] calculations" 5aaa0b7, "sched/nohz: Fix rq->cpu_load calculations some more" 5167e8d, "sched/nohz: Rewrite and fix load-avg computation -- again"
More importantly, it helps reduce the size of the main sched/core.c by yet another significant amount (~600 lines).
--- kernel/sched/Makefile | 2 +- kernel/sched/core.c | 569 ------------------------------------------------- kernel/sched/proc.c | 578 ++++++++++++++++++++++++++++++++++++++++++++++++++ kernel/sched/sched.h | 8 + 4 files changed, 587 insertions(+), 570 deletions(-)
kernel/sched/Makefile +1 -1
@@ -11,7 +11,7 @@ ifneq ($(CONFIG_SCHED_OMIT_FRAME_POINTER),y) CFLAGS_core.o := $(PROFILING) -fno-omit-frame-pointer endif -obj-y += core.o clock.o cputime.o idle_task.o fair.o rt.o stop_task.o +obj-y += core.o proc.o clock.o cputime.o idle_task.o fair.o rt.o stop_task.o obj-$(CONFIG_SMP) += cpupri.o obj-$(CONFIG_SCHED_AUTOGROUP) += auto_group.o obj-$(CONFIG_SCHEDSTATS) += stats.o
kernel/sched/core.c +0 -569
575 lines not on this page · raw message
kernel/sched/proc.c new file +578 -0
578 lines not on this page · raw message
kernel/sched/sched.h +8 -0
@@ -10,8 +10,16 @@#include "cpupri.h" #include "cpuacct.h" +struct rq ; +extern __read_mostly int scheduler_running; +extern unsigned long calc_load_update; +extern atomic_long_t calc_load_tasks; + +extern long calc_load_fold_active (struct rq *this_rq); +extern void update_cpu_load_active (struct rq *this_rq); +/* * Convert user-nice values [ -20 ... 0 ... 19 ] * to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ],
PATCH v2 2/2 sched: move update_load_[add/sub/set] from sched.h to fair.c
In reply to Paul GortmakerThese inlines are only used by kernel/sched/fair.c so they do not need to be present in the main kernel/sched/sched.h file.
--- kernel/sched/fair.c | 18 ++++++++++++++++++ kernel/sched/sched.h | 18 ------------------ 2 files changed, 18 insertions(+), 18 deletions(-)
kernel/sched/fair.c +18 -0
@@ -113,6 +113,24 @@ unsigned int __read_mostly sysctl_sched_shares_window = 10000000UL;unsigned int sysctl_sched_cfs_bandwidth_slice =5000UL ;#endif +static inline void update_load_add (struct load_weight *lw,unsigned long inc) +{ + lw->weight += inc; + lw->inv_weight =0 ; +} + +static inline void update_load_sub (struct load_weight *lw,unsigned long dec) +{ + lw->weight -= dec; + lw->inv_weight =0 ; +} + +static inline void update_load_set (struct load_weight *lw,unsigned long w) +{ + lw->weight = w; + lw->inv_weight =0 ; +} +/* * Increase the granularity value when there are more CPUs, * because with more CPUs the 'effective latency' as visible
kernel/sched/sched.h +0 -18
@@ -888,24 +888,6 @@ static inline void finish_lock_switch(struct rq *rq, struct task_struct *prev)#define WF_FORK 0x02/* child wakeup after fork */ #define WF_MIGRATED 0x4/* internal use, task got migrated */ -static inline void update_load_add (struct load_weight *lw,unsigned long inc) -{ - lw->weight += inc; - lw->inv_weight =0 ; -} - -static inline void update_load_sub (struct load_weight *lw,unsigned long dec) -{ - lw->weight -= dec; - lw->inv_weight =0 ; -} - -static inline void update_load_set (struct load_weight *lw,unsigned long w) -{ - lw->weight = w; - lw->inv_weight =0 ; -} -/* * To aid in avoiding the subversion of "niceness" due to uneven distribution * of tasks with abnormal "nice" values across CPUs the contribution that
Signature · 1 line
1.8.1.2
tip-bot for Paul Gortmaker
merge bot[tip:sched/urgent] sched: Move update_load_*() methods from sched.h to fair.c
sched: Move update_load_*() methods from sched.h to fair.c
Commit-ID: 8527632dc95472adb571701e852479531c0567a2 Gitweb: http://git.kernel.org/tip/8527632dc95472adb571701e852479531c0567a2 Author: Paul Gortmaker <[email protected]> AuthorDate: Fri, 19 Apr 2013 15:10:50 -0400 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 7 May 2013 13:14:51 +0200
sched: Move update_load_*() methods from sched.h to fair.c
These inlines are only used by kernel/sched/fair.c so they do not need to be present in the main kernel/sched/sched.h file.
--- kernel/sched/fair.c | 18 ++++++++++++++++++ kernel/sched/sched.h | 18 ------------------ 2 files changed, 18 insertions(+), 18 deletions(-)
kernel/sched/fair.c +18 -0
@@ -113,6 +113,24 @@ unsigned int __read_mostly sysctl_sched_shares_window = 10000000UL;unsigned int sysctl_sched_cfs_bandwidth_slice =5000UL ;#endif +static inline void update_load_add (struct load_weight *lw,unsigned long inc) +{ + lw->weight += inc; + lw->inv_weight =0 ; +} + +static inline void update_load_sub (struct load_weight *lw,unsigned long dec) +{ + lw->weight -= dec; + lw->inv_weight =0 ; +} + +static inline void update_load_set (struct load_weight *lw,unsigned long w) +{ + lw->weight = w; + lw->inv_weight =0 ; +} +/* * Increase the granularity value when there are more CPUs, * because with more CPUs the 'effective latency' as visible
kernel/sched/sched.h +0 -18
@@ -892,24 +892,6 @@ static inline void finish_lock_switch(struct rq *rq, struct task_struct *prev)#define WF_FORK 0x02/* child wakeup after fork */ #define WF_MIGRATED 0x4/* internal use, task got migrated */ -static inline void update_load_add (struct load_weight *lw,unsigned long inc) -{ - lw->weight += inc; - lw->inv_weight =0 ; -} - -static inline void update_load_sub (struct load_weight *lw,unsigned long dec) -{ - lw->weight -= dec; - lw->inv_weight =0 ; -} - -static inline void update_load_set (struct load_weight *lw,unsigned long w) -{ - lw->weight = w; - lw->inv_weight =0 ; -} -/* * To aid in avoiding the subversion of "niceness" due to uneven distribution * of tasks with abnormal "nice" values across CPUs the contribution that
Quoted 11 lines · Paul Gortmaker
Recent activity has had a focus on moving functionally related blocks of stuff out of
sched/core.cinto stand-alone files. The code relating to load calculations has grown significantly enough recently to warrant placing it in a separate file.Here we do that, and in doing so, we shed ~20k of code from
sched/core.c(~10%).A couple small static functions in the core
sched.hheader were also localized to their singular user insched/fair.cat the same time, with the goal to also reduce the amount of "broadcast" content in thatsched.hfile.
Quoted 8 lines
Paul.
---v2 changes:
1) rebase from tip's sched/core (v3.9-rc1-38-gb329fd5) to today's
tip master (v3.9-rc6-2031-g27f8b76).2) rename file from
load_avg.ctoproc.c
Thanks, looks good to me. Note, I'll try to apply this after the initial round of trees went to Linus in the merge window, to reduce interactions between the trees. Please send me a friendly reminder if I forget about it! :-)
Thanks,
Ingo
Quoted 19 lines · Ingo Molnar
Quoted 16 lines · Paul Gortmaker
Recent activity has had a focus on moving functionally related blocks of stuff out of
sched/core.cinto stand-alone files. The code relating to load calculations has grown significantly enough recently to warrant placing it in a separate file.Here we do that, and in doing so, we shed ~20k of code from
sched/core.c(~10%).A couple small static functions in the core
sched.hheader were also localized to their singular user insched/fair.cat the same time, with the goal to also reduce the amount of "broadcast" content in thatsched.hfile.Paul.
---v2 changes:
Quoted 7 lines
Quoted 3 lines
1) rebase from tip's sched/core (v3.9-rc1-38-gb329fd5) to today's
tip master (v3.9-rc6-2031-g27f8b76).2) rename file from
load_avg.ctoproc.cThanks, looks good to me. Note, I'll try to apply this after the initial round of trees went to Linus in the merge window, to reduce interactions between the trees. [...]
Ok, all relevant trees are now upstream - mind sending a refreshed series against upstream merge commit 534c97b0950b or later?
Thanks,
Ingo
Quoted 26 lines · [Re: [PATCHv2 0/2] sched: move content out of core files for load…
Quoted 23 lines · Ingo Molnar
Quoted 19 lines · Paul Gortmaker
Recent activity has had a focus on moving functionally related blocks of stuff out of
sched/core.cinto stand-alone files. The code relating to load calculations has grown significantly enough recently to warrant placing it in a separate file.Here we do that, and in doing so, we shed ~20k of code from
sched/core.c(~10%).A couple small static functions in the core
sched.hheader were also localized to their singular user insched/fair.cat the same time, with the goal to also reduce the amount of "broadcast" content in thatsched.hfile.Paul.
---v2 changes:
1) rebase from tip's sched/core (v3.9-rc1-38-gb329fd5) to today's
tip master (v3.9-rc6-2031-g27f8b76).2) rename file from
load_avg.ctoproc.c
Quoted 6 lines
Quoted 3 lines
Thanks, looks good to me. Note, I'll try to apply this after the initial round of trees went to Linus in the merge window, to reduce interactions between the trees. [...]
Ok, all relevant trees are now upstream - mind sending a refreshed series against upstream merge commit
534c97b0950bor later?
Sure. After putting them on top of 534c97b095, I re-checked with a quick defconfig build. Also in comparison to v2, the patches are unchanged except for trivial line offset deltas. So it should be OK.
Thanks,
Paul.
---
The following changes since commit 534c97b0950b1967bca1c753aeaed32f5db40264:
Merge branch 'timers-nohz-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip (2013-05-05 13:23:27 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux.git for-ingo
for you to fetch changes up to 54aecbbcfcbea684257ebe674251f148ee340412:
sched: move update_load_[add/sub/set] from sched.h to fair.c (2013-05-06 09:39:50 -0400)
----------------------------------------------------------------
Paul Gortmaker (2):
sched: fork load calculation code from sched/core --> sched/proc
sched: move update_load_[add/sub/set] from sched.h to fair.c
kernel/sched/Makefile | 2 +- kernel/sched/core.c | 569 ------------------------------------------------- kernel/sched/fair.c | 18 ++ kernel/sched/proc.c | 578 ++++++++++++++++++++++++++++++++++++++++++++++++++ kernel/sched/sched.h | 26 +-- 5 files changed, 605 insertions(+), 588 deletions(-) create mode 100644 kernel/sched/proc.c