Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp247386pxb; Wed, 18 Aug 2021 01:06:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiTI851ixZ9MqMzYec+VMuUlUOkXAHdzB0sYugz1ayXF0GF693ibQg47xua0F7DVQ0ouvb X-Received: by 2002:a05:6602:2ac7:: with SMTP id m7mr6217356iov.66.1629273998540; Wed, 18 Aug 2021 01:06:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629273998; cv=none; d=google.com; s=arc-20160816; b=jzrPFwlwtBGnPyiYR+beZPpeScmTpjO0/4niqzSVSmuUOjqwrT5eeYOn5hJ0bJPUVO AB53+XECVpPr3qpwf9KMFpz8o/zw4e/V23s3TdBM+NrOOzNrZM24FKXjXYWDQcAlYZFS HYcabs94XIoDufFf6v1HfhehVK8JaqXcxSDAEkLIBmjFhhO2NdyZ6i2BAtnc4kPcN6cm WW+7HOlLX7nGA4FLx+nJGClB09sYvTg3t70s4LqD7fXC+gr53LmpESz8SQswBJsuCppi q6b5mhs+bApnKVKtrWR3qPKswhmIYfyih2RZyEK8TlIPCjplhT55wAfZGKF7dG3ve0Oz gCew== 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=1WMx4mkNNLSE3AZhXFdl1Zzequ1+net7Dano3pGPZjA=; b=XH6QzEF7xaDB4++D/JxDJreUzW42qYLhfaJvL6iVWEIL2s+GAQ4bCi5r58+mUWJJJS /Hz385SVXGCb0Ar+CmKsXZpQjJElzxg7Z5GZOaqckR1xTFD2e93DidbzKmAxDOqeNikS x0RUK+c+YjInKidRWP6QrUvqbLt4z7Zer2KA/yYEAwr35vt8IIUoW4iRORIdAmKzrkBe YcZ90IUI6gHiJqjR9FLcAWWVanb5VBX3T6Vtpn3JvIsXI/PJkXQy91Imkk2nUmUZYIjT A0cUH3xdOIuA6zLBsV7/3VM8Pv//j/pj9plO6KhtPt9sxTV2tjES8SVF5q4IlpoqIKXn 3iFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eCjsWayN; 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 t7si4848927ilf.11.2021.08.18.01.06.27; Wed, 18 Aug 2021 01:06:38 -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=eCjsWayN; 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 S239532AbhHRIFh (ORCPT + 99 others); Wed, 18 Aug 2021 04:05:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:56728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239112AbhHRIDt (ORCPT ); Wed, 18 Aug 2021 04:03:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4438D60EB5; Wed, 18 Aug 2021 08:03:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629273792; bh=5FpJoSsWAijWF1s+2IOmDRgN6RifYoWI9x/j4oSsSuo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eCjsWayN9W0nDaLKUgwVjLP37cSR+eyzVa0lW+E3UgnWM8Ed+d2Ht97prOHtEab2/ X/x71YQb858la7JnAqUYjETDTaVoI228RR2bOvzi2OgjMVIlBlbZ/8S+YfbPlvuRmA qDyrCBWHP1jugX/jb0oNaBEO+69SPhZPEsL2XnfzI82tOaQvvxwQWf2JUtBdrTIfce C/L6LJmsBpGkFD6E+64WmOyCKq09uOEPezgI9Hl0j2zREAGQdwlgdGVajFmuLq70Dg dLof8zrC4r3wJKXv/W4ZxGmO8mrOtxCLU11Mxet2Amkm8KUuNk49BpAAlV2VYx+8An Dgwl0rIg9ooWw== Date: Wed, 18 Aug 2021 11:03:09 +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> <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: <20210816090700.313a54ba@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 16, 2021 at 09:07:00AM -0700, Jakub Kicinski wrote: > 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? write lock, because we are adding port to devlink->port_list. 9099 int devlink_port_register(struct devlink *devlink, 9100 struct devlink_port *devlink_port, 9101 unsigned int port_index) 9102 { ... 9115 list_add_tail(&devlink_port->list, &devlink->port_list);