From patchwork Wed Aug 16 21:20:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 110279 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1323328qge; Wed, 16 Aug 2017 14:20:57 -0700 (PDT) X-Received: by 10.98.212.27 with SMTP id a27mr2962741pfh.157.1502918457491; Wed, 16 Aug 2017 14:20:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502918457; cv=none; d=google.com; s=arc-20160816; b=pa78/7YXjWth0KC2YZxexq7rntwMGzqI3aFyCUvyzTlMJfgYyRHAUjv5QmwqoSfyOE orxv4z27Lp0YS9VNfv0d1btEhDeJNcu7taUiju/0zwKZIrLMtgFRNI+WHs2ZAkRcmq8A ccaWjV1j14Yts/9LEkqzyCC4l+QxKvkNMFfh2OiuoltbkkzFrDXKVcHqAePwzO0iGrZD tH2dOP8j2cb115snXOsA+OrqYboR+fE+X9KXy/tvdng5EBB8jjiMY2Zs42XqTYXsL/IM rM8aEpurRWTDkiRo/yNk6bP0yC5qm594NfMLB9zOjmoUkXPMcyaCrkusxH0DMwQM3W0u M2Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=A8/Rl7Gv6dCpDF6jdvNDJwYiQdE4TnHJJuO2cjenEjE=; b=twKQ2fdRZWS/vw9hYPrtWOUVKoZAFDSUMQNzntnZi7tCOWsxjWmf8wukk2l8bHHvkM eqP6fdsWRYlG/ap1GWAdS57i6r2sCnSRFy0JBDKUsEtwtDJ4Poe8dLaYpxTPVrBXgNSP YaIEzN5RQxYEdccjAIhq+93pxMgdVrY9Pp98Fof+C4L1aX5WGOcnwoIvjuvQe9t6wVNR SEE6cMhOD+xHi/9U082n3M+LnrZpkvJwmpGcL5E74WxH2/Z7dBUa6wx2cnCaxQbQ05QK uKk7p42aV1hkHBbJjJQrOlanJgAjBRRzwDbaio7Wh0Hj2glLujNJWqVRBIDsNA0Ke+pj EA9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TG0jMdW6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 76si1027203pfw.0.2017.08.16.14.20.57; Wed, 16 Aug 2017 14:20:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TG0jMdW6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752493AbdHPVUy (ORCPT + 26 others); Wed, 16 Aug 2017 17:20:54 -0400 Received: from mail-it0-f47.google.com ([209.85.214.47]:33822 "EHLO mail-it0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752105AbdHPVUt (ORCPT ); Wed, 16 Aug 2017 17:20:49 -0400 Received: by mail-it0-f47.google.com with SMTP id m34so21537117iti.1 for ; Wed, 16 Aug 2017 14:20:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=A8/Rl7Gv6dCpDF6jdvNDJwYiQdE4TnHJJuO2cjenEjE=; b=TG0jMdW6Z96KRPrgJ33PjM0+18CPwLoBKPc9hlWu7KVeMOQRctkQ7BeE6D9OoUmLRG ysKMkgz/V7DHgs66cbKsgIVUvjEBk5ll2Kf7c0sEdWZf273cU23XDKJ5+3zojJE2zBAR QsklZi3/GdC+9tpprrypY2p6FPynw7og/HZCk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=A8/Rl7Gv6dCpDF6jdvNDJwYiQdE4TnHJJuO2cjenEjE=; b=qDAUJ4BQxEDaQQM4XeZjmx4pwfYHIYkqwyzbfsb+IwVoPwb8x82gnkPMhSHnmM0Ziu 0pJ4dGhSnOKeroGDsaKovtLGsykyUyew+a/9bpkpmVDap+WVFZzP8as6tgwqlAO/GCUP eMmH2QhCP82uvs+qjjihE7AFitowJyF/qaS5hS8ZfMGAznaEkoxjH6qntTosM+/2GUuD 4Zu+AVlSnyzjRf3BS5K3XkbthTaBUw6U9eubSRwjxxUQbDIV+ovctC1hJ3Ex30VyRusn FjDGynzHHejYhLz1IlhwXuQsJc47tP1cQQmipWzSpyWDbg48J597Aiogj79rrP5KUPKw R5Jg== X-Gm-Message-State: AHYfb5i5Oj98wxAwr7JYt7P+E9pGGCMgJbPrrmwSn3R4MXLICeUTt5kL 0Bzh9kGW9oSsYeWQ X-Received: by 10.36.43.213 with SMTP id h204mr352881ita.19.1502918448529; Wed, 16 Aug 2017 14:20:48 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id 80sm918281itk.11.2017.08.16.14.20.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Aug 2017 14:20:47 -0700 (PDT) From: Mathieu Poirier To: mingo@redhat.com, peterz@infradead.org Cc: tj@kernel.org, vbabka@suse.cz, lizefan@huawei.com, akpm@linux-foundation.org, weiyongjun1@huawei.com, juri.lelli@arm.com, rostedt@goodmis.org, claudio@evidence.eu.com, luca.abeni@santannapisa.it, bristot@redhat.com, linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org Subject: [PATCH 1/7] sched/topology: Adding function partition_sched_domains_locked() Date: Wed, 16 Aug 2017 15:20:37 -0600 Message-Id: <1502918443-30169-2-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502918443-30169-1-git-send-email-mathieu.poirier@linaro.org> References: <1502918443-30169-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introducing function partition_sched_domains_locked() by taking the mutex locking code out of the original function. That way the work done by partition_sched_domains_locked() can be reused without dropping the mutex lock. This patch doesn't change the functionality provided by the original code. Signed-off-by: Mathieu Poirier --- include/linux/sched/topology.h | 9 +++++++++ kernel/sched/topology.c | 17 +++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h index 7d065abc7a47..59b568079e05 100644 --- a/include/linux/sched/topology.h +++ b/include/linux/sched/topology.h @@ -161,6 +161,9 @@ static inline struct cpumask *sched_domain_span(struct sched_domain *sd) return to_cpumask(sd->span); } +extern void partition_sched_domains_locked(int ndoms_new, + cpumask_var_t doms_new[], + struct sched_domain_attr *dattr_new); extern void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[], struct sched_domain_attr *dattr_new); @@ -206,6 +209,12 @@ extern void set_sched_topology(struct sched_domain_topology_level *tl); struct sched_domain_attr; static inline void +partition_sched_domains_locked(int ndoms_new, cpumask_var_t doms_new[], + struct sched_domain_attr *dattr_new) +{ +} + +static inline void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[], struct sched_domain_attr *dattr_new) { diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 9b4f2701ba3c..58133f2ce889 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -1840,15 +1840,15 @@ static int dattrs_equal(struct sched_domain_attr *cur, int idx_cur, * ndoms_new == 0 is a special case for destroying existing domains, * and it will not create the default domain. * - * Call with hotplug lock held + * Call with hotplug lock and sched_domains_mutex held */ -void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[], - struct sched_domain_attr *dattr_new) +void partition_sched_domains_locked(int ndoms_new, cpumask_var_t doms_new[], + struct sched_domain_attr *dattr_new) { int i, j, n; int new_topology; - mutex_lock(&sched_domains_mutex); + lockdep_assert_held(&sched_domains_mutex); /* Always unregister in case we don't destroy any domains: */ unregister_sched_domain_sysctl(); @@ -1902,7 +1902,16 @@ void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[], ndoms_cur = ndoms_new; register_sched_domain_sysctl(); +} +/* + * Call with hotplug lock held + */ +void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[], + struct sched_domain_attr *dattr_new) +{ + mutex_lock(&sched_domains_mutex); + partition_sched_domains_locked(ndoms_new, doms_new, dattr_new); mutex_unlock(&sched_domains_mutex); } From patchwork Wed Aug 16 21:20:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 110285 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1325065qge; Wed, 16 Aug 2017 14:22:46 -0700 (PDT) X-Received: by 10.98.74.199 with SMTP id c68mr2980798pfj.242.1502918566301; Wed, 16 Aug 2017 14:22:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502918566; cv=none; d=google.com; s=arc-20160816; b=wm/4hGae7VpXnZWTGLJdw/asdXtHGsSA/GVD40PeMBchH1QGIGQpqcgMMYCzQXLTYx 6SMjTAhEGe86jxbQLu68XDiIojs0YVKs/B3jGRxgKQt/Zy8+u74Uy1fE6hshzPMEnjgN DNvru0lS2eKAewTMuMcaTUC0AZJ+x7ttGp47CCx9z4+bT3HP/km0tjZkvryPl3oB9iXh tC3RWxJzHlVkRW73OHQ2DnXEPPUhToFkRIahVRpXQUbhNeOKnUvcYUG1QAqMSLlyeVq4 bvhFF8siDJS3HWVHUKFEVH91/esWLeOqloc4GWN0AEnmJVL8WKPxUa1SIoQyTZ1Jzn61 NR4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=vgj72HD53CNQquqxWf8RMoN2Zr9dsyVDBBSeHiY5OJE=; b=FeRawCLgkFzLg1xq493qkMRRL7d9khYghVyVb6jrRHMgmSdsUZchcvKt6prxrylXfJ dLRG2cBmAQBBDgO3MuHHpoKIBUsFQBsjPX+lkDQptxJQEgNxr9bMNgFXO/dVXpg8RWWM WC9fCFWKybdixQo+XuUXr15G7tEjMkXiKq8L6vuJwo1IgIl/9BDHrZYiEDTZs/7uXH1X c1UUhAGPitc5JfdGHQl4QmDyVe+y3jlsObBog5yIz5J5Tym9UEhFaRJF+kDvaqI6V6OD +3BE9OGGaB6TWF/jMjfoVyoVeCrfaj/6bhWIuD8oG6jXaGnximvzrwJNSPMYbGDoO5ON vgMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O8Jb/22e; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d8si1118344pln.20.2017.08.16.14.22.45; Wed, 16 Aug 2017 14:22:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O8Jb/22e; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752744AbdHPVWm (ORCPT + 26 others); Wed, 16 Aug 2017 17:22:42 -0400 Received: from mail-it0-f42.google.com ([209.85.214.42]:33090 "EHLO mail-it0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752428AbdHPVUv (ORCPT ); Wed, 16 Aug 2017 17:20:51 -0400 Received: by mail-it0-f42.google.com with SMTP id f16so21543518itb.0 for ; Wed, 16 Aug 2017 14:20:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vgj72HD53CNQquqxWf8RMoN2Zr9dsyVDBBSeHiY5OJE=; b=O8Jb/22ePi8ZkqVfZxXbYwtS6Tazl6Q4J7xvfCyWRPRVmiony9Uw76sN9Z9C7w93BX Eu3XG4k1raJ1+5KA+o45OzcXHiy/KkpllCaUMV9qpITiWtwkvo2C4NWsmRlJWZUTNALI wu6+UKDNqCg4lRz+DRLtI/Z5gqY0TOF91XUXs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vgj72HD53CNQquqxWf8RMoN2Zr9dsyVDBBSeHiY5OJE=; b=RKiGruvZiJmUJwb7s5TbnA4atV5tnJBhJ5N37DGwZd+blpP57zQwlvhyDfhVCjDERT YdppXDXD7vrnXo9LHSjqu7Wx/ysHw/gPfDHRbVd5smfIxVjpPqweWHjlmyyTpcWnxH4v NOteRkKbBl1zc6Nj5ISITPgYEeoZaSLzaO4dHtqqKWp7frOrRJQggtKQzCc+1uQotEwe N97jiJHrcNjwmpplQIlfZmT/JEyGSznAGhIUVmAKawQbMJnWl/w9JYjhnd3+I7RTHJBL PCYAOvLGgGMWmTUj4iMokSX5t3+fD194X5miq2pwMnKq/+rQ6DadamLxGVmZKZBFFiN7 +OzA== X-Gm-Message-State: AHYfb5g2cfvaJKFjiM1JiyTilziWDAdhm1kLFLT9NHJblj6wrG7VIs7p fenaWDCz29eh3zPJ X-Received: by 10.36.51.212 with SMTP id k203mr403537itk.136.1502918450982; Wed, 16 Aug 2017 14:20:50 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id 80sm918281itk.11.2017.08.16.14.20.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Aug 2017 14:20:49 -0700 (PDT) From: Mathieu Poirier To: mingo@redhat.com, peterz@infradead.org Cc: tj@kernel.org, vbabka@suse.cz, lizefan@huawei.com, akpm@linux-foundation.org, weiyongjun1@huawei.com, juri.lelli@arm.com, rostedt@goodmis.org, claudio@evidence.eu.com, luca.abeni@santannapisa.it, bristot@redhat.com, linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org Subject: [PATCH 2/7] cpuset: Rebuild root domain deadline accounting information Date: Wed, 16 Aug 2017 15:20:38 -0600 Message-Id: <1502918443-30169-3-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502918443-30169-1-git-send-email-mathieu.poirier@linaro.org> References: <1502918443-30169-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the topology of root domains is modified by CPUset or CPUhotplug operations information about the current deadline bandwidth held in the root domain is lost. This patch address the issue by recalculating the lost deadline bandwidth information by circling through the deadline tasks held in CPUsets and adding their current load to the root domain they are associated with. Signed-off-by: Mathieu Poirier --- include/linux/sched.h | 3 ++ include/linux/sched/deadline.h | 8 ++++++ kernel/cgroup/cpuset.c | 63 +++++++++++++++++++++++++++++++++++++++++- kernel/sched/deadline.c | 31 +++++++++++++++++++++ kernel/sched/sched.h | 3 -- kernel/sched/topology.c | 14 +++++++++- 6 files changed, 117 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/include/linux/sched.h b/include/linux/sched.h index 8337e2db0bb2..bb07b194d951 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -241,6 +241,9 @@ struct vtime { u64 gtime; }; +extern struct root_domain def_root_domain; +extern struct mutex sched_domains_mutex; + struct sched_info { #ifdef CONFIG_SCHED_INFO /* Cumulative counters: */ diff --git a/include/linux/sched/deadline.h b/include/linux/sched/deadline.h index 975be862e083..fcef5565dc94 100644 --- a/include/linux/sched/deadline.h +++ b/include/linux/sched/deadline.h @@ -28,4 +28,12 @@ static inline bool dl_time_before(u64 a, u64 b) return (s64)(a - b) < 0; } +#ifdef CONFIG_SMP + +struct root_domain; +extern void dl_add_task_root_domain(struct task_struct *p); +extern void dl_clear_root_domain(struct root_domain *rd); + +#endif /* CONFIG_SMP */ + #endif /* _LINUX_SCHED_DEADLINE_H */ diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 63ce8bbb476e..f6d1e485dc2d 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -800,6 +801,66 @@ static int generate_sched_domains(cpumask_var_t **domains, return ndoms; } +static void update_tasks_root_domain(struct cpuset *cs) +{ + struct css_task_iter it; + struct task_struct *task; + + css_task_iter_start(&cs->css, &it); + + while ((task = css_task_iter_next(&it))) + dl_add_task_root_domain(task); + + css_task_iter_end(&it); +} + +/* + * Called with cpuset_mutex held (rebuild_sched_domains()) + * Called with hotplug lock held (rebuild_sched_domains_locked()) + * Called with sched_domains_mutex held (partition_and_rebuild_domains()) + */ +static void rebuild_root_domains(void) +{ + struct cpuset *cs = NULL; + struct cgroup_subsys_state *pos_css; + + rcu_read_lock(); + + /* + * Clear default root domain DL accounting, it will be computed again + * if a task belongs to it. + */ + dl_clear_root_domain(&def_root_domain); + + cpuset_for_each_descendant_pre(cs, pos_css, &top_cpuset) { + + if (cpumask_empty(cs->effective_cpus)) { + pos_css = css_rightmost_descendant(pos_css); + continue; + } + + css_get(&cs->css); + + rcu_read_unlock(); + + update_tasks_root_domain(cs); + + rcu_read_lock(); + css_put(&cs->css); + } + rcu_read_unlock(); +} + +static void +partition_and_rebuild_domains(int ndoms_new, cpumask_var_t doms_new[], + struct sched_domain_attr *dattr_new) +{ + mutex_lock(&sched_domains_mutex); + partition_sched_domains_locked(ndoms_new, doms_new, dattr_new); + rebuild_root_domains(); + mutex_unlock(&sched_domains_mutex); +} + /* * Rebuild scheduler domains. * @@ -832,7 +893,7 @@ static void rebuild_sched_domains_locked(void) ndoms = generate_sched_domains(&doms, &attr); /* Have scheduler rebuild the domains */ - partition_sched_domains(ndoms, doms, attr); + partition_and_rebuild_domains(ndoms, doms, attr); out: put_online_cpus(); } diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 755bd3f1a1a9..ba64a5b8f40b 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -2214,6 +2214,37 @@ void __init init_sched_dl_class(void) GFP_KERNEL, cpu_to_node(i)); } +void dl_add_task_root_domain(struct task_struct *p) +{ + unsigned long flags; + struct rq_flags rf; + struct rq *rq; + struct dl_bw *dl_b; + + rq = task_rq_lock(p, &rf); + if (!dl_task(p)) + goto unlock; + + dl_b = &rq->rd->dl_bw; + raw_spin_lock_irqsave(&dl_b->lock, flags); + + dl_b->total_bw += p->dl.dl_bw; + + raw_spin_unlock_irqrestore(&dl_b->lock, flags); + +unlock: + task_rq_unlock(rq, p, &rf); +} + +void dl_clear_root_domain(struct root_domain *rd) +{ + unsigned long flags; + + raw_spin_lock_irqsave(&rd->dl_bw.lock, flags); + rd->dl_bw.total_bw = 0; + raw_spin_unlock_irqrestore(&rd->dl_bw.lock, flags); +} + #endif /* CONFIG_SMP */ static void switched_from_dl(struct rq *rq, struct task_struct *p) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index eeef1a3086d1..cfd3b5b5fe7f 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -650,9 +650,6 @@ struct root_domain { unsigned long max_cpu_capacity; }; -extern struct root_domain def_root_domain; -extern struct mutex sched_domains_mutex; - extern void init_defrootdomain(void); extern int sched_init_domains(const struct cpumask *cpu_map); extern void rq_attach_root(struct rq *rq, struct root_domain *rd); diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 58133f2ce889..3522dfc2566f 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -2,6 +2,7 @@ * Scheduler topology setup/handling methods */ #include +#include #include #include #include @@ -1862,8 +1863,19 @@ void partition_sched_domains_locked(int ndoms_new, cpumask_var_t doms_new[], for (i = 0; i < ndoms_cur; i++) { for (j = 0; j < n && !new_topology; j++) { if (cpumask_equal(doms_cur[i], doms_new[j]) - && dattrs_equal(dattr_cur, i, dattr_new, j)) + && dattrs_equal(dattr_cur, i, dattr_new, j)) { + struct root_domain *rd; + + /* + * This domain won't be destroyed and as such + * its dl_bw->total_bw needs to be cleared. It + * will be recomputed in function + * update_tasks_root_domain(). + */ + rd = cpu_rq(cpumask_any(doms_cur[i]))->rd; + dl_clear_root_domain(rd); goto match1; + } } /* No match - a current sched domain not in new doms_new[] */ detach_destroy_domains(doms_cur[i]); From patchwork Wed Aug 16 21:20:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 110280 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1323380qge; Wed, 16 Aug 2017 14:21:01 -0700 (PDT) X-Received: by 10.99.8.194 with SMTP id 185mr2876994pgi.273.1502918461056; Wed, 16 Aug 2017 14:21:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502918461; cv=none; d=google.com; s=arc-20160816; b=F4jEGRDWfWz46dJvtLiM7IuWRk1X6j3/RpZOccbIlkYCdmgM7Sb4Coiasv3JeV7+Rk TsQgpwrEDZi0ox1d9kSLwXHlVrd1gUXK8ymU0qxTu6OVRg50IwwVR39QvVPTMOx4xLo5 oI9JpEaOhB4Jynb8J7r6nsl+UWXvLrHy8tCar5HnfsVW6l7JjUvJc8MHV1QsWkSWVQfA jMXOPxcUYmIGxn38oST5n9PV8rpud83VL8JfUBZQ0ouxO9qyPz/kG9zvNXTXj3j29xzg QyIjJsUlp/6xjiR8m5bjRz7AVqrLbN2XyE7eEVCTNL+KmESN3t7Lem2xKbktTYi4PWbr Oezg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=QeJmxk+PFZ/Zq+5ovG1dI5IeCKluOyAxo20TVy5b650=; b=UYhmR3zKWQLnna+CULGZYRHj/yYSe+yXytvkeJsEy+y5kFblB9foKSn4L/pgblsfJz q2uPDGG0qWTnqmv7wYMuWarRwYZb/g00ojh9GAwhjsX8qr6MI0/mgEPm3/Y9cvvBXRiL h7BbDoGoROW1MojuNIDKCtYyO/95Zjicyo0Jc0ZPumIDXtfhdUjoVVOOA3m6vGf+YYHN XLEkQuSUuxbEco7Oa9S0zl5bQuxbR7nc29enPa9deat2J5rs1RFRTV0MvngF/ND7ZoGR JUvnT5DoeyhcQEmxrVIua+5r1GBTSMzgeIoP6jOG1fGWJacMeNA30VqJumqhM6Z1AcZM VpjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q4o99BBs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p81si1043425pfd.11.2017.08.16.14.21.00; Wed, 16 Aug 2017 14:21:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q4o99BBs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752555AbdHPVU5 (ORCPT + 26 others); Wed, 16 Aug 2017 17:20:57 -0400 Received: from mail-io0-f180.google.com ([209.85.223.180]:38472 "EHLO mail-io0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752488AbdHPVUy (ORCPT ); Wed, 16 Aug 2017 17:20:54 -0400 Received: by mail-io0-f180.google.com with SMTP id g71so17299611ioe.5 for ; Wed, 16 Aug 2017 14:20:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QeJmxk+PFZ/Zq+5ovG1dI5IeCKluOyAxo20TVy5b650=; b=Q4o99BBsColzz0xVTM/mMurf8EVhjTvc5xV5pzvRvVQJRfA4p87MMSLgosG53UEwua wkAnnmGGaeY0mcgmgaL7KjNcQkFnpawmj3wlvnWSkzyJPJySpgCAVwFcQlPjsjWFJj7o S3cCXRv5nFi7wcmrfveNfSYvXSQkfRJAhlzC0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QeJmxk+PFZ/Zq+5ovG1dI5IeCKluOyAxo20TVy5b650=; b=WS6o/iBfdnnb/aNmdScm+TPy+aMxtVAJAJMl//Nn+gEYAXqTnRPb86U5khbAPt0heF B4R/fcwzNB5GDiPJBXZZ0Y9IsuMsxQdr+/6NwBVLNv7t/NP3Ktoqnn8PJicKx660blDv Knk5KmEnsM02+0C5UUoWq5+vTIgZTnnobE/4fwHNxmboRAHt5+ZO/y4m2RQjoiCVrw2W 41DZZXWsccgHFAd7RR2F28cgCXYyWRLZDlstOcMT6D/VRd9F8+ko0EgeHG3eU0ZpaNWC pVyxGlIrWBo+Sro85Dx2fGSZ5KW4bXpZzs/VI8NMDy4clfkQQ5vnyyP+UHfTD9olZhu7 C9UA== X-Gm-Message-State: AHYfb5ja6LnRctx25vI2fMI/LHSyr1R90/QscpdWbUicM7Vl0jCtJt7L lP8dmNsaAF05WcKc X-Received: by 10.107.28.78 with SMTP id c75mr2662028ioc.282.1502918453336; Wed, 16 Aug 2017 14:20:53 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id 80sm918281itk.11.2017.08.16.14.20.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Aug 2017 14:20:52 -0700 (PDT) From: Mathieu Poirier To: mingo@redhat.com, peterz@infradead.org Cc: tj@kernel.org, vbabka@suse.cz, lizefan@huawei.com, akpm@linux-foundation.org, weiyongjun1@huawei.com, juri.lelli@arm.com, rostedt@goodmis.org, claudio@evidence.eu.com, luca.abeni@santannapisa.it, bristot@redhat.com, linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org Subject: [PATCH 3/7] sched/deadline: Keep new DL task within root domain's boundary Date: Wed, 16 Aug 2017 15:20:39 -0600 Message-Id: <1502918443-30169-4-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502918443-30169-1-git-send-email-mathieu.poirier@linaro.org> References: <1502918443-30169-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When considering to move a task to the DL policy we need to make sure the CPUs it is allowed to run on matches the CPUs of the root domains of the runqueue it is currently assigned to. Otherwise the task will be allowed to roam on CPUs outside of this root domain, something that will skew system deadline statistics and potentially lead to over selling DL bandwidth. For example say we have a 4 core system split in 2 cpuset: set1 has CPU 0 and 1 while set2 has CPU 2 and 3. This results in 3 cpuset - the default set that has all 4 CPUs along with set1 and set2 as just depicted. We also have task A that hasn't been assigned to any CPUset and as such, is part of the default CPUset. At the time we want to move task A to a DL policy it has been assigned to CPU1. Since CPU1 is part of set1 the root domain will have 2 CPUs in it and the bandwidth constraint checked against the current DL bandwidth allotment of those 2 CPUs. If task A is promoted to a DL policy it's 'cpus_allowed' mask is still equal to the CPUs in the default CPUset, making it possible for the scheduler to move it to CPU2 and CPU3, which could also be running DL tasks of their own. This patch makes sure that a task's cpus_allowed mask matches the CPUs in the root domain associated to the runqueue it has been assigned to. Signed-off-by: Mathieu Poirier --- kernel/sched/deadline.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index ba64a5b8f40b..2c0405d74367 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -2474,6 +2474,7 @@ int sched_dl_overflow(struct task_struct *p, int policy, const struct sched_attr *attr) { struct dl_bw *dl_b = dl_bw_of(task_cpu(p)); + struct root_domain *rd = cpu_rq(task_cpu(p))->rd; u64 period = attr->sched_period ?: attr->sched_deadline; u64 runtime = attr->sched_runtime; u64 new_bw = dl_policy(policy) ? to_ratio(period, runtime) : 0; @@ -2484,6 +2485,19 @@ int sched_dl_overflow(struct task_struct *p, int policy, return 0; /* + * By default a task is set to run on all the CPUs the system + * knows about. This is fine for as long as we don't deal with cpusets + * where runqueues are split between root domains. The computation + * below is based on root domain information, as such the task must be + * constrained to run within that root domain. It is the user's + * responsability to constrain the task to specific CPUs by either + * assigning the task to a cpuset or run the taskset utility. Here we + * simply make sure things are coherent. + */ + if (!cpumask_equal(&p->cpus_allowed, rd->span)) + goto out; + + /* * Either if a task, enters, leave, or stays -deadline but changes * its parameters, we may need to update accordingly the total * allocated bandwidth of the container. @@ -2518,7 +2532,7 @@ int sched_dl_overflow(struct task_struct *p, int policy, err = 0; } raw_spin_unlock(&dl_b->lock); - +out: return err; } From patchwork Wed Aug 16 21:20:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 110284 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1324139qge; Wed, 16 Aug 2017 14:21:51 -0700 (PDT) X-Received: by 10.99.37.6 with SMTP id l6mr2763535pgl.407.1502918511581; Wed, 16 Aug 2017 14:21:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502918511; cv=none; d=google.com; s=arc-20160816; b=DA0Vf+yjBSIir602dQXiFxm+y5ox1YhrgTL1Ggta+a39M6cY3GNMD4L5gM74KBpq4J kr4xRnbgQ04GE5Pjm2lP0MSGIr49dMHE6jTKIjbp07nY9FHDGDwOzlxGyXYD1zZh/hSE pcgZRNEinjGFQGbP0ZbrphMOGC1xG2IWfyutDaOB8Fv9fpArliINS3VpBZTyWiNqznh/ R0ApEnnWjPU/Tpoiiq+NHkD0WdGBUPM9x1UuzXfFuUDHQVAo9FbD6iFwJqkfqFUTGNy+ ZtZA6P6LnX5kKCwl2TbamGMWh5bFO8swTzqV6Gg+dpLRUgmqcfvLKWZJ+VuCdm9tvUE4 4o5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=K8/rSTPEOkMaV2XKAw16f6bLQEjuL/boke6ZWKVKJfY=; b=CNOQMRtxgdfpOQ/LWA8x0pFEoNzANssDTURilWHHGYud34WcHpZ3zCIp6FewrSj6M5 ZvrqySzE1XV0XS/7UIlkziyfVQCDgkX2HUH218mJR7MT9WyASykAAe4UPJm04TMPTpMp OuUEdeK0+kQ8iv0oiRvt/1nUYk4J3cgwMbBgKKNJiGuB0Ei3JUwgmh2qkijTEtP8d7Xq S32MQQhq/YYFz5NsfVtCPe/9vezeUuYiSE/Y3MbmYghgmgEY64MLjKroLnBPAeXylN+e BW6y6FDwOJCczb0M8xKBpx4TX8b0KysUGOW7UESYi5vBjm9sX9T2R/ZHT8vulcq7xaAW 4zgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZW4cjS3E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r13si1113480plj.167.2017.08.16.14.21.51; Wed, 16 Aug 2017 14:21:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZW4cjS3E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752666AbdHPVVt (ORCPT + 26 others); Wed, 16 Aug 2017 17:21:49 -0400 Received: from mail-io0-f180.google.com ([209.85.223.180]:35593 "EHLO mail-io0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752495AbdHPVU4 (ORCPT ); Wed, 16 Aug 2017 17:20:56 -0400 Received: by mail-io0-f180.google.com with SMTP id m88so17262455iod.2 for ; Wed, 16 Aug 2017 14:20:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=K8/rSTPEOkMaV2XKAw16f6bLQEjuL/boke6ZWKVKJfY=; b=ZW4cjS3EuCjZ+ZjkSRmXrFLdjj2sGnV/XOXYFtmhfk76XBt4vKOMCRY65v2DupQhbw M0cUrhXiW0cullQJWNmNaoTSf3EV8kCuhVhreV1rWreA4KZdoaMQxAxpgK1PMMnCqq68 wa9ZMMtIRDivaodfAGDu4cyRMSjHVbaomUle4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=K8/rSTPEOkMaV2XKAw16f6bLQEjuL/boke6ZWKVKJfY=; b=JbYw184jBCje3etYwdQkRPJIdpXMUYhRe+9kCI90d4bcIZXE81A2X7DRqDlFVc3Ekh TPmB0MCLgUfEj7nQuKl+ZzgbKf+3FO9wFco/rvwf0OLdM/GWnfaw0dH9SJBvcbPL84zz PBk7jblzz4roHUcF4DsSk2fEIPe2Rryk92Dfyxrvze+uoQ2twmC3FGR07mPlcG8lTtAT QjqXroLxsw2TVnKUe/Pxc55XKrodZRjlL5TpP5nJqtgXW4l5wTDfrSVauHmB8bP9Pj0O Xpfojg5glgoDim0qOugdqYCK2hEzUjJ8OUUp/rtlT+F7eHr5rNGFlZkQy1EuOhTy2xBm 3hpQ== X-Gm-Message-State: AHYfb5h0Iur6IBxLv/kZf168N0bVwwTmmSRNAPTVMKXYSQnePLw1xFxp MgMDdw9OWYJu/He9 X-Received: by 10.107.53.40 with SMTP id c40mr2923443ioa.289.1502918455510; Wed, 16 Aug 2017 14:20:55 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id 80sm918281itk.11.2017.08.16.14.20.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Aug 2017 14:20:54 -0700 (PDT) From: Mathieu Poirier To: mingo@redhat.com, peterz@infradead.org Cc: tj@kernel.org, vbabka@suse.cz, lizefan@huawei.com, akpm@linux-foundation.org, weiyongjun1@huawei.com, juri.lelli@arm.com, rostedt@goodmis.org, claudio@evidence.eu.com, luca.abeni@santannapisa.it, bristot@redhat.com, linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org Subject: [PATCH 4/7] cgroup: Constrain 'sched_load_balance' flag when DL tasks are present Date: Wed, 16 Aug 2017 15:20:40 -0600 Message-Id: <1502918443-30169-5-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502918443-30169-1-git-send-email-mathieu.poirier@linaro.org> References: <1502918443-30169-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch prevents the 'sched_load_balance' flag from being fippled off when DL tasks are present in a CPUset. Otherwise we end up with the DL tasks using CPUs belonging to different root domains, something that breaks the mathematical model behind DL bandwidth management. For example on a 4 core system CPUset "set1" has been created and CPUs 0 and 1 assigned to it. A DL task has also been spun off. By default the DL task can use all the CPUs in the default CPUset. If we set the base CPUset's cpuset.sched_load_balance to '0', CPU 0 and 1 are added to a newly created root domain while CPU 2 and 3 endup in the default root domain. But the DL task is still part of the base CPUset and as such can use CPUs 0 to 3, spanning at the same time more than one root domain. Signed-off-by: Mathieu Poirier --- kernel/cgroup/cpuset.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) -- 2.7.4 diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index f6d1e485dc2d..18df143b4013 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -447,6 +447,85 @@ static void free_trial_cpuset(struct cpuset *trial) kfree(trial); } +static bool cpuset_has_dl_tasks(struct cpuset *cs) +{ + bool dl_tasks = false; + struct css_task_iter it; + struct task_struct *task; + + /* Go through each task in @cs looking for a DL task */ + css_task_iter_start(&cs->css, &it); + + while (!dl_tasks && (task = css_task_iter_next(&it))) { + if (dl_task(task)) + dl_tasks = true; + } + + css_task_iter_end(&it); + + return dl_tasks; +} + +/* + * Assumes RCU read lock and cpuset_mutex are held. + */ +static int validate_dl_change(struct cpuset *cur, struct cpuset *trial) +{ + bool populated = false, dl_tasks = false; + int ret = -EBUSY; + struct cgroup_subsys_state *pos_css; + struct cpuset *cs; + + /* + * The cpuset.sched_load_balance flag is flipped off on + * the current cpuset. + */ + if (is_sched_load_balance(cur) && + !is_sched_load_balance(trial)) { + /* See if at least one descendant cpuset is populated */ + cpuset_for_each_descendant_pre(cs, pos_css, cur) { + /* Skip over ourselve */ + if (cs == cur) + continue; + + /* Empty cpusets are of no interest */ + if (cpumask_empty(cs->cpus_allowed)) { + pos_css = css_rightmost_descendant(pos_css); + continue; + } + + /* + * @cur has at least one children and CPUs have been + * assigned to it - there is no need to go further. + */ + populated = true; + break; + } + + dl_tasks = cpuset_has_dl_tasks(cur); + + /* + * This CPUset has a children that is populated by (at least) + * one CPU. When the sched_load_balance flag gets flipped off + * it will create a new root domain for the children CPUset, + * and that new root domain will include the CPUs assigned to + * the CPUset. + * + * Since the tasks in the current CPUset have not been assigned + * to the children CPUset they will simply stay here and use + * all the CPUs available in this set. For DL tasks this can't + * be allowed since they will be executing on CPUs associated to + * more than one root domains. + */ + if (populated && dl_tasks) + goto out; + } + + ret = 0; +out: + return ret; +} + /* * validate_change() - Used to validate that any proposed cpuset change * follows the structural rules for cpusets. @@ -481,6 +560,9 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial) if (!is_cpuset_subset(c, trial)) goto out; + if (validate_dl_change(cur, trial)) + goto out; + /* Remaining checks don't apply to root cpuset */ ret = 0; if (cur == &top_cpuset) From patchwork Wed Aug 16 21:20:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 110281 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1323480qge; Wed, 16 Aug 2017 14:21:07 -0700 (PDT) X-Received: by 10.101.76.76 with SMTP id l12mr2790617pgr.161.1502918466880; Wed, 16 Aug 2017 14:21:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502918466; cv=none; d=google.com; s=arc-20160816; b=fEFHlNUtjbhsuKTJ88G1XvUKrcI9uAfDEePrq1gJdoX1/PSc5PYA5d7HHG6tzOhis9 /A5K2J16W3HQO+B2/fq+5CwWvFnW2fML7ZH+9Z3BPkZA8R6WViHJxEr4XGJdh7Aty7h8 j+dAxkUlKvOoEDS/bx/Y7PO6ngyaNa64OP84otPuHAYT++9XTdsV1fC19T/HZApl6SGK nMgSvRLCVjdTZiBPPDz1ayiYeSfe63irHdxA78AbkwU1KAs2oxOHHRYPUWYXgRWSAGv9 DmxU7RLdDbKScRlSVmOPky0GN+fnKQM9HyCo+qQFzqexP9PBA4MnjJzs+s42BzySVXLH 6AEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=ePka7MoBqX4VPf4SeuVO6yFK+ih1iNTydl0uFRIkVgc=; b=sgI4Sa8K3RFAgjsgNNO+VyxhOVZv3AdQnEVw5j/CuDFrrVL0UfIlreax90wmjZILN4 HPagnrFo/YLHku/RPkiulE9O8OLxiY/JPc62YwAieKnCqHQlExGVxmvy0LnjM1OtcOuy C6Z6GP4NVydFiSD+llT+uVfnAokfnwyiwDWM8z3qx1LgHAfqTigTUizTdGQp20bog+kF dAB6B8Ne6ugm3t2A7PhBFvm3vfxb9+29hFWiFf+CTt37cy+UP2Urtwr9tqaqLq14bybY N6Xuflt6eseN4V/ZJ0KtRSXLZcbKGMqZZVKq8poZWxa20QkLGnEIFFSOFZR6vEOmoZpD rd/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NyhYqAjJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p81si1043425pfd.11.2017.08.16.14.21.06; Wed, 16 Aug 2017 14:21:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NyhYqAjJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752588AbdHPVVC (ORCPT + 26 others); Wed, 16 Aug 2017 17:21:02 -0400 Received: from mail-io0-f175.google.com ([209.85.223.175]:33813 "EHLO mail-io0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752488AbdHPVU6 (ORCPT ); Wed, 16 Aug 2017 17:20:58 -0400 Received: by mail-io0-f175.google.com with SMTP id o9so17467527iod.1 for ; Wed, 16 Aug 2017 14:20:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ePka7MoBqX4VPf4SeuVO6yFK+ih1iNTydl0uFRIkVgc=; b=NyhYqAjJv/eRbdyw1xvabGeHCe7yEyqv5jy5PerhGd00FQkN/qeOZ9KpsJeq7yHPK2 vw0MEkx3BR+bHCMNzN2YK55juEeJV2KYutMe/G/KPtMJvLAet1KilBOdjIn7AHWDx0X6 hMKh+lEXIa0e82Qu4BBWUk4J6vIAvYzEW+uWE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ePka7MoBqX4VPf4SeuVO6yFK+ih1iNTydl0uFRIkVgc=; b=orb/NA30hWbz28QfqaZJk0y+ziDdChIxGWuzgeioEFvzgTRsXjVUUoIFjfNnE+WscO tQudMRO09pVwHsr3W85UVTEdoJOa+eFd3tlwwMF+QTq5YKPWlsPZ3XZ4nGbVmuzN4mdY 2Zq3NjW3mlmk3wnKNRqh9FSNJNLEvcKtmHFOiznv5486O2O3AhoX76DX5h2UNhsql8kc MtUy6QwtjGXRUbVuReqKV5XjSyDumgXfkuIyXzdrjVdx6TrMl+Q6izbdwsXtGfQjG26D FKuwoOZ/+S/Ce77sD2NGalJkdlW9LN8meNR6IcRwbqLy8Voq632u64B4Rk/VGG+h6xR3 acqA== X-Gm-Message-State: AHYfb5ggytr9I912+O6Ov4DO6+5HszZZ4yNcTSoUtyua5HHY+CPoSv/O SKo4Ie4OqBD3/iksjoOU8A== X-Received: by 10.107.59.19 with SMTP id i19mr2615164ioa.96.1502918457949; Wed, 16 Aug 2017 14:20:57 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id 80sm918281itk.11.2017.08.16.14.20.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Aug 2017 14:20:56 -0700 (PDT) From: Mathieu Poirier To: mingo@redhat.com, peterz@infradead.org Cc: tj@kernel.org, vbabka@suse.cz, lizefan@huawei.com, akpm@linux-foundation.org, weiyongjun1@huawei.com, juri.lelli@arm.com, rostedt@goodmis.org, claudio@evidence.eu.com, luca.abeni@santannapisa.it, bristot@redhat.com, linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org Subject: [PATCH 5/7] cgroup: Concentrate DL related validation code in one place Date: Wed, 16 Aug 2017 15:20:41 -0600 Message-Id: <1502918443-30169-6-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502918443-30169-1-git-send-email-mathieu.poirier@linaro.org> References: <1502918443-30169-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Having two different places to validate DL operations makes no sense. As such move everything in the same function. Signed-off-by: Mathieu Poirier --- kernel/cgroup/cpuset.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) -- 2.7.4 diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 18df143b4013..8d2ba5591dfb 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -477,6 +477,15 @@ static int validate_dl_change(struct cpuset *cur, struct cpuset *trial) struct cpuset *cs; /* + * We can't shrink if we won't have enough room for SCHED_DEADLINE + * tasks. + */ + if (is_cpu_exclusive(cur) && + !cpuset_cpumask_can_shrink(cur->cpus_allowed, + trial->cpus_allowed)) + goto out; + + /* * The cpuset.sched_load_balance flag is flipped off on * the current cpuset. */ @@ -606,16 +615,6 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial) goto out; } - /* - * We can't shrink if we won't have enough room for SCHED_DEADLINE - * tasks. - */ - ret = -EBUSY; - if (is_cpu_exclusive(cur) && - !cpuset_cpumask_can_shrink(cur->cpus_allowed, - trial->cpus_allowed)) - goto out; - ret = 0; out: rcu_read_unlock(); From patchwork Wed Aug 16 21:20:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 110283 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1323875qge; Wed, 16 Aug 2017 14:21:33 -0700 (PDT) X-Received: by 10.98.197.70 with SMTP id j67mr2872306pfg.319.1502918493875; Wed, 16 Aug 2017 14:21:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502918493; cv=none; d=google.com; s=arc-20160816; b=A9TNAvRIhKwmyaXla327+8eQG3BtEhuVS7DKMGHShdgekdE/Ncr9oGbUpK+TQUFP/p mROHhU1PWGKjV5qU7VvQh3etkaUTpH+hUoxBxqK/5YjP4+PQkzrs4Q0MoczQ3BXvoPlT c2hKFMH7dmZBlOgCTEkeCH445Ld9IrUtLPwuBfJKL61O9giCR7hFWwPQrM6EcCrHYfnT mm1jIY0rjw7aeMk5jbPhJnSyY63+PWqJXmzPjo279+xPg2/LRpusLfnNkBakREs/BmrW EYG1oiVD8wQYLlm1xB6LlLueS4F8HcSI0vFwrdKG0bp/G0QCkg0B61KtcxnVpCNMUYuh z7TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=CA101HbjwGS/L04BuqPfXwSu0gs0iWBxn7UO5TeOZGw=; b=i7e5o+tyxQz6jr4lYQRtwHFUOTZbxp/ao51to4IgE4l/FqQ3+Mozl+kceJ1BgdMWdV ZYQkt2lkG5XpTeofdim2mk/FDbMUe1AXShO6ytFHYVn9wCWYBiCDTh0XatWYobIW1QWk hVx/14VFbYrza7OIvuBXqU7VQajKp/XDfHYzlSCzN5qcdoOgYm5OddcjoAmlAJ+0r932 oKr5aCbPMVcBNJEmrIrhYCtlPWTJDeEqdL36Aq3ttfhfbBToKn0m3JGnKdetuSVry3Gm 6avdMpik1ohv+a6baXUznLPnAfpMMN7gdQ0BRLogGJgGBLUnse4b6VxriX5VlevG2+I3 6WtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cpzZn7X4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t8si1036974pfe.331.2017.08.16.14.21.33; Wed, 16 Aug 2017 14:21:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cpzZn7X4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752642AbdHPVVa (ORCPT + 26 others); Wed, 16 Aug 2017 17:21:30 -0400 Received: from mail-io0-f177.google.com ([209.85.223.177]:33820 "EHLO mail-io0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752561AbdHPVVA (ORCPT ); Wed, 16 Aug 2017 17:21:00 -0400 Received: by mail-io0-f177.google.com with SMTP id o9so17467778iod.1 for ; Wed, 16 Aug 2017 14:21:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CA101HbjwGS/L04BuqPfXwSu0gs0iWBxn7UO5TeOZGw=; b=cpzZn7X4bUDeVitg/ida2LpLmzuXHpq1Jtm28g3kv/LC97iXV4F6/GpRFUNa8pmimO 9YIh2tBnG+RWZRs/9+kG2i/CNnHA2TRl8FSdc1rJBNICne0VWee4mwsYT+cHl8q2B7Li PiFsxBfi50HbnlNTBomnbVb2BhRe90yjGJAzM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CA101HbjwGS/L04BuqPfXwSu0gs0iWBxn7UO5TeOZGw=; b=Fv/q2rxPn+HR5FJoozGnFbNqgrWlXlyYyaKJMZ2sQB6Mnx16/1ldBadR9aOCiJtON+ d2GINy0MBIhrvoAp2F94HKKi0gQUXolHH1mLfaVHWmjxRk0ue91KPVh/V4Cq3UmBgVBK vRH2BNKtv2jFfp+Xoot7/eds5tUyUG+TpQgoCaIOd7fylQ8fnUoeS58BBHvyRjEqm4ko Y1ORK8SK85juviQ8+obDbx7rk/Oaozl5kOdZNA11SNQt/wuVZ8Lk/naCFUt/+viBynHm OoTDMDivyZCXSi4+JYMzFp1bJ0q6xhuLKZTFr2Aq+P9EcnDXqqQzuGVq7xVtPPADaYoD uhZw== X-Gm-Message-State: AHYfb5jYrYGsA8L9MsGskaJgiaM/c+fXQgDgnd/L4boSkMdOnHjLNS+a pSRxLkPgXt4dnaLU X-Received: by 10.107.145.3 with SMTP id t3mr2852439iod.16.1502918460146; Wed, 16 Aug 2017 14:21:00 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id 80sm918281itk.11.2017.08.16.14.20.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Aug 2017 14:20:59 -0700 (PDT) From: Mathieu Poirier To: mingo@redhat.com, peterz@infradead.org Cc: tj@kernel.org, vbabka@suse.cz, lizefan@huawei.com, akpm@linux-foundation.org, weiyongjun1@huawei.com, juri.lelli@arm.com, rostedt@goodmis.org, claudio@evidence.eu.com, luca.abeni@santannapisa.it, bristot@redhat.com, linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org Subject: [PATCH 6/7] cgroup: Constrain the addition of CPUs to a new CPUset Date: Wed, 16 Aug 2017 15:20:42 -0600 Message-Id: <1502918443-30169-7-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502918443-30169-1-git-send-email-mathieu.poirier@linaro.org> References: <1502918443-30169-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Care must be taken when CPUs are added to a new CPUset. If an ancestor of that set has its sched_load_balance flag switch off then the CPUs in the new CPUset will be added to a new root domain. If the ancestor also had DL tasks those will end up covering more than one root domain, breaking at the same time the DL integrity model. This patch prevents adding CPUs to a new CPUset if one of its ancestor had its sched_load_balance flag off and had DL tasks assigned to it. Signed-off-by: Mathieu Poirier --- kernel/cgroup/cpuset.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) -- 2.7.4 diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 8d2ba5591dfb..fb38feaf3fda 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -530,6 +530,28 @@ static int validate_dl_change(struct cpuset *cur, struct cpuset *trial) goto out; } + /* + * CPUs are being added to a CPUset. If any parent of @trial has its + * sched_load_balance flag switched off this operation will create a + * new root domain spanning trailcs->cpus_allowed. At the same time + * if any parent of @trial has a DL task, that task will end up + * spanning more than one root domain. + */ + if (cpumask_empty(cur->cpus_allowed) && + !cpumask_empty(trial->cpus_allowed)) { + struct cpuset *parent; + + parent = parent_cs(trial); + /* Go up until we reach the top_cpuset */ + while (parent) { + if (cpuset_has_dl_tasks(parent) && + !is_sched_load_balance(parent)) + goto out; + + parent = parent_cs(parent); + } + } + ret = 0; out: return ret; From patchwork Wed Aug 16 21:20:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 110282 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1323558qge; Wed, 16 Aug 2017 14:21:11 -0700 (PDT) X-Received: by 10.84.210.165 with SMTP id a34mr3204293pli.478.1502918471156; Wed, 16 Aug 2017 14:21:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502918471; cv=none; d=google.com; s=arc-20160816; b=YGwY2VkkaAJRtzbxkt2amCcY/rNiFsIW+aePg81GeMgdFJJbjn55g7QE6qVZSjJnTG mMR7jwdHpy/QdH6iAzgtKOP50BVLJ3VhSArsmi98nA/0C0UzuMOkEgeWRvHxy7ywXszH omZjeaCCEitaB27nffGltvMmKQX4++5ZlUaXPQZhrIhAhHmpryIrqAN3i4+Wu5miCvUR Z5aEGIfAxxN5Y2cJUnNiFqmdqvlvoTr7uirDHPDzbqtb6r8vBdAeGhMIr8Dam0gMX+W0 NCLGVdqhguIfE5ieF/2+coDx5dpGIPGA6S+BkBQvGg1oGyYc/mrn3aykNY4Kk3NOFXzV 2r0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=st88wpeLOIoulo26dBXbcumaT8k6YLu4JnjG+AFEht0=; b=BCxF1mnArWN0wFtVcBnidWlHFl76t12CjOMb8VZmzpcq/CbkNznGe9GJKnN0QMiYwZ 6RjvwB8ByzDr6Yq/ti9sNpOsjnkLTUVi4zlMSXGmdZxV6+1X2zZOCPPYRWH7B1+5w3A9 gs4+sUHvpdP+RUfLLWGF9L8/20kF3WbcUcRPgWRHBxSh/0XjUqu3X1LroLcxQl9ewx55 U6sscx4pufZg4KTjF6Hsk6NwYebcP/VF7L4zsGszKKWXGE3HdLNOKLJc/q2JyAN8A40f 18QCIYo2E6pRiFSnW+U3YMnW7+hI7PIEsUgB7t8EyY2zcXjwo0pe1fKpVE+xSxoBoknD fxNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MiSbYqhM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t8si1036974pfe.331.2017.08.16.14.21.10; Wed, 16 Aug 2017 14:21:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MiSbYqhM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752617AbdHPVVG (ORCPT + 26 others); Wed, 16 Aug 2017 17:21:06 -0400 Received: from mail-it0-f53.google.com ([209.85.214.53]:34935 "EHLO mail-it0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752488AbdHPVVD (ORCPT ); Wed, 16 Aug 2017 17:21:03 -0400 Received: by mail-it0-f53.google.com with SMTP id 76so23295694ith.0 for ; Wed, 16 Aug 2017 14:21:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=st88wpeLOIoulo26dBXbcumaT8k6YLu4JnjG+AFEht0=; b=MiSbYqhMyJhfBfR6DT4od99FbR9h6X+uCH0J+yn04IrBAMxnHrs6QssqRnPIo56aO9 XvjD0MFkDdj7vxtwjIoeFikZsCR8cKWRCyeH6gSZX2tdyhitlm2ZSKdHVn5DZeM4djE9 UcjVEdOWlwPStEuknlpS41+T/ACBujNmhYxjM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=st88wpeLOIoulo26dBXbcumaT8k6YLu4JnjG+AFEht0=; b=gdsFrtDTD6eodZk8Yl4E4K4MIHI7xZkZHRK+G1e/YH8iFKUZH4L+8msB/FPa2I+x3r oS1dfs1zA6+s9fSmkTG1ImeKcJcz9NANFvSyCd03LVP6XXreiy6OXa/PKhr99T6izkRU Hv/EXjZNo0381S8pbGlvU7+5qDe2FwS26PDyJM8aulFnqaP6q8wG3PfFzo7zRjRebCig MKnWVonjDTIGq+/cU4QZQ0LaADX4jFsO4hRqevE42Uda02RAOg2XruyRXipaDL5Knvn+ e6ni7iHNusUc0SwT6KDWrEKFptwsdbPDAwaH4sZq99qhMPuDPOW76J+7c5k7MHmx/cXc wOgw== X-Gm-Message-State: AHYfb5j3Qpox5uhBOOiG5zl04JbfDYPejhrWZ9RmFpCqJIambNvLoDrp u81vPciugPSyeWKL X-Received: by 10.36.195.196 with SMTP id s187mr427622itg.112.1502918462631; Wed, 16 Aug 2017 14:21:02 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id 80sm918281itk.11.2017.08.16.14.21.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Aug 2017 14:21:01 -0700 (PDT) From: Mathieu Poirier To: mingo@redhat.com, peterz@infradead.org Cc: tj@kernel.org, vbabka@suse.cz, lizefan@huawei.com, akpm@linux-foundation.org, weiyongjun1@huawei.com, juri.lelli@arm.com, rostedt@goodmis.org, claudio@evidence.eu.com, luca.abeni@santannapisa.it, bristot@redhat.com, linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org Subject: [PATCH 7/7] sched/core: Don't change the affinity of DL tasks Date: Wed, 16 Aug 2017 15:20:43 -0600 Message-Id: <1502918443-30169-8-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502918443-30169-1-git-send-email-mathieu.poirier@linaro.org> References: <1502918443-30169-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that we mandate that on creation, the ->cpus_allowed mask of a future DL task has to be equal to the rd->span of the root domain it will be associated with, changing the affinity of a DL task doesn't make sense anymore. Indeed, if we set the task to a smaller affinity set then we may be running out of CPU cycle. If we try to increase the size of the affinity set the new CPUs are necessarily part of another root domain where DL utilation for the task won't be accounted for. As such simply refuse to change the affinity set of a DL task. Signed-off-by: Mathieu Poirier --- kernel/sched/core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 0869b20fba81..a1948d127d8f 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4629,15 +4629,15 @@ long sched_setaffinity(pid_t pid, const struct cpumask *in_mask) cpumask_and(new_mask, in_mask, cpus_allowed); /* - * Since bandwidth control happens on root_domain basis, - * if admission test is enabled, we only admit -deadline - * tasks allowed to run on all the CPUs in the task's - * root_domain. + * Since bandwidth control happens on root_domain basis, if admission + * test is enabled, we don't allow the task' CPUs to change. If + * @new_mask is smaller than we risk running out of cycles. If it is + * bigger than we may be using DL bandwidth allocated to other CPUs. */ #ifdef CONFIG_SMP if (task_has_dl_policy(p) && dl_bandwidth_enabled()) { rcu_read_lock(); - if (!cpumask_subset(task_rq(p)->rd->span, new_mask)) { + if (!cpumask_equal(task_rq(p)->rd->span, new_mask)) { retval = -EBUSY; rcu_read_unlock(); goto out_free_new_mask;