Re: [PATCH net-next v1] tcp: remove redundant memset in hot paths with CONFIG_INIT_STACK_ALL_ZERO
From: Eric Dumazet
Date: Thu Mar 12 2026 - 08:53:44 EST
On Thu, Mar 12, 2026 at 1:48 PM Jiayuan Chen <jiayuan.chen@xxxxxxxxx> wrote:
>
> Modern compilers with CONFIG_INIT_STACK_ALL_ZERO enabled
> (-ftrivial-auto-var-init=zero) automatically zero-initialize all stack
> variables via `rep stos` in the function prologue. However, the compiler
> cannot eliminate explicit memset() calls on those same variables,
> resulting in redundant zeroing of the same memory region.
>
> Replace explicit memset() with `= {0}` initializers for stack variables
> in TCP hot path functions. With `= {0}`, the compiler recognizes a single
> initialization and generates only one zeroing sequence, whereas a
> separate memset() after declaration always produces a second `rep stos`.
No sorry. It seems you missed
commit cfcceb7a39fc10a6f896af8229bf81d96acb22cc
Author: Keita Morisaki <kmta1236@xxxxxxxxx>
Date: Wed Mar 4 20:15:17 2026 +0900
tcp: shrink per-packet memset in __tcp_transmit_skb()
No need to resend your patch, I do not think it is a good idea.