From patchwork Mon Mar 18 21:17:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 10858575 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 82D4E139A for ; Mon, 18 Mar 2019 21:17:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6239D293A0 for ; Mon, 18 Mar 2019 21:17:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FFD229532; Mon, 18 Mar 2019 21:17:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2F8F29540 for ; Mon, 18 Mar 2019 21:17:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727611AbfCRVRW (ORCPT ); Mon, 18 Mar 2019 17:17:22 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:51038 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727055AbfCRVRW (ORCPT ); Mon, 18 Mar 2019 17:17:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Message-Id:Date:Subject:To:From: Sender:Reply-To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=1w7a+dbYnqKB3SZi8lXID/YS2OOIjB8Oy2rvILtQyeE=; b=e+P49rUKaC4/zUFINSHUhudtW aEpSl/tg8coSzZbnh94iLMkAitQQSFaPT6MuZce78uCYOlp8yZhlfMY+ZfxG4jKOtDOdCdgZM5yPK 4BVuusF9eEfwtxJcgkN24GZM3yFphF3Xy017Vp1Y1CHsVluE4n3pxIwqCFSgiU5oNHJ0t439a2MLi YASjuZy3ywsoKbz6aqPrOmiINC8oiPtlKvKlNMyi9rHUoh1cFLtZMfrZAYLh4OmlpF6bv8Kcu4ML1 1/iouc4QNvefXnV521h4kaTnWziq3vtCQ7XT0eHALh+2EfdES/Y5Ov7A6Pw/UIOXHwmAq7buEVa2t Pz9VyLCbQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5zdD-0000uk-Fo; Mon, 18 Mar 2019 21:17:15 +0000 From: Matthew Wilcox To: linux-usb@vger.kernel.org, Oliver Neukum , Greg Kroah-Hartman , Mathias Nyman , Johan Hovold , Matthew Wilcox , Roger Quadros , Alan Stern , Sebastian Andrzej Siewior , Martin Blumenstingl , Dmitry Torokhov , "Gustavo A. R. Silva" , Miquel Raynal , Mathias Payer , Mans Rullgard , Kai-Heng Feng , Jia-Ju Bai , linux-kernel@vger.kernel.org Subject: [PATCH 0/4] Convert USB subsystem to XArray Date: Mon, 18 Mar 2019 14:17:09 -0700 Message-Id: <20190318211713.3462-1-willy@infradead.org> X-Mailer: git-send-email 2.14.5 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-)