From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Mon, 27 Jan 2020 18:28:13 +0100 Subject: [PATCH] ZEN: INTERACTIVE: Tune CFS for interactivity 5.7: Take "sysctl_sched_nr_migrate" tune from early XanMod builds of 128. As of 5.7, XanMod uses 256 but that may affect applications that require timely response to IRQs. 5.15: Per comment [1] on our ZEN INTERACTIVE commit, reducing the cost of migration causes the system less responsive under high load. Most likely the combination of reduced migration cost + the higher number of tasks that can be migrated at once contributes to this. To better handle this situation, restore the mainline migration cost value and also reduce the max number of tasks that can be migrated in batch from 128 to 64. If this doesn't help, we'll restore the reduced migration cost and keep total number of tasks that can be migrated at once to 32. [1] https://github.com/zen-kernel/zen-kernel/commit/be5ba234ca0a5aabe74bfc7e1f636f085bd3823c#commitcomment-63159674 --- init/Kconfig | 8 ++++++++ kernel/sched/core.c | 4 +++- kernel/sched/fair.c | 23 +++++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/init/Kconfig b/init/Kconfig index d687aecdae2852f6737a13b7ef0ce821b3b1c196..b93204f59bba0f0faa98082a0e358d6d83da54f0 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -132,6 +132,14 @@ config ZEN_INTERACTIVE Background-reclaim hugepages...: no -> yes MG-LRU minimum cache TTL.......: 0 -> 1000 ms + --- CFS CPU Scheduler ---------------------------------- + + Scheduling latency.............: 6 -> 4 ms + Minimal granularity............: 0.75 -> 0.4 ms + Wakeup granularity.............: 1 -> 0.5 ms + Bandwidth slice size...........: 5 -> 3 ms + Task rebalancing threshold.....: 32 -> 64 + config BROKEN bool diff --git a/kernel/sched/core.c b/kernel/sched/core.c index da0bf6fe9ecdcf697a1f9dff304c71d0d3433155..3cbef426d646e63711343e1e58867fe654ec296f 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -142,7 +142,9 @@ __read_mostly int sysctl_resched_latency_warn_once = 1; * Number of tasks to iterate in a single balance run. * Limited because this is done with IRQs disabled. */ -#ifdef CONFIG_PREEMPT_RT +#ifdef CONFIG_ZEN_INTERACTIVE +const_debug unsigned int sysctl_sched_nr_migrate = 64; +#elif defined(CONFIG_PREEMPT_RT) const_debug unsigned int sysctl_sched_nr_migrate = 8; #else const_debug unsigned int sysctl_sched_nr_migrate = 32; diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 77b2048a932622a0188f8f93680d9215559a941c..5d0a04b72787745ff785ef195812233ed77bd7d4 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -68,8 +68,13 @@ * * (default: 6ms * (1 + ilog(ncpus)), units: nanoseconds) */ +#ifdef CONFIG_ZEN_INTERACTIVE +unsigned int sysctl_sched_latency = 4000000ULL; +static unsigned int normalized_sysctl_sched_latency = 4000000ULL; +#else unsigned int sysctl_sched_latency = 6000000ULL; static unsigned int normalized_sysctl_sched_latency = 6000000ULL; +#endif /* * The initial- and re-scaling of tunables is configurable @@ -89,8 +94,13 @@ unsigned int sysctl_sched_tunable_scaling = SCHED_TUNABLESCALING_LOG; * * (default: 0.75 msec * (1 + ilog(ncpus)), units: nanoseconds) */ +#ifdef CONFIG_ZEN_INTERACTIVE +unsigned int sysctl_sched_min_granularity = 400000ULL; +static unsigned int normalized_sysctl_sched_min_granularity = 400000ULL; +#else unsigned int sysctl_sched_min_granularity = 750000ULL; static unsigned int normalized_sysctl_sched_min_granularity = 750000ULL; +#endif /* * Minimal preemption granularity for CPU-bound SCHED_IDLE tasks. @@ -103,7 +113,11 @@ unsigned int sysctl_sched_idle_min_granularity = 750000ULL; /* * This value is kept at sysctl_sched_latency/sysctl_sched_min_granularity */ +#ifdef CONFIG_ZEN_INTERACTIVE +static unsigned int sched_nr_latency = 10; +#else static unsigned int sched_nr_latency = 8; +#endif /* * After fork, child runs first. If set to 0 (default) then @@ -120,8 +134,13 @@ unsigned int sysctl_sched_child_runs_first __read_mostly; * * (default: 1 msec * (1 + ilog(ncpus)), units: nanoseconds) */ +#ifdef CONFIG_ZEN_INTERACTIVE +unsigned int sysctl_sched_wakeup_granularity = 500000UL; +static unsigned int normalized_sysctl_sched_wakeup_granularity = 500000UL; +#else unsigned int sysctl_sched_wakeup_granularity = 1000000UL; static unsigned int normalized_sysctl_sched_wakeup_granularity = 1000000UL; +#endif const_debug unsigned int sysctl_sched_migration_cost = 500000UL; @@ -174,8 +193,12 @@ int __weak arch_asym_cpu_priority(int cpu) * * (default: 5 msec, units: microseconds) */ +#ifdef CONFIG_ZEN_INTERACTIVE +static unsigned int sysctl_sched_cfs_bandwidth_slice = 3000UL; +#else static unsigned int sysctl_sched_cfs_bandwidth_slice = 5000UL; #endif +#endif #ifdef CONFIG_SYSCTL static struct ctl_table sched_fair_sysctls[] = {