Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp445012pxb; Mon, 16 Aug 2021 08:57:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQirRd5ZFXPbI8klaGqNBcEGoWYUN+vroQLCyIl0fP5aWEZYn+UqIyoVtgWKBAg6QPlXtb X-Received: by 2002:a05:6402:220e:: with SMTP id cq14mr21048142edb.52.1629129453720; Mon, 16 Aug 2021 08:57:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629129453; cv=none; d=google.com; s=arc-20160816; b=Mr/RUSYPNH2+pTWOXsBrcq+xmSATCTiTpxJEKA+zA8Yri5q0MUi9vSM3tiLKredF4L lMupghWwTvdeafkIFrBx3M/orAgAyRyXsV0ILJf6rI8+V3ULgMBw6G4jGEoJ5dItX3QU Quw2VCsV8nzmiCoG5vOetWlR6v3zUKrHDzXv5kA1vh3fxrVH8bZ5POFStE1aGFvrc2h3 oKNmrQFmiTxTyMLURx6gkwOwO2qgijk0dORE9QYUC6TbVayxjYTfo2xapLxJmyxRTTu8 +ijbnq76z13g04e2OsLRjFZoBshZQfwKqi433075Eyz1UTwLwcUIwrDEQC2N4TdV97qj B97w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vowSDyvV6BVV9nkqTgL8FEX7Ao6omBZWMHCvTvaYtvQ=; b=w0eCh99YIqeU0KAodUt8WQjfoeNNU2eajTGC/rHYnc1kx3tI83yMjcaRgxpkF8NTkF +E/USUzPw4Ixog5Xi44wJkZ+D73PPZoEGK6STr9GfEG4jKUwN3xyXixGOBbD8J6y89vL LoRii8ahWI0qiI1uPh0XvRuubjNn2FFXfkHJdRBlQz1ZNqiaiPMwhhmPNmPMFTvz2Kg/ GX2Rf7I/u61830RnDSAbZeNsvXBd61DE2e+Kk43LiKTkJ8ildRGJpVXZ7ASyRj/unO+S s0J8upfiSvqzK1ozcO38xBD2V0MH/fMFAMZML4UOEaxrc6ePqt8KGAmTc9cOdzzEbdXX aTDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="eR/LqbLz"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m20si11308808edq.489.2021.08.16.08.57.11; Mon, 16 Aug 2021 08:57:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="eR/LqbLz"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236652AbhHPP4Q (ORCPT + 99 others); Mon, 16 Aug 2021 11:56:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:42472 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237406AbhHPPyt (ORCPT ); Mon, 16 Aug 2021 11:54:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 79E3660F4B; Mon, 16 Aug 2021 15:53:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629129229; bh=wjnnlmVi3Qh8uS9MigPn3yJA2hsAEy/ZbPM5padIYCI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eR/LqbLzu0HGG6fZDVjcWPHFekOC2mneksHBNVGKeuM9Cw1T1xzV9bbzjuBxgM4tj nYvJPXZZQ7o3v51+n3svA0qXNaulJG9xK00Q9XOEiYlTG6tRQKQcCrFMNXBKGnpab/ FVQEHFabQBsmdr2te0sSHcg4MKwJ0svoTihZcgbOWoZA0DoaqCp+qUvWK8NzWKU2zN 1vLyDRANb7AVO36P2kMmtWK+iwp0WVo2XI7i7wttx7zL4GceB0nSmlyPitZoG4DCg3 4V5dR45G+J3nF8bJCw9mdVky+JYZt7LuWfIwKcvV5+F+LA9kFiWI08tQuG+ltBuuza 1UYeUDAgk/pfw== Date: Mon, 16 Aug 2021 18:53:45 +0300 From: Leon Romanovsky To: Jakub Kicinski Cc: "David S . Miller" , Guangbin Huang , Jacob Keller , Jiri Pirko , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Salil Mehta , Shannon Nelson , Yisen Zhuang , Yufeng Mo Subject: Re: [PATCH net-next 3/6] devlink: Count struct devlink consumers Message-ID: References: <20210816084741.1dd1c415@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210816084741.1dd1c415@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 16, 2021 at 08:47:41AM -0700, Jakub Kicinski wrote: > On Sat, 14 Aug 2021 12:57:28 +0300 Leon Romanovsky wrote: > > From: Leon Romanovsky > > > > The struct devlink itself is protected by internal lock and doesn't > > need global lock during operation. That global lock is used to protect > > addition/removal new devlink instances from the global list in use by > > all devlink consumers in the system. > > > > The future conversion of linked list to be xarray will allow us to > > actually delete that lock, but first we need to count all struct devlink > > users. > > Not a problem with this set but to state the obvious the global devlink > lock also protects from concurrent execution of all the ops which don't > take the instance lock (DEVLINK_NL_FLAG_NO_LOCK). You most likely know > this but I thought I'd comment on an off chance it helps. The end goal will be something like that: 1. Delete devlink lock 2. Rely on xa_lock() while grabbing devlink instance (past devlink_try_get) 3. Convert devlink->lock to be read/write lock to make sure that we can run get query in parallel. 4. Open devlink netlink to parallel ops, ".parallel_ops = true". Thanks > > > The reference counting provides us a way to ensure that no new user > > space commands success to grab devlink instance which is going to be > > destroyed makes it is safe to access it without lock. >