Allow schedulers to be selectable through Kconfig
v5 cover Allow schedulers to be selectable through Kconfig
Add machinery to allow the schedulers to be individually selectable through the Kconfig interface. The first patch in the series sets up the CONFIG_EXPERT Kconfig variable that is only enabled by passing an environment variable to the build. The second patch in the series sets up the Kconfig options for the schedulers and places the appropriate CONFIG_ options around the scheduler list. The third, fourth, and fifth patches rework the scheduler list from being manually curated into a model where just compiling any schedulers into the hypervisor causes the scheduler list to be built up.
---
Changed since v4:
* Removed the ability to configure the credit scheduler. It is always compiled in, so there is no need for the defensive check for schedulers in the linker (added in v4) and no reason to provide the static inlines (added in v3) since credit is always present.
* Remove extra size field that was accidentally left in.
Changed since v3:
* Add defensive check for schedulers in the linker
Changed since v2:
* Added a predecessor patch that introduces a environment variable for the build to enable expert configuration options (1/5)
* Hide the scheduler menu behind the expert option (2/5)
* Provide static inlines for credit functions that are assumed to be present if it is compiled out (2/5)
* Provide an absolute default of the credit scheduler if the scheduler menu is not visible (2/5)
Changed since v1:
* Marked credit2 as EXPERIMENTAL
* Removed confusing language from the commit message
* Alphabetize the schedulers
* rename the __start and __end symbols to better match the rest of the file
* Simplify the calculation of the number of schedulers
* Make the scheduler ops structures static to their files
Jonathan Creekmore (5):
build: Env var to enable expert config options
build: Hook the schedulers into Kconfig
build: Alloc space for sched list in the link file
sched: Register the schedulers into the list
sched: Use the auto-generated list of schedulers
xen/Kconfig | 4 +++ xen/Makefile | 1 + xen/arch/arm/xen.lds.S | 4 +++ xen/arch/x86/xen.lds.S | 4 +++ xen/common/Kconfig | 59 +++++++++++++++++++++++++++++++++++++++++++++ xen/common/Makefile | 8 +++--- xen/common/sched_arinc653.c | 4 ++- xen/common/sched_credit.c | 4 ++- xen/common/sched_credit2.c | 4 ++- xen/common/sched_rt.c | 4 ++- xen/common/schedule.c | 19 ++++++--------- xen/include/xen/sched-if.h | 7 ++---- 12 files changed, 98 insertions(+), 24 deletions(-)
Signature · 1 line
2.6.4
PATCH v5 1/5 build: Env var to enable expert config options
Add an additional environment variable, defaulting to disabled, that enables the CONFIG_EXPERT configuration option. The purpose of the CONFIG_EXPERT configuration option is to make non-standard Kconfig options visible during the configuration process. The CONFIG_EXPERT option is not, itself, visible during the Kconfig configuration process, so typical users will never see it nor any of the non-standard configuration options.
--- xen/Kconfig | 4 ++++ xen/Makefile | 1 + 2 files changed, 5 insertions(+)
xen/Kconfig +4 -0
@@ -22,3 +22,7 @@ config DEFCONFIG_LIST string option defconfig_list default "$ARCH_DEFCONFIG" + +config EXPERT + string + option env="XEN_CONFIG_EXPERT"
xen/Makefile +1 -0
@@ -11,6 +11,7 @@ export XEN_DOMAIN ?= $(shell ([ -x /bin/dnsdomainname ] && /bin/dnsdomainname) | export XEN_BUILD_DATE ?= $(shell LC_ALL=C date) export XEN_BUILD_TIME ?= $(shell LC_ALL=C date +%T) export XEN_BUILD_HOST ?= $(shell hostname) +export XEN_CONFIG_EXPERT ?= n export BASEDIR := $(CURDIR) export XEN_ROOT := $(BASEDIR)/..
Signature · 1 line
2.6.4
Re: [PATCH v5 1/5] build: Env var to enable expert config options
xen/Kconfig config DEFCONFIG_LIST · line 28
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 14.01.16 at 15:49, <[email protected]> wrote:
xen/Kconfig +4
-0@@ -22,3 +22,7 @@ config DEFCONFIG_LIST string option defconfig_list default "$ARCH_DEFCONFIG" + +config EXPERT + string + option env="XEN_CONFIG_EXPERT"
This better wouldn't go in ahead of
http://lists.xenproject.org/archives/html/xen-devel/2016-01/msg01321.html
and would then need adjustment to take care of avoiding re-introduction of that same problem.
Jan
Re: [PATCH v5 1/5] build: Env var to enable expert config options
Quoted 16 lines · Jan Beulich
xen/Kconfig config DEFCONFIG_LIST · line 28
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 14.01.16 at 15:49, <[email protected]> wrote:
xen/Kconfig +0
-0@@ -22,3 +22,7 @@ config DEFCONFIG_LISTstring
optiondefconfig_list
default "$ARCH_DEFCONFIG"xen/Kconfig +4
-0+ +config EXPERT + string + option env="XEN_CONFIG_EXPERT"This better wouldn't go in ahead of
http://lists.xenproject.org/archives/html/xen-devel/2016-01/msg01321.html
and would then need adjustment to take care of avoiding re-introduction of that same problem.
I don't follow what problem would be reintroduced, this patch seems to be correctly defining and exporting XEN_CONFIG_EXPERT from xen/Makefile before any inclusion of kconfig related things
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v5 1/5] build: Env var to enable expert config options
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 15.01.16 at 16:47, <[email protected]> wrote:
Quoted 16 lines · Jan Beulich
xen/Kconfig config DEFCONFIG_LIST · line 28
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 14.01.16 at 15:49, <[email protected]> wrote:
xen/Kconfig +4
-0@@ -22,3 +22,7 @@ config DEFCONFIG_LIST string option defconfig_list default "$ARCH_DEFCONFIG" + +config EXPERT + string + option env="XEN_CONFIG_EXPERT"This better wouldn't go in ahead of
http://lists.xenproject.org/archives/html/xen-devel/2016-01/msg01321.html
and would then need adjustment to take care of avoiding re-introduction of that same problem.
Quoted 3 lines
I don't follow what problem would be reintroduced, this patch seems to be correctly defining and exporting
XEN_CONFIG_EXPERTfrom xen/Makefile before any inclusion of kconfig related things
Ah, wait, this variable comes from the environment in the first place, and hence should be visible to Makefile.kconfig no matter what. I'm sorry for the noise then.
Jan
PATCH v5 2/5 build: Hook the schedulers into Kconfig
In reply to Jonathan CreekmoreAllow the schedulers to be independently enabled or disabled (except credit) at compile-time. To match existing behavior, all four schedulers are compiled in by default, although the Credit2, RTDS, and ARINC653 are marked EXPERIMENTAL to match their not currently supported status.
---
Changed since v4:
* Removed the "if unsure" language
* Removed ability to disable the "credit" scheduler
* Remove stub vcpu_migration_delay functions since credit cannot be disabled
Changed since v2:
* Hid the scheduler menu behind the EXPERT option
* Provide static inlines for credit functions that are assumed to be always available
* Provide an absolute default of the credit scheduler if the scheduler menu is not visible
Changed since v1:
* Marked credit2 as EXPERIMENTAL
* Removed confusing language from the commit message
* Alphabetize the schedulers
--- xen/common/Kconfig | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ xen/common/Makefile | 8 +++---- xen/common/schedule.c | 12 +++++++++-- 3 files changed, 73 insertions(+), 6 deletions(-)
xen/common/Kconfig +59 -0
@@ -51,4 +51,63 @@ config KEXEC If unsure, say Y. +# Enable schedulers +menu "Schedulers" + visible if EXPERT = "y" + +config SCHED_CREDIT + bool + default y + ---help--- + The traditional credit scheduler is a general purpose scheduler. + +config SCHED_CREDIT2 + bool "Credit2 scheduler support (EXPERIMENTAL)" + default y + ---help--- + The credit2 scheduler is a general purpose scheduler that is + optimized for lower latency and higher VM density. + +config SCHED_RTDS + bool "RTDS scheduler support (EXPERIMENTAL)" + default y + ---help--- + The RTDS scheduler is a soft and firm real-time scheduler for + multicore, targeted for embedded, automotive, graphics and gaming + in the cloud, and general low-latency workloads. + +config SCHED_ARINC653 + bool "ARINC653 scheduler support (EXPERIMENTAL)" + default y + ---help--- + The ARINC653 scheduler is a hard real-time scheduler for single + cores, targeted for avionics, drones, and medical devices. + +choice + prompt "Default Scheduler?" + default SCHED_CREDIT_DEFAULT if SCHED_CREDIT + default SCHED_CREDIT2_DEFAULT if SCHED_CREDIT2 + default SCHED_RTDS_DEFAULT if SCHED_RTDS + default SCHED_ARINC653_DEFAULT if SCHED_ARINC653 + + config SCHED_CREDIT_DEFAULT + bool "Credit Scheduler" if SCHED_CREDIT + config SCHED_CREDIT2_DEFAULT + bool "Credit2 Scheduler" if SCHED_CREDIT2 + config SCHED_RTDS_DEFAULT + bool "RT Scheduler" if SCHED_RTDS + config SCHED_ARINC653_DEFAULT + bool "ARINC653 Scheduler" if SCHED_ARINC653 +endchoice + +config SCHED_DEFAULT + string + default "credit" if SCHED_CREDIT_DEFAULT + default "credit2" if SCHED_CREDIT2_DEFAULT + default "rtds" if SCHED_RTDS_DEFAULT + default "arinc653" if SCHED_ARINC653_DEFAULT + default "credit" + +endmenu + endmenu
xen/common/Makefile +4 -4
@@ -30,10 +30,10 @@ obj-y += rangeset.o obj-y += radix-tree.o obj-y += rbtree.o obj-y += rcupdate.o -obj-y += sched_credit.o -obj-y += sched_credit2.o -obj-y += sched_arinc653.o -obj-y += sched_rt.o +obj-$(CONFIG_SCHED_ARINC653) += sched_arinc653.o +obj-$(CONFIG_SCHED_CREDIT) += sched_credit.o +obj-$(CONFIG_SCHED_CREDIT2) += sched_credit2.o +obj-$(CONFIG_SCHED_RTDS) += sched_rt.o obj-y += schedule.o obj-y += shutdown.o obj-y += softirq.o
xen/common/schedule.c +10 -2
@@ -38,8 +38,8 @@#include <public/sched.h> #include <xsm/xsm.h> -/* opt_sched: scheduler - default to credit */ -static char __initdata opt_sched[10 ] ="credit" ; +/* opt_sched: scheduler - default to configured value */ +static char __initdata opt_sched[10 ] =CONFIG_SCHED_DEFAULT ;string_param ("sched" , opt_sched);/* if sched_smt_power_savings is set,
@@ -65,10 +65,18 @@ DEFINE_PER_CPU(struct schedule_data, schedule_data); DEFINE_PER_CPU(struct scheduler *, scheduler);static const struct scheduler *schedulers[] = { +#ifdef CONFIG_SCHED_CREDIT &sched_credit_def, +#endif +#ifdef CONFIG_SCHED_CREDIT2 &sched_credit2_def, +#endif +#ifdef CONFIG_SCHED_ARINC653 &sched_arinc653_def, +#endif +#ifdef CONFIG_SCHED_RTDS &sched_rtds_def, +#endif };static struct scheduler __read_mostly ops;
Signature · 1 line
2.6.4
Re: [PATCH v5 2/5] build: Hook the schedulers into Kconfig
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 14.01.16 at 15:49, <[email protected]> wrote:
xen/common/Kconfig +0
-0@@ -51,4 +51,63 @@ config KEXEC If unsure, say Y.
xen/common/Kconfig config KEXEC · line 62
Quoted 10 lines
xen/common/Kconfig +9
-0+# Enable schedulers +menu "Schedulers" + visible if EXPERT = "y" + +config SCHED_CREDIT + bool + default y + ---help--- + The traditional credit scheduler is a general purpose scheduler.
So is this option now useful for anything?
xen/common/Kconfig config KEXEC · line 91
Quoted 6 lines
xen/common/Kconfig +6
-0+choice + prompt "Default Scheduler?" + default SCHED_CREDIT_DEFAULT if SCHED_CREDIT + default SCHED_CREDIT2_DEFAULT if SCHED_CREDIT2 + default SCHED_RTDS_DEFAULT if SCHED_RTDS + default SCHED_ARINC653_DEFAULT if SCHED_ARINC653
And certainly all these defaults are now pointless, considering that the condition of the first one is "if y".
Jan
Re: [PATCH v5 2/5] build: Hook the schedulers into Kconfig
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 14.01.16 at 15:49, <[email protected]> wrote:
xen/common/Kconfig +0
-0@@ -51,4 +51,63 @@ config KEXEC If unsure, say Y.
Quoted 11 lines
xen/common/Kconfig config KEXEC · line 62
Quoted 9 lines
xen/common/Kconfig +9
-0+# Enable schedulers +menu "Schedulers" + visible if EXPERT = "y" + +config SCHED_CREDIT + bool + default y + ---help--- + The traditional credit scheduler is a general purpose scheduler.So is this option now useful for anything?
It keeps the code between all of the schedulers consistent (all of them have a #define if they are compiled it) and helps keep my downstream patch smaller.
Quoted 10 lines
xen/common/Kconfig config KEXEC · line 91
Quoted 7 lines
xen/common/Kconfig +6
-0+choice + prompt "Default Scheduler?" + default SCHED_CREDIT_DEFAULT if SCHED_CREDIT + default SCHED_CREDIT2_DEFAULT if SCHED_CREDIT2 + default SCHED_RTDS_DEFAULT if SCHED_RTDS + default SCHED_ARINC653_DEFAULT if SCHED_ARINC653And certainly all these defaults are now pointless, considering that the condition of the first one is "if y".
Yes, I could rip all of those out now since credit is always the default. I left it in there for the ideal case that credit didn't have to be special cased but, at this point, I will rip it out if you want.
Re: [PATCH v5 2/5] build: Hook the schedulers into Kconfig
Quoted 22 lines · Jonathan Creekmore
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 14.01.16 at 15:49, <[email protected]> wrote:
xen/common/Kconfig +0
-0@@ -51,4 +51,63 @@ config KEXECIf unsure, say Y.
Quoted 12 lines
Quoted 10 lines
xen/common/Kconfig +9
-0+# Enable schedulers +menu "Schedulers" + visible if EXPERT = "y" + +config SCHED_CREDIT + bool + default y + ---help--- + The traditional credit scheduler is a general purposescheduler.
So is this option now useful for anything?
Quoted 2 lines
It keeps the code between all of the schedulers consistent (all of them have a #define if they are compiled it)
FWIW I think this (consistency) is a reasonable argument for having this option even if it doesn't actually do anything.
Quoted 14 lines
and helps keep my downstream
patch smaller.Quoted 10 lines
xen/common/Kconfig config KEXEC · line 91
Quoted 7 lines
xen/common/Kconfig +6
-0+choice + prompt "Default Scheduler?" + default SCHED_CREDIT_DEFAULT if SCHED_CREDIT + default SCHED_CREDIT2_DEFAULT if SCHED_CREDIT2 + default SCHED_RTDS_DEFAULT if SCHED_RTDS + default SCHED_ARINC653_DEFAULT if SCHED_ARINC653And certainly all these defaults are now pointless, considering that the condition of the first one is "if y".
Quoted 3 lines
Yes, I could rip all of those out now since credit is always the default. I left it in there for the ideal case that credit didn't have to be special cased but, at this point, I will rip it out if you want.
What is the behaviour of the above set of "default"s if more than one of the SCHED_* is enabled? Does it pick the first, last, one at random?
If credit is now always the default I think that would be better expressed with a single "default SCHED_CREDIT_DEFAULT".
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v5 2/5] build: Hook the schedulers into Kconfig
Quoted 24 lines
Quoted 1 line
Quoted 1 line · On 14.01.16 at 17:34, <[email protected]> wrote:
Quoted 22 lines · Jonathan Creekmore
Quoted 19 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 14.01.16 at 15:49, <[email protected]> wrote:
xen/common/Kconfig +9
-0@@ -51,4 +51,63 @@ config KEXEC If unsure, say Y. +# Enable schedulers +menu "Schedulers" + visible if EXPERT = "y" + +config SCHED_CREDIT + bool + default y + ---help--- + The traditional credit scheduler is a general purposeQuoted 1 line
scheduler.
So is this option now useful for anything?
Quoted 5 lines
Quoted 2 lines
It keeps the code between all of the schedulers consistent (all of them have a #define if they are compiled it)
FWIW I think this (consistency) is a reasonable argument for having this option even if it doesn't actually do anything.
While I can see your point, I dislike useless clutter in .config (also on Linux, where I every once in a while send some cleanup patches).
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
xen/common/Kconfig config KEXEC · line 91
Quoted 6 lines
xen/common/Kconfig +6
-0+choice + prompt "Default Scheduler?" + default SCHED_CREDIT_DEFAULT if SCHED_CREDIT + default SCHED_CREDIT2_DEFAULT if SCHED_CREDIT2 + default SCHED_RTDS_DEFAULT if SCHED_RTDS + default SCHED_ARINC653_DEFAULT if SCHED_ARINC653And certainly all these defaults are now pointless, considering that the condition of the first one is "if y".
Quoted 6 lines
Quoted 3 lines
Yes, I could rip all of those out now since credit is always the default. I left it in there for the ideal case that credit didn't have to be special cased but, at this point, I will rip it out if you want.
What is the behaviour of the above set of "default"s if more than one of the SCHED_* is enabled? Does it pick the first, last, one at random?
The first for which the condition is true.
Quoted 2 lines
If credit is now always the default I think that would be better expressed with a single "default
SCHED_CREDIT_DEFAULT".
Indeed.
Jan
Re: [PATCH v5 2/5] build: Hook the schedulers into Kconfig
Quoted 28 lines · Jan Beulich
Quoted 28 lines
Quoted 1 line
Quoted 1 line · On 14.01.16 at 17:34, <[email protected]> wrote:
Quoted 25 lines · Jonathan Creekmore
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 14.01.16 at 15:49, <[email protected]> wrote:
xen/common/Kconfig +0
-0@@ -51,4 +51,63 @@ config KEXECIf unsure, say Y.
Quoted 12 lines
Quoted 10 lines
xen/common/Kconfig +9
-0+# Enable schedulers +menu "Schedulers" + visible if EXPERT = "y" + +config SCHED_CREDIT + bool + default y + ---help--- + The traditional credit scheduler is a general purposescheduler.
So is this option now useful for anything?
It keeps the code between all of the schedulers consistent (all of them
have a #define if they are compiled it)
Quoted 7 lines
Quoted 3 lines
FWIW I think this (consistency) is a reasonable argument for having this
option even if it doesn't actually do anything.While I can see your point, I dislike useless clutter in .config (also on Linux, where I every once in a while send some cleanup patches).
I don't think this one is useless clutter, it provides useful information to someone looking at the .config rather than then having to go and check the source to find out what the defaults were.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v5 2/5] build: Hook the schedulers into Kconfig
In reply to Jan BeulichQuoted 44 lines · Jan Beulich
Quoted 24 lines
Quoted 1 line
Quoted 1 line · On 14.01.16 at 17:34, <[email protected]> wrote:
Quoted 22 lines · Jonathan Creekmore
Quoted 19 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 14.01.16 at 15:49, <[email protected]> wrote:
xen/common/Kconfig +9
-0@@ -51,4 +51,63 @@ config KEXEC If unsure, say Y. +# Enable schedulers +menu "Schedulers" + visible if EXPERT = "y" + +config SCHED_CREDIT + bool + default y + ---help--- + The traditional credit scheduler is a general purposeQuoted 1 line
scheduler.
So is this option now useful for anything?
Quoted 5 lines
Quoted 2 lines
It keeps the code between all of the schedulers consistent (all of them have a #define if they are compiled it)
FWIW I think this (consistency) is a reasonable argument for having this option even if it doesn't actually do anything.
While I can see your point, I dislike useless clutter in .config (also on Linux, where I every once in a while send some cleanup patches).
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
xen/common/Kconfig config KEXEC · line 91
Quoted 6 lines
xen/common/Kconfig +6
-0+choice + prompt "Default Scheduler?" + default SCHED_CREDIT_DEFAULT if SCHED_CREDIT + default SCHED_CREDIT2_DEFAULT if SCHED_CREDIT2 + default SCHED_RTDS_DEFAULT if SCHED_RTDS + default SCHED_ARINC653_DEFAULT if SCHED_ARINC653And certainly all these defaults are now pointless, considering that the condition of the first one is "if y".
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Yes, I could rip all of those out now since credit is always the default. I left it in there for the ideal case that credit didn't have to be special cased but, at this point, I will rip it out if you want.
What is the behaviour of the above set of "default"s if more than one of the SCHED_* is enabled? Does it pick the first, last, one at random?
The first for which the condition is true.
Absolutely correct. The first true condition is the one that is chosen.
Quoted 4 lines
Quoted 2 lines
If credit is now always the default I think that would be better expressed with a single "default
SCHED_CREDIT_DEFAULT".Indeed.
And that is what I have already done for a v6 that I am sitting on to see if I get more review comments.
PATCH v5 3/5 build: Alloc space for sched list in the link file
In reply to Jonathan CreekmoreCreates a section to contain scheduler entry pointers that are gathered together into an array. This will allow, in a follow-on patch, scheduler entries to be automatically gathered together into the array for automatic parsing.
---
Changed since v4:
* Remove defensive check for schedulers since the credit scheduler must always be present
Changed since v3:
* Add defensive check for schedulers in the linker
Changed since v1:
* rename the __start and __end symbols to better match the rest of the file
--- xen/arch/arm/xen.lds.S | 4 ++++ xen/arch/x86/xen.lds.S | 4 ++++ 2 files changed, 8 insertions(+)
xen/arch/arm/xen.lds.S +4 -0
@@ -57,6 +57,10 @@ SECTIONS . = ALIGN(PAGE_SIZE); *(.data.page_aligned) *(.data) + . = ALIGN(8); + __start_schedulers_array = .; + *(.data.schedulers) + __end_schedulers_array = .; *(.data.rel) *(.data.rel.*) CONSTRUCTORS
xen/arch/x86/xen.lds.S +4 -0
@@ -80,6 +80,10 @@ SECTIONS __stop___pre_ex_table = .; *(.data.read_mostly) + . = ALIGN(8); + __start_schedulers_array = .; + *(.data.schedulers) + __end_schedulers_array = .; *(.data.rel.ro) *(.data.rel.ro.*) } :text
Signature · 1 line
2.6.4
PATCH v5 4/5 sched: Register the schedulers into the list
In reply to Jonathan CreekmoreAdds a simple macro to place a pointer to a scheduler into an array section at compile time. Also, goes ahead and generates the array entries with each of the schedulers.
--- xen/common/sched_arinc653.c | 2 ++ xen/common/sched_credit.c | 2 ++ xen/common/sched_credit2.c | 2 ++ xen/common/sched_rt.c | 2 ++ xen/include/xen/sched-if.h | 2 ++ 5 files changed, 10 insertions(+)
xen/common/sched_arinc653.c +2 -0
@@ -767,6 +767,8 @@ const struct scheduler sched_arinc653_def = { .tick_resume = NULL, }; +REGISTER_SCHEDULER (sched_arinc653_def); +/* * Local variables: * mode: C
xen/common/sched_credit.c +2 -0
@@ -2027,3 +2027,5 @@ const struct scheduler sched_credit_def = { .tick_suspend = csched_tick_suspend, .tick_resume = csched_tick_resume, }; + +REGISTER_SCHEDULER (sched_credit_def);
xen/common/sched_credit2.c +2 -0
@@ -2228,3 +2228,5 @@ const struct scheduler sched_credit2_def = { .alloc_domdata = csched2_alloc_domdata, .free_domdata = csched2_free_domdata, }; + +REGISTER_SCHEDULER (sched_credit2_def);
xen/common/sched_rt.c +2 -0
@@ -1199,3 +1199,5 @@ const struct scheduler sched_rtds_def = { .wake = rt_vcpu_wake, .context_saved = rt_context_saved, }; + +REGISTER_SCHEDULER (sched_rtds_def);
xen/include/xen/sched-if.h +2 -0
@@ -170,6 +170,8 @@ extern const struct scheduler sched_credit2_def;extern const struct scheduler sched_arinc653_def;extern const struct scheduler sched_rtds_def; +#define REGISTER_SCHEDULER (x) static const struct scheduler *x##_entry \ + __used_section(".data.schedulers") = &x;struct cpupool {
Signature · 1 line
2.6.4
PATCH v5 5/5 sched: Use the auto-generated list of schedulers
In reply to Jonathan CreekmoreInstead of having a manually-curated list of schedulers, use the array that was auto-generated simply by compiling in the scheduler files as the sole source of truth of the available schedulers.
---
Changed since v4:
* Remove extra size field that was accidentally left in
Changed since v1:
* Simplify the calculation of the number of schedulers
* Make the scheduler ops structures static to their files
--- xen/common/sched_arinc653.c | 2 +- xen/common/sched_credit.c | 2 +- xen/common/sched_credit2.c | 2 +- xen/common/sched_rt.c | 2 +- xen/common/schedule.c | 23 ++++++----------------- xen/include/xen/sched-if.h | 5 ----- 6 files changed, 10 insertions(+), 26 deletions(-)
xen/common/sched_arinc653.c +1 -1
@@ -724,7 +724,7 @@ a653sched_adjust_global(const struct scheduler *ops,* callback functions. * The symbol must be visible to the rest of Xen at link time. */ -const struct scheduler sched_arinc653_def = { +static const struct scheduler sched_arinc653_def = { .name ="ARINC 653 Scheduler" , .opt_name ="arinc653" , .sched_id =XEN_SCHEDULER_ARINC653 ,
xen/common/sched_credit.c +1 -1
@@ -1991,7 +1991,7 @@ static void csched_tick_resume(const struct scheduler *ops, unsigned int cpu)static struct csched_private _csched_priv; -const struct scheduler sched_credit_def = { +static const struct scheduler sched_credit_def = { .name ="SMP Credit Scheduler" , .opt_name ="credit" , .sched_id =XEN_SCHEDULER_CREDIT ,
xen/common/sched_credit2.c +1 -1
@@ -2194,7 +2194,7 @@ csched2_deinit(const struct scheduler *ops)static struct csched2_private _csched2_priv; -const struct scheduler sched_credit2_def = { +static const struct scheduler sched_credit2_def = { .name ="SMP Credit Scheduler rev2" , .opt_name ="credit2" , .sched_id =XEN_SCHEDULER_CREDIT2 ,
xen/common/sched_rt.c +1 -1
@@ -1170,7 +1170,7 @@ rt_dom_cntl(static struct rt_private _rt_priv; -const struct scheduler sched_rtds_def = { +static const struct scheduler sched_rtds_def = { .name ="SMP RTDS Scheduler" , .opt_name ="rtds" , .sched_id =XEN_SCHEDULER_RTDS ,
xen/common/schedule.c +6 -17
@@ -64,20 +64,9 @@ static void poll_timer_fn(void *data); DEFINE_PER_CPU(struct schedule_data, schedule_data); DEFINE_PER_CPU(struct scheduler *, scheduler); -static const struct scheduler *schedulers[] = { -#ifdef CONFIG_SCHED_CREDIT - &sched_credit_def, -#endif -#ifdef CONFIG_SCHED_CREDIT2 - &sched_credit2_def, -#endif -#ifdef CONFIG_SCHED_ARINC653 - &sched_arinc653_def, -#endif -#ifdef CONFIG_SCHED_RTDS - &sched_rtds_def, -#endif -}; +extern const struct scheduler *__start_schedulers_array[], *__end_schedulers_array[]; +#define NUM_SCHEDULERS (__end_schedulers_array - __start_schedulers_array) +static const struct scheduler **schedulers = __start_schedulers_array;static struct scheduler __read_mostly ops;
@@ -1468,7 +1457,7 @@ void __init scheduler_init(void)open_softirq (SCHEDULE_SOFTIRQ , schedule); -for ( i =0 ; i <ARRAY_SIZE (schedulers); i++ ) +for ( i =0 ; i <NUM_SCHEDULERS ; i++) {if ( schedulers[i]->global_init && schedulers[i]->global_init () <0 ) schedulers[i] =NULL ;
@@ -1479,7 +1468,7 @@ void __init scheduler_init(void)if ( !ops.name ) {printk ("Could not find scheduler: %s\n" , opt_sched); -for ( i =0 ; i <ARRAY_SIZE (schedulers); i++ ) +for ( i =0 ; i <NUM_SCHEDULERS ; i++ )if ( schedulers[i] ) { ops = *schedulers[i];
@@ -1599,7 +1588,7 @@ struct scheduler *scheduler_alloc(unsigned int sched_id, int *perr)int i;struct scheduler *sched; -for ( i =0 ; i <ARRAY_SIZE (schedulers); i++ ) +for ( i =0 ; i <NUM_SCHEDULERS ; i++ )if ( schedulers[i] && schedulers[i]->sched_id == sched_id ) goto found; *perr = -ENOENT ;
xen/include/xen/sched-if.h +0 -5
@@ -165,11 +165,6 @@ struct scheduler {void (*tick_resume) (const struct scheduler *,unsigned int ); }; -extern const struct scheduler sched_credit_def; -extern const struct scheduler sched_credit2_def; -extern const struct scheduler sched_arinc653_def; -extern const struct scheduler sched_rtds_def; -#define REGISTER_SCHEDULER (x) static const struct scheduler *x##_entry \ __used_section(".data.schedulers") = &x;
Signature · 1 line
2.6.4
Re: [PATCH v5 5/5] sched: Use the auto-generated list of schedulers
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 14.01.16 at 15:49, <[email protected]> wrote:
xen/common/schedule.c +0
-8@@ -64,20 +64,9 @@ static void poll_timer_fn(void *data); DEFINE_PER_CPU(struct schedule_data, schedule_data); DEFINE_PER_CPU(struct scheduler *, scheduler); -static const struct scheduler *schedulers[] = { -#ifdef CONFIG_SCHED_CREDIT - &sched_credit_def, -#endif -#ifdef CONFIG_SCHED_CREDIT2 - &sched_credit2_def, -#endif -#ifdef CONFIG_SCHED_ARINC653
xen/common/schedule.c static void poll_timer_fn(void *data); · line 70
Quoted 10 lines
xen/common/schedule.c +3
-6- &sched_arinc653_def, -#endif -#ifdef CONFIG_SCHED_RTDS - &sched_rtds_def, -#endif -}; +extern const struct scheduler *__start_schedulers_array[], *__end_schedulers_array[]; +#define NUM_SCHEDULERS (__end_schedulers_array - __start_schedulers_array) +static const struct scheduler **schedulers = __start_schedulers_array;
#define or properly constified (to help the compiler recognize it won't ever change).
Jan
Re: [PATCH v5 5/5] sched: Use the auto-generated list of schedulers
Quoted 20 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 14.01.16 at 15:49, <[email protected]> wrote:
xen/common/schedule.c +0
-13@@ -64,20 +64,9 @@ static void poll_timer_fn(void *data); DEFINE_PER_CPU(struct schedule_data, schedule_data); DEFINE_PER_CPU(struct scheduler *, scheduler); -static const struct scheduler *schedulers[] = { -#ifdef CONFIG_SCHED_CREDIT - &sched_credit_def, -#endif -#ifdef CONFIG_SCHED_CREDIT2 - &sched_credit2_def, -#endif -#ifdef CONFIG_SCHED_ARINC653 - &sched_arinc653_def, -#endif -#ifdef CONFIG_SCHED_RTDS - &sched_rtds_def, -#endif
Quoted 8 lines
xen/common/schedule.c static void poll_timer_fn(void *data); · line 69
Quoted 5 lines
xen/common/schedule.c +3
-1-}; +extern const struct scheduler *__start_schedulers_array[], *__end_schedulers_array[]; +#define NUM_SCHEDULERS (__end_schedulers_array - __start_schedulers_array) +static const struct scheduler **schedulers = __start_schedulers_array;#define or properly constified (to help the compiler recognize it won't ever change).
I will make it a define in the next version.