From: Martin KaFai Lau <martin.lau@linux.dev>
To: Amery Hung <ameryhung@gmail.com>
Cc: alexei.starovoitov@gmail.com, andrii@kernel.org,
daniel@iogearbox.net, tj@kernel.org, martin.lau@kernel.org,
kernel-team@meta.com, bpf@vger.kernel.org
Subject: Re: [RFC bpf-next v1 2/4] bpf: Support cookie for linked-based struct_ops attachment
Date: Wed, 9 Jul 2025 15:13:22 -0700 [thread overview]
Message-ID: <68f4b77c-3265-489e-9190-0333ed54b697@linux.dev> (raw)
In-Reply-To: <20250708230825.4159486-3-ameryhung@gmail.com>
On 7/8/25 4:08 PM, Amery Hung wrote:
> @@ -906,6 +904,10 @@ static long bpf_struct_ops_map_update_elem(struct bpf_map *map, void *key,
> goto unlock;
> }
>
> + err = bpf_struct_ops_prepare_attach(st_map, 0);
A follow-up on the "using the map->id as the cookie" comment in the cover
letter. I meant to use the map->id here instead of 0. If the cookie is intended
to identify a particular struct_ops instance (i.e., the struct_ops map), then
map->id should be a good fit, and it is automatically generated by the kernel
during the map creation. As a result, I suspect that most of the changes in
patch 1 and patch 2 will not be needed.
If I understand correctly, the kfunc implementation needs to look up the scx_ops
instance (i.e., the struct_ops map) from the map->id/cookie. There is a similar
map->id lookup in bpf_map_get_fd_by_id(), which requires acquiring a spin_lock.
If performance is a concern, we can investigate whether it can be rcu-ified.
From a quick glance, bpf_map_free_id() is called before call_rcu(). Note that
bpf_struct_ops_map_free() will wait for an RCU grace period.
next prev parent reply other threads:[~2025-07-09 22:13 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-08 23:08 [RFC bpf-next v1 0/4] Support cookie for link-based struct_ops attachment Amery Hung
2025-07-08 23:08 ` [RFC bpf-next v1 1/4] bpf: Factor out bpf_struct_ops_prepare_attach() Amery Hung
2025-07-08 23:08 ` [RFC bpf-next v1 2/4] bpf: Support cookie for linked-based struct_ops attachment Amery Hung
2025-07-09 22:13 ` Martin KaFai Lau [this message]
2025-07-10 18:26 ` Martin KaFai Lau
2025-07-10 18:39 ` Amery Hung
2025-07-10 19:47 ` Martin KaFai Lau
2025-07-10 21:00 ` Amery Hung
2025-07-11 18:41 ` Andrii Nakryiko
2025-07-11 19:29 ` Amery Hung
2025-07-11 20:21 ` Alexei Starovoitov
2025-07-11 21:38 ` Amery Hung
2025-07-14 20:46 ` Andrii Nakryiko
2025-07-14 21:02 ` Amery Hung
2025-07-14 22:51 ` Martin KaFai Lau
2025-07-11 21:55 ` Martin KaFai Lau
2025-07-08 23:08 ` [RFC bpf-next v1 3/4] libbpf: Support link-based struct_ops attach with options Amery Hung
2025-07-08 23:08 ` [RFC bpf-next v1 4/4] selftests/bpf: Test bpf_get_attach_cookie() in struct_ops program Amery Hung
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=68f4b77c-3265-489e-9190-0333ed54b697@linux.dev \
--to=martin.lau@linux.dev \
--cc=alexei.starovoitov@gmail.com \
--cc=ameryhung@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@meta.com \
--cc=martin.lau@kernel.org \
--cc=tj@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).