From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 29F842C853 for ; Fri, 10 May 2024 00:31:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715301068; cv=none; b=iFbC7Cl0kyu68pbT3PAadBskFXdZRexhdcZksIW8bUTwD6sHLhHQPzEQ9fZdxFOxqCtg+JIwAcDFOt/BE+X6+wyfeI0oDz0CLBrfStv7zTG8m60qcf+u19pOjh0PnkOBsi2fQLGWIlCkWfLNklSJNBFoj13Eh32XcL0yYUg51x4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715301068; c=relaxed/simple; bh=0KgQrDUz9XM38RTU0UKKESCM6bwbLhmxO4pbT7KG+xU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cPtoH5NUQZvg60BNSeqQcrmsntXMMf5lpNXNCAN9y9vC7hqlCOZ3rJEma9N3PhZ/DxCHf8SvgEv0qTMRvWtqL5GMgLAeTzTAnY1+JBzsd/LE+T2ELN78TqFKBJ7/1vDkHl/xO0fIDvHaP0RaLgHBdeqDWg79HYTYSA6RiUcJpRE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=rX3ONkD5; arc=none smtp.client-ip=209.85.216.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="rX3ONkD5" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-2b5388087f9so1152387a91.0 for ; Thu, 09 May 2024 17:31:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1715301066; x=1715905866; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=uW7kaHfhybyf7BeUNmVZfbR4EXdAjRYiQZg99RGCKIE=; b=rX3ONkD5mxRxzsiOE/Js1ZlOlAPFmHjzD26Hmg/hB7YrkiVzdKNuJFOjDL0kT9aY19 wzCgXHP2KlzSHnWkWgwSsqx1X89g8/xOTqY/E07CYsgsoll9ZUds+QqHgdhR9EQfTljE QcaOAdo8fAy8JvTzfNsNSsbdo6v0XdVlcPzNk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715301066; x=1715905866; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=uW7kaHfhybyf7BeUNmVZfbR4EXdAjRYiQZg99RGCKIE=; b=R5OXIAdE96KVSfBzlwyYuK6sAEv9/aslUrvJPB147+HaH1m8WY1MGtvxe7qtvbtH9g MLGgXBNi8DAgYtHW/1Dd+KzNfPzddeszg6gpvnMi2FDHk04FeRU+CMukjRr/oPZ8Clmy TcVcIF5pX6M14LUB8QG59OLr5ZHouCfajftvttPtO/vTwlCV7e4/kBHw+FDdLoKBn5Cl xMgVSXdH9/37cNmpRBmvfDtKwg0In41Du5sO1oe73tlKmD+aleN/Y0SLVrVzTRkGCEBO EoNdlTE9nJv+MeRwfTHU3I4gVXEy2OZkxxZAyPRuFwhBXCjYa96kIKwodBu+0OpqZgvC x3fw== X-Forwarded-Encrypted: i=1; AJvYcCWNryZlDX3pUqRkXzTnTLuqTszMT5jqfJn4nIk++l/a6v2XU4clGSqdl6DX8udenwk2q3jQvdmF8GJxfNGLQja2gSNzDomw X-Gm-Message-State: AOJu0YzwmWweCH/zvYXSF0udnquWO4RqdFTuFpTYttMsQLUbLPgyo2BR a+trx6j8C7k/YhSAjN+VHkk3zfvhxxwYGxHxViRGrE4b4MWZy9tcSUyoedXAvck= X-Google-Smtp-Source: AGHT+IG4t+GAVKOh7/FjtEXQWtNTTgiQcAduFs5qq7NWKRBkX7tswNr5fhXjKQpcwb1Az4bClUsw0w== X-Received: by 2002:a17:90b:3587:b0:2b2:a607:ea4a with SMTP id 98e67ed59e1d1-2b6ccd8fc28mr1005227a91.44.1715301066486; Thu, 09 May 2024 17:31:06 -0700 (PDT) Received: from LQ3V64L9R2 (c-24-6-151-244.hsd1.ca.comcast.net. [24.6.151.244]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0bf30bb9sm20245965ad.135.2024.05.09.17.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 17:31:05 -0700 (PDT) Date: Thu, 9 May 2024 17:31:02 -0700 From: Joe Damato To: Tariq Toukan Cc: Jakub Kicinski , Zhu Yanjun , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, saeedm@nvidia.com, gal@nvidia.com, nalramli@fastly.com, "David S. Miller" , Eric Dumazet , Leon Romanovsky , "open list:MELLANOX MLX5 core VPI driver" , Paolo Abeni , Tariq Toukan Subject: Re: [PATCH net-next 0/1] mlx5: Add netdev-genl queue stats Message-ID: References: <20240503173429.10402325@kernel.org> <8678e62c-f33b-469c-ac6c-68a060273754@gmail.com> <20240508175638.7b391b7b@kernel.org> <20240508190839.16ec4003@kernel.org> <32495a72-4d41-4b72-84e7-0d86badfd316@gmail.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-Disposition: inline In-Reply-To: <32495a72-4d41-4b72-84e7-0d86badfd316@gmail.com> On Thu, May 09, 2024 at 01:16:15PM +0300, Tariq Toukan wrote: > > > On 09/05/2024 9:30, Joe Damato wrote: > > On Wed, May 08, 2024 at 07:08:39PM -0700, Jakub Kicinski wrote: > > > On Thu, 9 May 2024 01:57:52 +0000 Joe Damato wrote: > > > > If I'm following that right and understanding mlx5 (two things I am > > > > unlikely to do simultaneously), that sounds to me like: > > > > > > > > - mlx5e_get_queue_stats_rx and mlx5e_get_queue_stats_tx check if i < > > > > priv->channels.params.num_channels (instead of priv->stats_nch), > > > > > > Yes, tho, not sure whether the "if i < ...num_channels" is even > > > necessary, as core already checks against real_num_rx_queues. > > > > > > > and when > > > > summing mlx5e_sq_stats in the latter function, it's up to > > > > priv->channels.params.mqprio.num_tc instead of priv->max_opened_tc. > > > > > > > > - mlx5e_get_base_stats accumulates and outputs stats for everything from > > > > priv->channels.params.num_channels to priv->stats_nch, and > > > > > > I'm not sure num_channels gets set to 0 when device is down so possibly > > > from "0 if down else ...num_channels" to stats_nch. > > > > Yea, you were right: > > > > if (priv->channels.num == 0) > > i = 0; > > else > > i = priv->channels.params.num_channels; > > for (; i < priv->stats_nch; i++) { > > > > Seems to be working now when I adjust the queue count and the test is > > passing as I adjust the queue count up or down. Cool. > > > > I agree that get_base should include all inactive queues stats. > But it's not straight forward to implement. > > A few guiding points: > > Use mlx5e_get_dcb_num_tc(params) for current num_tc. > > txq_ix (within the real_num_tx_queues) is calculated by c->ix + tc * > params->num_channels. > > The txqsq stats struct is chosen by channel_stats[c->ix]->sq[tc]. > > It means, in the base stats you should include SQ stats for: > 1. all SQs of non-active channels, i.e. ch in [params.num_channels, > priv->stats_nch), tc in [0, priv->max_opened_tc). > 2. all SQs of non-active TCs in active channels [0, params.num_channels), tc > in [mlx5e_get_dcb_num_tc(params), priv->max_opened_tc). > > Now I actually see that the patch has issues in mlx5e_get_queue_stats_tx. > You should not loop over all TCs of channel index i. > You must do a reverse mapping from "i" to the pair/tuple [ch_ix, tc], and > then access a single TXQ stats by priv->channel_stats[ch_ix].sq[tc]. It looks like txq2sq probably will help with this? Something like: for (j = 0; j < mlx5e_get_dcb_num_tc(); j++) { sq = priv->txq2sq[j]; if (sq->ch_ix == i) { /* this sq->stats is what I need */ } } Is that right? Not sure if I'm missing something obvious here, sorry, I've been puzzling over the mlx5 source for a bit. BTW: kind of related but in mlx5e_alloc_txqsq the int tc param is unused (I think). It might be helpful to struct mlx5e_txqsq to have a tc field and then in mlx5e_alloc_txqsq: sq->tc = tc; Not sure if that'd be helpful in general, but I could send that as a separate patch.