From: Cong Wang Reduce memory waste in struct sk_psock by: 1. Change psock->eval from u32 to u8. The eval field only holds values from enum sk_psock_verdict (4 possible values), so 8 bits is sufficient. 2. Move refcnt up in the struct to pack with other small fields, improving cache locality for psock reference counting operations. refcnt is frequently accessed during sk_psock_get/put, and placing it near the socket pointers (sk, sk_redir) keeps them in the same cache line. These changes reduce holes in the struct and prepare for subsequent patches that will add new fields. Signed-off-by: Cong Wang --- include/linux/skmsg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/skmsg.h b/include/linux/skmsg.h index 61e2c2e6840b..84657327b0ea 100644 --- a/include/linux/skmsg.h +++ b/include/linux/skmsg.h @@ -85,8 +85,9 @@ struct sk_psock { struct sock *sk_redir; u32 apply_bytes; u32 cork_bytes; - u32 eval; + u8 eval; bool redir_ingress; /* undefined if sk_redir is null */ + refcount_t refcnt; struct sk_msg *cork; struct sk_psock_progs progs; #if IS_ENABLED(CONFIG_BPF_STREAM_PARSER) @@ -100,7 +101,6 @@ struct sk_psock { unsigned long state; struct list_head link; spinlock_t link_lock; - refcount_t refcnt; void (*saved_unhash)(struct sock *sk); void (*saved_destroy)(struct sock *sk); void (*saved_close)(struct sock *sk, long timeout); -- 2.34.1