From: Tengda Wu wutengda2@huawei.com
Offering: HULK hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IAD6H2
--------------------------------
After backport LTS commit 4b359df7b2ad ("[Backport] bpf: Optimize the free of inner map"), two fields `free_after_rcu_gp` and `sleepable_refcnt` were introduced into struct bpf_map, which result in a kabi breakage.
Use KABI_FILL_HOLE and KABI_USE to fix kabi breakage in struct bpf_map.
Before: ------ struct bpf_map { <SNIP> /* --- cacheline 3 boundary (192 bytes) --- */ struct mutex freeze_mutex; /* 192 32 */ atomic64_t writecnt; /* 224 8 */ struct { spinlock_t lock; /* 232 4 */ enum bpf_prog_type type; /* 236 4 */ bool jited; /* 240 1 */ bool xdp_has_frags; /* 241 1 */ } owner; /* 232 12 */
/* XXX last struct has 2 bytes of padding */
bool bypass_spec_v1; /* 244 1 */ bool frozen; /* 245 1 */ bool free_after_mult_rcu_gp; /* 246 1 */
/* XXX 1 byte hole, try to pack */
s64 * elem_count; /* 248 8 */ /* --- cacheline 4 boundary (256 bytes) --- */ u64 kabi_reserved1; /* 256 8 */ u64 kabi_reserved2; /* 264 8 */ u64 kabi_reserved3; /* 272 8 */ u64 kabi_reserved4; /* 280 8 */
/* size: 320, cachelines: 5, members: 32 */ /* sum members: 271, holes: 2, sum holes: 17 */ /* padding: 32 */ /* paddings: 1, sum paddings: 2 */ /* forced alignments: 3, forced holes: 1, sum forced holes: 16 */ } __attribute__((__aligned__(64)));
After: ------ struct bpf_map { <SNIP> /* --- cacheline 3 boundary (192 bytes) --- */ struct mutex freeze_mutex; /* 192 32 */ atomic64_t writecnt; /* 224 8 */ struct { spinlock_t lock; /* 232 4 */ enum bpf_prog_type type; /* 236 4 */ bool jited; /* 240 1 */ bool xdp_has_frags; /* 241 1 */ } owner; /* 232 12 */
/* XXX last struct has 2 bytes of padding */
bool bypass_spec_v1; /* 244 1 */ bool frozen; /* 245 1 */ bool free_after_mult_rcu_gp; /* 246 1 */ bool free_after_rcu_gp; /* 247 1 */ s64 * elem_count; /* 248 8 */ /* --- cacheline 4 boundary (256 bytes) --- */ union { atomic64_t sleepable_refcnt; /* 256 8 */ struct { u64 kabi_reserved1; /* 256 8 */ } kabi_hidden_308; /* 256 8 */ union { }; /* 256 0 */ }; /* 256 8 */ u64 kabi_reserved2; /* 264 8 */ u64 kabi_reserved3; /* 272 8 */ u64 kabi_reserved4; /* 280 8 */
/* size: 320, cachelines: 5, members: 33 */ /* sum members: 272, holes: 1, sum holes: 16 */ /* padding: 32 */ /* paddings: 1, sum paddings: 2 */ /* forced alignments: 3, forced holes: 1, sum forced holes: 16 */ } __attribute__((__aligned__(64)));
Fixes: 1dce7525ede3 ("bpf: Optimize the free of inner map") Signed-off-by: Tengda Wu wutengda2@huawei.com --- include/linux/bpf.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/include/linux/bpf.h b/include/linux/bpf.h index dd164b2267ec..abc920234c28 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -302,11 +302,10 @@ struct bpf_map { bool bypass_spec_v1; bool frozen; /* write-once; write-protected by freeze_mutex */ bool free_after_mult_rcu_gp; - bool free_after_rcu_gp; - atomic64_t sleepable_refcnt; + KABI_FILL_HOLE(bool free_after_rcu_gp) s64 __percpu *elem_count;
- KABI_RESERVE(1) + KABI_USE(1, atomic64_t sleepable_refcnt) KABI_RESERVE(2) KABI_RESERVE(3) KABI_RESERVE(4)