From: Eduard Zingerman <eddyz87@gmail.com>
To: bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org
Cc: daniel@iogearbox.net, martin.lau@linux.dev, kernel-team@fb.com,
yonghong.song@linux.dev, eddyz87@gmail.com
Subject: [PATCH bpf-next v3 06/11] bpf: set 'changed' status if propagate_liveness() did any updates
Date: Wed, 11 Jun 2025 13:08:31 -0700 [thread overview]
Message-ID: <20250611200836.4135542-6-eddyz87@gmail.com> (raw)
In-Reply-To: <20250611200836.4135542-1-eddyz87@gmail.com>
Add an out parameter to `propagate_liveness()` to record whether any
new liveness bits were set during its execution.
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
---
kernel/bpf/verifier.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 25b50a98558b..e060d1060a37 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -18856,12 +18856,15 @@ static int propagate_liveness_reg(struct bpf_verifier_env *env,
*/
static int propagate_liveness(struct bpf_verifier_env *env,
const struct bpf_verifier_state *vstate,
- struct bpf_verifier_state *vparent)
+ struct bpf_verifier_state *vparent,
+ bool *changed)
{
struct bpf_reg_state *state_reg, *parent_reg;
struct bpf_func_state *state, *parent;
int i, frame, err = 0;
+ bool tmp;
+ changed = changed ?: &tmp;
if (vparent->curframe != vstate->curframe) {
WARN(1, "propagate_live: parent frame %d current frame %d\n",
vparent->curframe, vstate->curframe);
@@ -18880,6 +18883,7 @@ static int propagate_liveness(struct bpf_verifier_env *env,
&parent_reg[i]);
if (err < 0)
return err;
+ *changed |= err > 0;
if (err == REG_LIVE_READ64)
mark_insn_zext(env, &parent_reg[i]);
}
@@ -18891,6 +18895,7 @@ static int propagate_liveness(struct bpf_verifier_env *env,
state_reg = &state->stack[i].spilled_ptr;
err = propagate_liveness_reg(env, state_reg,
parent_reg);
+ *changed |= err > 0;
if (err < 0)
return err;
}
@@ -19266,7 +19271,7 @@ static int is_state_visited(struct bpf_verifier_env *env, int insn_idx)
* they'll be immediately forgotten as we're pruning
* this state and will pop a new one.
*/
- err = propagate_liveness(env, &sl->state, cur);
+ err = propagate_liveness(env, &sl->state, cur, NULL);
/* if previous state reached the exit with precision and
* current state is equivalent to it (except precision marks)
--
2.47.1
next prev parent reply other threads:[~2025-06-11 20:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-11 20:08 [PATCH bpf-next v3 01/11] Revert "bpf: use common instruction history across all states" Eduard Zingerman
2025-06-11 20:08 ` [PATCH bpf-next v3 02/11] bpf: compute SCCs in program control flow graph Eduard Zingerman
2025-06-11 20:08 ` [PATCH bpf-next v3 03/11] bpf: frame_insn_idx() utility function Eduard Zingerman
2025-06-11 20:08 ` [PATCH bpf-next v3 04/11] bpf: starting_state parameter for __mark_chain_precision() Eduard Zingerman
2025-06-11 20:08 ` [PATCH bpf-next v3 05/11] bpf: set 'changed' status if propagate_precision() did any updates Eduard Zingerman
2025-06-11 20:08 ` Eduard Zingerman [this message]
2025-06-11 20:08 ` [PATCH bpf-next v3 07/11] bpf: move REG_LIVE_DONE check to clean_live_states() Eduard Zingerman
2025-06-11 20:08 ` [PATCH bpf-next v3 08/11] bpf: propagate read/precision marks over state graph backedges Eduard Zingerman
2025-06-11 20:08 ` [PATCH bpf-next v3 09/11] bpf: remove {update,get}_loop_entry functions Eduard Zingerman
2025-06-11 20:08 ` [PATCH bpf-next v3 10/11] bpf: include backedges in peak_states stat Eduard Zingerman
2025-06-11 20:08 ` [PATCH bpf-next v3 11/11] selftests/bpf: tests with a loop state missing read/precision mark Eduard Zingerman
2025-06-11 22:45 ` [PATCH bpf-next v3 01/11] Revert "bpf: use common instruction history across all states" Alexei Starovoitov
2025-06-11 22:57 ` Eduard Zingerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250611200836.4135542-6-eddyz87@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=martin.lau@linux.dev \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.