Message ID | f6507b10-5bb5-4407-bd4d-c547193a5a28@paulmck-laptop |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-85628-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3571526dyb; Wed, 28 Feb 2024 11:45:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV8AphM+RaBhSFrWCwm7uOtIyzFMNkSrrcZYLcnMvf6zk4WbrYxBR5wVLXNt3V85zSzcVpJGw+3VwU1gVtFyy5GsrtRiA== X-Google-Smtp-Source: AGHT+IHrzO2j3iSjIrNUOL0HbZH/3Jga1v8grqK4eR35vHIdpX5bx1SyxwGIRfZGRXnusxOcYFXM X-Received: by 2002:a05:6a20:c91b:b0:1a0:e232:b4d5 with SMTP id gx27-20020a056a20c91b00b001a0e232b4d5mr237278pzb.53.1709149547796; Wed, 28 Feb 2024 11:45:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709149547; cv=pass; d=google.com; s=arc-20160816; b=pbGOWRf1hwTzv4tBVBwejkJ0S2vbbRC3qTLoVK1vyzdzEzgnUPE+V/v0rjtwRfPm3j 6SpthjMqt+ecBAjE3RfVHmUJew8AZm2yAM0EsnjdJ/IO9OBBpK9sqmPOjxobDysDIcEZ PuruCN5Y/nfoIQy9NT4qr2m3nWPvvpFXThPaJaSapa5Z6elU7A1yJRfTstZ06qayt0DE RXCJ+Wf8fTWBZaYiqd7fTSS2YhUaWbYHdwblLExyXnj3sUBgQsfcG126GuuSHqKcu6A7 sNET3y4EvjESD0xfQxjR0sWq1Bc3IIhKupKGiFfJ9XbxRnllrrxkcTmh/EQEbnUDtcS9 aEew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Mswom4W81eAfGBrrrJAx1kgU1xcOa1jdZNt+DroAE94=; fh=UHrhq233cCwHNLD4ywZGPj3Dd4S2gixqDJ66CgEmCUQ=; b=yM4L5gV93YYFFl1Jm3r+cNv8mEFYMUl1OW1vVP9SozWoaRcdmBhizzmiqgbsqYU0p0 uij8RtRXxE/V69E+HctpHoYknsEvS/ynWlKuQfRVlNExhr7XQAY+1ujZMNJSpXRqWxgP 1qeNPgfuZwr343DHBBhPqm364KoYa3UwPycH/V0IYO5258Nk1mwypS+8uCauQEh9/NXy ndGfCzOax8Pmf8VSlwtMmU8eCUudvd+BD6PjZ4LVjb6c8DrK54s1xGUtwuXj5WUF0F9D shgFns3+KYTaCfWD7qF1hL1cqmBkKzYE5REzODsJJul4UXgik+IDk70pDCb3UcdWQaqE Ruuw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b1iFGEj+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85628-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85628-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id c6-20020a6566c6000000b005d8b7053276si179554pgw.160.2024.02.28.11.45.47 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 11:45:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85628-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b1iFGEj+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85628-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85628-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 4DA1CB234A1 for <ouuuleilei@gmail.com>; Wed, 28 Feb 2024 19:41:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F2FD5E090; Wed, 28 Feb 2024 19:38:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="b1iFGEj+" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 411F55E074; Wed, 28 Feb 2024 19:38:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709149110; cv=none; b=ixqUwtTl2ml/mM8JNU5ovjJX+35XW81gmD8QYFWfc0B9xZAb8YIbLL0S17Us4gHT0BpqyX2t4Gi7HMZb+9v0E4N5wW0g2laCetpq/frD4AnT5y3STD8YbpDVGtc9IxgT5Fxrfccsp4WK8PSV6S+sbjs8WbgfKOsKPsbgv2q05OQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709149110; c=relaxed/simple; bh=HKsFoZKnJ34YSBFn9vTGSnBy8Xop5g9WIhcVbvX1B6E=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=PlLGcavv2I/hTYDkl/aDk6B7vHhQVQzPFCP3omfDXkgF5o2V9H3S8v72FbpplNEjAXvVAqAKR5qLkfOi2BcFUeNCVx4sTqZRj/IeHS059FTACkYCY/9DauiT0bM+zuIMi/+I6aseNuqEswKyCUdZ58HXssSgaCYPfiRKupOfao0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=b1iFGEj+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1245C433C7; Wed, 28 Feb 2024 19:38:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709149109; bh=HKsFoZKnJ34YSBFn9vTGSnBy8Xop5g9WIhcVbvX1B6E=; h=Date:From:To:Cc:Subject:Reply-To:From; b=b1iFGEj+idZwyXYGELoyOx0I31GFrOItcdTvZYjxdyO8tk9y57qABVza2+j3QCN0H A29rheh2pPAOD49LuBeKJpJIqBBsYQa97eta4qmyyyfNyNhFvTXmL1NiL27dQpYkeG FpR0WCG3KxMCRt9W3nG2R9CiBg5Rb7P7Sc7cgRW6Iy+mfGbB8MqdrCj2FFyqzbT6lj rDOscHOOnD6zgn+kJIvDlbEu+cxpOlQlplajPzfJvhTud8avA79bTKBaafKxVcxPVt i7k/NQc6vs8sA+USwz3sxgYWDkBsxqpEl7RKPqFcc8uqzEk1GRqzCp/XkOGbYlQz34 BbIKnWc2aq51Q== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 4F340CE03F3; Wed, 28 Feb 2024 11:38:29 -0800 (PST) Date: Wed, 28 Feb 2024 11:38:29 -0800 From: "Paul E. McKenney" <paulmck@kernel.org> To: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Steven Rostedt <rostedt@goodmis.org>, Masami Hiramatsu <mhiramat@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Mathieu Desnoyers <mathieu.desnoyers@efficios.com>, Ankur Arora <ankur.a.arora@oracle.com>, Thomas Gleixner <tglx@linutronix.de>, kernel-team@meta.com Subject: [PATCH RFC ftrace] Chose RCU Tasks based on TASKS_RCU rather than PREEMPTION Message-ID: <f6507b10-5bb5-4407-bd4d-c547193a5a28@paulmck-laptop> Reply-To: paulmck@kernel.org Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792172975286295499 X-GMAIL-MSGID: 1792173196325171479 |
Series |
[RFC,ftrace] Chose RCU Tasks based on TASKS_RCU rather than PREEMPTION
|
|
Commit Message
Paul E. McKenney
Feb. 28, 2024, 7:38 p.m. UTC
The advent of CONFIG_PREEMPT_AUTO, AKA lazy preemption, will mean that
even kernels built with CONFIG_PREEMPT_NONE or CONFIG_PREEMPT_VOLUNTARY
might see the occasional preemption, and that this preemption just might
happen within a trampoline.
Therefore, update ftrace_shutdown() to invoke synchronize_rcu_tasks()
based on CONFIG_TASKS_RCU instead of CONFIG_PREEMPTION.
Only build tested.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Ankur Arora <ankur.a.arora@oracle.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: <linux-trace-kernel@vger.kernel.org>
Comments
On Wed, 28 Feb 2024 11:38:29 -0800 "Paul E. McKenney" <paulmck@kernel.org> wrote: > The advent of CONFIG_PREEMPT_AUTO, AKA lazy preemption, will mean that > even kernels built with CONFIG_PREEMPT_NONE or CONFIG_PREEMPT_VOLUNTARY > might see the occasional preemption, and that this preemption just might > happen within a trampoline. > > Therefore, update ftrace_shutdown() to invoke synchronize_rcu_tasks() > based on CONFIG_TASKS_RCU instead of CONFIG_PREEMPTION. > > Only build tested. > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > Cc: Steven Rostedt <rostedt@goodmis.org> > Cc: Masami Hiramatsu <mhiramat@kernel.org> > Cc: Mark Rutland <mark.rutland@arm.com> > Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> > Cc: Ankur Arora <ankur.a.arora@oracle.com> > Cc: Thomas Gleixner <tglx@linutronix.de> > Cc: <linux-trace-kernel@vger.kernel.org> > > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > index 2da4eaa2777d6..c9e6c69cf3446 100644 > --- a/kernel/trace/ftrace.c > +++ b/kernel/trace/ftrace.c > @@ -3156,7 +3156,7 @@ int ftrace_shutdown(struct ftrace_ops *ops, int command) > * synchronize_rcu_tasks() will wait for those tasks to > * execute and either schedule voluntarily or enter user space. > */ > - if (IS_ENABLED(CONFIG_PREEMPTION)) > + if (IS_ENABLED(CONFIG_TASKS_RCU)) > synchronize_rcu_tasks(); What happens if CONFIG_TASKS_RCU is not enabled? Does synchronize_rcu_tasks() do anything? Or is it just a synchronize_rcu()? If that's the case, perhaps just remove the if statement and make it: synchronize_rcu_tasks(); Not sure an extra synchronize_rcu() will hurt (especially after doing a synchronize_rcu_tasks_rude() just before hand! -- Steve
On Wed, Feb 28, 2024 at 03:22:36PM -0500, Steven Rostedt wrote: > On Wed, 28 Feb 2024 11:38:29 -0800 > "Paul E. McKenney" <paulmck@kernel.org> wrote: > > > The advent of CONFIG_PREEMPT_AUTO, AKA lazy preemption, will mean that > > even kernels built with CONFIG_PREEMPT_NONE or CONFIG_PREEMPT_VOLUNTARY > > might see the occasional preemption, and that this preemption just might > > happen within a trampoline. > > > > Therefore, update ftrace_shutdown() to invoke synchronize_rcu_tasks() > > based on CONFIG_TASKS_RCU instead of CONFIG_PREEMPTION. > > > > Only build tested. > > > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > > Cc: Steven Rostedt <rostedt@goodmis.org> > > Cc: Masami Hiramatsu <mhiramat@kernel.org> > > Cc: Mark Rutland <mark.rutland@arm.com> > > Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> > > Cc: Ankur Arora <ankur.a.arora@oracle.com> > > Cc: Thomas Gleixner <tglx@linutronix.de> > > Cc: <linux-trace-kernel@vger.kernel.org> > > > > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > > index 2da4eaa2777d6..c9e6c69cf3446 100644 > > --- a/kernel/trace/ftrace.c > > +++ b/kernel/trace/ftrace.c > > @@ -3156,7 +3156,7 @@ int ftrace_shutdown(struct ftrace_ops *ops, int command) > > * synchronize_rcu_tasks() will wait for those tasks to > > * execute and either schedule voluntarily or enter user space. > > */ > > - if (IS_ENABLED(CONFIG_PREEMPTION)) > > + if (IS_ENABLED(CONFIG_TASKS_RCU)) > > synchronize_rcu_tasks(); > > What happens if CONFIG_TASKS_RCU is not enabled? Does > synchronize_rcu_tasks() do anything? Or is it just a synchronize_rcu()? It is just a synchronize_rcu(). > If that's the case, perhaps just remove the if statement and make it: > > synchronize_rcu_tasks(); > > Not sure an extra synchronize_rcu() will hurt (especially after doing a > synchronize_rcu_tasks_rude() just before hand! That would work for me. If there are no objections, I will make this change. Thanx, Paul
On Wed, Feb 28, 2024 at 01:16:04PM -0800, Paul E. McKenney wrote: > On Wed, Feb 28, 2024 at 03:22:36PM -0500, Steven Rostedt wrote: > > On Wed, 28 Feb 2024 11:38:29 -0800 > > "Paul E. McKenney" <paulmck@kernel.org> wrote: > > > > > The advent of CONFIG_PREEMPT_AUTO, AKA lazy preemption, will mean that > > > even kernels built with CONFIG_PREEMPT_NONE or CONFIG_PREEMPT_VOLUNTARY > > > might see the occasional preemption, and that this preemption just might > > > happen within a trampoline. > > > > > > Therefore, update ftrace_shutdown() to invoke synchronize_rcu_tasks() > > > based on CONFIG_TASKS_RCU instead of CONFIG_PREEMPTION. > > > > > > Only build tested. > > > > > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > > > Cc: Steven Rostedt <rostedt@goodmis.org> > > > Cc: Masami Hiramatsu <mhiramat@kernel.org> > > > Cc: Mark Rutland <mark.rutland@arm.com> > > > Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> > > > Cc: Ankur Arora <ankur.a.arora@oracle.com> > > > Cc: Thomas Gleixner <tglx@linutronix.de> > > > Cc: <linux-trace-kernel@vger.kernel.org> > > > > > > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > > > index 2da4eaa2777d6..c9e6c69cf3446 100644 > > > --- a/kernel/trace/ftrace.c > > > +++ b/kernel/trace/ftrace.c > > > @@ -3156,7 +3156,7 @@ int ftrace_shutdown(struct ftrace_ops *ops, int command) > > > * synchronize_rcu_tasks() will wait for those tasks to > > > * execute and either schedule voluntarily or enter user space. > > > */ > > > - if (IS_ENABLED(CONFIG_PREEMPTION)) > > > + if (IS_ENABLED(CONFIG_TASKS_RCU)) > > > synchronize_rcu_tasks(); > > > > What happens if CONFIG_TASKS_RCU is not enabled? Does > > synchronize_rcu_tasks() do anything? Or is it just a synchronize_rcu()? > > It is just a synchronize_rcu(). > > > If that's the case, perhaps just remove the if statement and make it: > > > > synchronize_rcu_tasks(); > > > > Not sure an extra synchronize_rcu() will hurt (especially after doing a > > synchronize_rcu_tasks_rude() just before hand! > > That would work for me. If there are no objections, I will make this > change. But I did check the latency of synchronize_rcu_tasks_rude() (about 100ms) and synchronize_rcu() (about 20ms). This is on a 80-hardware-thread x86 system that is being flooded with calls to one or the other of these two functions, but is otherwise idle. So adding that unnecessary synchronize_rcu() adds about 20% to that synchronization delay. Which might still be OK, but... In the immortal words of MS-DOS, "Are you sure?". ;-) Thanx, Paul
On Fri, 1 Mar 2024 12:25:10 -0800 "Paul E. McKenney" <paulmck@kernel.org> wrote: > > That would work for me. If there are no objections, I will make this > > change. > > But I did check the latency of synchronize_rcu_tasks_rude() (about 100ms) > and synchronize_rcu() (about 20ms). This is on a 80-hardware-thread > x86 system that is being flooded with calls to one or the other of > these two functions, but is otherwise idle. So adding that unnecessary > synchronize_rcu() adds about 20% to that synchronization delay. > > Which might still be OK, but... In the immortal words of MS-DOS, > "Are you sure?". ;-) It's just safe to keep it. It's definitely not a fast path. -- Steve
On Fri, Mar 01, 2024 at 03:30:01PM -0500, Steven Rostedt wrote: > On Fri, 1 Mar 2024 12:25:10 -0800 > "Paul E. McKenney" <paulmck@kernel.org> wrote: > > > > That would work for me. If there are no objections, I will make this > > > change. > > > > But I did check the latency of synchronize_rcu_tasks_rude() (about 100ms) > > and synchronize_rcu() (about 20ms). This is on a 80-hardware-thread > > x86 system that is being flooded with calls to one or the other of > > these two functions, but is otherwise idle. So adding that unnecessary > > synchronize_rcu() adds about 20% to that synchronization delay. > > > > Which might still be OK, but... In the immortal words of MS-DOS, > > "Are you sure?". ;-) > > It's just safe to keep it. It's definitely not a fast path. OK, you got it! ;-) Thanx, Paul
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 2da4eaa2777d6..c9e6c69cf3446 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -3156,7 +3156,7 @@ int ftrace_shutdown(struct ftrace_ops *ops, int command) * synchronize_rcu_tasks() will wait for those tasks to * execute and either schedule voluntarily or enter user space. */ - if (IS_ENABLED(CONFIG_PREEMPTION)) + if (IS_ENABLED(CONFIG_TASKS_RCU)) synchronize_rcu_tasks(); ftrace_trampoline_free(ops);