Re: [PATCH net-next v1] tcp: remove redundant memset in hot paths with CONFIG_INIT_STACK_ALL_ZERO
From: Jiayuan Chen
Date: Thu Mar 12 2026 - 09:50:08 EST
On 3/12/26 8:53 PM, Eric Dumazet wrote:
On Thu, Mar 12, 2026 at 1:48 PM Jiayuan Chen <jiayuan.chen@xxxxxxxxx> wrote:Thanks. It seems this patch for __tcp_transmit_skb only saves a few bytes
Modern compilers with CONFIG_INIT_STACK_ALL_ZERO enabledNo sorry. It seems you missed
(-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`.
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.
of memset.