From: Jens Axboe <[email protected]>
To: Xin Wang <[email protected]>
Cc: [email protected], [email protected],
[email protected], Xin Wang <[email protected]>
Subject: Re: [PATCH] io_uring: extract the function that checks the legitimacy of sq/cq entries
Date: Thu, 14 Mar 2024 13:29:09 -0600 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
On 3/12/24 1:44 PM, Xin Wang wrote:
> In the io_uring_create function, the sq_entries and cq_entries passed
> in by the user are examined. The checking logic is the same for both, so
> the common code can be extracted for reuse.
Looks fine to me, though not sure how helpful it really is, it's not
like it's a lot of code and it's easy enough to read as it is. However,
a few minor comments:
> O_RDWR | O_CLOEXEC, NULL);
> }
>
> +static bool io_validate_entries(unsigned int *entries, unsigned int max_entries, __u32 flags)
Line too long, please break list other functions. Also needs a better
name, probably io_validate_ring_entries() would be better.
> +{
> + if (!(*entries))
> + return false;
> + if (*entries > max_entries) {
> + if (!(flags & IORING_SETUP_CLAMP))
> + return false;
> + *entries = max_entries;
> + }
> + return true;
> +}
And I don't know why you use parens for the first *entries check, but
then not for the next? Should be consistent, at least.
> @@ -3854,13 +3861,8 @@ static __cold int io_uring_create(unsigned entries, struct io_uring_params *p,
> * to a power-of-two, if it isn't already. We do NOT impose
> * any cq vs sq ring sizing.
> */
> - if (!p->cq_entries)
> + if (!io_validate_entries(&(p->cq_entries), IORING_MAX_CQ_ENTRIES, p->flags))
Again not sure what these parens are doing here?
--
Jens Axboe
prev parent reply other threads:[~2024-03-14 19:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-12 19:44 [PATCH] io_uring: extract the function that checks the legitimacy of sq/cq entries Xin Wang
2024-03-14 19:29 ` Jens Axboe [this message]
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] \
/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