From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDD9A36604A; Tue, 24 Mar 2026 08:20:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774340401; cv=none; b=hrsqact+emeiBGEUD2AYotq70LATN4VItKzpHnf/SY/wczgkoOD7iJ2D+lxvZhZllNg4rEswSwAugI17/GXSqL1fRUlql0cLx3y28ZLF3gU7W4TeFa9jQWIO+t4p6rGPvWgA0QhtJ3fpsFrkjJl1atsRykBEI4ERlk9WsVT9r8g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774340401; c=relaxed/simple; bh=0KS7A+LST6OwO2RkIAG0SXJ90lxXvwRemlRXibbDUOg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qq0FJ/JL9ZgRWzTIhK2jnorbZosCW467eNMzEewXv3/uSVEuMcDnXkZzsIbqgma6prnQG91KPBp/qMBPQPC2Bc5wnes3a8519SCQzUfrpO69bfjSulfiFxVcJDolY03bQOeEhTGY/G+uoKUE3/2SeTD6dZLb9SyRo6y7KAMc1CA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qTOhzK4J; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qTOhzK4J" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B237C19424; Tue, 24 Mar 2026 08:19:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774340401; bh=0KS7A+LST6OwO2RkIAG0SXJ90lxXvwRemlRXibbDUOg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qTOhzK4J20Q15jnFLrJL0MeldtdgcMc34s/F/hiRqCtnDyUU0YVvAMIvKqGu+llg2 alaJZE+kQLWvN5Ks/zoqpU02+bq3EnImWDkzBlTriyfrE8alQURlP8KTmsWxKf6OIu cBJBgGEduMEouZIg+sYD9AwawPrw4IdThLGf51jEgjSGJJqk6uH3vjVR5P47ZxAIOp QGdInYbv3o0/o34g7/pLOjzw7tXQno2mxM0R7fXIKgtWf7VL0egQxpjbKeD0bb9C/v wv7ueRwdxTqH/K/Kifg5XVy3u1IrXH3Qf7csG2XwzEZB8tLAwatRrGZMcoRdAPxGmn fGynPMbaZkbTg== From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , Menglong Dong , Steven Rostedt Subject: [PATCHv4 bpf-next 06/25] bpf: Factor fsession link to use struct bpf_tramp_node Date: Tue, 24 Mar 2026 09:18:27 +0100 Message-ID: <20260324081846.2334094-7-jolsa@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260324081846.2334094-1-jolsa@kernel.org> References: <20260324081846.2334094-1-jolsa@kernel.org> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Now that we split trampoline attachment object (bpf_tramp_node) from the link object (bpf_tramp_link) we can use bpf_tramp_node as fsession's fexit attachment object and get rid of the bpf_fsession_link object. Signed-off-by: Jiri Olsa --- include/linux/bpf.h | 6 +----- kernel/bpf/syscall.c | 21 ++++++--------------- kernel/bpf/trampoline.c | 14 +++++++------- 3 files changed, 14 insertions(+), 27 deletions(-) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index f97aa34ee4c2..d536640aef41 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -1883,15 +1883,11 @@ struct bpf_shim_tramp_link { struct bpf_tracing_link { struct bpf_tramp_link link; + struct bpf_tramp_node fexit; struct bpf_trampoline *trampoline; struct bpf_prog *tgt_prog; }; -struct bpf_fsession_link { - struct bpf_tracing_link link; - struct bpf_tramp_link fexit; -}; - struct bpf_raw_tp_link { struct bpf_link link; struct bpf_raw_event_map *btp; diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 6db6d1e74379..003ad95940c9 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -3637,21 +3637,7 @@ static int bpf_tracing_prog_attach(struct bpf_prog *prog, key = bpf_trampoline_compute_key(tgt_prog, NULL, btf_id); } - if (prog->expected_attach_type == BPF_TRACE_FSESSION) { - struct bpf_fsession_link *fslink; - - fslink = kzalloc_obj(*fslink, GFP_USER); - if (fslink) { - bpf_tramp_link_init(&fslink->fexit, BPF_LINK_TYPE_TRACING, - &bpf_tracing_link_lops, prog, attach_type, - bpf_cookie); - link = &fslink->link; - } else { - link = NULL; - } - } else { - link = kzalloc_obj(*link, GFP_USER); - } + link = kzalloc_obj(*link, GFP_USER); if (!link) { err = -ENOMEM; goto out_put_prog; @@ -3659,6 +3645,11 @@ static int bpf_tracing_prog_attach(struct bpf_prog *prog, bpf_tramp_link_init(&link->link, BPF_LINK_TYPE_TRACING, &bpf_tracing_link_lops, prog, attach_type, bpf_cookie); + if (prog->expected_attach_type == BPF_TRACE_FSESSION) { + link->fexit.link = &link->link.link; + link->fexit.cookie = bpf_cookie; + } + mutex_lock(&prog->aux->dst_mutex); /* There are a few possible cases here: diff --git a/kernel/bpf/trampoline.c b/kernel/bpf/trampoline.c index 1a2c99bf491e..de4598984e3e 100644 --- a/kernel/bpf/trampoline.c +++ b/kernel/bpf/trampoline.c @@ -815,7 +815,7 @@ static int __bpf_trampoline_link_prog(struct bpf_tramp_node *node, struct bpf_trampoline_ops *ops, void *data) { - struct bpf_fsession_link *fslink = NULL; + struct bpf_tracing_link *tr_link = NULL; enum bpf_tramp_prog_type kind; struct bpf_tramp_node *node_existing; struct hlist_head *prog_list; @@ -865,8 +865,8 @@ static int __bpf_trampoline_link_prog(struct bpf_tramp_node *node, hlist_add_head(&node->tramp_hlist, prog_list); if (kind == BPF_TRAMP_FSESSION) { tr->progs_cnt[BPF_TRAMP_FENTRY]++; - fslink = container_of(node, struct bpf_fsession_link, link.link.node); - hlist_add_head(&fslink->fexit.node.tramp_hlist, &tr->progs_hlist[BPF_TRAMP_FEXIT]); + tr_link = container_of(node, struct bpf_tracing_link, link.node); + hlist_add_head(&tr_link->fexit.tramp_hlist, &tr->progs_hlist[BPF_TRAMP_FEXIT]); tr->progs_cnt[BPF_TRAMP_FEXIT]++; } else { tr->progs_cnt[kind]++; @@ -876,7 +876,7 @@ static int __bpf_trampoline_link_prog(struct bpf_tramp_node *node, hlist_del_init(&node->tramp_hlist); if (kind == BPF_TRAMP_FSESSION) { tr->progs_cnt[BPF_TRAMP_FENTRY]--; - hlist_del_init(&fslink->fexit.node.tramp_hlist); + hlist_del_init(&tr_link->fexit.tramp_hlist); tr->progs_cnt[BPF_TRAMP_FEXIT]--; } else { tr->progs_cnt[kind]--; @@ -917,10 +917,10 @@ static int __bpf_trampoline_unlink_prog(struct bpf_tramp_node *node, tgt_prog->aux->is_extended = false; return err; } else if (kind == BPF_TRAMP_FSESSION) { - struct bpf_fsession_link *fslink = - container_of(node, struct bpf_fsession_link, link.link.node); + struct bpf_tracing_link *tr_link = + container_of(node, struct bpf_tracing_link, link.node); - hlist_del_init(&fslink->fexit.node.tramp_hlist); + hlist_del_init(&tr_link->fexit.tramp_hlist); tr->progs_cnt[BPF_TRAMP_FEXIT]--; kind = BPF_TRAMP_FENTRY; } -- 2.53.0