Joanne Koong
8845b4681b
bpf: Add alignment padding for "map_extra" + consolidate holes
This patch makes 2 changes regarding alignment padding
for the "map_extra" field.
1) In the kernel header, "map_extra" and "btf_value_type_id"
are rearranged to consolidate the hole.
Before:
struct bpf_map {
...
u32 max_entries; /* 36 4 */
u32 map_flags; /* 40 4 */
/* XXX 4 bytes hole, try to pack */
u64 map_extra; /* 48 8 */
int spin_lock_off; /* 56 4 */
int timer_off; /* 60 4 */
/* --- cacheline 1 boundary (64 bytes) --- */
u32 id; /* 64 4 */
int numa_node; /* 68 4 */
...
bool frozen; /* 117 1 */
/* XXX 10 bytes hole, try to pack */
/* --- cacheline 2 boundary (128 bytes) --- */
...
struct work_struct work; /* 144 72 */
/* --- cacheline 3 boundary (192 bytes) was 24 bytes ago --- */
struct mutex freeze_mutex; /* 216 144 */
/* --- cacheline 5 boundary (320 bytes) was 40 bytes ago --- */
u64 writecnt; /* 360 8 */
/* size: 384, cachelines: 6, members: 26 */
/* sum members: 354, holes: 2, sum holes: 14 */
/* padding: 16 */
/* forced alignments: 2, forced holes: 1, sum forced holes: 10 */
} __attribute__((__aligned__(64)));
After:
struct bpf_map {
...
u32 max_entries; /* 36 4 */
u64 map_extra; /* 40 8 */
u32 map_flags; /* 48 4 */
int spin_lock_off; /* 52 4 */
int timer_off; /* 56 4 */
u32 id; /* 60 4 */
/* --- cacheline 1 boundary (64 bytes) --- */
int numa_node; /* 64 4 */
...
bool frozen /* 113 1 */
/* XXX 14 bytes hole, try to pack */
/* --- cacheline 2 boundary (128 bytes) --- */
...
struct work_struct work; /* 144 72 */
/* --- cacheline 3 boundary (192 bytes) was 24 bytes ago --- */
struct mutex freeze_mutex; /* 216 144 */
/* --- cacheline 5 boundary (320 bytes) was 40 bytes ago --- */
u64 writecnt; /* 360 8 */
/* size: 384, cachelines: 6, members: 26 */
/* sum members: 354, holes: 1, sum holes: 14 */
/* padding: 16 */
/* forced alignments: 2, forced holes: 1, sum forced holes: 14 */
} __attribute__((__aligned__(64)));
2) Add alignment padding to the bpf_map_info struct
More details can be found in commit 36f9814a49 ("bpf: fix uapi hole
for 32 bit compat applications")
Signed-off-by: Joanne Koong <joannekoong@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20211029224909.1721024-3-joannekoong@fb.com
2021-11-01 14:16:03 -07:00
..
2019-02-10 09:28:43 -08:00
2018-02-09 00:24:38 +01:00
2021-01-26 00:15:03 +01:00
2021-11-01 14:16:03 -07:00
2021-10-18 18:35:36 -07:00
2020-12-18 17:32:28 -03:00
2018-04-30 17:56:24 +02:00
2021-08-24 14:48:40 -07:00
2018-12-18 16:17:40 -03:00
2020-06-09 12:40:03 -03:00
2020-07-21 10:50:35 +01:00
2021-09-11 16:14:53 -03:00
2020-12-18 17:32:28 -03:00
2017-11-04 09:27:46 +01:00
2021-08-27 17:29:18 -07:00
2019-05-29 15:15:07 +02:00
2020-07-13 15:32:56 -07:00
2021-09-11 16:12:26 -03:00
2017-11-28 14:29:20 -03:00
2021-09-10 18:15:22 -03:00
2019-02-18 15:39:49 -05:00
2020-11-03 08:36:51 -03:00
2021-09-10 18:15:22 -03:00
2018-12-14 11:44:31 -08:00
2021-03-06 16:54:22 -03:00
2021-05-21 16:03:08 -03:00
2019-06-15 14:06:13 -07:00
2021-01-22 20:41:29 -08:00
2021-09-10 18:15:22 -03:00
2020-04-14 09:01:08 -03:00
2018-05-28 17:41:00 +02:00
2018-05-28 17:41:00 +02:00
2020-12-17 14:40:24 -03:00
2021-01-20 14:23:00 -08:00
2018-10-16 08:10:01 -07:00
2020-03-13 20:56:34 +01:00
2019-09-30 17:29:02 -03:00
2020-11-03 08:46:30 -03:00