Page MenuHomeFreeBSD

Cap IOSIZE_MAX to INT_MAX for 32-bit processes.
ClosedPublic

Authored by jhb on Mar 30 2016, 11:51 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 16, 11:54 AM
Unknown Object (File)
Sat, Nov 16, 8:17 AM
Unknown Object (File)
Tue, Nov 5, 8:58 PM
Unknown Object (File)
Oct 20 2024, 3:31 AM
Unknown Object (File)
Oct 19 2024, 8:00 PM
Unknown Object (File)
Oct 2 2024, 3:41 AM
Unknown Object (File)
Sep 30 2024, 3:03 PM
Unknown Object (File)
Sep 27 2024, 8:59 AM
Subscribers

Details

Summary

Cap IOSIZE_MAX to INT_MAX for 32-bit processes.

Test Plan
  • Run the recently added 'large_file_test' from an i386 aio_test under amd64. It is able to do a INT_MAX + 1 sized aio_read without this fix (when that should be failing). This test now properly fails after this fix (regardless of the 'clamp' setting on the host).

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb retitled this revision from to Cap IOSIZE_MAX to INT_MAX for 32-bit processes..
jhb updated this object.
jhb edited the test plan for this revision. (Show Details)
jhb added a reviewer: kib.
sys/fs/devfs/devfs_vnops.c
62 ↗(On Diff #14755)

I think this is good enough reason to define *IOSIZE_MAX as calls to external function. Also, it would allow to avoid harmless but useless SV_ILP32 checks in ILP32 arches.

sys/fs/devfs/devfs_vnops.c
62 ↗(On Diff #14755)

Mm, ok. BTW, I figured the compiler would be smart enough to reduce 'x ? INT_MAX : INT_MAX' to just remove the 'x' test entirely and substitute 'INT_MAX', so I assumed it would DTRT on 32-bit platforms (those don't need the clamping at all even)

We could do:

#ifdef __ILP32__
#define IOSIZE_MAX  SSIZE_MAX
#else
#define IOSIZE_MAX iosize_max()
#endif

since making it a function means the compiler won't inline it anymore.

sys/fs/devfs/devfs_vnops.c
62 ↗(On Diff #14755)

I was more about the sys/sysent.h contamination of the devfs and other unrelated sources.

For your proposal, iosize_max() would be still a function for LP64, or did I misunderstood ?

sys/fs/devfs/devfs_vnops.c
62 ↗(On Diff #14755)

Yes, it would still be a function.

  • Use functions for DEVFS_IOSIZE_MAX and IOSIZE_MAX if LP64.
  • Drop sysent includes.
kib edited edge metadata.
kib added inline comments.
sys/kern/sys_generic.c
94 ↗(On Diff #14797)

So you are making the sysctl instantiated on 64bit hosts only. Strange, but it is fine.

172 ↗(On Diff #14797)

I would use ?: there, it saves 2-3 lines.

This revision is now accepted and ready to land.Apr 1 2016, 7:24 AM
jhb marked an inline comment as done.Apr 1 2016, 6:27 PM
jhb added inline comments.
sys/kern/sys_generic.c
94 ↗(On Diff #14797)

It wouldn't be used otherwise (even before it was effectively a no-op since INT_MAX == SSIZE_MAX on 32-bit platfoms)

jhb edited edge metadata.
  • Use ?: to trim code size.
This revision now requires review to proceed.Apr 1 2016, 6:27 PM
This revision was automatically updated to reflect the committed changes.