From: "Théo Lebrun" <theo.lebrun@bootlin.com>
To: "Maxime Chevallier" <maxime.chevallier@bootlin.com>
Cc: "Andrew Lunn" <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Nicolas Ferre" <nicolas.ferre@microchip.com>,
"Claudiu Beznea" <claudiu.beznea@tuxon.dev>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Alexandre Ghiti" <alex@ghiti.fr>,
"Samuel Holland" <samuel.holland@sifive.com>,
"Richard Cochran" <richardcochran@gmail.com>,
"Russell King" <linux@armlinux.org.uk>,
"Thomas Bogendoerfer" <tsbogend@alpha.franken.de>,
"Vladimir Kondratiev" <vladimir.kondratiev@mobileye.com>,
"Gregory CLEMENT" <gregory.clement@bootlin.com>,
<netdev@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-riscv@lists.infradead.org>,
<linux-mips@vger.kernel.org>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
"Tawfik Bayouk" <tawfik.bayouk@mobileye.com>
Subject: Re: [PATCH net-next 08/13] net: macb: introduce DMA descriptor helpers (is 64bit? is PTP?)
Date: Wed, 26 Mar 2025 11:59:13 +0100 [thread overview]
Message-ID: <D8Q58KMGV4R4.ELW8TLEK5W5V@bootlin.com> (raw)
In-Reply-To: <20250324095522.2ab1c38b@fedora.home>
Hello Maxime,
On Mon Mar 24, 2025 at 9:55 AM CET, Maxime Chevallier wrote:
> On Fri, 21 Mar 2025 20:09:39 +0100
> Théo Lebrun <theo.lebrun@bootlin.com> wrote:
>
>> Introduce macb_dma_is_64b() and macb_dma_is_ptp() helper functions.
>> Many codepaths are made simpler by dropping conditional compilation.
>>
>> This implies three changes:
>> - Always compile related structure definitions inside <macb.h>.
>> - Make the field hw_dma_cap in struct macb always present.
>> - MACB_EXT_DESC can be dropped as it is useless now.
>>
>> The common case is:
>>
>> #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
>> struct macb_dma_desc_64 *desc_64;
>> if (bp->hw_dma_cap & HW_DMA_CAP_64B) {
>> desc_64 = macb_64b_desc(bp, desc);
>> // ...
>> }
>> #endif
>>
>> And replaced by:
>>
>> struct macb_dma_desc_64 *desc_64;
>> if (macb_dma_is_64b(bp)) {
>> desc_64 = macb_64b_desc(bp, desc);
>> // ...
>> }
>
> Just a thought, but this is adding some more branches in the hotpath on
> 32 bits DMA setups. Did you measure any performance changes on
> these platforms (if you have access to one :) )
>
> As the caps can't be changed dynamically, maybe these helpers could be
> replaced more efficiently with some static_key ? This would benefit
> both 32 and 64 bits systems as the following would be more efficient
>
> if (bp->hw_dma_cap & HW_DMA_CAP_64B) {
> // ...
> }
>
> Just a thought of course, maybe this patch doesn't really hurt perfs :)
Good question! I asked myself the same thing before posting.
We go from:
void bar(struct macb *bp) {
#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
if (bp->hw_dma_cap & HW_DMA_CAP_64B) {
foo();
}
#endif
}
To:
static bool macb_dma_is_64b(struct macb *bp)
{
return IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) &&
bp->hw_dma_cap & HW_DMA_CAP_64B;
}
void bar(struct macb *bp) {
if (macb_dma_is_64b(bp)) {
foo();
}
}
In the first case, we use explicit preprocessor directives to remove
code if CONFIG_ARCH_DMA_ADDR_T_64BIT isn't defined.
In the second case, our compiler optimises away the IS_ENABLED() call.
- If false, then the branch doesn't appear.
- If true, then only the capability check is inlined in bar().
I checked the assembly on arm/arm64/MIPS.
Conclusion: the hotpath doesn't change.
Thanks,
--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
WARNING: multiple messages have this Message-ID (diff)
From: "Théo Lebrun" <theo.lebrun@bootlin.com>
To: "Maxime Chevallier" <maxime.chevallier@bootlin.com>
Cc: "Andrew Lunn" <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Nicolas Ferre" <nicolas.ferre@microchip.com>,
"Claudiu Beznea" <claudiu.beznea@tuxon.dev>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Alexandre Ghiti" <alex@ghiti.fr>,
"Samuel Holland" <samuel.holland@sifive.com>,
"Richard Cochran" <richardcochran@gmail.com>,
"Russell King" <linux@armlinux.org.uk>,
"Thomas Bogendoerfer" <tsbogend@alpha.franken.de>,
"Vladimir Kondratiev" <vladimir.kondratiev@mobileye.com>,
"Gregory CLEMENT" <gregory.clement@bootlin.com>,
<netdev@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-riscv@lists.infradead.org>,
<linux-mips@vger.kernel.org>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
"Tawfik Bayouk" <tawfik.bayouk@mobileye.com>
Subject: Re: [PATCH net-next 08/13] net: macb: introduce DMA descriptor helpers (is 64bit? is PTP?)
Date: Wed, 26 Mar 2025 11:59:13 +0100 [thread overview]
Message-ID: <D8Q58KMGV4R4.ELW8TLEK5W5V@bootlin.com> (raw)
In-Reply-To: <20250324095522.2ab1c38b@fedora.home>
Hello Maxime,
On Mon Mar 24, 2025 at 9:55 AM CET, Maxime Chevallier wrote:
> On Fri, 21 Mar 2025 20:09:39 +0100
> Théo Lebrun <theo.lebrun@bootlin.com> wrote:
>
>> Introduce macb_dma_is_64b() and macb_dma_is_ptp() helper functions.
>> Many codepaths are made simpler by dropping conditional compilation.
>>
>> This implies three changes:
>> - Always compile related structure definitions inside <macb.h>.
>> - Make the field hw_dma_cap in struct macb always present.
>> - MACB_EXT_DESC can be dropped as it is useless now.
>>
>> The common case is:
>>
>> #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
>> struct macb_dma_desc_64 *desc_64;
>> if (bp->hw_dma_cap & HW_DMA_CAP_64B) {
>> desc_64 = macb_64b_desc(bp, desc);
>> // ...
>> }
>> #endif
>>
>> And replaced by:
>>
>> struct macb_dma_desc_64 *desc_64;
>> if (macb_dma_is_64b(bp)) {
>> desc_64 = macb_64b_desc(bp, desc);
>> // ...
>> }
>
> Just a thought, but this is adding some more branches in the hotpath on
> 32 bits DMA setups. Did you measure any performance changes on
> these platforms (if you have access to one :) )
>
> As the caps can't be changed dynamically, maybe these helpers could be
> replaced more efficiently with some static_key ? This would benefit
> both 32 and 64 bits systems as the following would be more efficient
>
> if (bp->hw_dma_cap & HW_DMA_CAP_64B) {
> // ...
> }
>
> Just a thought of course, maybe this patch doesn't really hurt perfs :)
Good question! I asked myself the same thing before posting.
We go from:
void bar(struct macb *bp) {
#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
if (bp->hw_dma_cap & HW_DMA_CAP_64B) {
foo();
}
#endif
}
To:
static bool macb_dma_is_64b(struct macb *bp)
{
return IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) &&
bp->hw_dma_cap & HW_DMA_CAP_64B;
}
void bar(struct macb *bp) {
if (macb_dma_is_64b(bp)) {
foo();
}
}
In the first case, we use explicit preprocessor directives to remove
code if CONFIG_ARCH_DMA_ADDR_T_64BIT isn't defined.
In the second case, our compiler optimises away the IS_ENABLED() call.
- If false, then the branch doesn't appear.
- If true, then only the capability check is inlined in bar().
I checked the assembly on arm/arm64/MIPS.
Conclusion: the hotpath doesn't change.
Thanks,
--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2025-03-26 10:59 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-21 19:09 [PATCH net-next 00/13] Support the Cadence MACB/GEM instances on Mobileye EyeQ5 SoCs Théo Lebrun
2025-03-21 19:09 ` Théo Lebrun
2025-03-21 19:09 ` [PATCH net-next 01/13] dt-bindings: net: cdns,macb: add Mobileye EyeQ5 ethernet interface Théo Lebrun
2025-03-21 19:09 ` Théo Lebrun
2025-03-21 20:37 ` Rob Herring (Arm)
2025-03-21 20:37 ` Rob Herring (Arm)
2025-03-21 20:49 ` Andrew Lunn
2025-03-21 20:49 ` Andrew Lunn
2025-03-24 16:14 ` Théo Lebrun
2025-03-24 16:14 ` Théo Lebrun
2025-03-21 19:09 ` [PATCH net-next 02/13] dt-bindings: net: cdns,macb: allow tsu_clk without tx_clk Théo Lebrun
2025-03-21 19:09 ` Théo Lebrun
2025-03-24 16:30 ` Rob Herring
2025-03-24 16:30 ` Rob Herring
2025-03-27 14:55 ` Théo Lebrun
2025-03-27 14:55 ` Théo Lebrun
2025-03-21 19:09 ` [PATCH net-next 03/13] dt-bindings: net: cdns,macb: allow dma-coherent Théo Lebrun
2025-03-21 19:09 ` Théo Lebrun
2025-03-24 16:31 ` Rob Herring (Arm)
2025-03-24 16:31 ` Rob Herring (Arm)
2025-03-21 19:09 ` [PATCH net-next 04/13] net: macb: use BIT() macro for capability definitions Théo Lebrun
2025-03-21 19:09 ` Théo Lebrun
2025-03-21 20:50 ` Andrew Lunn
2025-03-21 20:50 ` Andrew Lunn
2025-03-21 19:09 ` [PATCH net-next 05/13] net: macb: add no LSO capability (MACB_CAPS_NO_LSO) Théo Lebrun
2025-03-21 19:09 ` Théo Lebrun
2025-03-21 20:51 ` Andrew Lunn
2025-03-21 20:51 ` Andrew Lunn
2025-03-24 8:18 ` Claudiu Beznea
2025-03-24 8:18 ` Claudiu Beznea
2025-03-26 10:04 ` Théo Lebrun
2025-03-26 10:04 ` Théo Lebrun
2025-03-21 19:09 ` [PATCH net-next 06/13] net: macb: simplify macb_probe() code touching match data Théo Lebrun
2025-03-21 19:09 ` Théo Lebrun
2025-03-21 20:57 ` Andrew Lunn
2025-03-21 20:57 ` Andrew Lunn
2025-03-21 19:09 ` [PATCH net-next 07/13] net: macb: move HW IP alignment value to macb_config Théo Lebrun
2025-03-21 19:09 ` Théo Lebrun
2025-03-21 21:06 ` Andrew Lunn
2025-03-21 21:06 ` Andrew Lunn
2025-03-24 17:49 ` Théo Lebrun
2025-03-24 17:49 ` Théo Lebrun
2025-03-24 18:36 ` Andrew Lunn
2025-03-24 18:36 ` Andrew Lunn
2025-03-26 5:01 ` Katakam, Harini
2025-03-26 5:01 ` Katakam, Harini
2025-03-27 17:07 ` Théo Lebrun
2025-03-27 17:07 ` Théo Lebrun
2025-03-21 19:09 ` [PATCH net-next 08/13] net: macb: introduce DMA descriptor helpers (is 64bit? is PTP?) Théo Lebrun
2025-03-21 19:09 ` Théo Lebrun
2025-03-24 8:20 ` Claudiu Beznea
2025-03-24 8:20 ` Claudiu Beznea
2025-03-24 8:55 ` Maxime Chevallier
2025-03-24 8:55 ` Maxime Chevallier
2025-03-26 10:59 ` Théo Lebrun [this message]
2025-03-26 10:59 ` Théo Lebrun
2025-03-21 19:09 ` [PATCH net-next 09/13] net: macb: sort #includes Théo Lebrun
2025-03-21 19:09 ` Théo Lebrun
2025-03-21 21:11 ` Andrew Lunn
2025-03-21 21:11 ` Andrew Lunn
2025-03-21 19:09 ` [PATCH net-next 10/13] net: macb: Add "mobileye,eyeq5-gem" compatible Théo Lebrun
2025-03-21 19:09 ` Théo Lebrun
2025-03-24 8:18 ` Claudiu Beznea
2025-03-24 8:18 ` Claudiu Beznea
2025-03-25 17:25 ` Théo Lebrun
2025-03-25 17:25 ` Théo Lebrun
2025-03-27 8:13 ` Claudiu Beznea
2025-03-27 8:13 ` Claudiu Beznea
2025-03-21 19:09 ` [PATCH net-next 11/13] MIPS: mobileye: add EyeQ5 DMA IOCU support Théo Lebrun
2025-03-21 19:09 ` Théo Lebrun
2025-03-21 19:09 ` [PATCH net-next 12/13] MIPS: mobileye: eyeq5: add two Cadence GEM Ethernet controllers Théo Lebrun
2025-03-21 19:09 ` Théo Lebrun
2025-03-21 19:09 ` [PATCH net-next 13/13] MIPS: mobileye: eyeq5-epm: add two Cadence GEM Ethernet PHYs Théo Lebrun
2025-03-21 19:09 ` Théo Lebrun
2025-03-21 21:16 ` Andrew Lunn
2025-03-21 21:16 ` Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D8Q58KMGV4R4.ELW8TLEK5W5V@bootlin.com \
--to=theo.lebrun@bootlin.com \
--cc=alex@ghiti.fr \
--cc=andrew+netdev@lunn.ch \
--cc=aou@eecs.berkeley.edu \
--cc=claudiu.beznea@tuxon.dev \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=gregory.clement@bootlin.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=pabeni@redhat.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=richardcochran@gmail.com \
--cc=robh@kernel.org \
--cc=samuel.holland@sifive.com \
--cc=tawfik.bayouk@mobileye.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=tsbogend@alpha.franken.de \
--cc=vladimir.kondratiev@mobileye.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.