From: Cong Wang <xiyou.wangcong@gmail.com>
To: Yahui Chen <goodluckwillcomesoon@gmail.com>
Cc: "bpf@vger.kernel.org" <bpf@vger.kernel.org>, zhangwei123171@jd.com
Subject: Re: can add a new bpf helper function bpf_map_compare_and_update_elem?
Date: Fri, 26 Nov 2021 12:25:10 -0800 [thread overview]
Message-ID: <YaFCplDzX3NjN3iB@unknown> (raw)
In-Reply-To: <CAPydje8FKWzRCR33RanGZkucavFZNb2zSGhfQdrd49Uvgc2YxQ@mail.gmail.com>
On Thu, Nov 25, 2021 at 04:34:48PM +0800, Yahui Chen wrote:
> Suppose we have a map, MAP_A, and the user program does the following:
>
> 1. bpf_map_lookup_elem(MAP_A, key, value)
> 2. change the value
> 3. bpf_map_update_elem(MAP_A, key, value, FLAG)
>
> At the same time, the kernel's BPF program may also be modifying the value.
>
> Then we have concurrency problems.
>
This is why we have bpf spinlock. ;)
> Therefore, can we add a helper function like compare and swap?
>
I don't think you can atomically compare and swap values larger than
CPU word size.
Thanks.
next prev parent reply other threads:[~2021-11-26 20:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-25 8:34 can add a new bpf helper function bpf_map_compare_and_update_elem? Yahui Chen
2021-11-26 20:25 ` Cong Wang [this message]
2021-11-29 6:49 ` Yahui Chen
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=YaFCplDzX3NjN3iB@unknown \
--to=xiyou.wangcong@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=goodluckwillcomesoon@gmail.com \
--cc=zhangwei123171@jd.com \
/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