From: Uladzislau Rezki <urezki@gmail.com>
To: "Joel Fernandes (Google)" <joel@joelfernandes.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-kernel@vger.kernel.org,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Josh Triplett <josh@joshtriplett.org>,
Lai Jiangshan <jiangshanlai@gmail.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
"Paul E. McKenney" <paulmck@kernel.org>,
rcu@vger.kernel.org, Steven Rostedt <rostedt@goodmis.org>,
urezki@gmail.com
Subject: Re: [PATCH rcu/dev -fixes 3/4] rcu/tree: Avoid using xchg() in kfree_call_rcu_add_ptr_to_bulk()
Date: Mon, 20 Apr 2020 19:18:29 +0200 [thread overview]
Message-ID: <20200420171829.GA12196@pc636> (raw)
In-Reply-To: <20200420153837.194532-4-joel@joelfernandes.org>
On Mon, Apr 20, 2020 at 11:38:36AM -0400, Joel Fernandes (Google) wrote:
> From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>
> There is no need to use xchg(), the access is serialized by krcp->lock.
> The xchg() function adds some atomic barriers which remain hidden in
> x86's disassembly but are visible on ARM for instance.
>
> Replace xchg() with a load + store.
>
> Acked-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> kernel/rcu/tree.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> index cd61649e1b001..f6eb3aee0935e 100644
> --- a/kernel/rcu/tree.c
> +++ b/kernel/rcu/tree.c
> @@ -3088,7 +3088,8 @@ kfree_call_rcu_add_ptr_to_bulk(struct kfree_rcu_cpu *krcp,
> /* Check if a new block is required. */
> if (!krcp->bhead ||
> krcp->bhead->nr_records == KFREE_BULK_MAX_ENTR) {
> - bnode = xchg(&krcp->bcached, NULL);
> + bnode = krcp->bcached;
> + krcp->bcached = NULL;
> if (!bnode) {
> WARN_ON_ONCE(sizeof(struct kfree_rcu_bulk_data) > PAGE_SIZE);
>
>
But we populate the cache without holding the krcp->lock. That is why it
is xchg here. See below:
<snip>
if (cmpxchg(&krcp->bcached, NULL, bhead))
free_page((unsigned long) bhead);
<snip>
we do not hold any krcp->lock here, we do not need it.
--
Vlad Rezki
next prev parent reply other threads:[~2020-04-20 17:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-20 15:38 [PATCH rcu/dev -fixes 0/4] Joel Fernandes (Google)
2020-04-20 15:38 ` [PATCH rcu/dev -fixes 1/4] rcu/tree: Keep kfree_rcu() awake during lock contention Joel Fernandes (Google)
2020-04-21 13:12 ` Uladzislau Rezki
2020-04-20 15:38 ` [PATCH rcu/dev -fixes 2/4] rcu/tree: Skip entry into the page allocator for PREEMPT_RT Joel Fernandes (Google)
2020-04-22 10:35 ` Uladzislau Rezki
2020-04-22 11:45 ` Uladzislau Rezki
2020-04-22 13:18 ` joel
2020-04-22 13:28 ` Paul E. McKenney
2020-04-20 15:38 ` [PATCH rcu/dev -fixes 3/4] rcu/tree: Avoid using xchg() in kfree_call_rcu_add_ptr_to_bulk() Joel Fernandes (Google)
2020-04-20 17:18 ` Uladzislau Rezki [this message]
2020-04-20 18:19 ` Joel Fernandes
2020-04-20 15:38 ` [PATCH rcu/dev -fixes 4/4] rcu/tree: Use consistent style for comments Joel Fernandes (Google)
2020-04-21 13:08 ` Uladzislau Rezki
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=20200420171829.GA12196@pc636 \
--to=urezki@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=jiangshanlai@gmail.com \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--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