lkml.org 
[lkml]   [2019]   [Mar]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subject[PATCH 0/4] Convert USB subsystem to XArray
Date
I would like to remove the IDR and radix tree APIs from the kernel.
This patch series converts all the IDRs and radix trees in the USB
subsystem to use the XArray APIs. Testing of these patches has been
minimal, mostly limited to compilation testing. I would be grateful if
you could take these patches through your tree. To cut down on wasted
electrons, only this cover letter is being distributed to everyone
listed by get-maintainers; the patches can be found on the linux-usb
mailing list.

Please check these patches over carefully and test them; there may be
off-by-one errors, locking mistakes, or various other failures on my part.

Substantive interface changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- The IDR and radix tree required callers to handle their own locking.
The XArray embeds a spinlock which is taken for modifications to
the data structure; plain lookups occur under the RCU read lock or
under the spinlock.
- You can take the spinlock yourself (xa_lock() and friends) to protect
related data.
- idr_alloc() returned -ENOSPC, radix_tree_insert() returned -EEXIST.
xa_insert() and xa_alloc() return -EBUSY.
- The search keys which the radix tree calls "tags", the XArray calls
"marks".
- There is no preloading in the XArray API. Most users of the
preloading APIs only needed to use it because they were trying to
allocate under their own spinlock. If your locking is exceptionally
complicated, you may need to use xa_insert() with a NULL pointer.
- The radix tree provided GFP flags as part of the tree definition;
the XArray (like the IDR) passes GFP flags at the point of allocation.
- radix_tree_insert() of a NULL pointer was not well-specified. The
XArray treats it as reserving the entry (it reads back as NULL but
a subsequent xa_insert() to that slot will fail).
- xa_alloc() and xa_alloc_cyclic() need the XArray initialised with
XA_FLAGS_ALLOC or XA_FLAGS_ALLOC1. If the allocation is 1-based,
then specifying a limit on the allocation which includes 0 will
never allocate ID 0.
- xa_alloc_cyclic() returns 1 if the allocation wraps, unlike
idr_alloc_cyclic() which provides no indication.
- There is no equivalent to idr_for_each(); the xa_for_each() iterator
is similar to idr_for_each_entry().
- idr_replace() has no exact equivalent. Some users relied on its exact
semantics of only storing if the entry was non-NULL, but all users of
idr_replace() were able to use xa_store() or xa_cmpxchg().
- The family of radix tree gang lookup functions have been replaced with
xa_extract().

Matthew Wilcox (4):
usb: Convert xhci-mem to XArray
cdc-acm: Convert acm_minors to XArray
usb: Convert usb_bus_idr to XArray
usb/serial: Convert serial_minors to XArray

drivers/usb/class/cdc-acm.c | 33 ++++++-------
drivers/usb/core/devices.c | 10 ++--
drivers/usb/core/hcd.c | 40 ++++-----------
drivers/usb/core/usb.c | 1 -
drivers/usb/host/r8a66597-hcd.c | 4 +-
drivers/usb/host/xhci-mem.c | 86 ++++++++++++---------------------
drivers/usb/host/xhci.h | 5 +-
drivers/usb/mon/mon_main.c | 7 ++-
drivers/usb/serial/usb-serial.c | 21 ++++----
include/linux/usb/hcd.h | 3 +-
10 files changed, 74 insertions(+), 136 deletions(-)

--
2.20.1

\
 
 \ /
  Last update: 2019-03-18 22:18    [W:0.186 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site