linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joel Fernandes <joel@joelfernandes.org>
To: paulmck@kernel.org
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Network Development <netdev@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	rcu@vger.kernel.org, kernel-team <kernel-team@cloudflare.com>
Subject: Re: [PATCH] net: raise RCU qs after each threaded NAPI poll
Date: Mon, 4 Mar 2024 04:16:12 -0500	[thread overview]
Message-ID: <f3ed94a9-e50e-4d4b-bede-cc3078d4acab@joelfernandes.org> (raw)
In-Reply-To: <CAEXW_YRDiTXJ_GwK5soSVno73yN9FUA5GjLYAOcCTtqQvPGcFA@mail.gmail.com>

Hi Paul,

On 3/2/2024 8:01 PM, Joel Fernandes wrote:
>> As you noted, one thing that Ankur's series changes is that preemption
>> can occur anywhere that it is not specifically disabled in kernels
>> built with CONFIG_PREEMPT_NONE=y or CONFIG_PREEMPT_VOLUNTARY=y.  This in
>> turn changes Tasks Rude RCU's definition of a quiescent state for these
>> kernels, adding all code regions where preemption is not specifically
>> disabled to the list of such quiescent states.
>>
>> Although from what I know, this is OK, it would be good to check the
>> calls to call_rcu_tasks_rude() or synchronize_rcu_tasks_rude() are set
>> up so as to expect these new quiescent states.  One example where it
>> would definitely be OK is if there was a call to synchronize_rcu_tasks()
>> right before or after that call to synchronize_rcu_tasks_rude().
>>
>> Would you be willing to check the call sites to verify that they
>> are OK with this change in 
> Yes, I will analyze and make sure those users did not unexpectedly
> assume something about AUTO (i.e. preempt enabled sections using
> readers).

Other than RCU test code, there are just 3 call sites for RUDE right now, all in
ftrace.c.

(Long story short, PREEMPT_AUTO should not cause wreckage in TASKS_RCU_RUDE
other than any preexisting wreckage that !PREEMPT_AUTO already had. Steve is on
CC as well to CMIIW).

Case 1: For !CONFIG_DYNAMIC_FTRACE update of ftrace_trace_function

This config is itself expected to be slow. However seeing what it does, it is
trying to make sure the global function pointer "ftrace_trace_function" is
updated and any readers of that pointers would have finished reading it. I don't
personally think preemption has to be disabled across the entirety of the
section that calls into this function. So sensitivity to preempt disabling
should not be relevant for this case IMO, but lets see if ftrace folks disagree
(on CC). It has more to do with, any callers of this function pointer are no
longer calling into the old function.

Case 2: Trampoline structures accessing

For this there is a code comment that says preemption will disabled so it should
not be dependent on any of the preemptiblity modes, because preempt_disable()
should disable preempt with PREEMPT_AUTO.

		/*
		 * We need to do a hard force of sched synchronization.
		 * This is because we use preempt_disable() to do RCU, but
		 * the function tracers can be called where RCU is not watching
		 * (like before user_exit()). We can not rely on the RCU
		 * infrastructure to do the synchronization, thus we must do it
		 * ourselves.
		 */
		synchronize_rcu_tasks_rude();
		[...]
		ftrace_trampoline_free(ops);

Code comment probably needs update because it says 'can not rely on RCU..' ;-)

My *guess* is the preempt_disable() mentioned in this case is
ftrace_ops_trampoline() where trampoline-related datas tructures are accessed
for stack unwinding purposes. This is a data structure protection thing AFAICS
and nothing to do with "trampoline execution" itself which needs "Tasks RCU" to
allow for preemption in trampolines.

Case 3: This has to do with update of function graph tracing and there is the
same comment as case 2, where preempt will be disabled in readers, so it should
be safe for PREEMPT_AUTO (famous last words).

Though I am not yet able to locate that preempt_disable() which is not an
PREEMPT_AUTO-related issue anyway. Maybe its buried in function graph tracing
logic somewhere?

Finally, my thought also was, if any of these thread usages/cases of Tasks RCU
RUDE assume working only on a CONFIG_PREEMPT_NONE=y or
CONFIG_PREEMPT_VOLUNTARY=y kernel, that could be worrying but AFAICS, they don't
assume anything related to that.

thanks,

 - Joel

  parent reply	other threads:[~2024-03-04  9:16 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-27 15:44 [PATCH] net: raise RCU qs after each threaded NAPI poll Yan Zhai
2024-02-27 16:44 ` Eric Dumazet
2024-02-27 18:32   ` Paul E. McKenney
2024-02-27 21:22     ` Yan Zhai
2024-02-27 22:58       ` Paul E. McKenney
2024-02-28  3:10     ` Jakub Kicinski
2024-02-28  4:42       ` Paul E. McKenney
2024-02-28 14:43         ` Jakub Kicinski
2024-02-28 15:15           ` Paul E. McKenney
2024-02-28 15:35             ` Jakub Kicinski
2024-02-28 15:57               ` Yan Zhai
2024-02-28 11:50     ` Toke Høiland-Jørgensen
2024-02-28 15:10       ` Paul E. McKenney
2024-02-28 15:48         ` Yan Zhai
2024-02-28 17:47           ` Paul E. McKenney
2024-02-28 15:37     ` Joel Fernandes
2024-02-28 16:37       ` Yan Zhai
2024-02-28 17:18         ` Paul E. McKenney
2024-02-28 20:14           ` Joel Fernandes
2024-02-28 21:13             ` Paul E. McKenney
2024-02-28 21:27               ` Joel Fernandes
2024-02-28 21:52                 ` Paul E. McKenney
2024-02-28 22:10                   ` Joel Fernandes
2024-02-28 22:19                     ` Paul E. McKenney
2024-02-28 22:33                       ` Steven Rostedt
2024-02-28 22:48                         ` Alexei Starovoitov
2024-02-28 22:58                           ` Paul E. McKenney
2024-02-29 14:21                             ` Joel Fernandes
2024-02-29 16:57                               ` Paul E. McKenney
2024-02-29 17:41                                 ` Joel Fernandes
2024-02-29 18:29                                   ` Paul E. McKenney
2024-03-02  2:24                                     ` Joel Fernandes
2024-03-03  0:25                                       ` Paul E. McKenney
2024-03-03  1:01                                         ` Joel Fernandes
2024-03-04  9:16                                           ` Joel Fernandes
2024-03-05 17:53                                             ` Paul E. McKenney
2024-03-05 19:57                                               ` Mark Rutland
2024-03-05 21:52                                                 ` Paul E. McKenney
2024-03-06 16:56                                               ` Steven Rostedt
2024-03-07 16:57                                             ` Mark Rutland
2024-03-07 18:34                                               ` Mark Rutland
2024-03-07 18:52                                               ` Steven Rostedt
2024-03-07 18:58                                                 ` Paul E. McKenney
2024-03-04  9:16                                           ` Joel Fernandes [this message]
2024-02-28 22:49                         ` Paul E. McKenney
2024-02-27 21:17   ` Yan Zhai
2024-02-28 23:53   ` Yan Zhai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f3ed94a9-e50e-4d4b-bede-cc3078d4acab@joelfernandes.org \
    --to=joel@joelfernandes.org \
    --cc=kernel-team@cloudflare.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).