From patchwork Thu Jan 2 11:22:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinas Rasheed X-Patchwork-Id: 13924411 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (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 D6C021A8408; Thu, 2 Jan 2025 11:23:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735817009; cv=none; b=R93A9KgcQrHzX9Ba48wAhUJ9XmqlgZn38fg29Tix19RD6NW1i7BzcCE/AtkoFU9tDPIVgBA8om831nvlotyJRwz30XcSMuN40uZJvX0QzoB5V9HVwolqc8WcdPs8bBUSNTMrMZgWA1Ym05fm0t2aIgtT+ozL8idR1xbA328v1qY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735817009; c=relaxed/simple; bh=MOQMeSIQO7U5yYoK/IjRKrjGxVHpPBy4mc41c5kVDnE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QljL/1qg05jjXOlWI9OJanCrsqaYlDrnq4noogdsGhZnHF+nUow9IuoayQ2/A4mW2VzZE1uudFFes9sahzh8zfEDFAiXNw0rDIlI3GfLf628sqhlZAWKOkk2819z8cut3Ov+39t6lKzEZv//SgPljunIWIgSjnNE3NQOM0e+7dc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=W+Twyoly; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="W+Twyoly" Received: from pps.filterd (m0431383.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50296eg2032682; Thu, 2 Jan 2025 03:23:01 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=F mLlLBupTsRITUFy9f5Omy2qiAtzwiJFTFpWlSufOTk=; b=W+TwyolywSir8tOAy 2x5kCiIu5fiF3htQqYmuXRlGphy10YdfUJGt4zjvhXMvLTPzhmMO85J7N6zMU+WA jlKHviE0R0NYJpb/5+zq3XWngkROvpyUNZHgkKt3f3SOX69lxyfgSWcGgP2DSHjs U5BSyVguLHJsUOSaH7NHX1b9nATtFqaSSue1ny3kFoYTYN1NqARcM2NBqltJK8Bk /vOFf3Z6KIATgWgm+dSy887WV8tWsff0VA+ofzyvkVUP7+LfMNGXaBcRxcV3CUsH uysAk2stm9U8oqMy7ykAKqpNA7Yo3xUvVoutcaRnuuHsOlCdUg4yz/bGNbueGh0O 6vdvA== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 43wqvmr5u8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Jan 2025 03:23:01 -0800 (PST) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 2 Jan 2025 03:22:59 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Thu, 2 Jan 2025 03:22:59 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id CEC853F708C; Thu, 2 Jan 2025 03:22:58 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , "Shinas Rasheed" , Veerasenareddy Burru , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Abhijit Ayarekar , Satananda Burla Subject: [PATCH net v4 1/4] octeon_ep: fix race conditions in ndo_get_stats64 Date: Thu, 2 Jan 2025 03:22:43 -0800 Message-ID: <20250102112246.2494230-2-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250102112246.2494230-1-srasheed@marvell.com> References: <20250102112246.2494230-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: RCmfcWYVQPNxIgPuSxOlxwI1_WGJXzcC X-Proofpoint-ORIG-GUID: RCmfcWYVQPNxIgPuSxOlxwI1_WGJXzcC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_01 X-Patchwork-Delegate: kuba@kernel.org ndo_get_stats64() can race with ndo_stop(), which frees input and output queue resources. Check if netdev is running before accessing per queue resources. Fixes: 6a610a46bad1 ("octeon_ep: add support for ndo ops") Signed-off-by: Shinas Rasheed --- V4: - Check if netdev is running, as decision for accessing resources rather than availing lock implementations, in ndo_get_stats64() V3: https://lore.kernel.org/all/20241218115111.2407958-2-srasheed@marvell.com/ - No changes V2: https://lore.kernel.org/all/20241216075842.2394606-2-srasheed@marvell.com/ - Changed sync mechanism to fix race conditions from using an atomic set_bit ops to a much simpler synchronize_net() V1: https://lore.kernel.org/all/20241203072130.2316913-2-srasheed@marvell.com/ drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c index 549436efc204..a452ee3b9a98 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c @@ -995,16 +995,14 @@ static void octep_get_stats64(struct net_device *netdev, struct octep_device *oct = netdev_priv(netdev); int q; - if (netif_running(netdev)) - octep_ctrl_net_get_if_stats(oct, - OCTEP_CTRL_NET_INVALID_VFID, - &oct->iface_rx_stats, - &oct->iface_tx_stats); - tx_packets = 0; tx_bytes = 0; rx_packets = 0; rx_bytes = 0; + + if (!netif_running(netdev)) + return; + for (q = 0; q < oct->num_oqs; q++) { struct octep_iq *iq = oct->iq[q]; struct octep_oq *oq = oct->oq[q]; From patchwork Thu Jan 2 11:22:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinas Rasheed X-Patchwork-Id: 13924412 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (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 2417D1ACEC2; Thu, 2 Jan 2025 11:23:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735817011; cv=none; b=fY6WgEq5CNSZZTiVw67PlMpLvRJyDBPXa7AuLeNsH5wHyBgcM2HkJDF2LzYzEfu63na/3lEdFwOeAvebWH1+YhXrYhOoSN9EaHu3ld+sUs/R8oJosHsqg+MG+jSS2DBwVTsSPnGj4gSlB5MHKy6OuXe+F5v39Q9hNDRYzePMWJg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735817011; c=relaxed/simple; bh=D/meY/WytVFRPYjcqhyPlcj0U6o6REdTC8y4oj7SRXE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Y1NeMFjRYy5yQE/ohTAdXzyj+fGzqCQXQlw/ypJUzqFxG8+oWl5NUyxctnjE5eY+oLvD3+6uwz75uZ2Js2N19UWA01NU3Z/QnZbAXTALaFyX1/zB+xqn86JwaD4tL7jHJhW40czZv98k4UNwUeBk+ag97vfof3xN75pRxYfF47g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=EyYnkCcP; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="EyYnkCcP" Received: from pps.filterd (m0431383.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50296s9W001789; Thu, 2 Jan 2025 03:23:04 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=a 3L9o4etz+uGV0CMi/b7T8lp3z/9F6TF25clPViGFB8=; b=EyYnkCcPq+T9gAi1P En+QJ4+lo6HS1MKUBE6EN4ylJKBrF1YVTGbcfwbP0KKH7oWU/oh6XwEt2GLwbYuA i8t6s62xEYNxtId7UVMe+2CO8COZwD0beXW4lrRG+UeEXW4iRX6+Uh0FnfZIjlNx JvoqquahKBFz4bgYwepGccN3yMWl8kF7wE+pW/6pIRuaVx+BZgKkSsTmseiHvzPY bt7xQDMQ6P97HUq9R1X1RyzBwUOmBSsBBCp1SuMF7z7p5fkNJduuv7GLlhNRXuBP 6e3FqKRxDJjN10NKvjG3skbMUdXu3vv10qs3Lgc1roBMQp0vRGZkJchv3qnzNMGe amZ9w== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 43wqvmr5u9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Jan 2025 03:23:03 -0800 (PST) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 2 Jan 2025 03:23:02 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Thu, 2 Jan 2025 03:23:02 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id DACA23F708D; Thu, 2 Jan 2025 03:23:01 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , "Shinas Rasheed" , Veerasenareddy Burru , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Satananda Burla , "Abhijit Ayarekar" Subject: [PATCH net v4 2/4] octeon_ep: remove firmware stats fetch in ndo_get_stats64 Date: Thu, 2 Jan 2025 03:22:44 -0800 Message-ID: <20250102112246.2494230-3-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250102112246.2494230-1-srasheed@marvell.com> References: <20250102112246.2494230-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: 1FqzMzreuVzuEGzPLXOLf8Snzn_XP_zt X-Proofpoint-ORIG-GUID: 1FqzMzreuVzuEGzPLXOLf8Snzn_XP_zt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_01 X-Patchwork-Delegate: kuba@kernel.org The per queue stats are available already and are retrieved from register reads during ndo_get_stats64. The firmware stats fetch call that happens in ndo_get_stats64() is currently not required The warn log is given below: [ 123.316837] ------------[ cut here ]------------ [ 123.316840] Voluntary context switch within RCU read-side critical section! [ 123.316917] pc : rcu_note_context_switch+0x2e4/0x300 [ 123.316919] lr : rcu_note_context_switch+0x2e4/0x300 [ 123.316947] Call trace: [ 123.316949] rcu_note_context_switch+0x2e4/0x300 [ 123.316952] __schedule+0x84/0x584 [ 123.316955] schedule+0x38/0x90 [ 123.316956] schedule_timeout+0xa0/0x1d4 [ 123.316959] octep_send_mbox_req+0x190/0x230 [octeon_ep] [ 123.316966] octep_ctrl_net_get_if_stats+0x78/0x100 [octeon_ep] [ 123.316970] octep_get_stats64+0xd4/0xf0 [octeon_ep] [ 123.316975] dev_get_stats+0x4c/0x114 [ 123.316977] dev_seq_printf_stats+0x3c/0x11c [ 123.316980] dev_seq_show+0x1c/0x40 [ 123.316982] seq_read_iter+0x3cc/0x4e0 [ 123.316985] seq_read+0xc8/0x110 [ 123.316987] proc_reg_read+0x9c/0xec [ 123.316990] vfs_read+0xc8/0x2ec [ 123.316993] ksys_read+0x70/0x100 [ 123.316995] __arm64_sys_read+0x20/0x30 [ 123.316997] invoke_syscall.constprop.0+0x7c/0xd0 [ 123.317000] do_el0_svc+0xb4/0xd0 [ 123.317002] el0_svc+0xe8/0x1f4 [ 123.317005] el0t_64_sync_handler+0x134/0x150 [ 123.317006] el0t_64_sync+0x17c/0x180 [ 123.317008] ---[ end trace 63399811432ab69b ]--- Fixes: 6a610a46bad1 ("octeon_ep: add support for ndo ops") Signed-off-by: Shinas Rasheed --- V4: - No changes V3: https://lore.kernel.org/all/20241218115111.2407958-3-srasheed@marvell.com/ - Added warn log that happened due to rcu_read_lock in commit message V2: https://lore.kernel.org/all/20241216075842.2394606-3-srasheed@marvell.com/ - No changes V1: https://lore.kernel.org/all/20241203072130.2316913-3-srasheed@marvell.com/ drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c index a452ee3b9a98..59e2f8d01954 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c @@ -1016,10 +1016,6 @@ static void octep_get_stats64(struct net_device *netdev, stats->tx_bytes = tx_bytes; stats->rx_packets = rx_packets; stats->rx_bytes = rx_bytes; - stats->multicast = oct->iface_rx_stats.mcast_pkts; - stats->rx_errors = oct->iface_rx_stats.err_pkts; - stats->collisions = oct->iface_tx_stats.xscol; - stats->tx_fifo_errors = oct->iface_tx_stats.undflw; } /** From patchwork Thu Jan 2 11:22:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinas Rasheed X-Patchwork-Id: 13924414 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (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 ECF581ABEDC; Thu, 2 Jan 2025 11:23:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735817012; cv=none; b=HirqvIPVWo/I9Y48bNTQ/gtbIXZCby2OamJjYEqa9y/Ws0LR4dsLfNhUZ2gvDzdLptzoTrGtfCcR3Ys8ljKf5dVVJwu1g/XO4CSmc3dnd7R5nfKHgnvak8o+ZhDid8OwC2TfNZxaB09+9bnXw9BqriO1visihA7Ww+8+8kssWmw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735817012; c=relaxed/simple; bh=n3qEMwcdS+0cQXbsStvgUvvF4aiGwmQeakoNy0X43ls=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jCDpsV9iYSAvZ26XqhO25VC400c3V85qqTZJpiFxsEfnjMJo+HPhX1Tk7MyKwBOHnqmWdIu7x6rYZiSVNsuNZA2rmZrcR51lmMtN0uj9Q8RF8Z89uBN+yvP6SxwjfN0rCy89ny6cxQI7tJx8++e8Zb4DWGYhZstd0yErnPYDpfA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=LIWg4ucM; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="LIWg4ucM" Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 502Aa4Y6001654; Thu, 2 Jan 2025 03:23:06 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=M ERyu8pxUUjvnW4He8SRoYXf+hsBGFeesxufKdoCXng=; b=LIWg4ucM8698Ha532 yFYPe7wtB7dmz1xTWwTrmVeVNuktfNPGKBPMFThWNU5Q8SFRiZt30reWnilh36Hu OM1isvst4bGckvTDi5v/q2qNQfqfFJy0ejzDHnn50xpjbSbT6BqSqymU0sbFCdsu q8fSX6OGypGPIGzkAxbyLO+tqobMlYrIJfH1wwWcd/JLFIQafzkTfghiLuE4yDHg 3x1rRl2MBVu5A8bimyq+hz68keeHQe6qhsT/FuRddvXwm2dhz496Ib68ZWwYVJ6a NS2C1WTxN282sdoX9xRswYfoLRH3/qJzANjU5+BQN98/cQDAN9q73euuIrYrV6eO COn4A== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 43ws6e01sh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Jan 2025 03:23:06 -0800 (PST) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 2 Jan 2025 03:23:05 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Thu, 2 Jan 2025 03:23:05 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id AE31A3F708C; Thu, 2 Jan 2025 03:23:04 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , "Shinas Rasheed" , Veerasenareddy Burru , Satananda Burla , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH net v4 3/4] octeon_ep_vf: fix race conditions in ndo_get_stats64 Date: Thu, 2 Jan 2025 03:22:45 -0800 Message-ID: <20250102112246.2494230-4-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250102112246.2494230-1-srasheed@marvell.com> References: <20250102112246.2494230-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: U3gKPhqT1DOBFSHGboRh2zq1TfF5BcJn X-Proofpoint-ORIG-GUID: U3gKPhqT1DOBFSHGboRh2zq1TfF5BcJn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Patchwork-Delegate: kuba@kernel.org ndo_get_stats64() can race with ndo_stop(), which frees input and output queue resources. Check if netdev is running before accessing per queue resources. Fixes: c3fad23cdc06 ("octeon_ep_vf: add support for ndo ops") Signed-off-by: Shinas Rasheed --- V4: - Check if netdev is running, as decision for accessing resources rather than availing lock implementations, in ndo_get_stats64() V3: https://lore.kernel.org/all/20241218115111.2407958-4-srasheed@marvell.com/ - No changes V2: https://lore.kernel.org/all/20241216075842.2394606-4-srasheed@marvell.com/ - Changed sync mechanism to fix race conditions from using an atomic set_bit ops to a much simpler synchronize_net() V1: https://lore.kernel.org/all/20241203072130.2316913-4-srasheed@marvell.com/ drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c index 7e6771c9cdbb..9b29cd698361 100644 --- a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c @@ -786,6 +786,10 @@ static void octep_vf_get_stats64(struct net_device *netdev, tx_bytes = 0; rx_packets = 0; rx_bytes = 0; + + if (!netif_running(netdev)) + return; + for (q = 0; q < oct->num_oqs; q++) { struct octep_vf_iq *iq = oct->iq[q]; struct octep_vf_oq *oq = oct->oq[q]; From patchwork Thu Jan 2 11:22:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinas Rasheed X-Patchwork-Id: 13924413 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (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 F06D8198E60; Thu, 2 Jan 2025 11:23:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735817011; cv=none; b=mXhIwDbJTYA03RzQZUxpeRjxuveuQ53Dy8wIWhoCQdJuucUU6HqMRJkU7XNHlZI/K+li5RIVaVzti7o61gE/EZgFbyjP/MZXSHIMSW5KyN+PwyM/bwtq+jMfi5r5Y1TUug0uhBv7GAuU8RKVoMa2/hs0jk9aYqq3sB8oNc62o6U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735817011; c=relaxed/simple; bh=jnjuB5+wjuNGPsoQqMDm/5by9oc8ShpkRpEjC4rtiNA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XyMF9ueLvjXDQCFMMJzBODJDKMUn6ibmcBKqh1qpMkehBFzs77M+L1VIvp2zMcZO/dSiCsc0TzOVRJjfughkwBX63dtNaCZv1iLgzqEUY5Th0vj2cWuzDH3EJvI/ibi8Rr8VWAq8Qk69PM9ZClMGwSarJy/lsBfbhXzockxSiA8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=NfM8jxT3; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="NfM8jxT3" Received: from pps.filterd (m0431383.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50296ssJ001779; Thu, 2 Jan 2025 03:23:10 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=C KCYEEe6hY3eOzsP+Yb+eqtI1kGl7G1WlHUsnCXahA4=; b=NfM8jxT3e3PXOioM/ PCrg3BcMK3B8ZOhAITl1//PSnT7OIyDJo5q91UHcXG3nxuBlhb2sDee/1cxj8w/9 2VGvIxu/lqpwP943xh66NaTc4uAPpSyfMBhsEZ1YZaknapU1g8Ca8K38iDyBHsEB iMDoqjEol/mGkx5nTyzceXJqGA8FZVOpsHfDSL3aAZxSBtk/edQgPXMw7umPvGbW ompoJHHeSUaQIW6NFIpcHon7WuvcVR16Qd7IdkAZY0lLl3dpyLqPkijDi0WSn4Lu /6kmU4+XvDR5z59IYMyGnyZ+GVN8mBj9vL6xMCQ89dAA+WmcHojQdRuMKvSKUPFv G8K/w== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 43wqvmr5ud-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Jan 2025 03:23:10 -0800 (PST) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 2 Jan 2025 03:23:08 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Thu, 2 Jan 2025 03:23:08 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id 55D6B3F708E; Thu, 2 Jan 2025 03:23:08 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , "Shinas Rasheed" , Veerasenareddy Burru , Satananda Burla , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH net v4 4/4] octeon_ep_vf: remove firmware stats fetch in ndo_get_stats64 Date: Thu, 2 Jan 2025 03:22:46 -0800 Message-ID: <20250102112246.2494230-5-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250102112246.2494230-1-srasheed@marvell.com> References: <20250102112246.2494230-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: wn3kuTbWGO43nH7-XJVKp0D-PA2gsWMM X-Proofpoint-ORIG-GUID: wn3kuTbWGO43nH7-XJVKp0D-PA2gsWMM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_01 X-Patchwork-Delegate: kuba@kernel.org The per queue stats are available already and are retrieved from register reads during ndo_get_stats64. The firmware stats fetch call that happens in ndo_get_stats64() is currently not required The warn log is given below: [ 123.316837] ------------[ cut here ]------------ [ 123.316840] Voluntary context switch within RCU read-side critical section! [ 123.316917] pc : rcu_note_context_switch+0x2e4/0x300 [ 123.316919] lr : rcu_note_context_switch+0x2e4/0x300 [ 123.316947] Call trace: [ 123.316949] rcu_note_context_switch+0x2e4/0x300 [ 123.316952] __schedule+0x84/0x584 [ 123.316955] schedule+0x38/0x90 [ 123.316956] schedule_timeout+0xa0/0x1d4 [ 123.316959] octep_send_mbox_req+0x190/0x230 [octeon_ep] [ 123.316966] octep_ctrl_net_get_if_stats+0x78/0x100 [octeon_ep] [ 123.316970] octep_get_stats64+0xd4/0xf0 [octeon_ep] [ 123.316975] dev_get_stats+0x4c/0x114 [ 123.316977] dev_seq_printf_stats+0x3c/0x11c [ 123.316980] dev_seq_show+0x1c/0x40 [ 123.316982] seq_read_iter+0x3cc/0x4e0 [ 123.316985] seq_read+0xc8/0x110 [ 123.316987] proc_reg_read+0x9c/0xec [ 123.316990] vfs_read+0xc8/0x2ec [ 123.316993] ksys_read+0x70/0x100 [ 123.316995] __arm64_sys_read+0x20/0x30 [ 123.316997] invoke_syscall.constprop.0+0x7c/0xd0 [ 123.317000] do_el0_svc+0xb4/0xd0 [ 123.317002] el0_svc+0xe8/0x1f4 [ 123.317005] el0t_64_sync_handler+0x134/0x150 [ 123.317006] el0t_64_sync+0x17c/0x180 [ 123.317008] ---[ end trace 63399811432ab69b ]--- Fixes: c3fad23cdc06 ("octeon_ep_vf: add support for ndo ops") Signed-off-by: Shinas Rasheed --- V4: - No changes V3: https://lore.kernel.org/all/20241218115111.2407958-5-srasheed@marvell.com/ - Added warn log that happened due to rcu_read_lock in commit message V2: https://lore.kernel.org/all/20241216075842.2394606-5-srasheed@marvell.com/ - No changes V1: https://lore.kernel.org/all/20241203072130.2316913-5-srasheed@marvell.com/ drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c index 9b29cd698361..33548f04497c 100644 --- a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c @@ -803,14 +803,6 @@ static void octep_vf_get_stats64(struct net_device *netdev, stats->tx_bytes = tx_bytes; stats->rx_packets = rx_packets; stats->rx_bytes = rx_bytes; - if (!octep_vf_get_if_stats(oct)) { - stats->multicast = oct->iface_rx_stats.mcast_pkts; - stats->rx_errors = oct->iface_rx_stats.err_pkts; - stats->rx_dropped = oct->iface_rx_stats.dropped_pkts_fifo_full + - oct->iface_rx_stats.err_pkts; - stats->rx_missed_errors = oct->iface_rx_stats.dropped_pkts_fifo_full; - stats->tx_dropped = oct->iface_tx_stats.dropped; - } } /**