Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1054797imm; Fri, 12 Oct 2018 10:58:28 -0700 (PDT) X-Google-Smtp-Source: ACcGV60KwKbZD/h9DbJUwHfLj8pe9LW8Yz/o/AwUdWsIiEjyAep6M6M3Yr4ff4Yv0xW4w2kBQFL2 X-Received: by 2002:a17:902:2e83:: with SMTP id r3-v6mr6970631plb.80.1539367108443; Fri, 12 Oct 2018 10:58:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539367108; cv=none; d=google.com; s=arc-20160816; b=lz9VSC5ljo704DNpJ7N+s4lIbUx3rIkVXq0T8hu7G2tbBly9+pdwYJQMw0e/wnYvku apilaEoHmkQyYj3tZxRx/RyHXXk50HnW4DUNjHWSUvUNhqnL2ZWvE3OUFUHv45lZyy47 8dqgGEME7Q8GEnp8yde1QEzWU1QkTgg04qX4DSBnyl7O/6ZD27qQ7gPtlojZc4G++lfx 8SsjO2s4/CjykMKzKSpmuxZ4ThAxrF0WvxM/8C+5QM4Bz3DRus2s91kjF+feLpqmxPuB TDPKysQNtUM+2ka4D8ztkpNSvOiZCiChu4oW1/yoNwBGTJigDeFi31ykhiTUwLfJGfz4 Zm9Q== 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=dSE82BKgi1/GXvdknAHUCGul1eOLVT6YUw8MmruqiSc=; b=I4ffN/i9umYInKp29OlWBB9+jd+mSfZv/6TeAoV87ldAGBBNFk+E9B91SgTlAKxlJd 8mCBcfo3Bhy6spAfakTvWva39wSwWOsj8EU0sTOjkZ2/DtZwJeUzXuKsK340Hiw2oAYj ZUgWAEKFKcGuscxa7y86EnA6VXk66MZadWqQ0PWiJVEJL890wIWZTRf1/CS5XFBnrqNM r6M6TgN3Txj3kVOTKN8kZD+5mgbcXiB5eNRfvdACItkoOGd3lSiAxPwWeAE//M0G9AVU hNZP465jkoZ4/0hssP1IfGqe8J5sxXpTAS15gcy4DF8czmC/ZycHmnB043LPo5x4Ni9C jopA== 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 f91-v6si1979817plf.324.2018.10.12.10.58.14; Fri, 12 Oct 2018 10:58:28 -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 S1727194AbeJMB35 (ORCPT + 99 others); Fri, 12 Oct 2018 21:29:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35510 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725981AbeJMB35 (ORCPT ); Fri, 12 Oct 2018 21:29:57 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5391880F8D; Fri, 12 Oct 2018 17:56:18 +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 74F2082779; Fri, 12 Oct 2018 17:56:16 +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 , Waiman Long Subject: [PATCH v13 02/11] cpuset: Define data structures to support scheduling partition Date: Fri, 12 Oct 2018 13:55:42 -0400 Message-Id: <1539366951-8498-3-git-send-email-longman@redhat.com> In-Reply-To: <1539366951-8498-1-git-send-email-longman@redhat.com> References: <1539366951-8498-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 12 Oct 2018 17:56:18 +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 2b5c447..29a2bdc 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -110,6 +110,13 @@ struct cpuset { 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. * * - top_cpuset.old_mems_allowed is initialized to mems_allowed. @@ -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, }; /** -- 1.8.3.1