Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp891042pxb; Wed, 27 Oct 2021 14:34:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiPcUIJl7/mIlLeEv2gAX0/H4uTpor/VF4Anf91dZBPKIOVq8wo9hDUgtEklAeFmgHOHIU X-Received: by 2002:a05:6402:28f:: with SMTP id l15mr542832edv.272.1635370453667; Wed, 27 Oct 2021 14:34:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635370453; cv=none; d=google.com; s=arc-20160816; b=c1KoscKU9btWPYxvHKOQpJ1eKsEyH4ybPIBaIQF4TpzNHX2p6apJiIZsYybkfvrUFB wYVOCyBvQsZDFxXI+m27Y+EoT6tT6qyjJiSWGPHkAvPZnNbXgmVoYFhvoDCrSzy+JHcx dw8OQ4uReVFHNBC+QpH/uQv4Ae3k/YYz6SEgmt64oGUeUv2K0i+mIvAA29GPH3gemwo+ 4DtpSL88eo+E3ZjsQ0pXVJw4OibPmeRbk5U/V/hh8INhH2uNCq5Y2XzM6VGabfnEdEcw DQZ0q1GO6Z2ZB3gBA30e/QRoF27NdsvZzzvgQ0/CgJeTG13ipdbKTmYOIuhFDYIA0/rA DSFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=1MPNTiEHfhgoykHDtmrfZnUX41O4AE1rL8LnnsqZp40=; b=ASUPrd4/wE4zw/+rRAL6YywO1cZ67xLemzpAOxYYsRrrIZMrjG7deGNLyxkVMuKS3+ HsVDyhEOc2EtKMWBx2OabltzkzPfsGJC/5wl54nml6YXw72+xr1TfOFCL+AQRZoKGhLu yUOYJ6Ar09MC3IUwjLVLKb18YiA89w7OVy0GemWeA7TS+T/9P1TiNLrpyZ7hUDz7rOr3 PhUQoqRmyGjzcq0UgE5XDoQk4RKdg4EAg6vvIIjTQZsvOlKkx5L7ZYjqW+uuYX0k34dB zytLKc4YoznS9NdNqxvBXdcpGhVnwnizaD+v7CDuzWYXB8V/GlyvqPXNUajtonoB9iG+ M50g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fbrt5wEc; 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 s4si1433770ejn.134.2021.10.27.14.33.42; Wed, 27 Oct 2021 14:34:13 -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=fbrt5wEc; 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 S240774AbhJ0Taz (ORCPT + 97 others); Wed, 27 Oct 2021 15:30:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:43838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240761AbhJ0Taw (ORCPT ); Wed, 27 Oct 2021 15:30:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B4A896103C; Wed, 27 Oct 2021 19:28:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635362906; bh=kcw33ieZ+6BozOAl8u0SxgljaLwMgNC0cYSj85UdbCg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=fbrt5wEcS5wh0pSsC+fjfTCFbaOY74aJ0JndrUwGj8kjDz/WGgkl81qQNF1lNCABu ZX2eSq7qeeVnsVyb5+kEx6GUYvzB56h88YcGk+MmW3iZwV2A2/mXc+nxGLgPB4aO4x BGKH6XshQAkMal5FTDBYc1tpD2NoVlOc3zwTM9rnMqFrBHMbhzXwHj5uROk/f3zUtY 21ZD7YNRJxjR5/zVBEJP8O+bJkxZp28kix2nydBKeoqgK9W2M4F59oMEUj59LTY19d wZZ/bF4k9JCE1WlIJI7LFxQUN0593gQAgEnBXg/XHt++a0ZTUU+eTOuH8oxmU/0JPt f3S0froNksEsQ== Date: Wed, 27 Oct 2021 12:28:24 -0700 From: Jakub Kicinski To: Leon Romanovsky Cc: Ido Schimmel , "David S . Miller" , Ido Schimmel , Jiri Pirko , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, syzbot+93d5accfaefceedf43c1@syzkaller.appspotmail.com, Edwin Peer Subject: Re: [PATCH net-next] netdevsim: Register and unregister devlink traps on probe/remove device Message-ID: <20211027122824.5bebb9a4@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: References: <20211026120234.3408fbcc@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> <20211026125602.7a8f8b7e@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> <20211027071723.12bd0b29@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 27 Oct 2021 22:15:41 +0300 Leon Romanovsky wrote: > One of the outcomes is that such chain usually prevents from us to ensure > proper locking annotation. > > Let's take as an example devlink_trap_policers_register(). > In some drivers, it is called before device_register() and we don't need > any locks at all, because we are in initialization flow. > > In mlxsw, it is called during devlink reload, and we don't really need to > lock it too, because we were supposed to lock everything for the reload. > > However, for the mlxsw, we created devlink_trap_policers_register() to be > dynamic, so we must lock devlink->lock, as we don't know how other users > of this API will use it. > > In the reality, no one uses it dynamically except mlxsw and we stuck > with function that calls to useless lock without us able to properly > annotate it with an invitation to misuse. > > It is an example of layering problem, there are many more subtle issues > like this that require some cabal knowledge of proper locks to make it > is safe. Now that you made me express my opinion I started feeling attached to my way of thinking :) Let me try to convert devlink core, netdevsim and nfp to devlink instance locking and see how far I can get...