All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Bjorn Andersson <andersson@kernel.org>,
	linux-remoteproc@vger.kernel.org,
	Baolin Wang <baolin.wang@linux.alibaba.com>
Subject: Re: [PATCH v2 0/4] hwspinlock: add summary in debugfs
Date: Mon, 29 Jun 2026 10:57:14 +0200	[thread overview]
Message-ID: <akIzahjROM4GAlOR@ninjato> (raw)
In-Reply-To: <ajk_u7TVT-kL8z2A@casper.infradead.org>

Hi Matthew,

> > Because the radix tree seems to have no dedicated tree nor maintainer, I
> > suggest that all these patches go in via hwspinlock. This also keeps the
> > dependencies zero.
> 
> The radix tree is deprecated.  I don't want to add any new functionality
> to it.  Here's a replacement patch to convert hwspinlock to use an
> XArray instead of a radix tree.  Compile tested only.

Okay, seems to work so far. Thank you again! Will merge your patch into
my series with your credits. Now I just need to wrap XArray into struct
seq_operations. Seems no one has needed that in the kernel so far.

Some comments and questions to get a better understanding.

> From 8ec88ed466e8153f546f7e8e69193cd5389488ee Mon Sep 17 00:00:00 2001
> From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> Date: Mon, 22 Jun 2026 09:38:30 -0400
> Subject: [PATCH] hwspinlock: Convert to XArray
> 
> The radix tree is deprecated.  The XArray uses the same data structure
> with a nicer interface.  The hwspinlock_tree_lock is not needed as the
> spinlock built into the XArray is sufficient for all these cases.
> 
> hwspin_lock_register_single() used to always return 0.  Its caller
> thinks it can return an errno, so I believe this to be a bug and so I
> have restored its ability to return an error.

I sent a patch for that previously and would rebase your patch on mine
to keep the one patch per issue ration.

> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>  drivers/hwspinlock/hwspinlock_core.c | 133 ++++++++++-----------------
>  1 file changed, 50 insertions(+), 83 deletions(-)
> 
> diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwspinlock_core.c
> index cc8e952a6772..1dd68b8410dd 100644
> --- a/drivers/hwspinlock/hwspinlock_core.c
> +++ b/drivers/hwspinlock/hwspinlock_core.c
> @@ -16,7 +16,7 @@
>  #include <linux/types.h>
>  #include <linux/err.h>
>  #include <linux/jiffies.h>
> -#include <linux/radix-tree.h>
> +#include <linux/xarray.h>

According to some quick grepping, there are 102 users of XArray
including this header and 423 users which are not including this header.
Do you think this is a useful improvement to add the header directly
(per subsystem to keep the number of patches limited)?

> -	void **slot;

Great, this obsoletes a fix concerning RCU annotations I have sent
previously!

> @@ -389,15 +375,9 @@ int of_hwspin_lock_get_id(struct device_node *np, int index)
>  	/* Find the hwspinlock device: we need its base_id */
>  	ret = -EPROBE_DEFER;
>  	rcu_read_lock();
> -	radix_tree_for_each_slot(slot, &hwspinlock_tree, &iter, 0) {
> -		hwlock = radix_tree_deref_slot(slot);
> -		if (unlikely(!hwlock))
> -			continue;
> -		if (radix_tree_deref_retry(hwlock)) {
> -			slot = radix_tree_iter_retry(&iter);
> +	xas_for_each(&xas, hwlock, ULONG_MAX) {
> +		if (xas_retry(&xas, hwlock))

So, the unlikely(!hwlock) case cannot happen with XArray?

> -	ret = radix_tree_tag_get(&hwspinlock_tree, id, HWSPINLOCK_UNUSED);
> +	ret = xas_get_mark(&xas, HWSPINLOCK_UNUSED);

xas_get_mark() returns bool, so I will update the code to match that.
Makes it more readable, too, IMO.

The rest I could understand, I think. Looks much leaner, in deed. Will
keep you in the loop once my next iteration is ready.

Happy hacking,

   Wolfram


  parent reply	other threads:[~2026-06-29  8:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-22  8:51 [PATCH v2 0/4] hwspinlock: add summary in debugfs Wolfram Sang
2026-06-22  8:52 ` [PATCH v2 1/4] radix-tree: add parameter doc for radix_tree_deref_slot_protected() Wolfram Sang
2026-06-22 10:16   ` Andy Shevchenko
2026-06-22  8:52 ` [PATCH v2 2/4] radix-tree: allow more lock types with radix_tree_deref_slot_protected() Wolfram Sang
2026-06-22 10:18   ` Andy Shevchenko
2026-06-22  8:52 ` [PATCH v2 3/4] hwspinlock: annotate slot pointer as RCU sensitive Wolfram Sang
2026-06-22 10:20   ` Andy Shevchenko
2026-06-29  9:07   ` Wolfram Sang
2026-06-22  8:52 ` [PATCH v2 4/4] hwspinlock: add summary in debugfs Wolfram Sang
2026-06-22 10:24   ` Andy Shevchenko
2026-06-22 13:59 ` [PATCH v2 0/4] " Matthew Wilcox
2026-06-22 16:20   ` Wolfram Sang
2026-06-29  8:57   ` Wolfram Sang [this message]
2026-06-29 10:40     ` Andy Shevchenko
2026-06-29 10:55       ` Wolfram Sang
2026-06-29 18:54     ` Matthew Wilcox
2026-07-01 15:07       ` Wolfram Sang
2026-06-29 10:03   ` Wolfram Sang

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=akIzahjROM4GAlOR@ninjato \
    --to=wsa+renesas@sang-engineering.com \
    --cc=andersson@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=willy@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.