Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp253050pxb; Wed, 18 Aug 2021 01:15:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpT0AtwBoTkOE9uahYpYFr7XTlAg8ett63cDaRu8ZN0729m0QjFhySLCjRdvvOOTPwgL6J X-Received: by 2002:a50:ef11:: with SMTP id m17mr8661671eds.233.1629274531440; Wed, 18 Aug 2021 01:15:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629274531; cv=none; d=google.com; s=arc-20160816; b=lIxK8IPxvu7uldo7YSe1UI/U05cRTOQprjBUkOprZRU/ZLkSc6kQ9JqR1l0hXrRFXx /TaNnKavvyS6dpVX3lbzQMVMIZ2VveNE47Pvc/SpGCGGdW/2hSub9Mzu1riD/91ZeY6S 56hgBaqkt26BvjMpmTOA684v0v3QLxlIY7ZIbH+pShAgZSCx7psM2/EL2xo+jOgUqyKx UBa9yN3yGY85yUTlLIw39Qi6uyEH3MUBjC4R97L45E7tUrG8Qs5D9NFT8vVfqtDZCjOb IDXZXl3L704X4r4s/Rdw5H2GBDjv1hN4f7d2WazPxrR8VmKQyW3wgij0WnnqIk769SUx 6+Bw== 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=ukewB9dt7wZLQFmMe9TbW81p85wToDi1oPqjuF08P4E=; b=DOT9dGev/kvA98qEAGrM59Sm3j0uth71WWcR1LFTCoj67IsEbV3zyHkN5+SrcVW6OH czmui6IMPcs0Fh8v7M1EVqnw1jyOZHgsXnrbRRxg+qplSkXXFRdcYfDeMbhydRuopGF7 PR6kROJBZKoJaHYNZUeJWe44cluicNLMifOZO85kg1IoZqP6QM3PSbDifHAHgS595wNY s7uID0xXugMT0/YNGAE5GMLn17svrecBE3yx36Rfx48yPUdu7KqwkSK2WdzLRT55xwLO NJGigExlK2FSjb9pVdPSQRkuYXIY7aBeK6aj2JRgZ08pGGkp7h7wnXa/2UeAM+DeQDPo 4pdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kTOoDBY7; 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 n17si5019475edd.241.2021.08.18.01.15.07; Wed, 18 Aug 2021 01:15:31 -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=kTOoDBY7; 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 S240489AbhHRINJ (ORCPT + 99 others); Wed, 18 Aug 2021 04:13:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:33226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240622AbhHRIMx (ORCPT ); Wed, 18 Aug 2021 04:12:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DA99060F58; Wed, 18 Aug 2021 08:12:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629274339; bh=zxrOxb1Q7G3y9Z3wfx9YmJefmG6HeicBAF0ENCXgsdA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kTOoDBY7gaKQ9QauedmZo6c8JZZbrhC7WVmBtnuxePFbSXT+9ZvcgOwmoxY4NR3OX 7q4hpKIC2Z9U0cbIncWT/xGmstdJTODWpmMz0nQ6BbAhP4Ca0P4ZqJ9GDmxFdrCDqA OSwiLmAcxs8sXMZNoWxPXxGHvMGgm41UTVHPbyWPdfTuhrXlX3UBCS0MFJH64DPKmO uxXy/APpXuSAMe6/nHpSoPCFnvR4gZfWSXBf0jmdj1M4HlqIYHKk2QQh6OgTJhGyxg JEkr8jBWaGq80u4E881Lk+PI//SWai8qFhFaGrGQ03oOqJhsGEgmm2bjyFc4WrGhRr Yg70ESYrwvqng== Date: Wed, 18 Aug 2021 11:12:15 +0300 From: Leon Romanovsky To: "Keller, Jacob E" Cc: Jakub Kicinski , "David S . Miller" , Guangbin Huang , 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> <20210816090700.313a54ba@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 16, 2021 at 09:32:17PM +0000, Keller, Jacob E wrote: > > > > -----Original Message----- > > From: Jakub Kicinski > > Sent: Monday, August 16, 2021 9:07 AM > > To: Leon Romanovsky > > Cc: David S . Miller ; Guangbin Huang > > ; Keller, Jacob E ; 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 > > > > On Mon, 16 Aug 2021 18:53:45 +0300 Leon Romanovsky wrote: > > > 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". > > > > IIUC that'd mean setting eswitch mode would hold write lock on > > the dl instance. What locks does e.g. registering a dl port take > > then? > > Also that I think we have some cases where we want to allow the driver to allocate new devlink objects in response to adding a port, but still want to block other global operations from running? I don't see the flow where operations on devlink_A should block devlink_B. Only in such flows we will need global lock like we have now - devlink->lock. In all other flows, write lock of devlink instance will protect from parallel execution. Thanks