Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp515156rdb; Wed, 17 Jan 2024 08:45:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IFgxlcsWaQpJq2oiS6OWL9UCOh/pFMxVEaxZriQDy3PKsNagZwSGWn7KkbhZEPZSASQpD3b X-Received: by 2002:a05:6a20:2907:b0:19a:3a7f:63cd with SMTP id t7-20020a056a20290700b0019a3a7f63cdmr3826687pzf.49.1705509949009; Wed, 17 Jan 2024 08:45:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705509948; cv=pass; d=google.com; s=arc-20160816; b=ZGi6ihi79WyYTDHfoIRMxEn3TWQbB/jcgsT+VUUAsyNv8heDyVnMueMqFJ7Cex/4WO ceFEdZ+vGDjwUxUezBdoJAkAufwKegyRGRa92luDA8TelE9a9fLDCxj2ga/UGn7bHHZp rYB7fDJ9yOpz29AaS5DFtoAHUpv4shcpehuNw9jT93UgEPa4bizBEJOp9mfrErHIzuu/ dJHxVhUJNRtnh1MHJtRx4zOqKuYvzWkKqoT6qQEcvHzrJUU69rRxGXy+d3hzkWuepyU2 15vtqrQdBTXC6/X7/cy0lUVsPhN5AxQxTCgRsgocmXol4w5wIDzZD6Uou3U0d3q5ivnn BW+A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=pwiZxk2/LIns0OuqqkiNPgLv6/0v49jXf5KKeW3bftU=; fh=0cYptx2rNTiuaWnhcL0TTYEVszmCn744IFt48f2CUlM=; b=oj4533Wz2gzXZYaXx4Au8GE/Zlp6qIMQCQuAN/QAkHjDXSJ+5TIDIQ+CQ3RqHKsG1Y FTMufGLxVZJO6PPr917Pxqez1iKhhRORUxgomSuNZdF8cBpbf+bY7QG63AcbaznEY6eC CYanzyVakgsA5MKYrHZLTqzDV23wnl3rxViLKhic0Qh6Rurc/5ZlecKQOerHHxinKYil 8jg6BDjqGaLO1emo+TGAMhMlUCF0gEp1tSa7c8bZm5va9V7pBJXqi20WaB/7J6Xtdhtv tpopyFZFluJXgTN0lhH1yvKrugBjyvRvKQ82J2eHF+1OZdAO24Ar/7cBU6/OxeDiAeXA 4ocg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CybQiS4s; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-29225-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29225-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id z2-20020a656642000000b005cec855e691si9490725pgv.761.2024.01.17.08.45.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 08:45:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29225-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CybQiS4s; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-29225-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29225-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7A6C028F5EA for ; Wed, 17 Jan 2024 16:37:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 19F592375B; Wed, 17 Jan 2024 16:36:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CybQiS4s" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69A05224CE for ; Wed, 17 Jan 2024 16:36:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705509381; cv=none; b=lcwEOsWj2rauzDL6aJTLoeknQ2zojSYPoexv/hxTLuyrB7xxO7zZhF435Vt/DTdK3Rxsqc9Q9J9/I3aP34rlyoXIDVjZlC7NaP7MTo5nbnybeTnP7bQdByTCQlOnb4BP/rMJ4ACN6iqJjbWb+vBzW5iYgZ+pCRY9hb+lO3Pczfw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705509381; c=relaxed/simple; bh=RIu0wCoHEEwmwrWrI4fk2QwIf3Z4+DNKewqmZMfVEmc=; h=DKIM-Signature:Received:X-MC-Unique:Received:Received:From:To:Cc: Subject:Date:Message-Id:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Scanned-By; b=Qr7gjkm5bRHyLNBJgIsFyeIQtqyvuqUbIWeMenbIbxuNrYBHSXsN7JqhNzQe6Cu5N4/GV5H//MkF1JM3FaCCKfczpH99Zp1xcTprvjlLHOVWmK2m6TLyhPNBxYA82293JVzgG94K+ZQC2Wk+3SkjqympOm5GnoYOEsneXArcrvg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=CybQiS4s; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705509378; 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: in-reply-to:in-reply-to:references:references; bh=pwiZxk2/LIns0OuqqkiNPgLv6/0v49jXf5KKeW3bftU=; b=CybQiS4s10mbG/ljtqMfKn7WsMwnsAP2UKXEni/lP08tGdpiRW0lt62zf323r8oJwwF8fc PqDTan7vqHTMOxN1RHVQPHFD3enCDDc+vg175+Z0zBeiFgBeBQhVuLf/61d3gpEVJUTuzE G4Dw0ioduPrGJWqkQI4pb+NGwJyqb9Y= 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-306-Ry1xxOizP6KjrjiwrnqQ_w-1; Wed, 17 Jan 2024 11:36:16 -0500 X-MC-Unique: Ry1xxOizP6KjrjiwrnqQ_w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 BEFDB81DA88; Wed, 17 Jan 2024 16:36:14 +0000 (UTC) Received: from llong.com (unknown [10.22.16.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 272321121306; Wed, 17 Jan 2024 16:36:13 +0000 (UTC) From: Waiman Long To: Tejun Heo , Zefan Li , Johannes Weiner , Frederic Weisbecker , Jonathan Corbet , "Paul E. McKenney" , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Davidlohr Bueso , Shuah Khan Cc: cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, rcu@vger.kernel.org, linux-kselftest@vger.kernel.org, Mrunal Patel , Ryan Phillips , Brent Rowsell , Peter Hunt , Cestmir Kalina , Nicolas Saenz Julienne , Alex Gladkov , Marcelo Tosatti , Phil Auld , Paul Gortmaker , Daniel Bristot de Oliveira , Juri Lelli , Peter Zijlstra , Costa Shulyupin , Waiman Long Subject: [RFC PATCH 6/8] cgroup/cpuset: Enable dynamic rcu_nocb mode on isolated CPUs Date: Wed, 17 Jan 2024 11:35:09 -0500 Message-Id: <20240117163511.88173-7-longman@redhat.com> In-Reply-To: <20240117163511.88173-1-longman@redhat.com> References: <20240117163511.88173-1-longman@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 The patch adds RCU no-callback isolation mode dynamically to isolated CPUs within isolated partitions when the full CPU isolation mode is enabled. This isolation feature will only be available for use by cpuset if the "rcu_nocb" boot command line option is specified in the kernel command line with or without the optional CPU list argument. Signed-off-by: Waiman Long --- kernel/cgroup/cpuset.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index d1d4ce213979..40bbb0a9cb84 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -218,6 +218,11 @@ enum isolated_cpus_modifiers { */ static cpumask_var_t isolated_cpus; +/* + * rcu_nocb_mask set up at boot time. + */ +static cpumask_var_t rcu_nocb_mask_preset; + /* * Enable full CPU isolation in isolated partitions, if set. */ @@ -229,15 +234,26 @@ static bool isolation_full; static int isolation_flags; enum cpuset_isolation_types { + ISOL_TYPE_RCU, /* RCU no-callback CPU mode */ ISOL_TYPE_MAX, }; +enum cpuset_isolation_flags { + ISOL_FLAG_RCU = BIT(ISOL_TYPE_RCU), +}; + static const char * const isolation_type_names[ISOL_TYPE_MAX] = { + [ISOL_TYPE_RCU] = "rcu_nocbs", }; /* Detect the cpuset isolation modes that can be enabled */ static __init int set_isolation_flags(void) { + if (rcu_nocb_enabled(NULL)) { + BUG_ON(!zalloc_cpumask_var(&rcu_nocb_mask_preset, GFP_KERNEL)); + (void)rcu_nocb_enabled(rcu_nocb_mask_preset); + isolation_flags |= ISOL_FLAG_RCU; + } return 0; } late_initcall(set_isolation_flags); @@ -1554,6 +1570,7 @@ static int partition_xcpus_del(int old_prs, struct cpuset *parent, static int update_isolation_cpumasks(struct cpumask *mask, int modifier) { int err; + bool enable = (modifier == ISOL_CPUS_ADD); lockdep_assert_cpus_held(); @@ -1569,6 +1586,25 @@ static int update_isolation_cpumasks(struct cpumask *mask, int modifier) if (WARN_ON_ONCE(cpumask_empty(mask))) return -EINVAL; + err = 0; + if (isolation_flags & ISOL_FLAG_RCU) { + /* + * When disabling rcu_nocb, make sure that we don't touch any + * CPUs that have already been set in rcu_nocb_mask_preset. + */ + if (!enable && cpumask_intersects(mask, rcu_nocb_mask_preset)) { + cpumask_var_t tmp_mask; + + if (WARN_ON_ONCE(!alloc_cpumask_var(&tmp_mask, GFP_KERNEL))) + return -ENOMEM; + if (cpumask_andnot(tmp_mask, mask, rcu_nocb_mask_preset)) + err = rcu_nocb_cpumask_update(tmp_mask, enable); + free_cpumask_var(tmp_mask); + } else { + err = rcu_nocb_cpumask_update(mask, enable); + } + } + WARN_ON_ONCE(err); return err; } -- 2.39.3