Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp600784rdb; Tue, 5 Dec 2023 14:22:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8yK/W9cP6wtEX+Flo7gtjAlwPGazuzS7cm6XHQizGdiv+4X5FRN8s2mjRaCjKjhVlv1Bc X-Received: by 2002:a17:90a:a016:b0:286:d7f1:b654 with SMTP id q22-20020a17090aa01600b00286d7f1b654mr2054794pjp.71.1701814954980; Tue, 05 Dec 2023 14:22:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701814954; cv=none; d=google.com; s=arc-20160816; b=Mtnr4HsJZmW02E4fJiY06qauVL+v2QwVADihrSK13ABI8Sv9j6lNuyy61Hzrr4nExd JIIh9mlXnXhB++NGBfrkSRd60O2sURZFRmTPCPyDsk1Dc75FxTMIgnNRGO3YiQIfwWLf F4rc/flaal/xgV8iYzGDyPzLF0q+ObIfGdAzybNePDX5z5VUDZbITWtwy7d/BQtoW+Xj /avX6Vq1Qdi3rCuMZfVmo/1UmK8wTigdbHGI9Q2QbMGA9tVbDSFu38W/hxLKlL5eJSHj 5sp+ymzRBY9HAqe/6+aS7aySj66iiufjQbFYupxLce54sKTloj4h5E5M5feNwF3BSvlz 6Fcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=dd8Gk/6yuQhjnMyi4P3XBRZAXca0Ynw9je2fzWn9dCc=; fh=HeJWgpfDihwASwHGoP5N5fUNHyeiXU3VPSIwzq1rs5Q=; b=NNT7u9g5TMMzETEiLFvUqvFP1ApHrsH9GQA3nQeVYwBqrb/LA8OA+NaUYvcI85c8wQ Zap6dk7hnPSy9aCXBRs6KYjHK/L7ChSXZqUmMHsBmOc+5I4R+0bqtZOhmqisOM0QfNc0 jBdMdmOyvRxj8PSF8oe4abkA+pUQHZxlg+xmzYTOionvoNa75DWXBpoawDG4AE5D2d2q vjrRh5dFcjaeTe2pmVeCODQv0OEnCmcI8cRXUAtDLiM03aMtcODAQkWotc3/EyUv+GYV sukMr9p3gQ56MOR1R8SaTCcKASlECrAd6Pn89K6zkzdnUPez7QgnepK9Zs+8N8wQU5xF O1BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZMH00W33; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id fu23-20020a17090ad19700b002865933ddc0si8074346pjb.102.2023.12.05.14.22.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 14:22:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZMH00W33; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 53DDA80BE2EF; Tue, 5 Dec 2023 14:22:33 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346590AbjLEWWX (ORCPT + 99 others); Tue, 5 Dec 2023 17:22:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346478AbjLEWWW (ORCPT ); Tue, 5 Dec 2023 17:22:22 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C465B1AA for ; Tue, 5 Dec 2023 14:22:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701814948; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=dd8Gk/6yuQhjnMyi4P3XBRZAXca0Ynw9je2fzWn9dCc=; b=ZMH00W33XfzCuBET7DftvIkszHXdi7970wC7y4YfMuG2uUiMwLKNVCMSd3qaMTmYlLm4Cj taUZIHhOXmeXgA/gCOTQBHCzEMwZrgXaA1D52vWWF/VNtPMtjFLsvpnNlMFOZkmxoHPq2J E68HvH1YOMJAoNDe8nurAVOKIPSMT5A= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-324-T3-aAeCqM9WgxgBvKthgAA-1; Tue, 05 Dec 2023 17:22:26 -0500 X-MC-Unique: T3-aAeCqM9WgxgBvKthgAA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1651E102F081; Tue, 5 Dec 2023 22:22:24 +0000 (UTC) Received: from llong.com (unknown [10.22.8.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EE182166B35; Tue, 5 Dec 2023 22:22:23 +0000 (UTC) From: Waiman Long To: Tejun Heo , Zefan Li , Johannes Weiner , Andrew Morton , Michal Hocko , Frederic Weisbecker Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Mrunal Patel , Ryan Phillips , Brent Rowsell , Peter Hunt , Cestmir Kalina , Waiman Long Subject: [PATCH-cgroup v2] cgroup/cpuset: Include isolated cpuset CPUs in cpu_is_isolated() check Date: Tue, 5 Dec 2023 17:21:14 -0500 Message-Id: <20231205222114.773446-1-longman@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 05 Dec 2023 14:22:33 -0800 (PST) Currently, the cpu_is_isolated() function checks only the statically isolated CPUs specified via the "isolcpus" and "nohz_full" kernel command line options. This function is used by vmstat and memcg to reduce interference with isolated CPUs by not doing stat flushing or scheduling works on those CPUs. Workloads running on isolated CPUs within isolated cpuset partitions should receive the same treatment to reduce unnecessary interference. This patch introduces a new cpuset_cpu_is_isolated() function to be called by cpu_is_isolated() so that the set of dynamically created cpuset isolated CPUs will be included in the check. Assuming that testing a bit in a cpumask is atomic, no synchronization primitive is currently used to synchronize access to the cpuset's isolated_cpus mask. Signed-off-by: Waiman Long --- include/linux/cpuset.h | 6 ++++++ include/linux/sched/isolation.h | 4 +++- kernel/cgroup/cpuset.c | 11 +++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h index d629094fac6e..875d12598bd2 100644 --- a/include/linux/cpuset.h +++ b/include/linux/cpuset.h @@ -77,6 +77,7 @@ extern void cpuset_lock(void); extern void cpuset_unlock(void); extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask); extern bool cpuset_cpus_allowed_fallback(struct task_struct *p); +extern bool cpuset_cpu_is_isolated(int cpu); extern nodemask_t cpuset_mems_allowed(struct task_struct *p); #define cpuset_current_mems_allowed (current->mems_allowed) void cpuset_init_current_mems_allowed(void); @@ -207,6 +208,11 @@ static inline bool cpuset_cpus_allowed_fallback(struct task_struct *p) return false; } +static inline bool cpuset_cpu_is_isolated(int cpu) +{ + return false; +} + static inline nodemask_t cpuset_mems_allowed(struct task_struct *p) { return node_possible_map; diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h index fe1a46f30d24..2b461129d1fa 100644 --- a/include/linux/sched/isolation.h +++ b/include/linux/sched/isolation.h @@ -2,6 +2,7 @@ #define _LINUX_SCHED_ISOLATION_H #include +#include #include #include @@ -67,7 +68,8 @@ static inline bool housekeeping_cpu(int cpu, enum hk_type type) static inline bool cpu_is_isolated(int cpu) { return !housekeeping_test_cpu(cpu, HK_TYPE_DOMAIN) || - !housekeeping_test_cpu(cpu, HK_TYPE_TICK); + !housekeeping_test_cpu(cpu, HK_TYPE_TICK) || + cpuset_cpu_is_isolated(cpu); } #endif /* _LINUX_SCHED_ISOLATION_H */ diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 2a16df86c55c..dfbb16aca9f4 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1518,6 +1518,17 @@ static void update_unbound_workqueue_cpumask(bool isolcpus_updated) WARN_ON_ONCE(ret < 0); } +/** + * cpuset_cpu_is_isolated - Check if the given CPU is isolated + * @cpu: the CPU number to be checked + * Return: true if CPU is used in an isolated partition, false otherwise + */ +bool cpuset_cpu_is_isolated(int cpu) +{ + return cpumask_test_cpu(cpu, isolated_cpus); +} +EXPORT_SYMBOL_GPL(cpuset_cpu_is_isolated); + /* * compute_effective_exclusive_cpumask - compute effective exclusive CPUs * @cs: cpuset -- 2.39.3