From: Boqun Feng <boqun.feng@gmail.com>
To: Frederic Weisbecker <frederic@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Joel Fernandes <joel@joelfernandes.org>,
Neeraj Upadhyay <neeraj.upadhyay@amd.com>,
"Paul E . McKenney" <paulmck@kernel.org>,
Uladzislau Rezki <urezki@gmail.com>,
Zqiang <qiang.zhang1211@gmail.com>, rcu <rcu@vger.kernel.org>
Subject: Re: [PATCH 11/11] rcu/nocb: Simplify (de-)offloading state machine
Date: Tue, 2 Jul 2024 16:19:36 -0700 [thread overview]
Message-ID: <ZoSLCHWKXAOvd5Zl@boqun-archlinux> (raw)
In-Reply-To: <20240530134552.5467-12-frederic@kernel.org>
On Thu, May 30, 2024 at 03:45:52PM +0200, Frederic Weisbecker wrote:
> Now that the (de-)offloading process can only apply to offline CPUs,
> there is no more concurrency between rcu_core and nocb kthreads. Also
> the mutation now happens on empty queues.
>
> Therefore the state machine can be reduced to a single bit called
> SEGCBLIST_OFFLOADED. Simplify the transition as follows:
>
> * Upon offloading: queue the rdp to be added to the rcuog list and
> wait for the rcuog kthread to set the SEGCBLIST_OFFLOADED bit. Unpark
> rcuo kthread.
>
> * Upon de-offloading: Park rcuo kthread. Queue the rdp to be removed
> from the rcuog list and wait for the rcuog kthread to clear the
> SEGCBLIST_OFFLOADED bit.
>
> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> ---
[...]
> diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h
> index 24daf606de0c..72a2990d2087 100644
> --- a/kernel/rcu/tree_nocb.h
> +++ b/kernel/rcu/tree_nocb.h
[...]
> @@ -1079,29 +1080,14 @@ static int rcu_nocb_rdp_deoffload(struct rcu_data *rdp)
> * but we stick to paranoia in this rare path.
> */
> rcu_nocb_lock_irqsave(rdp, flags);
> - rcu_segcblist_clear_flags(&rdp->cblist, SEGCBLIST_KTHREAD_GP);
> - rcu_nocb_unlock_irqrestore(rdp, flags);
> + rcu_segcblist_clear_flags(&rdp->cblist, SEGCBLIST_OFFLOADED);
> + raw_spin_unlock_irqrestore(&rdp->nocb_lock, flags);
>
Dropping rdp->nocb_lock unconditionally means we are the holder of it,
right? If so, I think we better replace the above
rcu_nocb_lock_irqsave() with raw_spin_lock_irqsave().
Regards,
Boqun
> list_del(&rdp->nocb_entry_rdp);
> }
> +
> mutex_unlock(&rdp_gp->nocb_gp_kthread_mutex);
>
> - /*
> - * Lock one last time to acquire latest callback updates from kthreads
> - * so we can later handle callbacks locally without locking.
> - */
> - rcu_nocb_lock_irqsave(rdp, flags);
> - /*
> - * Theoretically we could clear SEGCBLIST_LOCKING after the nocb
> - * lock is released but how about being paranoid for once?
> - */
> - rcu_segcblist_clear_flags(cblist, SEGCBLIST_LOCKING);
> - /*
> - * Without SEGCBLIST_LOCKING, we can't use
> - * rcu_nocb_unlock_irqrestore() anymore.
> - */
> - raw_spin_unlock_irqrestore(&rdp->nocb_lock, flags);
> -
> return 0;
> }
>
[...]
next prev parent reply other threads:[~2024-07-02 23:20 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-30 13:45 [PATCH 00/11] rcu/nocb: (De-)offloading on offline CPUs Frederic Weisbecker
2024-05-30 13:45 ` [PATCH 01/11] rcu/nocb: Introduce RCU_NOCB_LOCKDEP_WARN() Frederic Weisbecker
2024-05-30 13:45 ` [PATCH 02/11] rcu/nocb: Move nocb field at the end of state struct Frederic Weisbecker
2024-05-30 13:45 ` [PATCH 03/11] rcu/nocb: Assert no callbacks while nocb kthread allocation fails Frederic Weisbecker
2024-05-30 13:45 ` [PATCH 04/11] rcu/nocb: Introduce nocb mutex Frederic Weisbecker
2024-05-30 13:45 ` [PATCH 05/11] rcu/nocb: (De-)offload callbacks on offline CPUs only Frederic Weisbecker
2024-05-30 13:45 ` [PATCH 06/11] rcu/nocb: Remove halfway (de-)offloading handling from bypass Frederic Weisbecker
2024-05-30 13:45 ` [PATCH 07/11] rcu/nocb: Remove halfway (de-)offloading handling from rcu_core()'s QS reporting Frederic Weisbecker
2024-05-30 13:45 ` [PATCH 08/11] rcu/nocb: Remove halfway (de-)offloading handling from rcu_core Frederic Weisbecker
2024-05-30 13:45 ` [PATCH 09/11] rcu/nocb: Remove SEGCBLIST_RCU_CORE Frederic Weisbecker
2024-05-30 13:45 ` [PATCH 10/11] rcu/nocb: Remove SEGCBLIST_KTHREAD_CB Frederic Weisbecker
2024-05-30 13:45 ` [PATCH 11/11] rcu/nocb: Simplify (de-)offloading state machine Frederic Weisbecker
2024-07-02 23:19 ` Boqun Feng [this message]
2024-07-03 12:17 ` Frederic Weisbecker
2024-07-03 22:56 ` [PATCH 11/11 v2] " Frederic Weisbecker
2024-07-03 23:52 ` Paul E. McKenney
2024-07-19 17:30 ` [PATCH 00/11] rcu/nocb: (De-)offloading on offline CPUs Paul E. McKenney
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=ZoSLCHWKXAOvd5Zl@boqun-archlinux \
--to=boqun.feng@gmail.com \
--cc=frederic@kernel.org \
--cc=joel@joelfernandes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neeraj.upadhyay@amd.com \
--cc=paulmck@kernel.org \
--cc=qiang.zhang1211@gmail.com \
--cc=rcu@vger.kernel.org \
--cc=urezki@gmail.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
all inboxes | Powered by JetHome®