From: Jiri Olsa <olsajiri@gmail.com>
To: Juntong Deng <juntong.deng@outlook.com>
Cc: ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com,
andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com,
song@kernel.org, yonghong.song@linux.dev, kpsingh@kernel.org,
sdf@fomichev.me, haoluo@google.com, memxor@gmail.com,
snorcht@gmail.com, brauner@kernel.org, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH bpf-next v4 1/5] bpf: Introduce task_file open-coded iterator kfuncs
Date: Wed, 20 Nov 2024 11:55:23 +0100 [thread overview]
Message-ID: <Zz3AG0htZjt9RTFl@krava> (raw)
In-Reply-To: <AM6PR03MB508013A6E8B5DEF15A87B1EC99202@AM6PR03MB5080.eurprd03.prod.outlook.com>
On Tue, Nov 19, 2024 at 05:53:58PM +0000, Juntong Deng wrote:
SNIP
> +/**
> + * bpf_iter_task_file_next() - Get the next file in bpf_iter_task_file
> + *
> + * bpf_iter_task_file_next acquires a reference to the struct file.
> + *
> + * The reference to struct file acquired by the previous
> + * bpf_iter_task_file_next() is released in the next bpf_iter_task_file_next(),
> + * and the last reference is released in the last bpf_iter_task_file_next()
> + * that returns NULL.
> + *
> + * @it: the bpf_iter_task_file to be checked
> + *
> + * @returns a pointer to bpf_iter_task_file_item
> + */
> +__bpf_kfunc struct bpf_iter_task_file_item *bpf_iter_task_file_next(struct bpf_iter_task_file *it)
> +{
> + struct bpf_iter_task_file_kern *kit = (void *)it;
> + struct bpf_iter_task_file_item *item = &kit->item;
> +
> + if (item->file)
> + fput(item->file);
> +
missing rcu_read_lock ?
jirka
> + item->file = task_lookup_next_fdget_rcu(item->task, &kit->next_fd);
> + item->fd = kit->next_fd;
> +
> + kit->next_fd++;
> +
> + if (!item->file)
> + return NULL;
> +
> + return item;
> +}
> +
> +/**
> + * bpf_iter_task_file_destroy() - Destroy a bpf_iter_task_file
> + *
> + * If the iterator does not iterate to the end, then the last
> + * struct file reference is released at this time.
> + *
> + * @it: the bpf_iter_task_file to be destroyed
> + */
> +__bpf_kfunc void bpf_iter_task_file_destroy(struct bpf_iter_task_file *it)
> +{
> + struct bpf_iter_task_file_kern *kit = (void *)it;
> + struct bpf_iter_task_file_item *item = &kit->item;
> +
> + if (item->file)
> + fput(item->file);
> +}
> +
> __bpf_kfunc_end_defs();
>
> DEFINE_PER_CPU(struct mmap_unlock_irq_work, mmap_unlock_work);
> --
> 2.39.5
>
next prev parent reply other threads:[~2024-11-20 10:55 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-19 17:49 [PATCH bpf-next v4 0/5] bpf: Add open-coded style process file iterator and bpf_fget_task() kfunc Juntong Deng
2024-11-19 17:53 ` [PATCH bpf-next v4 1/5] bpf: Introduce task_file open-coded iterator kfuncs Juntong Deng
2024-11-20 10:55 ` Jiri Olsa [this message]
2024-11-20 11:04 ` Jiri Olsa
2024-11-19 17:53 ` [PATCH bpf-next v4 2/5] selftests/bpf: Add tests for open-coded style process file iterator Juntong Deng
2024-11-20 11:27 ` Jiri Olsa
2024-11-26 22:24 ` Juntong Deng
2024-11-27 11:21 ` Jiri Olsa
2024-12-10 14:17 ` Juntong Deng
2024-11-19 17:54 ` [PATCH bpf-next v4 3/5] bpf: Add bpf_fget_task() kfunc Juntong Deng
2024-11-19 17:54 ` [PATCH bpf-next v4 4/5] bpf: Make fs kfuncs available for SYSCALL and TRACING program types Juntong Deng
2024-11-19 17:54 ` [PATCH bpf-next v4 5/5] selftests/bpf: Add tests for bpf_fget_task() kfunc Juntong Deng
2024-11-19 18:40 ` [PATCH bpf-next v4 0/5] bpf: Add open-coded style process file iterator and " Juntong Deng
2024-11-20 9:12 ` Christian Brauner
2024-11-26 22:15 ` Juntong Deng
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=Zz3AG0htZjt9RTFl@krava \
--to=olsajiri@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=brauner@kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=juntong.deng@outlook.com \
--cc=kpsingh@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=sdf@fomichev.me \
--cc=snorcht@gmail.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.