bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Jonathan Lemon <jonathan.lemon@gmail.com>
Cc: Networking <netdev@vger.kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Yonghong Song <yhs@fb.com>, bpf <bpf@vger.kernel.org>,
	Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH 1/1 v3 bpf-next] bpf: increment and use correct thread iterator
Date: Fri, 11 Dec 2020 16:28:09 -0800	[thread overview]
Message-ID: <CAEf4BzaA48yB5mnX5VAfLdUMa54Fq_pxpT__s0DbB7nYPzenMg@mail.gmail.com> (raw)
In-Reply-To: <20201211230134.qswet7pfrda23ooa@bsd-mbp.dhcp.thefacebook.com>

On Fri, Dec 11, 2020 at 3:01 PM Jonathan Lemon <jonathan.lemon@gmail.com> wrote:
>
> On Fri, Dec 11, 2020 at 12:23:34PM -0800, Andrii Nakryiko wrote:
> > > @@ -164,7 +164,7 @@ task_file_seq_get_next(struct bpf_iter_seq_task_file_info *info)
> > >                 curr_files = get_files_struct(curr_task);
> > >                 if (!curr_files) {
> > >                         put_task_struct(curr_task);
> > > -                       curr_tid = ++(info->tid);
> > > +                       curr_tid = curr_tid + 1;
> >
> > Yonghong might know definitively, but it seems like we need to update
> > info->tid here as well:
> >
> > info->tid = curr_tid;
> >
> > If the search eventually yields no task, then info->tid will stay at
> > some potentially much smaller value, and we'll keep re-searching tasks
> > from the same TID on each subsequent read (if user keeps reading the
> > file). So corner case, but good to have covered.
>
> That applies earlier as well:
>
>                 curr_task = task_seq_get_next(ns, &curr_tid, true);
>                 if (!curr_task) {
>                         info->task = NULL;
>                         info->files = NULL;
>                         return NULL;
>                 }
>

True, info->tid = curr_tid + 1; seems to be needed here?

> The logic seems to be "if task == NULL, then return NULL and stop".
> Is the seq_iterator allowed to continue/restart if seq_next returns NULL?

I don't think we allow seeking, so no restarts. But nothing will
prevent the user to keep calling read() after it returns 0 byte, so
yes, continuation is possible.

> --
> Jonathan

  reply	other threads:[~2020-12-12  0:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11 17:11 [PATCH 0/1 v3 bpf-next] bpf: increment and use correct thread iterator Jonathan Lemon
2020-12-11 17:11 ` [PATCH 1/1 " Jonathan Lemon
2020-12-11 20:23   ` Andrii Nakryiko
2020-12-11 23:01     ` Jonathan Lemon
2020-12-12  0:28       ` Andrii Nakryiko [this message]
2020-12-14  7:00       ` Yonghong Song
2020-12-18 16:53   ` Yonghong Song
2020-12-18 18:06     ` Jonathan Lemon
2020-12-18 18:21       ` Yonghong Song
2020-12-18 19:28       ` Andrii Nakryiko

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=CAEf4BzaA48yB5mnX5VAfLdUMa54Fq_pxpT__s0DbB7nYPzenMg@mail.gmail.com \
    --to=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=jonathan.lemon@gmail.com \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=yhs@fb.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;
as well as URLs for NNTP newsgroup(s).