Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4362152imm; Mon, 15 Oct 2018 13:31:10 -0700 (PDT) X-Google-Smtp-Source: ACcGV61BA2QrfqsDf0OhU23KsngKED+FcLlwkM85MZvttOkJk2SvEwfAhOdYDgU/WnMVeX2hO45B X-Received: by 2002:a62:1dca:: with SMTP id d193-v6mr18787724pfd.157.1539635470366; Mon, 15 Oct 2018 13:31:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539635470; cv=none; d=google.com; s=arc-20160816; b=SyVjCGiNAbhsShfXtUqwGl4C2DOzd0FRXmY4l0J8rS/sNxP7Si/3BJFkn2PRISiAd6 RUl8slUtme32Oas/2kE+JBI8AEsouva2eF4fYCaelaqZ86E/x6Fd8LSw6Pfbw6+2dU7Q Cwa4fdZfHUOTY0NFZFJwP7vg9+anj5XS20tvnpffrQ4+ALtTr08IIMBtTUU741W/hKwT gp/VNdqlRjARU5H9jqyWSC0yvc2W7R6SOgDC5WAu5vpOadR6a20bLw5e30/p7iZMILCo nRRbBWdaPKSGjL1rqQR5VE19o9CC3xTFLQbBBtrW+PBqpnizPeuIg9YCbugS6arG4wsC 5wqA== 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; bh=lnDBWr9ydmDCR5j4KgvMtwo2PXoGefFRBeLw7bkhSrY=; b=AdlwTFFAuGr8lkln/lI+TR41guUDPaEAt26/WCui1R6K+HoQglkKsAcqcC8NP520TK RMJthAW0ey0ucEb3iphiU8qlgxDkXNVh/vsldRAxm5pn3ko1JlXUcXpcjZkhoESijy09 mvLIcTfJkIx44TnxLI5Jp7oYm54w+ELwPQ/j7CGMLVCg4qDrn/2SzwzFV5Nt2FM+/7We Dfk/QqNSNQ/iv4q7dardJo//wKZI5uN+qc+fkKnsZeCKXPxqWmOjsdsEpfpxwsM+Ikod VSLXLBN4VHtd8LAYU7YO3viN2fAd1pz//Egdyl1qItXe9v3oqF5muPXDi9Z0pAt49crv lrsg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u7-v6si11878669pfu.143.2018.10.15.13.30.54; Mon, 15 Oct 2018 13:31:10 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727005AbeJPERP (ORCPT + 99 others); Tue, 16 Oct 2018 00:17:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51224 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725917AbeJPERN (ORCPT ); Tue, 16 Oct 2018 00:17:13 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 31B6830016EE; Mon, 15 Oct 2018 20:30:23 +0000 (UTC) Received: from llong.com (dhcp-17-8.bos.redhat.com [10.18.17.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 72E9D768AE; Mon, 15 Oct 2018 20:30:21 +0000 (UTC) From: Waiman Long To: Tejun Heo , Li Zefan , Johannes Weiner , Peter Zijlstra , Ingo Molnar Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, kernel-team@fb.com, pjt@google.com, luto@amacapital.net, Mike Galbraith , torvalds@linux-foundation.org, Roman Gushchin , Juri Lelli , Patrick Bellasi , Tom Hromatka , Waiman Long Subject: [PATCH v14 02/12] cpuset: Define data structures to support scheduling partition Date: Mon, 15 Oct 2018 16:29:27 -0400 Message-Id: <1539635377-22335-3-git-send-email-longman@redhat.com> In-Reply-To: <1539635377-22335-1-git-send-email-longman@redhat.com> References: <1539635377-22335-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 15 Oct 2018 20:30:23 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From a cpuset point of view, a scheduling partition is a group of cpusets with their own set of exclusive CPUs that are not shared by other tasks outside the scheduling partition. In the legacy hierarchy, scheduling partitions are supported indirectly via the right use of the load balancing and the exclusive CPUs flag which is not intuitive and can be hard to use. To fully support the concept of scheduling partitions in the default hierarchy, we need to add some new field into the cpuset structure as well as a new tmpmasks structure that is used to pre-allocate cpumasks at the top level cpuset functions to avoid memory allocation in inner functions as memory allocation failure in those inner functions may cause a cpuset to have inconsistent states. Signed-off-by: Waiman Long --- kernel/cgroup/cpuset.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 2b5c4477d969..29a2bdc671fd 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -109,6 +109,13 @@ struct cpuset { cpumask_var_t effective_cpus; nodemask_t effective_mems; + /* + * CPUs allocated to child sub-partitions (default hierarchy only) + * - CPUs granted by the parent = effective_cpus U subparts_cpus + * - effective_cpus and subparts_cpus are mutually exclusive. + */ + cpumask_var_t subparts_cpus; + /* * This is old Memory Nodes tasks took on. * @@ -134,6 +141,30 @@ struct cpuset { /* for custom sched domain */ int relax_domain_level; + + /* number of CPUs in subparts_cpus */ + int nr_subparts_cpus; + + /* partition root state */ + int partition_root_state; +}; + +/* + * Partition root states: + * + * 0 - not a partition root + * 1 - partition root + */ +#define PRS_DISABLED 0 +#define PRS_ENABLED 1 + +/* + * Temporary cpumasks for working with partitions that are passed among + * functions to avoid memory allocation in inner functions. + */ +struct tmpmasks { + cpumask_var_t addmask, delmask; /* For partition root */ + cpumask_var_t new_cpus; /* For update_cpumasks_hier() */ }; static inline struct cpuset *css_cs(struct cgroup_subsys_state *css) @@ -218,9 +249,15 @@ static inline int is_spread_slab(const struct cpuset *cs) return test_bit(CS_SPREAD_SLAB, &cs->flags); } +static inline int is_partition_root(const struct cpuset *cs) +{ + return cs->partition_root_state; +} + static struct cpuset top_cpuset = { .flags = ((1 << CS_ONLINE) | (1 << CS_CPU_EXCLUSIVE) | (1 << CS_MEM_EXCLUSIVE)), + .partition_root_state = PRS_ENABLED, }; /** -- 2.18.0