Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should entries be u32 for std.os.linux.IoUring.init? #22470

Closed
LAC-Tech opened this issue Jan 12, 2025 · 4 comments
Closed

Should entries be u32 for std.os.linux.IoUring.init? #22470

LAC-Tech opened this issue Jan 12, 2025 · 4 comments
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@LAC-Tech
Copy link

Zig Version

0.13.0

Steps to Reproduce and Observed Behavior

Visit here, and observe entries is u16:
https://ziglang.org/documentation/0.13.0/std/#src/std/os/linux/IoUring.zig

The code then calls the lower level function, where it's u32:
https://ziglang.org/documentation/0.13.0/std/#std.os.linux.io_uring_setup

This is the correct type according to the linux man pages:
https://www.man7.org/linux/man-pages/man2/io_uring_setup.2.html

Expected Behavior

I just want to know if there's a reason it's u16 in the wrapper, or it was just a typo.

@LAC-Tech LAC-Tech added the bug Observed behavior contradicts documented or intended behavior label Jan 12, 2025
@wooster0
Copy link
Contributor

There is this doc comment on init at least:

/// `entries` must be a power of two between 1 and 32768, although the kernel will make the final
/// call on how many entries the submission and completion queues will ultimately have,
/// see https://github.com/torvalds/linux/blob/v5.8/fs/io_uring.c#L8027-L8050.

Could be that the API takes 32 bits but the value must still fit in 16 bits.

@wooster0
Copy link
Contributor

Yeah if you follow the link and read the code you'll find

	if (entries > IORING_MAX_ENTRIES) {
		if (!(p->flags & IORING_SETUP_CLAMP))
			return -EINVAL;
		entries = IORING_MAX_ENTRIES;
	}
#define IORING_MAX_ENTRIES	32768

@LAC-Tech
Copy link
Author

In that case, why not u15, which is exactly 32768?

@mlugg
Copy link
Member

mlugg commented Jan 12, 2025

The maximum value of a u15 is 32767, not 32768. This will hopefully be addressed by #3806.

@mlugg mlugg closed this as not planned Won't fix, can't repro, duplicate, stale Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

3 participants