Pack bpf_reg_state to bring it's size from 88 bytes to 80. Consequently, bpf_func_state changes from 1048 to 960. Thus bpf_func_state moves from 2K to 1K allocator bucket. 1K bucket is the one it fit before the SCEV series. With this optimization SCEV increases memory consumption on a subset of Meta internal programs by 3%, without this optimization the increase is 48%. Signed-off-by: Eduard Zingerman --- include/linux/bpf_verifier.h | 14 +++++++------- kernel/bpf/states.c | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h index d47d4613eb3c..a539c5f049ff 100644 --- a/include/linux/bpf_verifier.h +++ b/include/linux/bpf_verifier.h @@ -172,12 +172,6 @@ struct bpf_reg_state { * gets parent_id set to the dynptr's id. */ u32 parent_id; - /* - * Distinguishes inner-map lookups and their keys and values. Zero for - * other registers. Kept outside the metadata union for ID remapping - * during state comparisons. - */ - u32 map_uid; /* * The value described by this register, interpreted as s64, lies on * a line described by a linear equation base + step * k. @@ -185,8 +179,14 @@ struct bpf_reg_state { */ u16 base; u16 step; + /* + * Distinguishes inner-map lookups and their keys and values. Zero for + * other registers. Kept outside the metadata union for ID remapping + * during state comparisons. + */ + u32 map_uid:31; /* if (!precise && SCALAR_VALUE) min/max/tnum don't affect safety */ - bool precise; + u32 precise:1; }; static inline s64 reg_smin(const struct bpf_reg_state *reg) diff --git a/kernel/bpf/states.c b/kernel/bpf/states.c index 94339729f524..862f7ceb1daf 100644 --- a/kernel/bpf/states.c +++ b/kernel/bpf/states.c @@ -1171,7 +1171,7 @@ static bool states_maybe_looping(struct bpf_verifier_state *old, fcur = cur->frame[fr]; for (i = 0; i < MAX_BPF_REG; i++) if (memcmp(&fold->regs[i], &fcur->regs[i], - offsetof(struct bpf_reg_state, precise))) + offsetofend(struct bpf_reg_state, step))) return false; return true; } -- 2.53.0