* [PATCH v2] sched: Simplify __sched_init runtime checks
@ 2022-01-24 8:53 Chun-Hung Tseng
2022-01-24 10:33 ` Huichun Feng
2022-02-12 20:45 ` Huichun Feng
0 siblings, 2 replies; 3+ messages in thread
From: Chun-Hung Tseng @ 2022-01-24 8:53 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman, bristot, christian, linux-kernel
Cc: Chun-Hung Tseng
Improve runtime checks in __sched_init(void) by replacing if conditional
checks with preprocessor directives.
Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
---
kernel/sched/core.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 848eaa0efe0e..1b27ca7f485a 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -9308,28 +9308,29 @@ void __init sched_init(void)
#ifdef CONFIG_RT_GROUP_SCHED
ptr += 2 * nr_cpu_ids * sizeof(void **);
#endif
- if (ptr) {
- ptr = (unsigned long)kzalloc(ptr, GFP_NOWAIT);
+
+#if defined(CONFIG_FAIR_GROUP_SCHED) || defined(CONFIG_RT_GROUP_SCHED)
+ ptr = (unsigned long)kzalloc(ptr, GFP_NOWAIT);
#ifdef CONFIG_FAIR_GROUP_SCHED
- root_task_group.se = (struct sched_entity **)ptr;
- ptr += nr_cpu_ids * sizeof(void **);
+ root_task_group.se = (struct sched_entity **)ptr;
+ ptr += nr_cpu_ids * sizeof(void **);
- root_task_group.cfs_rq = (struct cfs_rq **)ptr;
- ptr += nr_cpu_ids * sizeof(void **);
+ root_task_group.cfs_rq = (struct cfs_rq **)ptr;
+ ptr += nr_cpu_ids * sizeof(void **);
- root_task_group.shares = ROOT_TASK_GROUP_LOAD;
- init_cfs_bandwidth(&root_task_group.cfs_bandwidth);
+ root_task_group.shares = ROOT_TASK_GROUP_LOAD;
+ init_cfs_bandwidth(&root_task_group.cfs_bandwidth);
#endif /* CONFIG_FAIR_GROUP_SCHED */
#ifdef CONFIG_RT_GROUP_SCHED
- root_task_group.rt_se = (struct sched_rt_entity **)ptr;
- ptr += nr_cpu_ids * sizeof(void **);
-
- root_task_group.rt_rq = (struct rt_rq **)ptr;
- ptr += nr_cpu_ids * sizeof(void **);
+ root_task_group.rt_se = (struct sched_rt_entity **)ptr;
+ ptr += nr_cpu_ids * sizeof(void **);
+ root_task_group.rt_rq = (struct rt_rq **)ptr;
+ ptr += nr_cpu_ids * sizeof(void **);
#endif /* CONFIG_RT_GROUP_SCHED */
- }
+#endif /* CONFIG_FAIR_GROUP_SCHED || CONFIG_RT_GROUP_SCHED */
+
#ifdef CONFIG_CPUMASK_OFFSTACK
for_each_possible_cpu(i) {
per_cpu(load_balance_mask, i) = (cpumask_var_t)kzalloc_node(
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] sched: Simplify __sched_init runtime checks
2022-01-24 8:53 [PATCH v2] sched: Simplify __sched_init runtime checks Chun-Hung Tseng
@ 2022-01-24 10:33 ` Huichun Feng
2022-02-12 20:45 ` Huichun Feng
1 sibling, 0 replies; 3+ messages in thread
From: Huichun Feng @ 2022-01-24 10:33 UTC (permalink / raw)
To: henrybear327
Cc: bristot, bsegall, christian, dietmar.eggemann, juri.lelli,
linux-kernel, mgorman, mingo, peterz, rostedt, vincent.guittot
Improve runtime checks in __sched_init(void) by replacing if conditional
checks with preprocessor directives.
Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
Signed-off-by: Huichun Feng <foxhoundsk.tw@gmail.com>
---
kernel/sched/core.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 848eaa0efe0e..1b27ca7f485a 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -9308,28 +9308,29 @@ void __init sched_init(void)
#ifdef CONFIG_RT_GROUP_SCHED
ptr += 2 * nr_cpu_ids * sizeof(void **);
#endif
- if (ptr) {
- ptr = (unsigned long)kzalloc(ptr, GFP_NOWAIT);
+
+#if defined(CONFIG_FAIR_GROUP_SCHED) || defined(CONFIG_RT_GROUP_SCHED)
+ ptr = (unsigned long)kzalloc(ptr, GFP_NOWAIT);
#ifdef CONFIG_FAIR_GROUP_SCHED
- root_task_group.se = (struct sched_entity **)ptr;
- ptr += nr_cpu_ids * sizeof(void **);
+ root_task_group.se = (struct sched_entity **)ptr;
+ ptr += nr_cpu_ids * sizeof(void **);
- root_task_group.cfs_rq = (struct cfs_rq **)ptr;
- ptr += nr_cpu_ids * sizeof(void **);
+ root_task_group.cfs_rq = (struct cfs_rq **)ptr;
+ ptr += nr_cpu_ids * sizeof(void **);
- root_task_group.shares = ROOT_TASK_GROUP_LOAD;
- init_cfs_bandwidth(&root_task_group.cfs_bandwidth);
+ root_task_group.shares = ROOT_TASK_GROUP_LOAD;
+ init_cfs_bandwidth(&root_task_group.cfs_bandwidth);
#endif /* CONFIG_FAIR_GROUP_SCHED */
#ifdef CONFIG_RT_GROUP_SCHED
- root_task_group.rt_se = (struct sched_rt_entity **)ptr;
- ptr += nr_cpu_ids * sizeof(void **);
-
- root_task_group.rt_rq = (struct rt_rq **)ptr;
- ptr += nr_cpu_ids * sizeof(void **);
+ root_task_group.rt_se = (struct sched_rt_entity **)ptr;
+ ptr += nr_cpu_ids * sizeof(void **);
+ root_task_group.rt_rq = (struct rt_rq **)ptr;
+ ptr += nr_cpu_ids * sizeof(void **);
#endif /* CONFIG_RT_GROUP_SCHED */
- }
+#endif /* CONFIG_FAIR_GROUP_SCHED || CONFIG_RT_GROUP_SCHED */
+
#ifdef CONFIG_CPUMASK_OFFSTACK
for_each_possible_cpu(i) {
per_cpu(load_balance_mask, i) = (cpumask_var_t)kzalloc_node(
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] sched: Simplify __sched_init runtime checks
2022-01-24 8:53 [PATCH v2] sched: Simplify __sched_init runtime checks Chun-Hung Tseng
2022-01-24 10:33 ` Huichun Feng
@ 2022-02-12 20:45 ` Huichun Feng
1 sibling, 0 replies; 3+ messages in thread
From: Huichun Feng @ 2022-02-12 20:45 UTC (permalink / raw)
To: henrybear327
Cc: bristot, bsegall, christian, dietmar.eggemann, juri.lelli,
linux-kernel, mgorman, mingo, peterz, rostedt, vincent.guittot
Chun-Hung Tseng <henrybear327@gmail.com> writes:
>
> Improve runtime checks in __sched_init(void) by replacing if conditional
> checks with preprocessor directives.
>
> Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
Sorry, I didn't reply properly.
Signed-off-by: Huichun Feng <foxhoundsk.tw@gmail.com>
> ---
> kernel/sched/core.c | 29 +++++++++++++++--------------
> 1 file changed, 15 insertions(+), 14 deletions(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 848eaa0efe0e..1b27ca7f485a 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -9308,28 +9308,29 @@ void __init sched_init(void)
> #ifdef CONFIG_RT_GROUP_SCHED
> ptr += 2 * nr_cpu_ids * sizeof(void **);
> #endif
> - if (ptr) {
> - ptr = (unsigned long)kzalloc(ptr, GFP_NOWAIT);
> +
> +#if defined(CONFIG_FAIR_GROUP_SCHED) || defined(CONFIG_RT_GROUP_SCHED)
> + ptr = (unsigned long)kzalloc(ptr, GFP_NOWAIT);
>
> #ifdef CONFIG_FAIR_GROUP_SCHED
> - root_task_group.se = (struct sched_entity **)ptr;
> - ptr += nr_cpu_ids * sizeof(void **);
> + root_task_group.se = (struct sched_entity **)ptr;
> + ptr += nr_cpu_ids * sizeof(void **);
>
> - root_task_group.cfs_rq = (struct cfs_rq **)ptr;
> - ptr += nr_cpu_ids * sizeof(void **);
> + root_task_group.cfs_rq = (struct cfs_rq **)ptr;
> + ptr += nr_cpu_ids * sizeof(void **);
>
> - root_task_group.shares = ROOT_TASK_GROUP_LOAD;
> - init_cfs_bandwidth(&root_task_group.cfs_bandwidth);
> + root_task_group.shares = ROOT_TASK_GROUP_LOAD;
> + init_cfs_bandwidth(&root_task_group.cfs_bandwidth);
> #endif /* CONFIG_FAIR_GROUP_SCHED */
> #ifdef CONFIG_RT_GROUP_SCHED
> - root_task_group.rt_se = (struct sched_rt_entity **)ptr;
> - ptr += nr_cpu_ids * sizeof(void **);
> -
> - root_task_group.rt_rq = (struct rt_rq **)ptr;
> - ptr += nr_cpu_ids * sizeof(void **);
> + root_task_group.rt_se = (struct sched_rt_entity **)ptr;
> + ptr += nr_cpu_ids * sizeof(void **);
>
> + root_task_group.rt_rq = (struct rt_rq **)ptr;
> + ptr += nr_cpu_ids * sizeof(void **);
> #endif /* CONFIG_RT_GROUP_SCHED */
> - }
> +#endif /* CONFIG_FAIR_GROUP_SCHED || CONFIG_RT_GROUP_SCHED */
> +
> #ifdef CONFIG_CPUMASK_OFFSTACK
> for_each_possible_cpu(i) {
> per_cpu(load_balance_mask, i) = (cpumask_var_t)kzalloc_node(
> --
> 2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-12 20:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-24 8:53 [PATCH v2] sched: Simplify __sched_init runtime checks Chun-Hung Tseng
2022-01-24 10:33 ` Huichun Feng
2022-02-12 20:45 ` Huichun Feng
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.