From patchwork Thu Sep 19 12:10:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Furong Xu <0x1207@gmail.com> X-Patchwork-Id: 13807668 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 C441DCE8D7C for ; Thu, 19 Sep 2024 12:12:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=o32/nc+Dqjrsv+Sp5j6ph6epltryoYejvMuSKLYsEsQ=; b=WktFgCOfH7gVPGdjFfOTcoDr09 4uGCd6L1sQSUr750/JbUbCAhZCDwPCsnD6onyzFAvj6d4jknHXbe4U6xcD4iYNetRF++hSEsoOF/S uEW1xEselKhSet7eTesffeskr0yJ0wPCv4YXaSWDZyFWRAfnxgBRK3RYmXgA5coBWPhl3y0oslrae qD9MeDhWrFv3BZbO/L5/zXhSiCJxp5Fb3t7AzSHg6LSOTHcRM9OsJpt/Jnu8LIw2ntFNUVave89Of FO5Z3I0qK0aYfJ05NqluZx8ZZfiu/j0QfLx6H7Qt3PO8uzWagajbaOMcBH+/p0KnZRmS6BJAjJAOz nErpRU/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1srG0z-0000000ADI1-0FGB; Thu, 19 Sep 2024 12:12:05 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1srFzs-0000000ADDE-0Mit for linux-arm-kernel@lists.infradead.org; Thu, 19 Sep 2024 12:10:57 +0000 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-2053616fa36so10755655ad.0 for ; Thu, 19 Sep 2024 05:10:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726747855; x=1727352655; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=o32/nc+Dqjrsv+Sp5j6ph6epltryoYejvMuSKLYsEsQ=; b=ddrgIfqcaFiDB186YdMH27s2Lu0UsBQDAEDzl+MSeehXRjGvLpAjCCEw56+ajYENDt J1hQkWwsGp3YX7NgHZQw+R8nb4zhdj2uyRqI/zSs4e8XoKwNk1K3MMh0a2Kwt3Z4F7a9 SF3tzjF6+0Tixdwv/fwbVo7qYEW8B8Zim8P4VI5gvC72+tJt66nHSv2dd0k4OvG0cm3I 1mYpVjXhS6H3usbwhNYA4RBWiwevlQvpGo1l05+Pe1oRm4/fuyRZhQNGQGZuhcMpRXCJ fi3aiWd5sXZfN3ZVMbp3ZR1bKRrK7Z6usUtZBhLhoW33qK8Wlk0zu00+7aNtMukf6Y6C v/Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726747855; x=1727352655; 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=o32/nc+Dqjrsv+Sp5j6ph6epltryoYejvMuSKLYsEsQ=; b=gyWNSPBjotBUumDKEcGnyzIYEH11ZnKXH/og4LdIYD1srUMK2GScKS2cQb/d6V9FBH QAvWcptfx7am/tzJGxvC5GdnOA2OZkV1xfpCDUbmFkojiYNPLSTKQ8q5mVcknA/NqlLA bCUiQqHJxUX1t1xqUe6vH93pkQeweFzoAz0mTabTm/B3BkTtXzxZZfHxLGpsL+qMrnFh Mvbpt7Hx2k5SNiuUb8AWV1NMdRVHH8I1SLME9dRun1XJv/2srmjcC3cuuD9LGW8YiDye z+uffZHWYtzO6ZJgoeRHJ946YRtyk/pRLcfU5lOPZpX8c0M8FKu/BiYCAO7LkBgOCSJC 8fag== X-Forwarded-Encrypted: i=1; AJvYcCUvvO9vJFDrgHa5EiQPSrbnhmD70Lv5OFJZEC+FCCNRIGJ3skjInNCHybpHYWbqO1NPg3z7OU58hcmUmGLhis2E@lists.infradead.org X-Gm-Message-State: AOJu0YzARn1wp0qzYdo0dZgO2yA4dZnkXj7nF5OwKic2MF2STOombM7K XD5+2JrCJHeyDSO6hCHZZ6mh023ryC+Iy20uMjLrUnUbY2bVQjQC X-Google-Smtp-Source: AGHT+IGZREsj4SQwgdJITtOEHoTSJHe60c5soOhc/Mx1CbgeWx979RO8pm0n67220rUA8Tpw/0tJSQ== X-Received: by 2002:a17:902:f54c:b0:1fb:a1cb:cb25 with SMTP id d9443c01a7336-2076e3eaabcmr356890015ad.40.1726747854563; Thu, 19 Sep 2024 05:10:54 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-2079460327bsm78691445ad.103.2024.09.19.05.10.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2024 05:10:54 -0700 (PDT) From: Furong Xu <0x1207@gmail.com> To: Ong Boon Leong , "David S. Miller" , Alexandre Torgue , Jose Abreu , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Joao Pinto Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, rmk+kernel@armlinux.org.uk, linux@armlinux.org.uk, xfr@outlook.com, Furong Xu <0x1207@gmail.com> Subject: [PATCH net v2] net: stmmac: set PP_FLAG_DMA_SYNC_DEV only if XDP is enabled Date: Thu, 19 Sep 2024 20:10:28 +0800 Message-Id: <20240919121028.1348023-1-0x1207@gmail.com> 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-20240919_051056_151490_6D4DCBA2 X-CRM114-Status: GOOD ( 15.38 ) 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 Commit 5fabb01207a2 ("net: stmmac: Add initial XDP support") sets PP_FLAG_DMA_SYNC_DEV flag for page_pool unconditionally, page_pool_recycle_direct() will call page_pool_dma_sync_for_device() on every page even the page is not going to be reused by XDP program. When XDP is not enabled, the page which holds the received buffer will be recycled once the buffer is copied into new SKB by skb_copy_to_linear_data(), then the MAC core will never reuse this page any longer. Always setting PP_FLAG_DMA_SYNC_DEV wastes CPU cycles on unnecessary calling of page_pool_dma_sync_for_device(). After this patch, up to 9% noticeable performance improvement was observed on certain platforms. Fixes: 5fabb01207a2 ("net: stmmac: Add initial XDP support") Signed-off-by: Furong Xu <0x1207@gmail.com> --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index f3a1b179aaea..95d3d1081727 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -2022,7 +2022,7 @@ static int __alloc_dma_rx_desc_resources(struct stmmac_priv *priv, rx_q->queue_index = queue; rx_q->priv_data = priv; - pp_params.flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV; + pp_params.flags = PP_FLAG_DMA_MAP | (xdp_prog ? PP_FLAG_DMA_SYNC_DEV : 0); pp_params.pool_size = dma_conf->dma_rx_size; num_pages = DIV_ROUND_UP(dma_conf->dma_buf_sz, PAGE_SIZE); pp_params.order = ilog2(num_pages);