Repository navigation
fs/vfs: Add FS_UIO to option out vector I/O - #20820
Conversation
|
|
@jingfei195887 please help to review |
04340c3 to
e402d70
Compare
|
I have added CONFIG_DISABLE_DIRECTORY_OPERATIONS to this PR alongside CONFIG_FS_DIRENT_LITE. When enabled, it completely excludes fs_dir.c, libs/libc/dirent, lib_glob.c, and guards all POSIX directory interfaces. CONFIG_FS_DIRENT_LITE now depends on BUILD_FLAT && !DISABLE_DIRECTORY_OPERATIONS. All changes pass nxstyle and have been verified with clean builds. |
|
Thanks @Swatantra-66 for adding In parallel we opened #20868, which adds the same option with a narrower scope. The differences, for comparison:
One thing I noticed while comparing: with That is why #20868 keeps the libc layer and only drops the kernel directory layer: existing applications keep building, and e.g. NSH
|
e402d70 to
2e5a36d
Compare
|
Hi @xiaoxiang781216, @jingfei195887, Thank you for the review Per your suggestions, I have completely dropped all This PR (#20820) is now strictly focused on implementing |
2e5a36d to
b3f9afd
Compare
b3f9afd to
b070348
Compare
|
Thanks for the update! It looks like the PR description still describes CONFIG_FS_DIRENT_LITE, while the current changes introduce CONFIG_FS_UIO. Could you please update the description, including the testing section, to reflect the current scope? That would make it easier to review. Thanks! |
|
Would it make sense to also guard the I realize this would require updating the positional initializers and other member references (for example, the |
Provide a hidden Kconfig option CONFIG_FS_UIO (selected by subsystems such as drivers/serial that implement vector I/O). When disabled, file_read() and file_write() invoke the underlying driver read/write operations directly, avoiding struct iovec stack allocations and omitting fs_uio.c. POSIX readv() and writev() remain available via read/write fallback loops and are automatically stripped by the linker (--gc-sections) when unreferenced, preserving full POSIX compliance while saving memory on constrained targets. Signed-off-by: Swatantra Yadav <[email protected]>
b070348 to
54e22e7
Compare
|
Done, updated both Removed |
|
@jingfei195887 ,That's a valid point for saving additional RAM/pointers, but it is definitely better suited as a separate follow-up PR. Guarding Keeping the struct layout unchanged here allows |
|
@xiaoxiang781216 should i ignore arm-stm32 ci error or retrigger ci |
let's ignore ci error which is fixed by #20949 instead wasting ci resource by retrigger. |
@Swatantra-66 please remember to create a new patch to skip readv/writev callback in xxx_operation_s. |
|
Once this PR merges, I'll prepare the follow-up patch to guard the |
|
@xiaoxiang781216 @jingfei195887 as discussed, i have opened #21047 follow-up patch to guard the readv/writev callbacks in struct file_operations and struct mountpt_operations under CONFIG_FS_UIO |
Summary
Adds
CONFIG_FS_UIO, a configurable Kconfig option that allows optioning out internal vector I/O overhead on constrained targets while keeping scalar file I/O direct and fast.Motivation & Architecture
In default configurations,
file_read()andfile_write()synthesize a single-elementstruct iovecon the stack and delegate tofile_readv()andfile_writev(), which in turn initialize astruct uioand invokeu.i_ops->readv/u.i_ops->writev(falling back to scalarfile_readv_compat/file_writev_compatif unsupported).While this unifies the VFS path when vector I/O is actively used (e.g. by
drivers/serial), on small memory-constrained microcontrollers where vector I/O is not utilized, this introduces unnecessary overhead on every standardread()andwrite()call:struct iovecandstruct uioon the stack for every scalar read/write.fs_uio.cinto the binary.With
CONFIG_FS_UIO:drivers/serial) automaticallyselect FS_UIO.CONFIG_FS_UIOis disabled:file_read()andfile_write()call the driver's nativeread()/write()operations directly.fs_uio.cis omitted from the build, saving code space.readv()andwritev()remain fully available via scalar fallback loops (file_readv_compat()/file_writev_compat()) and are automatically garbage-collected by the linker (--gc-sections) if unreferenced by the application.Key Implementation Details
fs_uio.cis conditionally compiled in bothfs/vfs/CMakeLists.txtandfs/vfs/Make.defsonly whenCONFIG_FS_UIO=y.file_read()andfile_write(), scalar operations bypass vector structures whenCONFIG_FS_UIOis disabled and invokeinode->u.i_ops->read/inode->u.i_ops->writedirectly.readv()andwritev()retain full POSIX compliance across both configurations.#ifdefstructure: Unified fallback logic infile_readv()andfile_writev()avoids code duplication between vector and scalar paths.struct file_operationsandstruct mountpt_operationslayout remains unchanged, avoiding breaking in-tree and out-of-tree drivers.Impact
CONFIG_FS_UIO).SERIAL=y). When disabled, reduces memory footprint, avoids stack allocations, and streamlines scalar read/write operations.read()/write()and vectorreadv()/writev()continue to work across all configurations.Testing
Host Environment
Static Analysis & Coding Standards
nxstyle):tools/nxstyle fs/vfs/fs_read.c tools/nxstyle fs/vfs/fs_write.c # Result: 0 errors, 0 warningsBuild Verification Logs
Standard Build (
sim:nsh, withCONFIG_FS_UIO=yviaSERIAL=y):Build without Vector I/O (
CONFIG_FS_UIOnot set):