* Ebpf map question
@ 2023-04-28 9:55 Marco
2023-04-28 10:43 ` Toke Høiland-Jørgensen
0 siblings, 1 reply; 2+ messages in thread
From: Marco @ 2023-04-28 9:55 UTC (permalink / raw)
To: xdp-newbies
Hi
Assuming to have this struct:
struct hash_elem {
int cnt;
};
and kernel space program want read cnt value:
struct hash_elem *val = bpf_map_lookup_elem(&hash_map, &key);
if (val)
{
# time fraction
bpf_printk("My value %d", val->cnt);
}
What happens if the hash_map is a pinned map and in the same time
space of 'time fraction" a user program deletes the element of the
key?
What happen at val pointer?
Thanks.
Marco
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Ebpf map question
2023-04-28 9:55 Ebpf map question Marco
@ 2023-04-28 10:43 ` Toke Høiland-Jørgensen
0 siblings, 0 replies; 2+ messages in thread
From: Toke Høiland-Jørgensen @ 2023-04-28 10:43 UTC (permalink / raw)
To: ctxspi, xdp-newbies
Marco <ctxspi@gmail.com> writes:
> Hi
>
> Assuming to have this struct:
>
> struct hash_elem {
> int cnt;
> };
>
> and kernel space program want read cnt value:
>
> struct hash_elem *val = bpf_map_lookup_elem(&hash_map, &key);
>
> if (val)
> {
>
> # time fraction
>
> bpf_printk("My value %d", val->cnt);
> }
>
> What happens if the hash_map is a pinned map and in the same time
> space of 'time fraction" a user program deletes the element of the
> key?
> What happen at val pointer?
The val pointer is RCU-protected so it will stick around until the end
of your BPF program's execution. However, it's up to your own code to
protect against concurrent *updates* of the value...
-Toke
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-28 10:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-28 9:55 Ebpf map question Marco
2023-04-28 10:43 ` Toke Høiland-Jørgensen
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).