Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1249790pxb; Wed, 10 Feb 2021 04:04:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJwyjX9LfD71nd07VWTLBW4YUhSPnPlWMWhIANpCmugn0GAeUXJxk12aet55kwlCNrj6vOoH X-Received: by 2002:a17:906:8507:: with SMTP id i7mr2609308ejx.175.1612958685299; Wed, 10 Feb 2021 04:04:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612958685; cv=none; d=google.com; s=arc-20160816; b=Kr6QPqPUgWgNgKqaCEct7+VngdlPOVtLs3KZi3+wRpsiOllNNYw4aK9My8IxukVbRy oYXT99AN/2TO0JYBBNoRN9RLIRF1nF8WtaQgpzpq4wFr7Ib3mgikBKY7/s8b8wmLjN0y tqSOsY1d4Ew1oRVSxbDEMX4Uw/IpjnNy60A+BJJOXkfadGKI3x1jrzG8LvEwNTot71ct TRPMtyLCyiIO1oYk3nBHeDu7JfuSzWsE7CXWAJfdrtOReWIbYgESse8Zet76D640crI2 Gwcha4xzHoHZNlnqE7RKM3D7LWBv8sqOe4vXAkgPnOV6A3b1Yf9ePtZj/RZ7+PhPxaaj Iwlw== 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=2NPoseU3+T4T+f+cn5abepjcDycycu9LCWGAa05SN3E=; b=C9T+xuajmpJpLwVBp0M0JSR/yMhjQcGhJiW0aZBFGt+1qSGWKOthaxfKR2zkkBxBZG o+rMykzuikYQz6iEc8ib8YdLfI42Y5dCNcCuODWiptssa7yVPd5QR5JimMrgF852eHhd f4VWsn73zFqGus2AS0oGUDQRXqYQHEw6zquti7x6IERX2/S/prEMU+r11GIPpTrfJ/vS JawnkUKfY5tKf7/25AVs8f4pazQI7JJpWrJ477p8aHhH17/efOG4/n0lr+Ii0xHuVuTM 8K0PzjA2EVtS+l7SxS/tPx/apHCpr/yCDYRdgmsa6eW5irIEB3JuRVHjjLchZ/RslkZJ BTLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HE6uBupt; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f7si1386772edd.574.2021.02.10.04.04.21; Wed, 10 Feb 2021 04:04:45 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=HE6uBupt; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229888AbhBJMDt (ORCPT + 99 others); Wed, 10 Feb 2021 07:03:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231124AbhBJMBv (ORCPT ); Wed, 10 Feb 2021 07:01:51 -0500 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 306EFC06174A; Wed, 10 Feb 2021 04:01:10 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id f14so3643376ejc.8; Wed, 10 Feb 2021 04:01:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2NPoseU3+T4T+f+cn5abepjcDycycu9LCWGAa05SN3E=; b=HE6uBuptTXdUGANaII/WQiiYZJZFpbO8xPwk0jQG6BI9+8wbYqZeEtHkSrwaUJNC5A n61XWFq9B7QgH88rSSbipN2dQYkV0YwqwoRKtRQ7si+hB4VrWxD7jFVstJbfa42wNzRI 6MBR2D32RCSl/kXapuAkVfO/MA9OT9vEBkvH6U7HeuKKKRCQa6kGIE4mWwj6f4qgPqhn 2/S4izOkVM3uf+V/Ei2dNMCgZA1w6PBTBe7PCbI+PEsVlkvsblXDtVrLuUOcEfBAVj/v BBIrka+bIjfuHATphmnBwbKBYAzlySe8vfl1lBfM4i1cdaX3lUjccX628VlmiN8nWH6a MiTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2NPoseU3+T4T+f+cn5abepjcDycycu9LCWGAa05SN3E=; b=JYvs0u23TPT2KmEpDmXx8/gcUFjl9rW/G0pKM7wYM9AETPQCPwg0PBvr2dEZJlCx5F dh2fH1LmB5fORtA+dQn5aYiJR3GmQQTjFlLyG1sVkbpQ/z0lsKXAWCOwvgsJ2/HK4TP3 nV5XyX4ikmXcuv9ea+5ophx+RdjGs8f4NxC9H4EALBkGqptPxCFuQScb7J0v/r6uFC/z 3DfgmDsdrVwrVPojxlaMypDlGV/ps0NbtB1imrRRa09rAyDjEdLJx+nEW05seruHTBS8 MgxSFmJE5h9CvKNC76HHp6HCEtmwNmjniVPqmhfVSKVqUD3X95UbUpZNMgwcQ4feDv38 4Dmg== X-Gm-Message-State: AOAM533dmRJm8Jk8fNSjfnZo37Wclnmk65I+2tuQTx8MPcnqDf1QkX+Y bE9WLdoCSZiGUzIGpustWWwOcJlY5x0= X-Received: by 2002:a17:907:da9:: with SMTP id go41mr2633618ejc.326.1612958468879; Wed, 10 Feb 2021 04:01:08 -0800 (PST) Received: from skbuf (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id o4sm830293edw.78.2021.02.10.04.01.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Feb 2021 04:01:08 -0800 (PST) Date: Wed, 10 Feb 2021 14:01:06 +0200 From: Vladimir Oltean To: Nikolay Aleksandrov Cc: Jakub Kicinski , "David S. Miller" , Andrew Lunn , Vivien Didelot , Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bridge@lists.linux-foundation.org, Roopa Prabhu , Jiri Pirko , Ido Schimmel , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Vadym Kochan , Taras Chornyi , Grygorii Strashko , Ioana Ciornei , Ivan Vecera , linux-omap@vger.kernel.org Subject: Re: [PATCH v3 net-next 00/11] Cleanup in brport flags switchdev offload for DSA Message-ID: <20210210120106.g7blqje3wq4j5l6j@skbuf> References: <20210210091445.741269-1-olteanv@gmail.com> <20210210104549.ga3lgjafn5x3htwj@skbuf> <20210210110125.rw6fvjtsqmmuglcg@skbuf> <90b255e6-efd2-b234-7bfc-4285331e56b1@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <90b255e6-efd2-b234-7bfc-4285331e56b1@nvidia.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 10, 2021 at 01:05:57PM +0200, Nikolay Aleksandrov wrote: > On 10/02/2021 13:01, Vladimir Oltean wrote: > > On Wed, Feb 10, 2021 at 12:52:33PM +0200, Nikolay Aleksandrov wrote: > >> On 10/02/2021 12:45, Vladimir Oltean wrote: > >>> Hi Nikolay, > >>> > >>> On Wed, Feb 10, 2021 at 12:31:43PM +0200, Nikolay Aleksandrov wrote: > >>>> Hi Vladimir, > >>>> Let's take a step back for a moment and discuss the bridge unlock/lock sequences > >>>> that come with this set. I'd really like to avoid those as they're a recipe > >>>> for future problems. The only good way to achieve that currently is to keep > >>>> the PRE_FLAGS call and do that in unsleepable context but move the FLAGS call > >>>> after the flags have been changed (if they have changed obviously). That would > >>>> make the code read much easier since we'll have all our lock/unlock sequences > >>>> in the same code blocks and won't play games to get sleepable context. > >>>> Please let's think and work in that direction, rather than having: > >>>> + spin_lock_bh(&p->br->lock); > >>>> + if (err) { > >>>> + netdev_err(p->dev, "%s\n", extack._msg); > >>>> + return err; > >>>> } > >>>> + > >>>> > >>>> which immediately looks like a bug even though after some code checking we can > >>>> verify it's ok. WDYT? > >>>> > >>>> I plan to get rid of most of the br->lock since it's been abused for a very long > >>>> time because it's essentially STP lock, but people have started using it for other > >>>> things and I plan to fix that when I get more time. > >>> > >>> This won't make the sysfs codepath any nicer, will it? > >>> > >> > >> Currently we'll have to live with a hack that checks if the flags have changed. I agree > >> it won't be pretty, but we won't have to unlock and lock again in the middle of the > >> called function and we'll have all our locking in the same place, easier to verify and > >> later easier to remove. Once I get rid of most of the br->lock usage we can revisit > >> the drop of PRE_FLAGS if it's a problem. The alternative is to change the flags, then > >> send the switchdev notification outside of the lock and revert the flags if it doesn't > >> go through which doesn't sound much better. > >> I'm open to any other suggestions, but definitely would like to avoid playing locking games. > >> Even if it means casing out flag setting from all other store_ functions for sysfs. > > > > By casing out flag settings you mean something like this? > > > > > > #define BRPORT_ATTR(_name, _mode, _show, _store) \ > > const struct brport_attribute brport_attr_##_name = { \ > > .attr = {.name = __stringify(_name), \ > > .mode = _mode }, \ > > .show = _show, \ > > .store_unlocked = _store, \ > > }; > > > > #define BRPORT_ATTR_FLAG(_name, _mask) \ > > static ssize_t show_##_name(struct net_bridge_port *p, char *buf) \ > > { \ > > return sprintf(buf, "%d\n", !!(p->flags & _mask)); \ > > } \ > > static int store_##_name(struct net_bridge_port *p, unsigned long v) \ > > { \ > > return store_flag(p, v, _mask); \ > > } \ > > static BRPORT_ATTR(_name, 0644, \ > > show_##_name, store_##_name) > > > > static ssize_t brport_store(struct kobject *kobj, > > struct attribute *attr, > > const char *buf, size_t count) > > { > > ... > > > > } else if (brport_attr->store_unlocked) { > > val = simple_strtoul(buf, &endp, 0); > > if (endp == buf) > > goto out_unlock; > > ret = brport_attr->store_unlocked(p, val); > > } > > > > Yes, this can work but will need a bit more changes because of br_port_flags_change(). > Then the netlink side can be modeled in a similar way. What I just don't understand is how others can get away with doing sleepable work in atomic context but I can't make the notifier blocking by dropping a spinlock which isn't needed there, because it looks ugly :D