From: Ammar Faizi <[email protected]>
To: Keith Busch <[email protected]>
Cc: Facebook Kernel Team <[email protected]>,
Jens Axboe <[email protected]>, Christoph Hellwig <[email protected]>,
Al Viro <[email protected]>,
Keith Busch <[email protected]>,
Fernanda Ma'rouf <[email protected]>,
io-uring Mailing List <[email protected]>,
Linux Block Mailing List <[email protected]>,
Linux fsdevel Mailing List <[email protected]>,
Linux NVME Mailing List <[email protected]>
Subject: Re: [PATCHv2 6/7] io_uring: add support for dma pre-mapping
Date: Wed, 3 Aug 2022 06:25:14 +0700 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
On 8/3/22 2:36 AM, Keith Busch wrote:
> From: Keith Busch <[email protected]>
>
> Provide a new register operation that can request to pre-map a known
> bvec to the requested fixed file's specific implementation. If
> successful, io_uring will use the returned dma tag for future fixed
> buffer requests to the same file.
>
> Signed-off-by: Keith Busch <[email protected]>
[...]
> +static int io_register_map_buffers(struct io_ring_ctx *ctx, void __user *arg)
> +{
> + struct io_uring_map_buffers map;
> + struct io_fixed_file *file_slot;
> + struct file *file;
> + int ret, i;
> +
> + if (!capable(CAP_SYS_ADMIN))
> + return -EPERM;
> +
> + ret = get_map_range(ctx, &map, arg);
> + if (ret < 0)
> + return ret;
> +
> + file_slot = io_fixed_file_slot(&ctx->file_table,
> + array_index_nospec(map.fd, ctx->nr_user_files));
> + if (!file_slot || !file_slot->file_ptr)
> + return -EBADF;
The @file_slot NULL-check doesn't make sense. The definition of
io_fixed_file_slot() is:
static inline struct io_fixed_file *
io_fixed_file_slot(struct io_file_table *table, unsigned i)
{
return &table->files[i];
}
which takes the address of an element in the array. So @file_slot
should never be NULL, if it ever be, something has gone wrong.
If you ever had @ctx->file_table.files being NULL in this path, you
should NULL-check the @->files itself, *not* the return value of
io_fixed_file_slot().
IOW:
...
// NULL check here.
if (!ctx->file_table.files)
return -EBADF;
file_slot = io_fixed_file_slot(&ctx->file_table,
array_index_nospec(map.fd, ctx->nr_user_files));
if (!file_slot->file_ptr)
return -EBADF;
...
> for (i = 0; i < ctx->nr_user_files; i++) {
> - struct file *file = io_file_from_index(&ctx->file_table, i);
> + struct io_fixed_file *f = io_fixed_file_slot(&ctx->file_table, i);
> + struct file *file;
>
> - if (!file)
> + if (!f)
> continue;
The same thing, this @f NULL-check is not needed.
> - if (io_fixed_file_slot(&ctx->file_table, i)->file_ptr & FFS_SCM)
> + if (f->file_ptr & FFS_SCM)
> continue;
> +
> + io_dma_unmap_file(ctx, f);
> + file = io_file_from_fixed(f);
> io_file_bitmap_clear(&ctx->file_table, i);
> fput(file);
> }
--
Ammar Faizi
next prev parent reply other threads:[~2022-08-02 23:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-02 19:36 [PATCHv2 0/7] dma mapping optimisations Keith Busch
2022-08-02 19:36 ` [PATCHv2 1/7] blk-mq: add ops to dma map bvec Keith Busch
2022-08-02 19:36 ` [PATCHv2 2/7] file: " Keith Busch
2022-08-02 19:36 ` [PATCHv2 3/7] iov_iter: introduce type for preregistered dma tags Keith Busch
2022-08-02 19:36 ` [PATCHv2 4/7] block: add dma tag bio type Keith Busch
2022-08-02 19:36 ` [PATCHv2 5/7] io_uring: introduce file slot release helper Keith Busch
2022-08-02 19:36 ` [PATCHv2 6/7] io_uring: add support for dma pre-mapping Keith Busch
2022-08-02 23:25 ` Ammar Faizi [this message]
2022-08-02 19:36 ` [PATCHv2 7/7] nvme-pci: implement dma_map support Keith Busch
2022-08-03 20:52 ` [PATCHv2 0/7] dma mapping optimisations Jens Axboe
2022-08-04 16:28 ` Keith Busch
2022-08-04 16:42 ` Jens Axboe
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 \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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