Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp3109329rdb; Tue, 6 Feb 2024 07:26:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IEPL3CfYCNAdjaXLiUrzedZn4j1VXGV6/TyqpDudGU4JQeZf+HGgV98/dlBZv6ZbTTZLMMK X-Received: by 2002:a05:622a:1a1e:b0:42c:2736:b1ab with SMTP id f30-20020a05622a1a1e00b0042c2736b1abmr4006517qtb.50.1707233198619; Tue, 06 Feb 2024 07:26:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707233198; cv=pass; d=google.com; s=arc-20160816; b=RJ7eLHFiJOU2wKvDuhgQuWWHbZhwGIoG900psW9ZwTtLj7NE/2ekCogIqGhIDGixhn JnTIAX2AbYnR6ffd9NQtRWeWIiUvS1HCZpzYof4eiLG0tgJhvZPuk3XGNtp4p7t11eHM j1XDl04M/x8jGcmgTZR4SBso18NmO8Df7eWlkQgrPvn9N5uWPr/tTaU9+VQQXwHnO5rA ZRkrL+fedUybV+LWp06JXvSYKNAsbjpQ2mhSEvdOCCDo/A85rl0lHgV7brgVko0mvLIu PAWIdSCsaocVMzxZ53MSjNKilh4O3QUZqz1EHBAXT/OBZ+z177SQajqbtVxuXzLvlpO5 Nxjw== 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=zo98ZI4PSIiuv7WyBfYRhAdwmBiiN+kZoiKDVoCad60=; fh=mPMvlAeDMDOGY2Cm9N0+X5tbZQGLlErXDpAp/DOIfVU=; b=BAqiuKu6aMTX9meuRpXYPbw68dE+kPeUOPepXYIo6Y2CyIYaAdvdP+7veGAchR0+ca GZLL3E2905cIIU7EpZfBcnOxdv3WfbhjQHHWvVyYG70iAklTZyVw+g0a8QZiIoMtCsa6 Itd/Dd6YwtfV+xK6WH8AxM67iP06cISsPpLphTUOkt4xAmhbT+O/6qV0EgmIOlnqrwww +/6n3pE/aRICu4xAYBd6kgY1WfPCLD7EvuouXaqoqZzHAX5czQfumn1OBndHuuCcZRac Dl6hU+Vc/rM2ra0F5rRrye8Q/lnVrcUNV2ZLe0cpTP5G0T7BIhJeqT9hh9KUM/79Xpmv P30A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CEad+EnP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-55232-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55232-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCVAywNdJf8JnJkecE2bDrFHMXNmDoTgamXY/K962MSF/jwoO6KRd0gvGKJOo2zeaHEIn/988+S3rr9WJEnfFsp7LHvsO2/4/FmZ8kgWAw== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y18-20020a05620a44d200b007853f2207fesi2757577qkp.617.2024.02.06.07.26.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 07:26:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55232-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=@kernel.org header.s=k20201202 header.b=CEad+EnP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-55232-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55232-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 50CBB1C2240B for ; Tue, 6 Feb 2024 15:26:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E63F9137C35; Tue, 6 Feb 2024 15:21:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CEad+EnP" 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 194B9135A6A; Tue, 6 Feb 2024 15:21:16 +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=1707232877; cv=none; b=FEv5ZF8X+nBrAhJ7u55yoLM4hzDRoexHEJ3bSOoWhaBs0hLw4ehWpYGOqxkgdqx5BThJLJsojxttaPpYFo+7aXhTAP4nJ7riEgu4iz7cqc1zX+iMp4/hhMebMeVrGltGoqJpMqqj3J3ikPGeYD5AENHQCpsuXZ2WZIrtv6LWW2A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707232877; c=relaxed/simple; bh=LyjQlt4G4x0nfdud4poStAqX33ymR17t5R2+B2AlI2g=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lgDjvlO9nFDfnOGAmVXI8ajVF3zDwk3pwxNz8H2bf5Ic8kgDlDZe5oRQ1TKni0GHYwKkSYbEqF3rFpf/zT5OzKbk1TfHJGNc1uBl960evrUWClAdKxHPzgH+3n3NIW/veghW0lyZ5/PDO+dKN0SDKNUriwhvqAQFRzrKFDkWrrY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CEad+EnP; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93BF1C43390; Tue, 6 Feb 2024 15:21:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707232876; bh=LyjQlt4G4x0nfdud4poStAqX33ymR17t5R2+B2AlI2g=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=CEad+EnPMUSBFizg/2pJsnkWPFwZP5QKGaQS7aD32TgLB2E8+yMr6sp0plnyZu3S1 QjlpUwXEt9SJGFNTASyqOKO0CWh+CQ61pEBVy4gY7SimuA0P/TP5/k5/oAyDN3d1jN ShHLe0I7UtGcdYMPHVsbelbBV+mcEIKO5KPO433+98pSwAVMw0YBcU1NkLrn41z/Tc rccytoFbjcT0KP+TGOwQaeha9IKR3PHjCw49qnCC98ZsYcPDPucak61ROR2CspRV7S AqYFECKD8RQ1r3iWDZf6mV53A0Hg1xRdeypKXlsH9d6Zw+MEEEMTPXeTEHRAk7uwhJ UaeoVypy3SEAw== Date: Tue, 6 Feb 2024 07:21:14 -0800 From: Jakub Kicinski To: Shinas Rasheed Cc: "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Haseeb Gani , Vimlesh Kumar , Sathesh B Edara , "egallen@redhat.com" , "mschmidt@redhat.com" , "pabeni@redhat.com" , "horms@kernel.org" , "wizhao@redhat.com" , "kheib@redhat.com" , "konguyen@redhat.com" , "David S. Miller" , Eric Dumazet , Jonathan Corbet , Veerasenareddy Burru , Satananda Burla , Shannon Nelson , Tony Nguyen , Joshua Hay , Rahul Rameshbabu , Brett Creeley , Andrew Lunn , Jacob Keller Subject: Re: [EXT] Re: [PATCH net-next v5 1/8] octeon_ep_vf: Add driver framework and device initialization Message-ID: <20240206072114.244738a9@kernel.org> In-Reply-To: References: <20240129050254.3047778-1-srasheed@marvell.com> <20240129050254.3047778-2-srasheed@marvell.com> <20240131161406.22a9e330@kernel.org> <20240205154448.1c5a5ad8@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 Tue, 6 Feb 2024 07:42:12 +0000 Shinas Rasheed wrote: > > > We do cancel_work_sync in octep_vf_remove function. > > > > But the device is still registered, so the timeout can happen after you > > cancel but before you unregister. > > There is rtnl_lock inside octep_vf_tx_timeout_task (the work task > function), which can protect from unregister_netdev, for such cases > (code snippet for quick reference below): > > static void octep_vf_tx_timeout_task(struct work_struct *work) > { > struct octep_vf_device *oct = container_of(work, struct octep_vf_device, tx_timeout_task); > struct net_device *netdev = oct->netdev; > > rtnl_lock(); > if (netif_running(netdev)) { > octep_vf_stop(netdev); > octep_vf_open(netdev); > } > rtnl_unlock(); > } > > I hope this takes care of it? Please let me know if my thought > process feels wrong. Thanks! The problem I see is that if the queue is somehow overloaded or delayed there can be a race where we cancel, then timeout happens, work doesn't run for a while, and we free the netdev. So what I'm suggesting is - hold a reference on the netdevice. That way you can be sure it doesn't get freed and you can depend on the rtnl+netif_running() doing its job.