From patchwork Wed Jan 17 16:35:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 13522023 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 4857D224E4 for ; Wed, 17 Jan 2024 16:36:15 +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=1705509376; cv=none; b=IePCjS3IsEXKHlkc7+2GhwbzGl22oukDXLtSBgrxNa6CqNT4u0/DK8zuUKvs5BfiUDVgOO9NvqcOaecHSFjcYiKwKBvAODLSJGBCiy8bg4t6+9lT1f0dEPGpd0GbHOkWkYo0kjtbvGyDbUMLCTFU8m4zUywdO31PRWAN0oZEFTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705509376; c=relaxed/simple; bh=cqoNjlPc6YRXzLiB2bCt5YjvjoQjt75FOzIQ4Y3qvrA=; 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=flJUHY1jBF+vMO/XAuxJhclgiKSzN8PgAmggPPMokL+oZDg9otj5/qci1fz1vkYhZqlvZMV/exwjPP5fWlZc2I1QJD3eyU5Lv+NEif1SJusexrqUQdvZU3SaY6E/2bDJ+dR2Y076hp0IFQSbnZR0YvGbDfRN4VsbMgmP34khfCw= 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=Ef8YCtBz; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ef8YCtBz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705509374; 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=v6l2z5hmcKTog3XiOuPlPdWnGHwPaZmCTdkb04dCE+c=; b=Ef8YCtBzuuwRFd2xPGC07XuHvbxW+Cxbx3kDOxhOFDSIyKoBoqkxzFbhBpbNbTVhtxKee7 DVfL9WgB1DugC9sXBvU643paSG+CDNlQfskaphJLC5i30dHd87Koi84SjRrwmH0d5QkCFL oZ7RvPuOUI0SJwnDcGXq/4L10Tlh1sY= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-292-NamU-_HuOXOPyQsDLH2XPg-1; Wed, 17 Jan 2024 11:36:12 -0500 X-MC-Unique: NamU-_HuOXOPyQsDLH2XPg-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 B0F6529AC003; Wed, 17 Jan 2024 16:36:09 +0000 (UTC) Received: from llong.com (unknown [10.22.16.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22AAD1121306; Wed, 17 Jan 2024 16:36:08 +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 3/8] rcu/no_cb: Add rcu_nocb_enabled() to expose the rcu_nocb state Date: Wed, 17 Jan 2024 11:35:06 -0500 Message-Id: <20240117163511.88173-4-longman@redhat.com> In-Reply-To: <20240117163511.88173-1-longman@redhat.com> References: <20240117163511.88173-1-longman@redhat.com> Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 Add a new rcu_nocb_enabled() helper to expose the rcu_nocb state to other kernel subsystems like cpuset. That will allow cpuset to determine if RCU no-callback can be enabled on isolated CPUs within isolated partitions. If so, the corresponding RCU functions can be called to enable it when full CPU isolation is requested. Signed-off-by: Waiman Long --- include/linux/rcupdate.h | 6 ++++++ kernel/rcu/tree_nocb.h | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index b649344075d2..976d55a3e523 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -120,6 +120,12 @@ void rcu_init(void); extern int rcu_scheduler_active; void rcu_sched_clock_irq(int user); +#ifdef CONFIG_RCU_NOCB_CPU +int rcu_nocb_enabled(struct cpumask *out_mask); +#else +static inline int rcu_nocb_enabled(struct cpumask *out_mask) { return 0; } +#endif + #ifdef CONFIG_TASKS_RCU_GENERIC void rcu_init_tasks_generic(void); #else diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index bbcf6f4152a3..020a347ccd52 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -81,6 +81,18 @@ static int __init parse_rcu_nocb_poll(char *arg) } __setup("rcu_nocb_poll", parse_rcu_nocb_poll); +/* + * Return the rcu_nocb state & optionally copy out rcu_nocb_mask. + */ +int rcu_nocb_enabled(struct cpumask *out_mask) +{ + if (!rcu_state.nocb_is_setup) + return 0; + if (out_mask) + cpumask_copy(out_mask, rcu_nocb_mask); + return 1; +} + /* * Don't bother bypassing ->cblist if the call_rcu() rate is low. * After all, the main point of bypassing is to avoid lock contention