From patchwork Wed Mar 8 16:26:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Leesoo Ahn X-Patchwork-Id: 13166104 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F174CC678D5 for ; Wed, 8 Mar 2023 16:27:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=TB0oTk+dydoQplweG4hcTdawy4GAPt1ADB5X3n/ETNE=; b=0jnecVITPjOLpf DqHnG3lJdqrOkGG1Fi7QuZ0iBy1UYnNnAe/BsoLGzR7LQHu799Sala9vUOSmoJ/SvODQTz9L4EXTA O4yUm+R3k0fO5QhcRCIakIwSkNgE7zgDjEqSqw2H+5rkvkAscLv/qBQPduz+m8AqZLkpuzec6w2fj mLpa6QkI6bIe1kkxSFoFu2oIfmDNiFQylWO5uAM/Y0t/4NeDuljy5c31HfostpS5TwxrUESQ/TZMr ll3UaCQoKlIfWPgCPdd8QG9h1aF1hPLPN8YYXbwwckhc3lmuwNqIFCl2nGjkyYMJDwQbGQilOgLvi bBtgtWoiOZ2aRwHwlRXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZwcf-005vW8-Ec; Wed, 08 Mar 2023 16:26:37 +0000 Received: from mail-pj1-f49.google.com ([209.85.216.49]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZwcc-005vUl-2Z for linux-arm-kernel@lists.infradead.org; Wed, 08 Mar 2023 16:26:35 +0000 Received: by mail-pj1-f49.google.com with SMTP id me6-20020a17090b17c600b0023816b0c7ceso2948214pjb.2 for ; Wed, 08 Mar 2023 08:26:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678292791; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LQUZMW3ATClSf/r8H/ZNppEXmMdqJP2TRdMQdlzdBEU=; b=0Rfxxz6nV2rjO5YiuNIvqPgpOTHMqRyebravr/YA/qBx4XRbcbOCLiDT8KuDFzsu52 PKvZmlYKcKz4Da7924h1kW4niewhO1s+zYcwf8NMJ8KOvYdu5VH9yWplFyQwZpMRyFz1 O+qBMMvElJI0L7+41hqwg/F5JAxpQA559LEX86ppY7sZWis6Dkeo997jAKM9IEto0JEq IRJhv1aW0d5Gmfvo/VCzZklnVZ7Vu1ubzsSBsjphwd8RWWA5PppFMiVPB5olI7HjAoUx Cz0DVRDOSCWQyWvyRQjj4i5aE+Xeiec5Smy7ODDk28vwaYUa6U4fNmWELQxkYwS3mAx6 NcHA== X-Gm-Message-State: AO0yUKWx4YbzdoVlz7A9mvMFoCob5nl2JSes/JE/fBN/KzG58ta7BL6l /UqM4WBCxkEM8ZRIFnQGgy8= X-Google-Smtp-Source: AK7set/ljF2NSlK5iXBS5nOBvYwYALtBT6qGPN3NaOl9NmTJAqQftRWcEmjCkHVWk/x0lRsa1htRvA== X-Received: by 2002:a17:90b:1b0f:b0:237:c18d:c459 with SMTP id nu15-20020a17090b1b0f00b00237c18dc459mr19250067pjb.31.1678292791395; Wed, 08 Mar 2023 08:26:31 -0800 (PST) Received: from localhost.localdomain ([14.4.134.166]) by smtp.gmail.com with ESMTPSA id mv15-20020a17090b198f00b0023087e8adf8sm9363818pjb.21.2023.03.08.08.26.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Mar 2023 08:26:31 -0800 (PST) From: Leesoo Ahn To: lsahn@ooseel.net Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH net-next] net: stmmac: call stmmac_finalize_xdp_rx() on a condition Date: Thu, 9 Mar 2023 01:26:18 +0900 Message-Id: <20230308162619.329372-1-lsahn@ooseel.net> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230308_082634_130943_46AED63B X-CRM114-Status: GOOD ( 15.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The current codebase calls the function no matter net device has XDP programs or not. So the finalize function is being called everytime when RX bottom-half in progress. It needs a few machine instructions for nothing in the case that XDP programs are not attached at all. Lets it call the function on a condition that if xdp_status variable has not zero value. That means XDP programs are attached to the net device and it should be finalized based on the variable. The following instructions show that it's better than calling the function unconditionally. 0.31 │6b8: ldr w0, [sp, #196] │ ┌──cbz w0, 6cc │ │ mov x1, x0 │ │ mov x0, x27 │ │→ bl stmmac_finalize_xdp_rx │6cc:└─→ldr x1, [sp, #176] with 'if (xdp_status)' statement, jump to '6cc' label if xdp_status has zero value. Signed-off-by: Leesoo Ahn --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index e4902a7bb61e..53c6e9b3a0c2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -5145,7 +5145,8 @@ static int stmmac_rx_zc(struct stmmac_priv *priv, int limit, u32 queue) rx_q->state.len = len; } - stmmac_finalize_xdp_rx(priv, xdp_status); + if (xdp_status) + stmmac_finalize_xdp_rx(priv, xdp_status); priv->xstats.rx_pkt_n += count; priv->xstats.rxq_stats[queue].rx_pkt_n += count; @@ -5425,7 +5426,8 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) rx_q->state.len = len; } - stmmac_finalize_xdp_rx(priv, xdp_status); + if (xdp_status) + stmmac_finalize_xdp_rx(priv, xdp_status); stmmac_rx_refill(priv, queue);