On 19.11.20 10:12, Sebastian Andrzej Siewior wrote: > On 2020-11-19 09:45:08 [+0200], Julian Wiedmann wrote: >> On 18.11.20 12:53, Sebastian Andrzej Siewior wrote: >>> The size of struct th_header is 8 byte and the size of struct th_sweep >>> is 16 byte. The memory for is allocated, initialized, used and >>> deallocated a few lines later. >>> >>> It is more efficient to avoid the allocation/free dance and keeping the >>> variable on stack. Especially since the compiler is smart enough to not >>> allocate the memory on stack but assign the values directly. >>> >>> Declare struct th_sweep/th_header on stack and initialize it to zero. >>> Use the local variable instead of the pointer. >>> >> >> Frankly, I'd much rather see us use the pointers that are returned from >> skb_push() and skb_put(). No need for the on-stack & memcpy indirection. > > You are aware that the compiler optimizes the on-stack memory away and > you get the zero-init for free due to the way the assignment is made? > There is no memcpy() in the resulting code. > > Sebastian > I am not worried about performance at all. Yet readability matters.