From patchwork Tue Feb 13 20:32:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 128295 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp32493ljc; Tue, 13 Feb 2018 12:33:18 -0800 (PST) X-Google-Smtp-Source: AH8x227TwvGd8adbx2wl7zwVNtP0aNJ7/WihYsMUVk2IG6HoXWIxLnbsONadFTyT1DEXw7poDkX6 X-Received: by 2002:a17:902:a984:: with SMTP id bh4-v6mr2174479plb.95.1518553998012; Tue, 13 Feb 2018 12:33:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518553998; cv=none; d=google.com; s=arc-20160816; b=0vM3WmWCdGmA4QyeiCJndgUH48mtwB/eDYSQ1ZWLXkjA9npVnnOAwFvCOSYOQi7VDa cEzUXbN3MeIhV0lRR/eQ2cvsX6zISHgdxysLDUncenAruf16kIbRuM11b9FgRRMFbTDa rWMG5d+6C4Za2OZrYm0SytO3+JLIZHHWZCL+zHSj1qibeWWzQu5E0O1IgbLlLbO06fCf fwuVC52f/K6vjKIRKQmnW9Yh3Yssa+Bp1oW40b/+xnOvCXZjMM+uRlRchKkJSAFFUDK0 I10Tqq5XSE93CIKUUn842x4Ckb+lMecvDecIOB/v0G2rxdral2tlqaGIcklQ3XNMXIXn /egg== 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=oUUAzyuPxc2AWJT2EOSXQAEFlSz5Oal6yF3Vntlh3d8=; b=kRXy88/Fd1JLzklmMsmlBUlWTQkX9RZuH1mXIShZ2t9ASmqmL1lc1cM8+IdY/iroIw BDCZMYqX4d3UL9srHIjcFaSMOkMgCRZ61TblsTr4Vqup5+QEJCUveOV2Xe/bfUZTWCHV 3+BU9dOtmVvgbTmtEADoG9H34Mtb7ibPaAPmtmvLFnioB4JHcUVIX6OI6vSuRPCqrmZ/ AbFaGiS0E2b5uyH+xO5R2EXU0d9blgNblOurAvVX5JzTttUV5+VKSJXrFw0hIDJu/4pz DOAqaqk3RkTAnMdnyZ/24PdhBtc8f1/tNGWoVr1Es7GepJbBZeBMA5hJtkg/Zqw5j2qg tqFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fhvNaP3V; 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 g5si171289pgp.433.2018.02.13.12.33.17; Tue, 13 Feb 2018 12:33:17 -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=fhvNaP3V; 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 S965882AbeBMUdM (ORCPT + 28 others); Tue, 13 Feb 2018 15:33:12 -0500 Received: from mail-pl0-f68.google.com ([209.85.160.68]:41680 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965846AbeBMUdE (ORCPT ); Tue, 13 Feb 2018 15:33:04 -0500 Received: by mail-pl0-f68.google.com with SMTP id k8so7191043pli.8 for ; Tue, 13 Feb 2018 12:33:04 -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=oUUAzyuPxc2AWJT2EOSXQAEFlSz5Oal6yF3Vntlh3d8=; b=fhvNaP3VFNS+rKp8IezXtyq1ExfwA0JvnoeHnWOcdBYWAd9+76CSseGsgm/PHlqzvn tNSinUrTQ8VDhzOO7GUN2aCMgi2/Q+otsAcU9nj3To93RM6I+47a/zTHyQKdlX88xfYw qatqfzmWizXlTGteL+xWX+9YeyDoaP800lQf0= 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=oUUAzyuPxc2AWJT2EOSXQAEFlSz5Oal6yF3Vntlh3d8=; b=o2NzcDhmPgdc5ctEPkCSqts7QGDW8F5iDnKA1LKMcAA+tnPfHkW+TbxemW6o5e5kvg I70+aJ2XOdhJJ2G8tErXH4QWwZScOEtpTuMozsFTdJ8NtzNhoTe4gnOJ4gA7GOGOced4 cKYj/E6wofJmCcBqqa6UtdeDroZUEp6VQlRmMkwLnt750qKk5R0NdILfD+RJZMBVmb/d O9mCN4qjgJYAZuA7ffHnSLyoGwOBMy1SRS3iMVholEVRNmybtX+jZj8Ec6nKZuZkrwmO b+DjTtMdqXDbwVyutIF/upF6osJ1VVh17v24RVxD7k5Kl9Ft/F0We6nCytxxqMC6joxA Ys3w== X-Gm-Message-State: APf1xPAtRjspqa7cVzqx18avgyigzTWqzluPfq/ulPO7D1qklehJFUvJ CIm+9E2pKcb72r+trpEJwKw5ng== X-Received: by 2002:a17:902:b484:: with SMTP id y4-v6mr2173272plr.89.1518553983767; Tue, 13 Feb 2018 12:33:03 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id o135sm35540873pfg.45.2018.02.13.12.33.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Feb 2018 12:33:03 -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, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V3 08/10] cgroup: Constrain the addition of CPUs to a new CPUset Date: Tue, 13 Feb 2018 13:32:45 -0700 Message-Id: <1518553967-20656-9-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518553967-20656-1-git-send-email-mathieu.poirier@linaro.org> References: <1518553967-20656-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 | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 4f5e8bac5337..4c1b71608c23 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,11 @@ 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); + +out: return ret; }