Re: [PATCH v2] staging: greybus: Convert uart.c from IDR to XArray

From: Fabio M. De Francesco
Date: Tue Aug 17 2021 - 06:17:20 EST


On Monday, August 16, 2021 4:46:08 PM CEST Alex Elder wrote:
> On 8/14/21 1:11 PM, Fabio M. De Francesco wrote:
> > Convert greybus/uart.c from IDR to XArray. The abstract data type XArray
> > is more memory-efficient, parallelisable, and cache friendly. It takes
> > advantage of RCU to perform lookups without locking. Furthermore, IDR is
> > deprecated because XArray has a better (cleaner and more consistent) API.
>
> I haven't verified the use of the new API (yet) but I have a few
> comments on your patch, below.
>
> -Alex
>
Hi Alex,

As I promised in another message, I've already submitted a v3 of this patch:
https://lkml.org/lkml/2021/8/16/1188

While I'm pretty sure that XArray should be used in place of the older and less
efficient IDR (some time ago Matthew Wilcox agreed and confirmed that this
is true), I'm not entirely sure if we should also prefer XArray over IDA for this
particular driver.

Initially I had decided to convert the other greybus file from IDA to XArray but
then I stopped because of the above-mentioned doubts.

I really don't know if it is worth doing this work. As far as I understand these API,
IDA (although it is not as versatile as IDR is) is more memory efficient than IDR.
In documentation I read: "The IDA is an ID allocator which does not provide the
ability to associate an ID with a pointer. As such, it only needs to store one bit
per ID, and so is more space efficient than an IDR.".

May you please say if you think that the driver would also benefit by the
conversion from IDA to XArray?

Thanks,

Fabio