All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	 John Fastabend <john.fastabend@gmail.com>
Cc: Yafang Shao <laoar.shao@gmail.com>,
	 Alexei Starovoitov <ast@kernel.org>,
	 Daniel Borkmann <daniel@iogearbox.net>,
	 Andrii Nakryiko <andrii@kernel.org>,
	 Martin KaFai Lau <martin.lau@linux.dev>,
	 Eddy Z <eddyz87@gmail.com>,  Song Liu <song@kernel.org>,
	 Yonghong Song <yonghong.song@linux.dev>,
	 KP Singh <kpsingh@kernel.org>,
	 Stanislav Fomichev <sdf@google.com>,
	 Hao Luo <haoluo@google.com>,  Jiri Olsa <jolsa@kernel.org>,
	 bpf <bpf@vger.kernel.org>
Subject: Re: [PATCH bpf-next 1/2] bpf: Add bits iterator
Date: Mon, 26 Feb 2024 16:34:32 -0800	[thread overview]
Message-ID: <65dd2e181f8a1_24aa9208c8@john.notmuch> (raw)
In-Reply-To: <CAADnVQKtL0mo2pqcKtOJ+nzG0K72dhH47KZP_-O06U6pfvzb1w@mail.gmail.com>

Alexei Starovoitov wrote:
> On Mon, Feb 26, 2024 at 3:21 PM John Fastabend <john.fastabend@gmail.com> wrote:
> > > +__bpf_kfunc int *bpf_iter_bits_next(struct bpf_iter_bits *it)
> > > +{
> > > +     struct bpf_iter_bits_kern *kit = (void *)it;
> > > +     const unsigned long *bits = kit->bits;
> > > +     int bit;
> > > +
> > > +     if (!bits)
> > > +             return NULL;
> > > +
> > > +     bit = find_next_bit(bits, kit->nr_bits, kit->bit + 1);
> >
> > Seems like this should be ok over unsafe memory as long as find_next_bit
> > is bounded?
> 
> Are you proposing to add find_next_bit() as a kfunc instead?

I was suggesting you could likely implement find_next_bit() in
BPF directly no need for a kfunc.

> 
> With the bpf_can_loop() proposal these two can be combined and
> it will probably achieve the same result.
> But imo this iterator is small enough to get in now and
> delete later when there is a better way.

Agree its fine to go in as is IMO. Mostly just curious if anyone
tried to implement it in BPF.

> Ideally we'd need to add new instructions to operate with bits efficiently.

+1.

  reply	other threads:[~2024-02-27  0:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-18 11:48 [PATCH bpf-next 0/2] bpf: Add a generic bits iterator Yafang Shao
2024-02-18 11:48 ` [PATCH bpf-next 1/2] bpf: Add " Yafang Shao
2024-02-26 23:21   ` John Fastabend
2024-02-27  0:20     ` Alexei Starovoitov
2024-02-27  0:34       ` John Fastabend [this message]
2024-02-18 11:48 ` [PATCH bpf-next 2/2] selftests/bpf: Add selftest for bits iter Yafang Shao
2024-02-22 17:36   ` Alexei Starovoitov
2024-02-23  2:29     ` Yafang Shao
2024-02-23 11:52       ` Eduard Zingerman
2024-02-25  2:29         ` Yafang Shao
2024-02-25 19:38   ` kernel test robot

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=65dd2e181f8a1_24aa9208c8@john.notmuch \
    --to=john.fastabend@gmail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=laoar.shao@gmail.com \
    --cc=martin.lau@linux.dev \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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.