Housekeeping: Rebase last 3 patches against tip:sched/core
Subsystems (5)
cover Housekeeping: Rebase last 3 patches against tip:sched/core
This is a resend of the last three patches that had a conflict againste22cdc3fc:
("sched/isolcpus: Fix "isolcpus=" boot parameter handling when !CONFIG_CPUMASK_OFFSTACK")
The conflict has been resolved by moving the following check 'cpumask_last(cpu_isolated_mask) >= nr_cpus_id' to the housekeeping code.
Frederic Weisbecker (3):
housekeeping: Move isolcpus to housekeeping
housekeeping: Add basic isolcpus flags
housekeeping: Document isolcpus flags
Documentation/admin-guide/kernel-parameters.txt | 35 ++++++---- drivers/base/cpu.c | 11 +++- include/linux/housekeeping.h | 1 + include/linux/sched.h | 2 - kernel/cgroup/cpuset.c | 15 ++--- kernel/housekeeping.c | 85 +++++++++++++++++++++---- kernel/sched/core.c | 16 +---- kernel/sched/topology.c | 24 ++----- 8 files changed, 117 insertions(+), 72 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/3 housekeeping: Move isolcpus to housekeeping
We want to centralize the isolation features on the housekeeping subsystem and scheduler domain isolation is a significant part of it.
No intended behaviour change, we just reuse the housekeeping cpumask and core code.
--- drivers/base/cpu.c | 11 +++++++- include/linux/housekeeping.h | 1 + include/linux/sched.h | 2 -- kernel/cgroup/cpuset.c | 15 ++++------- kernel/housekeeping.c | 61 +++++++++++++++++++++++++++++++++++--------- kernel/sched/core.c | 16 +----------- kernel/sched/topology.c | 24 +++++------------ 7 files changed, 72 insertions(+), 58 deletions(-)
drivers/base/cpu.c +10 -1
@@ -18,6 +18,7 @@#include <linux/cpufeature.h> #include <linux/tick.h> #include <linux/pm_qos.h> +#include <linux/housekeeping.h> #include "base.h"
@@ -271,8 +272,16 @@ static ssize_t print_cpus_isolated(struct device *dev, struct device_attribute *attr, char *buf) { int n = 0, len = PAGE_SIZE-2; +cpumask_var_t isolated; - n =scnprintf (buf, len,"%*pbl\n" ,cpumask_pr_args (cpu_isolated_map)); +if (!alloc_cpumask_var (&isolated,GFP_KERNEL )) +return -ENOMEM ; + +cpumask_andnot (isolated, cpu_possible_mask, +housekeeping_cpumask (HK_FLAG_DOMAIN )); + n =scnprintf (buf, len,"%*pbl\n" ,cpumask_pr_args (isolated)); + +free_cpumask_var (isolated);return n; }
include/linux/housekeeping.h +1 -0
@@ -11,6 +11,7 @@ enum hk_flags {HK_FLAG_MISC = (1 <<2 ),HK_FLAG_SCHED = (1 <<3 ),HK_FLAG_TICK = (1 <<4 ), + HK_FLAG_DOMAIN = (1 << 5), };#ifdef CONFIG_CPU_ISOLATION
include/linux/sched.h +0 -2
@@ -165,8 +165,6 @@ struct task_group;/* Task command name length: */ #define TASK_COMM_LEN 16 -extern cpumask_var_t cpu_isolated_map; -extern void scheduler_tick (void );#define MAX_SCHEDULE_TIMEOUT LONG_MAX
kernel/cgroup/cpuset.c +5 -10
@@ -57,7 +57,7 @@#include <linux/backing-dev.h> #include <linux/sort.h> #include <linux/oom.h> - +#include <linux/housekeeping.h> #include <linux/uaccess.h> #include <linux/atomic.h> #include <linux/mutex.h>
@@ -656,7 +656,6 @@ static int generate_sched_domains(cpumask_var_t **domains,int csn;/* how many cpuset ptrs in csa so far */ int i, j, k;/* indices for partition finding loops */ cpumask_var_t *doms;/* resulting partition; i.e. sched domains */ -cpumask_var_t non_isolated_cpus;/* load balanced CPUs */ struct sched_domain_attr *dattr;/* attributes for custom domains */ int ndoms =0 ;/* number of sched domains in result */ int nslot;/* next empty doms[] struct cpumask slot */
@@ -666,10 +665,6 @@ static int generate_sched_domains(cpumask_var_t **domains, dattr =NULL ; csa =NULL ; -if (!alloc_cpumask_var (&non_isolated_cpus,GFP_KERNEL )) - goto done; -cpumask_andnot (non_isolated_cpus, cpu_possible_mask, cpu_isolated_map); -/* Special case for the 99% of systems with one, full, sched domain */ if (is_sched_load_balance (&top_cpuset)) { ndoms =1 ;
@@ -683,7 +678,7 @@ static int generate_sched_domains(cpumask_var_t **domains,update_domain_attr_tree (dattr, &top_cpuset); }cpumask_and (doms[0 ], top_cpuset.effective_cpus, - non_isolated_cpus); +housekeeping_cpumask (HK_FLAG_DOMAIN )); goto done; }
@@ -707,7 +702,8 @@ static int generate_sched_domains(cpumask_var_t **domains,*/ if (!cpumask_empty (cp->cpus_allowed) && !(is_sched_load_balance (cp) && -cpumask_intersects (cp->cpus_allowed, non_isolated_cpus))) +cpumask_intersects (cp->cpus_allowed, +housekeeping_cpumask (HK_FLAG_DOMAIN ))))continue ;if (is_sched_load_balance (cp))
@@ -789,7 +785,7 @@ static int generate_sched_domains(cpumask_var_t **domains,if (apn == b->pn) {cpumask_or (dp, dp, b->effective_cpus); -cpumask_and (dp, dp, non_isolated_cpus); +cpumask_and (dp, dp,housekeeping_cpumask (HK_FLAG_DOMAIN ));if (dattr)update_domain_attr_tree (dattr + nslot, b);
@@ -802,7 +798,6 @@ static int generate_sched_domains(cpumask_var_t **domains,BUG_ON (nslot != ndoms); done: -free_cpumask_var (non_isolated_cpus);kfree (csa);/*
kernel/housekeeping.c +49 -12
81 lines not on this page · raw message
kernel/sched/core.c +1 -15
@@ -84,9 +84,6 @@ __read_mostly int scheduler_running;*/ int sysctl_sched_rt_runtime =950000 ; -/* CPUs with isolated domains */ -cpumask_var_t cpu_isolated_map; -/* * __task_rq_lock - lock the rq @p resides on. */
@@ -5735,10 +5732,6 @@ static inline void sched_init_smt(void) { }void __init sched_init_smp (void ) { -cpumask_var_t non_isolated_cpus; - -alloc_cpumask_var (&non_isolated_cpus,GFP_KERNEL ); -sched_init_numa ();/*
@@ -5748,16 +5741,12 @@ void __init sched_init_smp(void)*/ mutex_lock (&sched_domains_mutex);sched_init_domains (cpu_active_mask); -cpumask_andnot (non_isolated_cpus, cpu_possible_mask, cpu_isolated_map); -if (cpumask_empty (non_isolated_cpus)) -cpumask_set_cpu (smp_processor_id (), non_isolated_cpus);mutex_unlock (&sched_domains_mutex);/* Move init over to a non-isolated CPU */ -if (set_cpus_allowed_ptr (current, non_isolated_cpus) <0 ) +if (set_cpus_allowed_ptr (current,housekeeping_cpumask (HK_FLAG_DOMAIN )) <0 )BUG ();sched_init_granularity (); -free_cpumask_var (non_isolated_cpus);init_sched_rt_class ();init_sched_dl_class ();
@@ -5961,9 +5950,6 @@ void __init sched_init(void) calc_load_update = jiffies +LOAD_FREQ ;#ifdef CONFIG_SMP -/* May be allocated at isolcpus cmdline parse time */ -if (cpu_isolated_map ==NULL ) -zalloc_cpumask_var (&cpu_isolated_map,GFP_NOWAIT );idle_thread_set_boot_cpu ();set_cpu_rq_start_time (smp_processor_id ());#endif
kernel/sched/topology.c +6 -18
@@ -3,6 +3,7 @@*/ #include <linux/sched.h> #include <linux/mutex.h> +#include <linux/housekeeping.h> #include "sched.h"
@@ -469,21 +470,6 @@ cpu_attach_domain(struct sched_domain *sd, struct root_domain *rd, int cpu)update_top_cache_domain (cpu); } -/* Setup the mask of CPUs configured for isolated domains */ -static int __init isolated_cpu_setup (char *str) -{ -int ret; - -alloc_bootmem_cpumask_var (&cpu_isolated_map); - ret =cpulist_parse (str, cpu_isolated_map); -if (ret ||cpumask_last (cpu_isolated_map) >= nr_cpu_ids) { -pr_err ("sched: Error, all isolcpus= values must be between 0 and %u - ignoring them.\n" , nr_cpu_ids-1 ); -return 0 ; - } -return 1 ; -} -__setup ("isolcpus=" , isolated_cpu_setup); -struct s_data {struct sched_domain **__percpu sd;struct root_domain *rd;
@@ -1792,7 +1778,7 @@ int sched_init_domains(const struct cpumask *cpu_map) doms_cur =alloc_sched_domains (ndoms_cur);if (!doms_cur) doms_cur = &fallback_doms; -cpumask_andnot (doms_cur[0 ], cpu_map, cpu_isolated_map); +cpumask_and (doms_cur[0 ], cpu_map,housekeeping_cpumask (HK_FLAG_DOMAIN )); err =build_sched_domains (doms_cur[0 ],NULL );register_sched_domain_sysctl ();
@@ -1875,7 +1861,8 @@ void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[], doms_new =alloc_sched_domains (1 );if (doms_new) { n =1 ; -cpumask_andnot (doms_new[0 ], cpu_active_mask, cpu_isolated_map); +cpumask_and (doms_new[0 ], cpu_active_mask, +housekeeping_cpumask (HK_FLAG_DOMAIN )); } }else { n = ndoms_new;
@@ -1898,7 +1885,8 @@ void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[],if (!doms_new) { n =0 ; doms_new = &fallback_doms; -cpumask_andnot (doms_new[0 ], cpu_active_mask, cpu_isolated_map); +cpumask_and (doms_new[0 ], cpu_active_mask, +housekeeping_cpumask (HK_FLAG_DOMAIN )); }/* Build new domains: */
Signature · 1 line
2.7.4
PATCH 2/3 housekeeping: Add basic isolcpus flags
In reply to Frederic WeisbeckerAdd flags to control nohz and domain isolations from "isolcpus=", in order to centralize the isolation features to a common interface. Domain isolation remains the default so not to break the existing isolcpus boot paramater behaviour.
Further flags in the future may include 0hz (1hz tick offload) and timers, workqueue, RCU, kthread, watchdog, likely all merged together in a common flag ("async"?). In any case, this will have to be modifiable by cpusets.
--- kernel/housekeeping.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
kernel/housekeeping.c +25 -1
@@ -11,6 +11,7 @@#include <linux/init.h> #include <linux/kernel.h> #include <linux/static_key.h> +#include <linux/ctype.h> DEFINE_STATIC_KEY_FALSE (housekeeping_overriden);EXPORT_SYMBOL_GPL (housekeeping_overriden);
@@ -122,6 +123,29 @@ __setup("nohz_full=", housekeeping_nohz_full_setup);static int __init housekeeping_isolcpus_setup (char *str) { -return housekeeping_setup (str,HK_FLAG_DOMAIN ); +unsigned int flags =0 ; + +while (isalpha (*str)) { +if (!strncmp (str,"nohz," ,5 )) { + str +=5 ; + flags |=HK_FLAG_TICK ; +continue ; + } + +if (!strncmp (str,"domain," ,7 )) { + str +=7 ; + flags |=HK_FLAG_DOMAIN ; +continue ; + } + +pr_warn ("isolcpus: Error, unknown flag\n" ); +return 0 ; + } + +/* Default behaviour for isolcpus without flags */ +if (!flags) + flags |=HK_FLAG_DOMAIN ; + +return housekeeping_setup (str, flags); }__setup ("isolcpus=" , housekeeping_isolcpus_setup);
Signature · 1 line
2.7.4
PATCH 3/3 housekeeping: Document isolcpus flags
In reply to Frederic Weisbecker--- Documentation/admin-guide/kernel-parameters.txt | 35 +++++++++++++++---------- 1 file changed, 21 insertions(+), 14 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +21 -14
@@ -1727,20 +1727,27 @@ isapnp= [ISAPNP] Format: <RDP>,<reset>,<pci_scan>,<verbosity> - isolcpus= [KNL,SMP] Isolate CPUs from the general scheduler. - The argument is a cpu list, as described above. - - This option can be used to specify one or more CPUs - to isolate from the general SMP balancing and scheduling - algorithms. You can move a process onto or off an - "isolated" CPU via the CPU affinity syscalls or cpuset. - <cpu number> begins at 0 and the maximum value is - "number of CPUs in system - 1". - - This option is the preferred way to isolate CPUs. The - alternative -- manually setting the CPU mask of all - tasks in the system -- can cause problems and - suboptimal load balancer performance. + isolcpus= [KNL,SMP] Isolate a given set of CPUs from disturbance. + Format: [flag-list,]<cpu-list> + + Specify one or more CPUs to isolate from disturbances + specified in the flag list (default: domain): + + nohz + Disable the tick when a single task runs. + domain + Isolate from the general SMP balancing and scheduling + algorithms. This option is the preferred way to isolate + CPUs from tasks. The alternative -- manually setting the + CPU mask of all tasks in the system, can cause problems + and suboptimal load balancer performance. You can move a + process onto or off an "isolated" CPU via the CPU + affinity syscalls or cpuset. <cpu number> begins at 0 + and the maximum value is "number of CPUs in system - 1". + + The format of <cpu-list> is described above. + + iucv= [HW,NET]
Signature · 1 line
2.7.4