Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp175647lqs; Thu, 13 Jun 2024 07:14:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVI9NIztu+BoUo95JNwmLTl0LBMH6LHtwrbXV0l11fGp6v+qDehcMsgRchzchy8f2VvhcAJPyoZAleOoDS8PnM//9kI3Xa3lLu8/4CgqQ== X-Google-Smtp-Source: AGHT+IEz5dVPpsXO6ZolmSKc+JW4q6h5XGCduW/sTtl2MlKZA3tA+YQsC7SzB54tmdEugr987AmY X-Received: by 2002:a17:906:a259:b0:a6e:feae:e1df with SMTP id a640c23a62f3a-a6f47f894a7mr329908566b.21.1718288059925; Thu, 13 Jun 2024 07:14:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718288059; cv=pass; d=google.com; s=arc-20160816; b=gIJMgcw/fxAyo9DimKTUJuxsY/PoE7VsjF556oVNHHgWyZrfezfRB9Qh4wEYSQ5ZjC tm4O6719gdloAKt6NSZ0mPFsJ4hRkokkuWxkGHgwNe5+8ZXE/1yVa4oYGoU72tHClnNt 4N3+PW5Eb2x2+TjAE66x66PUickZpBYq8/Uz2/FlMXVK6CI3YX0TtGjoYv6ihBP+6heD 2KdR6iLpj1nmqY08uqFa0aGa7Kaw4oeliwV/O2vao+E1J9q2Lhdf/1tq9jNk9sR2Fok0 K8/4Rv76DsaAjIlyXQc9VDrMXcIkTxeQ0Vfri6qAgSt3eih9bAKdXq6itZy67Sf3EAoc qQpQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=9ImLj4yEnuP3KxiO9Uc2yulYAdCMZJddf0VtYCT8SmA=; fh=oZ+rlVdHKG0Kk+8rnlNPBGn3diZTzcuSYeCGlGydgZQ=; b=we6gOmrwfblanXao0eLShOQA4/XbfllAh5mn7YziVtMmhXIA+Pg5BqSCYydGJDUCvA K1RJte+O7uMRcvAOh0USvt5Y6bceBZrUkY5UXwJiNSfCWZsFUGXnvF+cC665c4Fri74p YPOjmsH3pHr9gRbuApZlm3nwfgLXVy2vsu08lo4z1wXiMUKpSDjalUPbhdlH8MmVOXG4 vE529aUTml/GhfeRBpqvvMrRwj3xBD4BRkofuWVfDJGkH5fJW2zzHG+Wxo6K2voAW0Vg e+xm9qFSkkBfC7SQRfxpDG6ADv2Ixpl9Cd6kf3hz5oBr6S3ICF7/85p53mNLNLOsVk4v TkZA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ogjDdw34; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-213410-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213410-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f56d21534si72001266b.6.2024.06.13.07.14.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 07:14:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213410-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ogjDdw34; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-213410-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213410-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id A113E1F21282 for ; Thu, 13 Jun 2024 14:14:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B2882AEFE; Thu, 13 Jun 2024 14:13:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ogjDdw34" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 352DC145321; Thu, 13 Jun 2024 14:13:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718288026; cv=none; b=CKLtDKWHuRYUjbOAlJ1CsMolvil5ER4TVGwQnrq0HIXL2wIIVAlVqyisrLGbpaKPsR1cUcbNR7qYGZlUvKQa1dyLaHI17cLrnQiTP4NPpNpmI/qAXvuzRt0L2LayuTdyBxAGVh5mM/DRs2yDzTvuf2W6rCcKeDZOhJRk315D6jM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718288026; c=relaxed/simple; bh=miLeVMM2w5yAcnT3uzAx4GpVzV/Y9CzVC17jsvEBUfU=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LFrRW8EsNPzlLdlfDrJ98UN7hAf2zD27vz4a+wAsvDSARhauN1EmjMqobC1P0FqC+2/8s6UcDvaKrrIdcoMepodiM1CjAkTZGmSRXqo1TpwB2h9QBwr8qnhRDAll1A5cmDqcskeC4h9QVYwayQ0ZkvGb8lnBwU7ZqUE0DxuEwpI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ogjDdw34; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C59BC2BBFC; Thu, 13 Jun 2024 14:13:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718288024; bh=miLeVMM2w5yAcnT3uzAx4GpVzV/Y9CzVC17jsvEBUfU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ogjDdw34aMYbnVFXO1TQJ6gxcFOElu+kQ1l9kcwCvX/5TJXX6Y46YnhOfBue9+SfZ KpPZTJi+ymmNr/Fe68Gb+Dj57jzeUz4dXcdurC3Y09XSnhkysiQrzzFouyiUXmPG+h 0Kw32Ke9rEiUSd1lqkOMQXvXVpp7YdjaLVT8YQdUjqxJpeUE/hzDrskqDgJmQaAtLh 37Y3FO250POxonskubWav59Lxb9Vj8N2COWpo2ifg80tyiSjgFNLU5YuwuFpltcUAS pavfyYFer7rPxxkOfzw+IPQUsivZ0OlfTrFK3ejk/7EUpbu2SoYv2OJdtoIY5zQygp rp62AoeqnUtCw== Date: Thu, 13 Jun 2024 07:13:43 -0700 From: Jakub Kicinski To: Larysa Zaremba Cc: , Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Paolo Abeni , Alexei Starovoitov , "Daniel Borkmann" , Jesper Dangaard Brouer , John Fastabend , Maciej Fijalkowski , , , , , Michal Kubiak Subject: Re: [PATCH iwl-net 0/3] ice: fix synchronization between .ndo_bpf() and reset Message-ID: <20240613071343.019e7dca@kernel.org> In-Reply-To: References: <20240610153716.31493-1-larysa.zaremba@intel.com> <20240611193837.4ffb2401@kernel.org> <20240612140935.54981c49@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 13 Jun 2024 10:54:12 +0200 Larysa Zaremba wrote: > > > The locking mechanisms I use here do not look pretty, but if I am not missing > > > anything, the synchronization they provide must be robust. > > > > Robust as in they may be correct here, but you lose lockdep and all > > other infra normal mutex would give you. > > I know, but __netif_queue_set_napi() requires rtnl_lock() inside the potential > critical section and creates a deadlock this way. However, after reading > patches that introduce this function, I think it is called too early in the > configuration. Seems like it should be called somewhere right after > netif_set_real_num_rx/_tx_queues(), much later in the configuration where we > already hold the rtnl_lock(). In such way, ice_vsi_rebuild() could be protected > with an internal mutex. WDYT? On a quick look I think that may work. For setting the NAPI it makes sense - netif_set_real_num_rx/_tx_queues() and netif_queue_set_napi() both inform netdev about the queue config, so its logical to keep them together. I was worried there may be an inconveniently placed netif_queue_set_napi() call which is clearing the NAPI pointer. But I don't see one. > > > A prettier way of protecting the same critical sections would be replacing > > > ICE_CFG_BUSY around ice_vsi_rebuild() with rtnl_lock(), this would eliminate > > > locking code from .ndo_bpf() altogether, ice_rebuild_pending() logic will have > > > to stay. > > > > > > At some point I have decided to avoid using rtnl_lock(), if I do not have to. I > > > think this is a goal worth pursuing? > > > > Is the reset for failure recovery, rather than reconfiguration? > > If so netif_device_detach() is generally the best way of avoiding > > getting called (I think I mentioned it to someone @intal recently). > > AFAIK, netif_device_detach() does not affect .ndo_bpf() calls. We were trying > such approach with idpf and it does work for ethtool, but not for XDP. I reckon that's an unintentional omission. In theory XDP is "pure software" but if the device is running driver will likely have to touch HW to reconfigure. So, if you're willing, do send a ndo_bpf patch to add a detached check.