Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1226803pxv; Fri, 23 Jul 2021 03:15:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiap6XglbYrWL6wHSbDNRO2ibfpkxndkPabqfYWGdmQtjm2l7f96k4NAiDN7ecQO+GVej+ X-Received: by 2002:a17:906:9b88:: with SMTP id dd8mr3952687ejc.83.1627035324867; Fri, 23 Jul 2021 03:15:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627035324; cv=none; d=google.com; s=arc-20160816; b=yz/qU8ojMETJs5qBWGkoSMZ7ZDBZ6fMs4N9hojkxYv7nvuwOhfJngd2wEq4AyNKMQF 8M/TGyqaTolul1F7Et5JzieYXTo4O0MwYRYx8M21oe6rrIX5hL+prnoFJhuUkeYD4lb9 zXqETGIHC0b+Tne42Uhoqk+56gikljjDXflcT5Kd6qq8A0vkwB+EvEc16XoNQHcG2yL2 t+B0bEixMvNwh0+hA++uBkWyToIIt+NgKXyn8CBwqDEihOJ4oDMaP/QW/5S7p41QkA65 Wm7xuhv7+vdCbSmEEBRiYb70U+CSrZvuT9XkWvZLSx/kueEFO/jYdD3eXLZ/23Lz6lKO uLaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=o3LHYIwGpCkKsSkV53n4TZ0vps5VvYe3NdwkzicqRUQ=; b=JWBG8BEj6HA607gi9FOuQ76l15r3uDIDXoPvpgaR6iPWM8aoYcl3F4owIAKZgbbG4F qeUbJJ2Crwqm3MvoplE7P2tBsYB2F9ZIofuij6KJZh/wUilcTs3qZphr7kW2WZO+erdb KlC5zB0Ei4qwjcVMWFIkqkbeEVUEdvSS/mFXcs+Nokm5VvuRm/mfe8rkZp0dHXYfKVvM zHr4vCuZ5cMRt23jwLPUBGVLfb8AkH9ulUqm1fhuERNc43zwq997GtCa7MwLabWJcnTP B6vU3MAqknWOKtcUu9D/+WMpT9cOccoJ0jqqH+U4lLqNanIzH3c07yMTRKO1rQVN+XtT EMLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cnIWmb3i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o8si8390854ejj.94.2021.07.23.03.15.02; Fri, 23 Jul 2021 03:15:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cnIWmb3i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231602AbhGWJc0 (ORCPT + 99 others); Fri, 23 Jul 2021 05:32:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49445 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231605AbhGWJcK (ORCPT ); Fri, 23 Jul 2021 05:32:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1627035162; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o3LHYIwGpCkKsSkV53n4TZ0vps5VvYe3NdwkzicqRUQ=; b=cnIWmb3ifDcxtcxklgu2eUmJhX3QOZYzsFEbMKtUuB+SswKFWnZHnkO5hPFOMMgWIZJCpm MwDZjmwkItVAyceIG1kxKRAzCVBHpGPerZAexPzTfSIkPi1Km9bOJAFp/L9wWFsfyY1pH5 jVfutYOibAKm5Rh/daKclZ2F3a9CAck= Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-205-RJFI8nRTMCiZaGZTOtRJ4Q-1; Fri, 23 Jul 2021 06:12:41 -0400 X-MC-Unique: RJFI8nRTMCiZaGZTOtRJ4Q-1 Received: by mail-io1-f71.google.com with SMTP id i19-20020a5d84130000b029044cbcdddd23so1310539ion.13 for ; Fri, 23 Jul 2021 03:12:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=o3LHYIwGpCkKsSkV53n4TZ0vps5VvYe3NdwkzicqRUQ=; b=j4RyEGMUvNSvw9nU3pYva6iPWEpbe4mBcdgVs1k3S8+FsyO/FgFTC7DmHdoB+wNI0k jvnWJRHRt80tQYjKB2IoKavGGCUUQeoUA+gA9VtkadMxfrOoQZXEh0us9tW27ugfgH6z eIS/5YBcyyuUhwv0L5/Z++8DFleXi79FX9SnxzGnDWIei3ruCU3i1dL9RMOM7BIApTqo Hnxm3D09Ekb9amm3JUyTjQ+FlBs+vX24HWjL+9Qpu3dWGLRondNzfWhwgjtV0ZGWKOoM SIK92VB5R5FXUn7LxZHF6jovuy/wTpCieUCKuWXDq0s170fx0rfv7zV2foq/G1CNVxMc ilMg== X-Gm-Message-State: AOAM531XmIrz5apmz7w1I7VcEYFcLfpgLbVBrttVR/VlO7GEzN8SQL+D SFlLwpkCzQNcYYrhzQreOSXIKFM+GReJ05P8/CCJ3RDfUcruMNc4mXmXyfSs8TqeLSNd5JIFQyt WKC1j20OwkHkh5TPkFfSg6fmlnsXn9aEY00zyQGSE X-Received: by 2002:a05:6602:24d8:: with SMTP id h24mr3412209ioe.27.1627035160996; Fri, 23 Jul 2021 03:12:40 -0700 (PDT) X-Received: by 2002:a05:6602:24d8:: with SMTP id h24mr3412199ioe.27.1627035160822; Fri, 23 Jul 2021 03:12:40 -0700 (PDT) MIME-Version: 1.0 References: <20210723035721.531372-1-sashal@kernel.org> <20210723035721.531372-9-sashal@kernel.org> In-Reply-To: <20210723035721.531372-9-sashal@kernel.org> From: =?UTF-8?B?w43DsWlnbyBIdWd1ZXQ=?= Date: Fri, 23 Jul 2021 12:12:30 +0200 Message-ID: Subject: Re: [PATCH AUTOSEL 5.13 09/19] sfc: ensure correct number of XDP queues To: Sasha Levin Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, "David S . Miller" , netdev@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Fri, Jul 23, 2021 at 5:57 AM Sasha Levin wrote: > > From: =C3=8D=C3=B1igo Huguet > > [ Upstream commit 788bc000d4c2f25232db19ab3a0add0ba4e27671 ] Applying this commit alone could be problematic, leading even to kernel crash in certain situations. The real fix is the previous one of the series: f43a24f446da sfc: fix lack of XDP TX queues - error XDP TX failed (-22) This one can be applied too, but not really a must-have. > Commit 99ba0ea616aa ("sfc: adjust efx->xdp_tx_queue_count with the real > number of initialized queues") intended to fix a problem caused by a > round up when calculating the number of XDP channels and queues. > However, this was not the real problem. The real problem was that the > number of XDP TX queues had been reduced to half in > commit e26ca4b53582 ("sfc: reduce the number of requested xdp ev queues")= , > but the variable xdp_tx_queue_count had remained the same. > > Once the correct number of XDP TX queues is created again in the > previous patch of this series, this also can be reverted since the error > doesn't actually exist. > > Only in the case that there is a bug in the code we can have different > values in xdp_queue_number and efx->xdp_tx_queue_count. Because of this, > and per Edward Cree's suggestion, I add instead a WARN_ON to catch if it > happens again in the future. > > Note that the number of allocated queues can be higher than the number > of used ones due to the round up, as explained in the existing comment > in the code. That's why we also have to stop increasing xdp_queue_number > beyond efx->xdp_tx_queue_count. > > Signed-off-by: =C3=8D=C3=B1igo Huguet > Signed-off-by: David S. Miller > Signed-off-by: Sasha Levin > --- > drivers/net/ethernet/sfc/efx_channels.c | 15 ++++++++------- > 1 file changed, 8 insertions(+), 7 deletions(-) > > diff --git a/drivers/net/ethernet/sfc/efx_channels.c b/drivers/net/ethern= et/sfc/efx_channels.c > index a3ca406a3561..bea0b27baf4b 100644 > --- a/drivers/net/ethernet/sfc/efx_channels.c > +++ b/drivers/net/ethernet/sfc/efx_channels.c > @@ -891,18 +891,20 @@ int efx_set_channels(struct efx_nic *efx) > if (efx_channel_is_xdp_tx(channel)) { > efx_for_each_channel_tx_queue(tx_queue, c= hannel) { > tx_queue->queue =3D next_queue++; > - netif_dbg(efx, drv, efx->net_dev,= "Channel %u TXQ %u is XDP %u, HW %u\n", > - channel->channel, tx_qu= eue->label, > - xdp_queue_number, tx_qu= eue->queue); > + > /* We may have a few left-over XD= P TX > * queues owing to xdp_tx_queue_c= ount > * not dividing evenly by EFX_MAX= _TXQ_PER_CHANNEL. > * We still allocate and probe th= ose > * TXQs, but never use them. > */ > - if (xdp_queue_number < efx->xdp_t= x_queue_count) > + if (xdp_queue_number < efx->xdp_t= x_queue_count) { > + netif_dbg(efx, drv, efx->= net_dev, "Channel %u TXQ %u is XDP %u, HW %u\n", > + channel->channe= l, tx_queue->label, > + xdp_queue_numbe= r, tx_queue->queue); > efx->xdp_tx_queues[xdp_qu= eue_number] =3D tx_queue; > - xdp_queue_number++; > + xdp_queue_number++; > + } > } > } else { > efx_for_each_channel_tx_queue(tx_queue, c= hannel) { > @@ -914,8 +916,7 @@ int efx_set_channels(struct efx_nic *efx) > } > } > } > - if (xdp_queue_number) > - efx->xdp_tx_queue_count =3D xdp_queue_number; > + WARN_ON(xdp_queue_number !=3D efx->xdp_tx_queue_count); > > rc =3D netif_set_real_num_tx_queues(efx->net_dev, efx->n_tx_chann= els); > if (rc) > -- > 2.30.2 > --=20 =C3=8D=C3=B1igo Huguet