From mboxrd@z Thu Jan 1 00:00:00 1970 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 69D7DEAD9 for ; Thu, 15 Jun 2023 19:47:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95106C433C8; Thu, 15 Jun 2023 19:47:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686858458; bh=AKMJ9Nhuvfu6Z+tz0mQlySiQlu7rOvQ1VIdI1LAzQI4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=UrrR+aU7enX0JTf+4gH04k7J/WrkrFfXZFRL74tHMQftQDtSHeeBkpgAnQgt406+J s+bBqIyk15lb3vvecX4AW2J/x+AjbJVPS8jGe9voJTky8KUUvenuQ1rxBiBl7CKifh hdb5jcQ5cHaJIF+gSAc4pwTdVwPLj3d5MFiiCnJriN7E8b3VLoNVv+l1UA6bq0Wbk7 t7hKzl6sT1vSn35jUPT/dsxnBc+HC2SAibQZ/uP6AeJ/il/R6XDx6FsFiBIjPHWXcn rz6BFAx04PFV97Z4AprMLZ5gFKdDTu/A0vLcI5Atu7HJ8JRH3FLU1Mf0KFjZ/C0SM+ NvPjUrW2daDuQ== Date: Thu, 15 Jun 2023 12:47:37 -0700 From: Jakub Kicinski To: Louis Peens Cc: David Miller , Paolo Abeni , Simon Horman , Tianyu Yuan , netdev@vger.kernel.org, stable@vger.kernel.org, oss-drivers@corigine.com Subject: Re: [PATCH net v2] nfp: fix rcu_read_lock/unlock while rcu_derefrencing Message-ID: <20230615124737.43025acb@kernel.org> In-Reply-To: <20230615073139.8656-1-louis.peens@corigine.com> References: <20230615073139.8656-1-louis.peens@corigine.com> Precedence: bulk X-Mailing-List: netdev@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, 15 Jun 2023 09:31:39 +0200 Louis Peens wrote: > From: Tianyu Yuan > > When CONFIG_PROVE_LOCKING and CONFIG_PROVE_RCU are enabled, using OVS with > vf reprs on bridge will lead to following log in dmesg: > > .../nfp/flower/main.c:269 suspicious rcu_dereference_check() usage! > > other info that might help us debug this: > > rcu_scheduler_active = 2, debug_locks = 1 > no locks held by swapper/15/0. > > ...... > Call Trace: > > dump_stack_lvl+0x8c/0xa0 > lockdep_rcu_suspicious+0x118/0x1a0 > nfp_flower_dev_get+0xc1/0x240 [nfp] > nfp_nfd3_rx+0x419/0xb90 [nfp] > ? validate_chain+0x640/0x1880 > nfp_nfd3_poll+0x3e/0x180 [nfp] > __napi_poll+0x28/0x1d0 > net_rx_action+0x2bd/0x3c0 > ? _raw_spin_unlock_irqrestore+0x42/0x70 > __do_softirq+0xc3/0x3c6 > irq_exit_rcu+0xeb/0x130 > common_interrupt+0xb9/0xd0 > > > ...... > > > In previous patch rcu_read_lock()/unlock() are removed because rcu-lock may > affect xdp_prog. However this removal will make RCU lockdep report above > warning because of missing of rcu_read_lock()/unlock() pair around > rcu_deference(). > > This patch resolves this problem by replacing rcu_deference() with > rcu_dereference_check() to annotate that access is safe if > rcu_read_lock/rcu_read_lock_bh is held. > > Fixes: d5789621b658 ("nfp: Remove rcu_read_lock() around XDP program invocation") I'd vote to simply revert that commit. Toke likely assumed that the RCU protection is only for XDP but turns out we have more datapath stuff that depends on it. No strong preference but my vote would be to not play with RCU flavors at the driver level. > CC: stable@vger.kernel.org > Signed-off-by: Tianyu Yuan > Acked-by: Simon Horman > Signed-off-by: Louis Peens > - reprs = rcu_dereference(app->reprs[rtype]); > + reprs = rcu_dereference_check(app->reprs[rtype], rcu_read_lock_bh_held()); If you prefer to keep the patch I think this is just rcu_dereference_bh() ? -- pw-bot: cr