From mboxrd@z Thu Jan 1 00:00:00 1970 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 9B891C3DA61 for ; Tue, 30 Jul 2024 09:00:18 +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:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+PyYxHAAjKY94HrEwTuVrgQc3+br0mLRkqh/sY77Zbs=; b=SX+dDQcJGyn//xXNahALVYFooP 3iu5KYKcrYLJP675g0RowA25u76nM+FEfXV3tCxCcmg6DHGlHeEnS2JM7lAW0Y/kNWklkvrjInmI/ NnI4A0BImUEKCxvzAhD6OkAKEOmHmqJoI5F1J57M7/Z81jmHWYsNZAOABFUHjB4MDubICInIZGc0a 9mj9+08pUhsJ//k3X0cxkqUNkUv7BISRf3M4s33iFo+K8tdI1UsyXCjpVRMk49iLVb7tXfPRz1g37 DjtuaIavq9rOIklbkDmtuZPsSohdGyvv3ABIMpEUhdXm1Ei38+bzCbJQv6OxNA2Hc569b8RkImqTy tS9+WeVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYiiA-0000000EPgL-2pxF; Tue, 30 Jul 2024 09:00:02 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYihG-0000000EPB3-0qZe for linux-arm-kernel@lists.infradead.org; Tue, 30 Jul 2024 08:59:08 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-428163f7635so23173125e9.2 for ; Tue, 30 Jul 2024 01:59:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1722329943; x=1722934743; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=+PyYxHAAjKY94HrEwTuVrgQc3+br0mLRkqh/sY77Zbs=; b=okR+SkuBD3ajQbT48DzZ7apwPanPvDZdG/oCXu2UQ+b+4Kx7MtpCcPW5iAAOeX3nJG 9hUWY+XU/wBzHOumyWe2Z0NFda2D7e64dSmb8e1x7erDnvRbAMJcqayEGbI1WMWbz5Tz bEIGUl1xA9UfLXX1pYGi3+YJBWKCzKo5sPfJg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722329943; x=1722934743; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+PyYxHAAjKY94HrEwTuVrgQc3+br0mLRkqh/sY77Zbs=; b=btQZkKgs3u5mUvexNaFakk4vuw2ot7I7zApFW5/A6EKfnaikfP6jXO3ItMZIjyKxIC 89nmBXvW268RukzP9fRR2mdqmvYpcrb9vjoDPHo17Fdp5RUBJLuiXw3wRilWmOS+ip9E txaKWK0pOZchIxWULalpo7UZS0MCUDL5iXjQT1c0RceuBcARUAbYVcPsA8h4GAQzhOEe 2YXQq0jSv564CX/Ql4XdQOjlMqTHqSUoQInu5yzwR/5e13wUp0UO2l/aH3WM5KbCIzPW m3OR66WmCsox+zjXYzuHrgh2t1bTGKd5jOeGGr8clwDNRgL5xyQ5G3yXUQnFrfSC4pdY +HKg== X-Forwarded-Encrypted: i=1; AJvYcCW7LL2SgqeG6I2MOB/aQOFHEZNlilLh9VGT7vzDSG0Mkx5bVWMBAzRi2qw9To9CqrLkSG3GwWi+ogWCrxUk1VprrBWtO3iEr+KjmUxKwQBH+fc52xs= X-Gm-Message-State: AOJu0YxL33gH4ZJOLDhkM+3SXx3XmTV+64WR3K/PEQt82c3wd7GdSlbW YEsmX4YEPgpBuKlyTXxyFTgBuPkwi5kINEvXMHm0BdvrTNMqNTzlldK76WYxcI0= X-Google-Smtp-Source: AGHT+IF/ePhGnUz5oRY8da3ygbH+O32+pdLnV9wMLAT92Wkbz17fdqBPIg9jUaaUhazOspOKL0yp8Q== X-Received: by 2002:a05:600c:1d9b:b0:426:5f7d:addc with SMTP id 5b1f17b1804b1-42811df6daamr52383965e9.37.1722329943453; Tue, 30 Jul 2024 01:59:03 -0700 (PDT) Received: from LQ3V64L9R2 ([80.208.222.2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-428218a3934sm28986935e9.45.2024.07.30.01.59.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 01:59:03 -0700 (PDT) Date: Tue, 30 Jul 2024 09:59:01 +0100 From: Joe Damato To: Elad Yifee Cc: Felix Fietkau , Sean Wang , Mark Lee , Lorenzo Bianconi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Daniel Golle Subject: Re: [PATCH net-next v2 1/2] net: ethernet: mtk_eth_soc: use prefetch methods Message-ID: Mail-Followup-To: Joe Damato , Elad Yifee , Felix Fietkau , Sean Wang , Mark Lee , Lorenzo Bianconi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Daniel Golle References: <20240729183038.1959-1-eladwf@gmail.com> <20240729183038.1959-2-eladwf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240729183038.1959-2-eladwf@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240730_015906_325112_FD78FA54 X-CRM114-Status: GOOD ( 23.89 ) 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 On Mon, Jul 29, 2024 at 09:29:54PM +0300, Elad Yifee wrote: > Utilize kernel prefetch methods for faster cache line access. > This change boosts driver performance, > allowing the CPU to handle about 5% more packets/sec. > > Signed-off-by: Elad Yifee > --- > Changes in v2: > - use net_prefetchw as suggested by Joe Damato > - add (NET_SKB_PAD + eth->ip_align) offset to prefetched data > - use eth->ip_align instead of NET_IP_ALIGN as it could be 0, > depending on the platform > --- > drivers/net/ethernet/mediatek/mtk_eth_soc.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c > index 16ca427cf4c3..4d0052dbe3f4 100644 > --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c > +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c [...] > @@ -2143,6 +2147,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, > dma_unmap_single(eth->dma_dev, ((u64)trxd.rxd1 | addr64), > ring->buf_size, DMA_FROM_DEVICE); > > + net_prefetch(data + NET_SKB_PAD + eth->ip_align); > skb = build_skb(data, ring->frag_size); > if (unlikely(!skb)) { > netdev->stats.rx_dropped++; > @@ -2150,7 +2155,8 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, > goto skip_rx; > } > > - skb_reserve(skb, NET_SKB_PAD + NET_IP_ALIGN); > + net_prefetchw(skb->data); > + skb_reserve(skb, NET_SKB_PAD + eth->ip_align); Based on the code in mtk_probe, I am guessing that only MTK_SOC_MT7628 can DMA to unaligned addresses, because for everything else eth->ip_align would be 0. Is that right? I am asking because the documentation in Documentation/core-api/unaligned-memory-access.rst refers to the case you mention, NET_IP_ALIGN = 0, suggesting that this is intentional for performance reasons on powerpc: One notable exception here is powerpc which defines NET_IP_ALIGN to 0 because DMA to unaligned addresses can be very expensive and dwarf the cost of unaligned loads. It goes on to explain that some devices cannot DMA to unaligned addresses and I assume that for your driver that is everything which is not MTK_SOC_MT7628 ?