Message ID | 20190204211751.19001-1-jgg@ziepe.ca (mailing list archive) |
---|---|
Headers | show
Return-Path: <linux-rdma-owner@kernel.org> 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 1703F13B4 for <patchwork-linux-rdma@patchwork.kernel.org>; Mon, 4 Feb 2019 21:18:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02C082B1EB for <patchwork-linux-rdma@patchwork.kernel.org>; Mon, 4 Feb 2019 21:18:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E52342B5B8; Mon, 4 Feb 2019 21:18:02 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 6670F2B1EB for <patchwork-linux-rdma@patchwork.kernel.org>; Mon, 4 Feb 2019 21:18:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729301AbfBDVSB (ORCPT <rfc822;patchwork-linux-rdma@patchwork.kernel.org>); Mon, 4 Feb 2019 16:18:01 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:44787 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729055AbfBDVSB (ORCPT <rfc822;linux-rdma@vger.kernel.org>); Mon, 4 Feb 2019 16:18:01 -0500 Received: by mail-pf1-f193.google.com with SMTP id u6so497820pfh.11 for <linux-rdma@vger.kernel.org>; Mon, 04 Feb 2019 13:18:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UwerIFIxflrXtNEh4Np2a90pelpEK5KLM4H7ffZh+/M=; b=meGIHSVNnrZpwPQaUPSIWMwuZbEDRXyrSn2/BgtJH/j0S5iWtf8Oy6KHREeff9X8ad /rgkjlWN5eu3ocsP+4D0Fnrf9dMqvfuOqW17hcAq0BQ23daungRE+1IoQBKTfCQ9cpvX qF6RCOXBwK243QoW+25iEwK6GB5XP6X7sBd3aDJqPeS7uZmk4/6s5S2qzFOLibYigCa7 vlvmZ9IEakpIneg9lRGt3PHDOi8XMr+kqnNw8ghiXoAHG5y2Rw31eGsEDElIc/FrknEG BJWdtT/RKoifa5I4XVP20AIvgXwtQtZXOkSJKkdGYiH6IYiMITSVyhqhBV99xQsFsCJ4 LKSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UwerIFIxflrXtNEh4Np2a90pelpEK5KLM4H7ffZh+/M=; b=KHL+7UAw8M16Xx+2TRrL4+JxILyVOrQtliFYnH6lm/ycb0VSzEGVqs7tHhqfh966fv xoL0fQwkXzi5t9rdwScHSg2i1/3nfzSDWSnaBZ8yV5bugc7ILa7CMWUmdVKGxNyLI7hl 3i0AYTcz3wBG8cJMix4xWP8nV88IO/aDwJ3RTvwdqNbCCXgALEuWNUJA70HdV2QClj22 lSiYshODV7FeoKxYvyDoE1ZDKtN0BvW7EMKNjO7c4rybwXhp781UF+LIwh1KPGGJDsJx k87BO4nkI600CQxCw6W0f/MduDrhXKTHqgFjQFDp4e6HqDHGsdD3TBap8fNWtqcG5c7Y e0Sg== X-Gm-Message-State: AHQUAuZPTu8jQ1hnoEKfmUX/92wmUZf9Br8K4lfewcJdwztgL01LlO3r Yo2qvcOlsW+vniuVACo2O2UuG8e99LM= X-Google-Smtp-Source: AHgI3IZOL97nspLQ9qkH8g53iscL/sNWjjnsp/XRAJhW+4uHrbu0mnHGPdbiFyZrQhmLeR0rwxXy/Q== X-Received: by 2002:a62:9913:: with SMTP id d19mr1375621pfe.107.1549315080058; Mon, 04 Feb 2019 13:18:00 -0800 (PST) Received: from ziepe.ca (S010614cc2056d97f.ed.shawcable.net. [174.3.196.123]) by smtp.gmail.com with ESMTPSA id y84sm2782512pfb.81.2019.02.04.13.17.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 04 Feb 2019 13:17:59 -0800 (PST) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from <jgg@ziepe.ca>) id 1gqlcs-0005KB-DK; Mon, 04 Feb 2019 14:17:58 -0700 From: Jason Gunthorpe <jgg@ziepe.ca> To: linux-rdma@vger.kernel.org Cc: Jason Gunthorpe <jgg@mellanox.com>, Matthew Wilcox <willy@infradead.org> Subject: [PATCH 0/8] Rework device, client and client data locking Date: Mon, 4 Feb 2019 14:17:43 -0700 Message-Id: <20190204211751.19001-1-jgg@ziepe.ca> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: <linux-rdma.vger.kernel.org> X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP |
Series |
Rework device, client and client data locking
|
expand
|
From: Jason Gunthorpe <jgg@mellanox.com> The convoluted locking in this file has become a problem now that we want to do more complicated things with the device registration life cycle. This replaces the scheme with simple approaching using xarray instead of linked lists. Each of the three xarray's has its own lock. Which lock to hold becomes very clear as they only protect one xarray, no more multiple locks protecting the same data. xarray makes this possible because it has restartable iteration which trivially solves the sticky locking problem between client data and client registration. The xarray is a natural fit for these datastructures as we now have an ID number direct lookup for the struct device and we have a direct lookup access pattern for client data. The client list is converted as well as that is a straightforward way to get unique per-client ID numbers for the client data array and keeps the locking scheme symmetrical. This code could be improved with two functional improvement to xarray - iteration over all allocated values (including NULL) and reverse find. For now some work arounds are used and I can explore xarray improvements later. Jason Gunthorpe (8): RDMA/device: Check that the rename is nop under the lock RDMA/device: Ensure that security memory is always freed RDMA/device: Call ib_cache_release_one() only from ib_device_release() RDMA/device: Get rid of reg_state RDMA/device: Use an ida instead of a free page in alloc_name RDMA/devices: Use xarray to store the clients RDMA/devices: Use xarray to store the client_data RDMA/devices: Re-organize device.c locking drivers/infiniband/core/cache.c | 3 + drivers/infiniband/core/core_priv.h | 4 +- drivers/infiniband/core/device.c | 729 ++++++++++++++++------------ drivers/infiniband/core/security.c | 4 +- include/rdma/ib_verbs.h | 33 +- 5 files changed, 439 insertions(+), 334 deletions(-)