sched: move content out of core files for load average
cover sched: move content out of core files for load average
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 average 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.
---
[ Patches sent here are tested on tip's sched/core, i.e. v3.9-rc1-38-gb329fd5
Assuming that this change is OK with folks, the timing can be whatever is most convenient -- i.e. I can update/respin it close to the end of the merge window for what will be v3.10-rc1, if that is what minimizes the inconvenience to folks who might be changing the code that is relocated here. ]
Paul Gortmaker (2):
sched: fork load calculation code from sched/core --> sched/load_avg
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/load_avg.c | 577 ++++++++++++++++++++++++++++++++++++++++++++++++ kernel/sched/sched.h | 26 +-- 5 files changed, 604 insertions(+), 588 deletions(-) create mode 100644 kernel/sched/load_avg.c
Signature · 1 line
1.8.1.2
PATCH 1/2 sched: fork load calculation code from sched/core --> sched/load_avg
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/load_avg.c | 577 ++++++++++++++++++++++++++++++++++++++++++++++++ kernel/sched/sched.h | 8 + 4 files changed, 586 insertions(+), 570 deletions(-) create mode 100644 kernel/sched/load_avg.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 load_avg.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/load_avg.c new file +577 -0
577 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
PATCH 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
Quoted 25 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 average 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.
---[ Patches sent here are tested on tip's sched/core, i.e. v3.9-rc1-38-gb329fd5
Assuming that this change is OK with folks, the timing can be whatever is most convenient -- i.e. I can update/respin it close to the end of the merge window for what will be v3.10-rc1, if that is what minimizes the inconvenience to folks who might be changing the code that is relocated here. ]
Paul Gortmaker (2):
sched: fork load calculation code from sched/core --> sched/load_avg
sched: move update_load_[add/sub/set] fromsched.htofair.c
Quoted 8 lines
kernel/sched/Makefile | 2 +- kernel/sched/core.c | 569 ----------------------------------------------- kernel/sched/fair.c | 18 ++ kernel/sched/load_avg.c | 577 ++++++++++++++++++++++++++++++++++++++++++++++++ kernel/sched/sched.h | 26 +-- 5 files changed, 604 insertions(+), 588 deletions(-) create mode 100644 kernel/sched/load_avg.c
Is there any impact positive over vmlinuz size after these changes?
Thanks,
Rakib
Quoted 8 lines · Rakib Mullick
Quoted 6 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 average 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%).
[...]
Quoted 13 lines
Quoted 4 lines
Paul Gortmaker (2):
sched: fork load calculation code from sched/core --> sched/load_avg
sched: move update_load_[add/sub/set] fromsched.htofair.cQuoted 8 lines
kernel/sched/Makefile | 2 +- kernel/sched/core.c | 569 ----------------------------------------------- kernel/sched/fair.c | 18 ++ kernel/sched/load_avg.c | 577 ++++++++++++++++++++++++++++++++++++++++++++++++ kernel/sched/sched.h | 26 +-- 5 files changed, 604 insertions(+), 588 deletions(-) create mode 100644 kernel/sched/load_avg.c
Quoted 1 line
Is there any impact positive over vmlinuz size after these changes?
As per the above description and diffstat, it is just a straight up code relocation, so aside from trivial differences in what the optimizer does, I'd expect no real change at all in the size or anything else
Paul.
--
Quoted 8 lines
Thanks,
Rakib
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 10 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 average 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.
Nice!
Peter, is this (and the naming of the new file) fine with you too?
Thanks,
Ingo
Peter Zijlstra
maintainerQuoted 9 lines · Ingo Molnar
Quoted 7 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 average 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%).
Quoted 7 lines
Quoted 3 lines
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.Nice!
Peter, is this (and the naming of the new file) fine with you too?
Yes and no.. that is I do like the change, but I don't like the filename. We have _waaaay_ too many different things we call load_avg.
That said, I'm having a somewhat hard time coming up with a coherent alternative :/
Quoted 16 lines · Peter Zijlstra
Quoted 15 lines · Ingo Molnar
Quoted 10 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 average 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.Nice!
Quoted 7 lines
Quoted 1 line
Peter, is this (and the naming of the new file) fine with you too?
Yes and no.. that is I do like the change, but I don't like the filename. We have _waaaay_ too many different things we call
load_avg.That said, I'm having a somewhat hard time coming up with a coherent alternative :/
Several of the relocated functions start their name with "calc_load..." Does "calc_load.c" sound any better?
Quoted 19 lines · Paul Gortmaker
Quoted 18 lines · Peter Zijlstra
Quoted 16 lines · Ingo Molnar
Quoted 10 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 average 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.Nice!
Peter, is this (and the naming of the new file) fine with you too?
Quoted 9 lines
Quoted 5 lines
Yes and no.. that is I do like the change, but I don't like the filename. We have _waaaay_ too many different things we call
load_avg.That said, I'm having a somewhat hard time coming up with a coherent alternative :/
Several of the relocated functions start their name with "
calc_load..." Does "calc_load.c" sound any better?
How about sched_load.c ?
Quoted 24 lines · [Re: [RFC PATCH 0/2] sched: move content out of core files for load average]…
Quoted 22 lines · Paul Gortmaker
Quoted 21 lines · Peter Zijlstra
Quoted 9 lines · Ingo Molnar
Quoted 7 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 average 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%).Quoted 7 lines
Quoted 3 lines
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.Nice!
Peter, is this (and the naming of the new file) fine with you too?
Yes and no.. that is I do like the change, but I don't like the filename. We have _waaaay_ too many different things we call
load_avg.
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
That said, I'm having a somewhat hard time coming up with a coherent alternative :/
Several of the relocated functions start their name with "
calc_load..." Does "calc_load.c" sound any better?How about
sched_load.c?
No, that doesn't work since it duplicates the path info in the file name -- something that none of the other kernel/sched/*.c files do. Do a "ls -1 kernel/sched" to see what I mean if it is not clear.
I honestly didn't spend a lot of time thinking about the file name. I chose load_avg.c since it had a parallel to the /proc/loadavg that linux has had since the early 1990s. I have no real attachment to that name, but at the same time I'd like to avoid having name choice become a bikeshedding event...
Thanks,
Paul.
We could use a name along the lines of "load_index.c"; it calls to mind where we actually consume these values and (being specific) is less overloaded than load_avg.
Quoted 51 lines · Paul Gortmaker
Quoted 24 lines · [Re: [RFC PATCH 0/2] sched: move content out of core files for load average]…
Quoted 22 lines · Paul Gortmaker
Quoted 21 lines · Peter Zijlstra
Quoted 9 lines · Ingo Molnar
Quoted 7 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 average 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%).Quoted 7 lines
Quoted 3 lines
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.Nice!
Peter, is this (and the naming of the new file) fine with you too?
Yes and no.. that is I do like the change, but I don't like the filename. We have _waaaay_ too many different things we call
load_avg.Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
That said, I'm having a somewhat hard time coming up with a coherent alternative :/
Several of the relocated functions start their name with "
calc_load..." Does "calc_load.c" sound any better?How about
sched_load.c?No, that doesn't work since it duplicates the path info in the file name -- something that none of the other
kernel/sched/*.cfiles do. Do a "ls -1 kernel/sched" to see what I mean if it is not clear.I honestly didn't spend a lot of time thinking about the file name. I chose
load_avg.csince it had a parallel to the/proc/loadavgthat linux has had since the early 1990s. I have no real attachment to that name, but at the same time I'd like to avoid having name choice become a bikeshedding event...Thanks,
Paul.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 3 lines · Paul Turner
We could use a name along the lines of "
load_index.c"; it calls to mind where we actually consume these values and (being specific) is less overloaded thanload_avg.
Hmm... How about using "load_machine.c" "load_cpu.c" and "load_entity.c"?
Thanks,
Charles
Quoted 54 lines
Quoted 40 lines · Paul Gortmaker
Quoted 22 lines · [Re: [RFC PATCH 0/2] sched: move content out of core files for load average]…
Quoted 20 lines · Paul Gortmaker
Quoted 19 lines · Peter Zijlstra
Quoted 7 lines · Ingo Molnar
Quoted 5 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 average calculations has grown significantly enough recently to warrant placing it in a separate file.Quoted 8 lines
Quoted 5 lines
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.Nice!
Peter, is this (and the naming of the new file) fine with you too?
Yes and no.. that is I do like the change, but I don't like the filename. We have _waaaay_ too many different things we call
load_avg.Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
That said, I'm having a somewhat hard time coming up with a coherent alternative :/
Several of the relocated functions start their name with "
calc_load..." Does "calc_load.c" sound any better?How about
sched_load.c?No, that doesn't work since it duplicates the path info in the file name -- something that none of the other
kernel/sched/*.cfiles do. Do a "ls -1 kernel/sched" to see what I mean if it is not clear.I honestly didn't spend a lot of time thinking about the file name. I chose
load_avg.csince it had a parallel to the/proc/loadavgthat linux has had since the early 1990s. I have no real attachment to that name, but at the same time I'd like to avoid having name choice become a bikeshedding event...Quoted 7 lines
Thanks,
Paul.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 29 lines · Paul Gortmaker
Quoted 27 lines · [Re: [RFC PATCH 0/2] sched: move content out of core files for load average]…
Quoted 25 lines · Paul Gortmaker
Quoted 23 lines · Peter Zijlstra
Quoted 9 lines · Ingo Molnar
Quoted 7 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 average 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%).Quoted 7 lines
Quoted 3 lines
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.Nice!
Peter, is this (and the naming of the new file) fine with you too?
Yes and no.. that is I do like the change, but I don't like the filename. We have _waaaay_ too many different things we call
load_avg.That said, I'm having a somewhat hard time coming up with a coherent alternative :/
Quoted 9 lines
Quoted 4 lines
Quoted 3 lines
Several of the relocated functions start their name with "
calc_load..." Does "calc_load.c" sound any better?How about
sched_load.c?No, that doesn't work since it duplicates the path info in the file name -- something that none of the other
kernel/sched/*.cfiles do. Do a "ls -1 kernel/sched" to see what I mean if it is not clear.
I understand your point, so just take sched out of it. I was just trying to give a hint, if it could help.
Quoted 6 lines
I honestly didn't spend a lot of time thinking about the file name. I chose
load_avg.csince it had a parallel to the/proc/loadavgthat linux has had since the early 1990s. I have no real attachment to that name, but at the same time I'd like to avoid having name choice become a bikeshedding event...
I also didn't spend a lot of time thinking about file name. What I said, it's from intuition and what I've seen so far. Name, it should be simple, clear and should suggest what it's dealing with. But I also think that, name doesn't make things different, how it works - that's what is important.
Thanks,
Rakib
Quoted 19 lines · Paul Gortmaker
Quoted 18 lines · Peter Zijlstra
Quoted 16 lines · Ingo Molnar
Quoted 10 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 average 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.Nice!
Peter, is this (and the naming of the new file) fine with you too?
Quoted 8 lines
Quoted 5 lines
Yes and no.. that is I do like the change, but I don't like the filename. We have _waaaay_ too many different things we call
load_avg.That said, I'm having a somewhat hard time coming up with a coherent alternative :/
Several of the relocated functions start their name with "
calc_load..." Does "calc_load.c" sound any better?
Peter has a point about load_avg being somewhat of a misnomer: that's not your fault in any way, we created overlapping naming within the scheduler and are now hurting from it.
Here are the main scheduler 'load' concepts we have right now:
- The externally visible 'average load' value extracted by tools like 'top' via /proc/loadavg and handled by fs/proc/loadavg.c. Internally the naming is all over the map: the fields that are updated are named 'avenrun[]', most other variables and methods are named calc_load_*(), and a few callbacks are named *_cpu_load_*().
- rq->cpu_load, a weighted, vectored scheduler-internal notion of task load average with multiple run length averages. Only exposed by debug interfaces but otherwise relied on by the scheduler for SMP load balancing.
- se->avg - per entity (per task) load average. This is integrated differently from the cpu_load - but work is ongoing to possibly integrate it with the rq->cpu_load metric. This metric is used for CPU internal execution time allocation and timeslicing, based on nice value priorities and cgroup weights and constraints.
Work is ongoing to integrate rq->cpu_load and se->avg - eventually they will become one metric.
It might eventually make sense to integrate the 'average load' calculation as well with all this - as they really have a similar purpose, the avenload[] vector of averages is conceptually similar to the rq->cpu_load[] vector of averages.
So I'd suggest to side-step all that existing confusion and simply name the new file kernel/sched/proc.c - our external /proc scheduler ABI towards userspace. This is similar to the already existing kernel/irq/proc.c pattern.
A technical request: mind doing your patch against the tip:master tree? It's at:
git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git master
We have changes pending both in the sched/core, timers/nohz, core/locking and smp/hotplug trees, and your split-up interacts with all that pending work, creating conflicts.
Thanks,
Ingo
Peter Zijlstra
maintainerQuoted 6 lines · Ingo Molnar
It might eventually make sense to integrate the 'average load' calculation as well
with all this - as they really have a similar purpose, the avenload[] vector of
averages is conceptually similar to the rq->cpu_load[] vector of averages.
The /proc/loadavg definition isn't useful for anything remotely sane wrt load-balancing or otherwise, so I don't really see that integration happening (its a measure of how many tasks are blocked, where the load-balancer needs a measure of how many tasks are wanting to run).
But yeah, sched/proc.c or sched/proc_loadavg.c works for me.
Quoted 8 lines · Peter Zijlstra
Quoted 6 lines · Ingo Molnar
It might eventually make sense to integrate the 'average load' calculation as well
with all this - as they really have a similar purpose, the avenload[] vector of
averages is conceptually similar to the rq->cpu_load[] vector of averages.
Quoted 4 lines
The
/proc/loadavgdefinition isn't useful for anything remotely sane wrt load-balancing or otherwise, so I don't really see that integration happening (its a measure of how many tasks are blocked, where the load-balancer needs a measure of how many tasks are wanting to run).
Well, loadavg also includes running tasks:
nr_active = this_rq->nr_running;
nr_active += (long) this_rq->nr_uninterruptible;but yeah, the two are not the same. It could at least integrate in terms of averaging code, working on two different instances of data structures - but yeah, full integration is indeed not possible.
Thanks,
Ingo
Quoted 56 lines · Ingo Molnar
Quoted 19 lines · Paul Gortmaker
Quoted 18 lines · Peter Zijlstra
Quoted 16 lines · Ingo Molnar
Quoted 10 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 average 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.Nice!
Peter, is this (and the naming of the new file) fine with you too?
Quoted 8 lines
Quoted 5 lines
Yes and no.. that is I do like the change, but I don't like the filename. We have _waaaay_ too many different things we call
load_avg.That said, I'm having a somewhat hard time coming up with a coherent alternative :/
Several of the relocated functions start their name with "
calc_load..." Does "calc_load.c" sound any better?Peter has a point about
load_avgbeing somewhat of a misnomer: that's not your fault in any way, we created overlapping naming within the scheduler and are now hurting from it.Here are the main scheduler 'load' concepts we have right now:
- The externally visible 'average load' value extracted by tools like 'top' via
/proc/loadavgand handled byfs/proc/loadavg.c. Internally the naming is all over the map: the fields that are updated are named 'avenrun[]', most other variables and methods are named calc_load_*(), and a few callbacks are named *_cpu_load_*().-
rq->cpu_load, a weighted, vectored scheduler-internal notion of task load average with multiple run length averages. Only exposed by debug interfaces but otherwise relied on by the scheduler for SMP load balancing.-
se->avg- per entity (per task) load average. This is integrated differently from thecpu_load- but work is ongoing to possibly integrate it with therq->cpu_loadmetric. This metric is used for CPU internal execution time allocation and timeslicing, based on nice value priorities and cgroup weights and constraints.Work is ongoing to integrate
rq->cpu_loadandse->avg- eventually they will become one metric.
Quoted 8 lines
It might eventually make sense to integrate the 'average load' calculation as well with all this - as they really have a similar purpose, the avenload[] vector of averages is conceptually similar to the rq->cpu_load[] vector of averages.
So I'd suggest to side-step all that existing confusion and simply name the new file
kernel/sched/proc.c- our external /proc scheduler ABI towards userspace. This is similar to the already existingkernel/irq/proc.cpattern.
Well, kernel/sched/stat.c - also exposes scheduler ABI to userspace. Aren't these things going to introduce confusion (stat.c and proc.c under same sched directory) ?
Thanks,
Rakib
Quoted 61 lines · Rakib Mullick
Quoted 60 lines · Ingo Molnar
Quoted 19 lines · Paul Gortmaker
Quoted 18 lines · Peter Zijlstra
Quoted 16 lines · Ingo Molnar
Quoted 10 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 average 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.Nice!
Peter, is this (and the naming of the new file) fine with you too?
Quoted 8 lines
Quoted 5 lines
Yes and no.. that is I do like the change, but I don't like the filename. We have _waaaay_ too many different things we call
load_avg.That said, I'm having a somewhat hard time coming up with a coherent alternative :/
Several of the relocated functions start their name with "
calc_load..." Does "calc_load.c" sound any better?Peter has a point about
load_avgbeing somewhat of a misnomer: that's not your fault in any way, we created overlapping naming within the scheduler and are now hurting from it.Here are the main scheduler 'load' concepts we have right now:
- The externally visible 'average load' value extracted by tools like 'top' via
/proc/loadavgand handled byfs/proc/loadavg.c. Internally the naming is all over the map: the fields that are updated are named 'avenrun[]', most other variables and methods are named calc_load_*(), and a few callbacks are named *_cpu_load_*().-
rq->cpu_load, a weighted, vectored scheduler-internal notion of task load average with multiple run length averages. Only exposed by debug interfaces but otherwise relied on by the scheduler for SMP load balancing.-
se->avg- per entity (per task) load average. This is integrated differently from thecpu_load- but work is ongoing to possibly integrate it with therq->cpu_loadmetric. This metric is used for CPU internal execution time allocation and timeslicing, based on nice value priorities and cgroup weights and constraints.Work is ongoing to integrate
rq->cpu_loadandse->avg- eventually they will become one metric.It might eventually make sense to integrate the 'average load' calculation as well with all this - as they really have a similar purpose, the avenload[] vector of averages is conceptually similar to the rq->cpu_load[] vector of averages.
Quoted 5 lines
Quoted 4 lines
So I'd suggest to side-step all that existing confusion and simply name the new file
kernel/sched/proc.c- our external /proc scheduler ABI towards userspace. This is similar to the already existingkernel/irq/proc.cpattern.Well,
kernel/sched/stat.c- also exposes scheduler ABI to userspace.
schedstats is more like a debug API, used by a low number of tools.
So I don't think it's particularly confusing.
Thanks,
Ingo