Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1399239lqm; Thu, 2 May 2024 13:37:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU677ZL+fW6NkmF3kYNvd+Fk5inbjLynenIFmhZ4f9dRZVG/WtLVO/2E+pQs+wFfWvT45ERHhoJMs0XUZEVDuSIksaQQFtrsJZwg5Ct0A== X-Google-Smtp-Source: AGHT+IEVKjU0vbSj3bk9uqPX1hLZWdyh7MPOkrSIYFdm2GhwaK7UoCFyH0xJw3N6B4EBWqa/GdAC X-Received: by 2002:a05:6870:170a:b0:22e:7390:da7 with SMTP id h10-20020a056870170a00b0022e73900da7mr1143676oae.21.1714682252118; Thu, 02 May 2024 13:37:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714682252; cv=pass; d=google.com; s=arc-20160816; b=FZSrP2GC7o+bA99txjNNCLuJ12GirFTWQaUJY2Qxl2vJyo7Lz0PRaNeTO9SCbj6+7J PnvoZEGYdKjjkS/+PvSom8Y2cdWAUup/ZdmxFutMZdc8RbBp8iPmYJBd/fyjArRMSX22 /6cFVr7lE4K/Ro6StcXOXKm1Smk17qWzBvT9noXMcUhUdCZ+jP9f2OK4IN1kVuMUoxtQ t1Sgg5pwR6UQuO9E5nia2zQTkKJRtqnUJydGLrlf2+LR86upDKrmkU0vsnT2EcKXU+zW kOstr0awWSIAgui/7NcQr/nxyQCfPdEVZO5VH0qb2uInensZgWwadBh7fYdsoUXdNHF9 LKGA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=NKIW82xynE28sXh1illyNkxP3ipnCGT4+/So5MYXvsk=; fh=PkU89ULE0lzpFU041412WHhaGJtWQaaZ08D6BO13nVA=; b=F5y+uzy2VPTW22Y91T0hTsEUDV4n1d2LlFhPxLyG1A3sAczycQdjYZyqxS10C5tP1R gHrZvrVIfPlzGd+JsVBMo4xCE/pdHgaLyxTx+qYfex/TUZW12F1V3BwVy6te+YK07XzS dPH/D8vsQxXkf5zDqY5+RDVUINVqqJ+BemKqqqjpwKH79aeEWGAvxRJ7t5awZcWE7WL/ x/hBlHgRZRgd6Py3OOhyoKYueFUL80pY1AhX96xAmH3jwErYKo2kc4s3mrBQczXojkee m9TN75hlKzdB1l8WprUoU4XNIzs95CEe16A8W9+D4p+3RWyHvrJzAV3h2bXZPjTqCcUa TYrg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="F0+Qp/ZV"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-166903-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166903-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id e15-20020ac85dcf000000b0043ae7068a00si1892575qtx.27.2024.05.02.13.37.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 13:37:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166903-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="F0+Qp/ZV"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-166903-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166903-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C19DC1C21818 for ; Thu, 2 May 2024 20:37:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F734176FDF; Thu, 2 May 2024 20:37:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="F0+Qp/ZV" Received: from mail-yw1-f196.google.com (mail-yw1-f196.google.com [209.85.128.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B72861EA8F; Thu, 2 May 2024 20:37:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.196 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714682240; cv=none; b=atGyiTl/Qn/6Y8CTmEWZdaYiXh77zavRl3agPcHKq96hPQhcFzoXe2pzN4uRieXhwzhCM/yU3KrSwW1JwIIJsAlqmfg2WxHfmgbSzfMgs/a9F40yN47NMhP0eVDYVuy25hHp11et2CBUGmqc/0J83uLEAtvcr39qX7G02VJ9Ndo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714682240; c=relaxed/simple; bh=2k7OPTWw2B8a6AN3gHmY8q9bPGj8mN1RIq+lrkfxLGE=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=cuRStAcFSARo5PKyx97Xfb3jME7kiUvowIQ2Zm5YHIV+L4bmnn0NyDDzT1KrwcOBfw3KKNyDIgEYw5V2sNQX2FThRIFBwXPgWlrbpJLJ6Z0nPKd6EuvAfRmkngMzMr7XmJA0gBCx1wy6OFeMQjJWrC5vHSJqHpb1M1CUvHS+YuU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=F0+Qp/ZV; arc=none smtp.client-ip=209.85.128.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yw1-f196.google.com with SMTP id 00721157ae682-61bed738438so34172917b3.2; Thu, 02 May 2024 13:37:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714682238; x=1715287038; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=NKIW82xynE28sXh1illyNkxP3ipnCGT4+/So5MYXvsk=; b=F0+Qp/ZVUZDtT/2BmWDOyps8lop3fCXQRMc+xZrez771IlBAklZD/wg2KeLtd4WdkB UVp5zjLSrv9UZODGvwPAYcszMjK4LS+i173v43ZxGnc5N34o3DO/MdI/LJs32fE4QUTl v8Bm6xO7dWKVdkSilzBSXt5Uo7q/cX6pQmxqnqW9b/S16BFa64kIm8ya1BRlbQvvVG3a cj4zJrZawf6lad7283JnkW7UokdrA4geQ9g6/nz0ohBInHLoihvosvXQMTDkaCXDhC/m yL2FZmELefNDNtvpgiFaxUjMNUlbvc5Rr3mIgLdqJqyEHB1gaOdTgwOeHmKVBebCgnow cbfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714682238; x=1715287038; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NKIW82xynE28sXh1illyNkxP3ipnCGT4+/So5MYXvsk=; b=Mg9Vt9y9Jc/CixNvd3nQmHfbkQr0NdeGeycM/urXEMNRWumhn2TcZsjUxu8ZONQRj6 1iyUwsvMOQiwOOibXcJPrA+AO3kSA0uvUe4+Z+tj33K3HnARWQpxkZPWfyBRavIfS2Yf U2aRcfmw+eNN+rOYWXFysk/7axxLASZ2XVJmVWClsuFm1rqb4xW8Q51azS6daZx5HmEy IVnekKSkULOxjN1z4M01O5QTfJZ5u6z+5HJiHBp14Whma97GQMZjOTAv+/3e28dZKJHB F/m1ocyY/MP+7CTpuglxxcUNqrQU2YK7/GO+Kt0wmgb/+998mwxnHrJFc1vnHXCIr7H5 oyZQ== X-Forwarded-Encrypted: i=1; AJvYcCUPCklEdZXyGfIpA/yiMLMMf5MxI4gbBgHZeJtARMPRgmEWIWjyyJYmTXvaydLEoQI7hkVTvNFIC7ZFtdtsXYe0bn81WMVhM7kV+ei0kZMNlK48t283aExLu3iV04lQ5K0tuRXw X-Gm-Message-State: AOJu0YxKwnFyL1Z/NOkLfjAfJAhB2a0CdcaXS9y6hH7rqEVfdQgkHtTC UBPA+gisxl/OcFBhjeqnUaGjr02xHwzip9DZnE8yRbhYfOcg1MOe X-Received: by 2002:a81:7303:0:b0:61b:bd65:3025 with SMTP id o3-20020a817303000000b0061bbd653025mr778076ywc.40.1714682237736; Thu, 02 May 2024 13:37:17 -0700 (PDT) Received: from [10.102.6.66] ([208.97.243.82]) by smtp.gmail.com with ESMTPSA id k14-20020a81ac0e000000b0061be24994e6sm375355ywh.30.2024.05.02.13.37.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 May 2024 13:37:17 -0700 (PDT) Message-ID: <85cb2625-7bac-45cd-af31-0d114253e6e4@gmail.com> Date: Thu, 2 May 2024 16:37:16 -0400 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFC net-next 07/10] net: dsa: mv88e6xxx: Track bridge mdb objects From: Joseph Huang To: Vladimir Oltean Cc: Joseph Huang , netdev@vger.kernel.org, Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Roopa Prabhu , Nikolay Aleksandrov , =?UTF-8?Q?Linus_L=C3=BCssing?= , linux-kernel@vger.kernel.org, bridge@lists.linux.dev References: <20240402001137.2980589-1-Joseph.Huang@garmin.com> <20240402001137.2980589-8-Joseph.Huang@garmin.com> <20240402122343.a7o5narxsctrkaoo@skbuf> <20240405110745.si4gc567jt5gwpbr@skbuf> <20240430005949.44lcegwhmcetpddm@skbuf> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 4/30/2024 12:27 PM, Joseph Huang wrote: > On 4/29/2024 8:59 PM, Vladimir Oltean wrote: >> On Mon, Apr 29, 2024 at 06:07:25PM -0400, Joseph Huang wrote: >>> Something like this (some layers omitted for brevity)? >>> >>>                                        +br_iterator >>>                                        |  for each mdb >>>                                        |    _br_switchdev_mdb_notify >>> rtnl_lock                             |      without F_DEFER flag >>>   |                                    |      | >>>   +switchdev_port_attr_set_deferred    |      +switchdev_port_obj_notify >>>     |                                  |        | >>>     +dsa_port_mrouter                  |        +dsa_user_port_obj_a/d >>>       |                                |          | >>>       +mv88e6xxx_port_mrouter----------+ >>> +mv88e6xxx_port_obj_a/d >>>                                          | >>>   +--------------------------------------+ >>>   | >>> rtnl_unlock >> >> At a _very_ superficial glance, I don't think you are properly >> accounting for the fact that even with rtnl_lock() held, there are still >> SWITCHDEV_OBJ_ID_PORT_MDB events which may be pending on the switchdev >> chain. Without a switchdev_deferred_process() flush call, you won't be >> getting rid of them, so when you rtnl_unlock(), they will still run. >> >> Even worse, holding rtnl_lock() will not stop the bridge multicast layer >> from modifying its br->mdb_list; only br->multicast_lock will. >> >> So you may be better off also acquiring br->multicast_lock, and >> notifying the MDB entries to the switchdev chain _with_the F_DEFER flag. > > Like this? > >                                       +br_iterator(dsa_cb) >                                       |  lock br->multicask_lock >                                       |  for each mdb >                                       |    br_switchdev_mdb_notify > rtnl_lock                             |      | >  |                                    |      +switchdev_port_obj_._defer >  +switchdev_port_attr_set_deferred    |  unlock br->multicast_lock >    |                                  | >    +dsa_port_mrouter                  | >      |                                | >      +mv88e6xxx_port_mrouter----------+ >                                         | >  +--------------------------------------+ >  | > rtnl_unlock > > (potential task change) > > rtnl_lock >  | >  +switchdev_deferred_process >  | flush all queued dfitems in queuing order >  | > rtnl_unlock > > I'm not that familiar with the bridge code, but is there any concern > with potential deadlock here (between rtnl_lock and br->multicast_lock)? Hi Nik, Do you know if it's safe to acquire rtnl_lock and br->multicast_lock in the following sequence? Is there any potential possibility for a deadlock? rtnl_lock spin_lock(br->multicast_lock) spin_unlock(br->multicast_lock) rtnl_unlock If the operation is safe, the next question is should it be spin_lock or spin_lock_bh? Thanks, Joseph