From patchwork Thu Feb 1 16:51:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 126560 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1879107ljc; Thu, 1 Feb 2018 08:52:42 -0800 (PST) X-Google-Smtp-Source: AH8x224UkFG/UxMCzAPiBka0bZ+Z/yihgEqyDNYMLxwK5mTwRgk8lTk5Ni11/9ve+hNVVdfaqAJK X-Received: by 2002:a17:902:b595:: with SMTP id a21-v6mr12168687pls.253.1517503962420; Thu, 01 Feb 2018 08:52:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517503962; cv=none; d=google.com; s=arc-20160816; b=AM7di/jgRwREq1+QuKT/T/hK3Aw0AjlNbW2rldFdhANTPLDH25sPSWAoS051JKXNb1 1rJQkyZwlmCgHyjlDUiPYyPpsG8i4Bk53eJfOlzUUXzUTVsSJ1Px79sbx17gayMvZWjg +Yk80QMtaCBZ5oHpUTj/iGQwcr0Jt0x5PB/nzKrwuQCzSvWq40Ih/y3/ubWAtxj4KKZK cejTU5H92L1L//tmOPxSjywp2BNS69Rx06skuE3Mp8FyqFvMIz4yKX3VevEhw1KUZ7+/ /cVhym0WJqQ5lGGxfOgUjLEh4X0XVNat0DyFYKBmJzYK2VOXrYS/N/3tDTuQtJmbm6b0 g2/A== 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=E3/l3qaIHVNvvwCkSVFxDR1ltO2nXjxvm+6TXtxZcrE=; b=vN5U2ed8bjzDsZJ8IavUm47SRjC76PBExOF01YeY0LecHkLOniPizR0e0BgkY2lp9Y YSbYhLAOk9kKM2+cp3D0LD9NGW/5/F8oX0VlO/SbNznggC/n37r6emrCex/Kw5iXJ2IS NT1Mcy+Y/Y0DCt3oxw/KuvZpFuf2ySKGlNRnQXGdtE879iz+pp0gNwnYI4+Kppj3J0Ii EDAIGzqduHNowiwYYrKHDOVt7ZT+tK1x00PQ3rMLGlqxDfxuwqKVZ3BkzxEnruxn2II8 fzvwXNyzRp9CnTu9BWy4g3EfMUlefDw/OWNZDXHrj563+/Trhp+qff120BssVrpOU4T5 K8lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MZFo4wvL; 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 d5si1575810pgn.564.2018.02.01.08.52.42; Thu, 01 Feb 2018 08:52:42 -0800 (PST) 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=MZFo4wvL; 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 S1752638AbeBAQwl (ORCPT + 28 others); Thu, 1 Feb 2018 11:52:41 -0500 Received: from mail-it0-f68.google.com ([209.85.214.68]:33709 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752789AbeBAQvV (ORCPT ); Thu, 1 Feb 2018 11:51:21 -0500 Received: by mail-it0-f68.google.com with SMTP id u12-v6so536027ite.0 for ; Thu, 01 Feb 2018 08:51:21 -0800 (PST) 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=E3/l3qaIHVNvvwCkSVFxDR1ltO2nXjxvm+6TXtxZcrE=; b=MZFo4wvLbhRVrZrxhH0SM3QROum/1iXpXMxbduVeWDMRelR6vIbl1NZvgmp8fHptN1 KcZrQQYg3DtVW/q+wa20bqnZ6wdnNrt5c5g5BHiAnAkzJ2iWgn/T4ecyYtcy6WpV0Ao9 mgyqNKPh/7o8SQvnzrVZgWM/lU7TQCw6Qf8kM= 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=E3/l3qaIHVNvvwCkSVFxDR1ltO2nXjxvm+6TXtxZcrE=; b=hdW63qGoQYTUEefl9fliZiyXClfUcRNKep8rOjRBAFQUm6jKE7hFW827y8zwMbXrqq k0U+GjO7FIPwRv9Z5PCjZjfx1XjfjHbXyJRUd4l5TVvY8R7hRaK+mh0Bpju65TB2wFWc w+9rR51ikwb4UQcT+Eh/p6q0l9EJtWSi02nr0mam7YkzNJzdS+jb+hgGbO29Z2donYV2 01z2Gk/nrhfzVgG513yV2pjFFFuUZ6+Qy6tKL0qhCHEGF3+YNkMLy4UNbhK7KpSJgaRa pyUARWkttw9zffCrUxMc1myyCGj+/id/UPBuTGT+YaPL6x2wB3gfeBZpU4G8ZnvMopIs Fd9w== X-Gm-Message-State: AKwxytcbS5J+vSMZHH+BPIr5iK91LjyWDj11BuW8P2ObXJqlBdkof7AH wnYl9vgrNRSZza8pBgt6U93RIg== X-Received: by 10.36.60.140 with SMTP id m134mr40316401ita.146.1517503881130; Thu, 01 Feb 2018 08:51:21 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id e83sm9270773iof.71.2018.02.01.08.51.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Feb 2018 08:51:20 -0800 (PST) From: Mathieu Poirier To: peterz@infradead.org Cc: lizefan@huawei.com, mingo@redhat.com, rostedt@goodmis.org, claudio@evidence.eu.com, bristot@redhat.com, tommaso.cucinotta@santannapisa.it, juri.lelli@redhat.com, luca.abeni@santannapisa.it, linux-kernel@vger.kernel.org Subject: [PATCH V2 5/7] cgroup: Constrain the addition of CPUs to a new CPUset Date: Thu, 1 Feb 2018 09:51:07 -0700 Message-Id: <1517503869-3179-6-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517503869-3179-1-git-send-email-mathieu.poirier@linaro.org> References: <1517503869-3179-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 | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index daa1b2bc7e11..6ae4ad995e9e 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -481,6 +481,43 @@ static bool cpuset_has_dl_tasks(struct cpuset *cs) * Assumes RCU read lock and cpuset_mutex are held. */ static int +validate_change_cpus(struct cpuset *cur, struct cpuset *trial) +{ + int ret = 0; + + /* + * 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 trial->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 and break the deadline integrity + * model. + */ + if (cpumask_weight(cur->cpus_allowed) < + cpumask_weight(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)) { + ret = -EBUSY; + goto out; + } + + parent = parent_cs(parent); + } + } + +out: + return ret; +} + +/* + * Assumes RCU read lock and cpuset_mutex are held. + */ +static int validate_change_load_balance(struct cpuset *cur, struct cpuset *trial) { bool populated = false, dl_tasks = false; @@ -553,8 +590,13 @@ validate_dl_change(struct cpuset *cur, struct cpuset *trial) /* Check if the sched_load_balance flag has been changed */ ret = validate_change_load_balance(cur, trial); if (ret) - return ret; + goto out; + ret = validate_change_cpus(cur, trial); + if (ret) + goto out; + +out: return ret; }