Commit baa35b3c authored by Kumar Kartikeya Dwivedi's avatar Kumar Kartikeya Dwivedi Committed by Alexei Starovoitov
Browse files

bpf: Retire rcu_trace_implies_rcu_gp() from local storage



This assumption will always hold going forward, hence just remove the
various checks and assume it is true with a comment for the uninformed
reader.

Reviewed-by: default avatarPaul E. McKenney <paulmck@kernel.org>
Reviewed-by: default avatarAmery Hung <ameryhung@gmail.com>
Signed-off-by: default avatarKumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20260227224806.646888-5-memxor@gmail.com


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent f41deee0
Loading
Loading
Loading
Loading
+19 −18
Original line number Diff line number Diff line
@@ -107,14 +107,12 @@ static void __bpf_local_storage_free_trace_rcu(struct rcu_head *rcu)
{
	struct bpf_local_storage *local_storage;

	/* If RCU Tasks Trace grace period implies RCU grace period, do
	 * kfree(), else do kfree_rcu().
	/*
	 * RCU Tasks Trace grace period implies RCU grace period, do
	 * kfree() directly.
	 */
	local_storage = container_of(rcu, struct bpf_local_storage, rcu);
	if (rcu_trace_implies_rcu_gp())
	kfree(local_storage);
	else
		kfree_rcu(local_storage, rcu);
}

/* Handle use_kmalloc_nolock == false */
@@ -138,10 +136,11 @@ static void bpf_local_storage_free_rcu(struct rcu_head *rcu)

static void bpf_local_storage_free_trace_rcu(struct rcu_head *rcu)
{
	if (rcu_trace_implies_rcu_gp())
	/*
	 * RCU Tasks Trace grace period implies RCU grace period, do
	 * kfree() directly.
	 */
	bpf_local_storage_free_rcu(rcu);
	else
		call_rcu(rcu, bpf_local_storage_free_rcu);
}

static void bpf_local_storage_free(struct bpf_local_storage *local_storage,
@@ -182,10 +181,11 @@ static void __bpf_selem_free_rcu(struct rcu_head *rcu)
/* rcu tasks trace callback for use_kmalloc_nolock == false */
static void __bpf_selem_free_trace_rcu(struct rcu_head *rcu)
{
	if (rcu_trace_implies_rcu_gp())
	/*
	 * RCU Tasks Trace grace period implies RCU grace period, do
	 * kfree() directly.
	 */
	__bpf_selem_free_rcu(rcu);
	else
		call_rcu(rcu, __bpf_selem_free_rcu);
}

/* Handle use_kmalloc_nolock == false */
@@ -214,10 +214,11 @@ static void bpf_selem_free_rcu(struct rcu_head *rcu)

static void bpf_selem_free_trace_rcu(struct rcu_head *rcu)
{
	if (rcu_trace_implies_rcu_gp())
	/*
	 * RCU Tasks Trace grace period implies RCU grace period, do
	 * kfree() directly.
	 */
	bpf_selem_free_rcu(rcu);
	else
		call_rcu(rcu, bpf_selem_free_rcu);
}

void bpf_selem_free(struct bpf_local_storage_elem *selem,