linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joel Fernandes <joel@joelfernandes.org>
To: paulmck@kernel.org
Cc: Yan Zhai <yan@cloudflare.com>, Eric Dumazet <edumazet@google.com>,
	netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Jiri Pirko <jiri@resnulli.us>, Simon Horman <horms@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Lorenzo Bianconi <lorenzo@kernel.org>,
	Coco Li <lixiaoyan@google.com>, Wei Wang <weiwan@google.com>,
	Alexander Duyck <alexanderduyck@fb.com>,
	Hannes Frederic Sowa <hannes@stressinduktion.org>,
	linux-kernel@vger.kernel.org, rcu@vger.kernel.org,
	bpf@vger.kernel.org, kernel-team@cloudflare.com,
	rostedt@goodmis.org, mark.rutland@arm.com
Subject: Re: [PATCH] net: raise RCU qs after each threaded NAPI poll
Date: Wed, 28 Feb 2024 17:10:43 -0500	[thread overview]
Message-ID: <3D27EFEF-0452-4555-8277-9159486B41BF@joelfernandes.org> (raw)
In-Reply-To: <02913b40-7b74-48b3-b15d-53133afd3ba6@paulmck-laptop>



> On Feb 28, 2024, at 4:52 PM, Paul E. McKenney <paulmck@kernel.org> wrote:
> 
> On Wed, Feb 28, 2024 at 04:27:47PM -0500, Joel Fernandes wrote:
>> 
>> 
>>>> On Feb 28, 2024, at 4:13 PM, Paul E. McKenney <paulmck@kernel.org> wrote:
>>> 
>>> On Wed, Feb 28, 2024 at 03:14:34PM -0500, Joel Fernandes wrote:
>>>>> On Wed, Feb 28, 2024 at 12:18 PM Paul E. McKenney <paulmck@kernel.org> wrote:
>>>>> 
>>>>> On Wed, Feb 28, 2024 at 10:37:51AM -0600, Yan Zhai wrote:
>>>>>> On Wed, Feb 28, 2024 at 9:37 AM Joel Fernandes <joel@joelfernandes.org> wrote:
>>>>>>> Also optionally, I wonder if calling rcu_tasks_qs() directly is better
>>>>>>> (for documentation if anything) since the issue is Tasks RCU specific. Also
>>>>>>> code comment above the rcu_softirq_qs() call about cond_resched() not taking
>>>>>>> care of Tasks RCU would be great!
>>>>>>> 
>>>>>> Yes it's quite surprising to me that cond_resched does not help here,
>>>>> 
>>>>> In theory, it would be possible to make cond_resched() take care of
>>>>> Tasks RCU.  In practice, the lazy-preemption work is looking to get rid
>>>>> of cond_resched().  But if for some reason cond_resched() needs to stay
>>>>> around, doing that work might make sense.
>>>> 
>>>> In my opinion, cond_resched() doing Tasks-RCU QS does not make sense
>>>> (to me), because cond_resched() is to inform the scheduler to run
>>>> something else possibly of higher priority while the current task is
>>>> still runnable. On the other hand, what's not permitted in a Tasks RCU
>>>> reader is a voluntary sleep. So IMO even though cond_resched() is a
>>>> voluntary call, it is still not a sleep but rather a preemption point.
>>> 
>>> From the viewpoint of Task RCU's users, the point is to figure out
>>> when it is OK to free an already-removed tracing trampoline.  The
>>> current Task RCU implementation relies on the fact that tracing
>>> trampolines do not do voluntary context switches.
>> 
>> Yes.
>> 
>>> 
>>>> So a Tasks RCU reader should perfectly be able to be scheduled out in
>>>> the middle of a read-side critical section (in current code) by
>>>> calling cond_resched(). It is just like involuntary preemption in the
>>>> middle of a RCU reader, in disguise, Right?
>>> 
>>> You lost me on this one.  This for example is not permitted:
>>> 
>>>   rcu_read_lock();
>>>   cond_resched();
>>>   rcu_read_unlock();
>>> 
>>> But in a CONFIG_PREEMPT=y kernel, that RCU reader could be preempted.
>>> 
>>> So cond_resched() looks like a voluntary context switch to me.  Recall
>>> that vanilla non-preemptible RCU will treat them as quiescent states if
>>> the grace period extends long enough.
>>> 
>>> What am I missing here?
>> 
>> That we are discussing Tasks-RCU read side section? Sorry I should have been more clear. I thought sleeping was not permitted in Tasks RCU reader, but non-sleep context switches (example involuntarily getting preempted were).
> 
> Well, to your initial point, cond_resched() does eventually invoke
> preempt_schedule_common(), so you are quite correct that as far as
> Tasks RCU is concerned, cond_resched() is not a quiescent state.

 Thanks for confirming. :-)

 - Joel



> 
>                        Thanx, Paul

  reply	other threads:[~2024-02-28 22:10 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 [this message]
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
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=3D27EFEF-0452-4555-8277-9159486B41BF@joelfernandes.org \
    --to=joel@joelfernandes.org \
    --cc=alexanderduyck@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hannes@stressinduktion.org \
    --cc=horms@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=kernel-team@cloudflare.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lixiaoyan@google.com \
    --cc=lorenzo@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=paulmck@kernel.org \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=weiwan@google.com \
    --cc=yan@cloudflare.com \
    /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).