From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: ctxspi@gmail.com, xdp-newbies@vger.kernel.org
Subject: Re: Ebpf map question
Date: Fri, 28 Apr 2023 12:43:24 +0200 [thread overview]
Message-ID: <87pm7o70dv.fsf@toke.dk> (raw)
In-Reply-To: <CAAVAo4MCYB9LKeDVJ=5Eaiy2gJ00bEvbvnE6PzQEc=U67WPQ4A@mail.gmail.com>
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
prev parent reply other threads:[~2023-04-28 10:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-28 9:55 Ebpf map question Marco
2023-04-28 10:43 ` Toke Høiland-Jørgensen [this message]
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=87pm7o70dv.fsf@toke.dk \
--to=toke@redhat.com \
--cc=ctxspi@gmail.com \
--cc=xdp-newbies@vger.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 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.