jingfei195887 opened a new pull request, #22444:
URL: https://github.com/apache/nuttx/pull/22444
## Summary
Make inode_addref a static inline in the private inode header so callers can
eliminate its call overhead and any redundant null check. Its null handling
and atomic reference increment are unchanged. Remove the separate source
file from Make and CMake.
## Impact
- Functionality: unchanged inode reference semantics. The measured small
sim build uses 72 fewer text bytes.
- Internal linkage: inode_addref no longer has a standalone external symbol;
its callers include the private inode header. Public APIs, inode layout,
Kconfig, hardware and drivers do not change. No application migration.
- Build process: remove one source entry from both build systems.
- Documentation: no new interface or configuration to document.
- No dependency on another open production PR. No runtime speed claim.
## Testing
I confirm that changes are verified on the local setup and work as intended.
Host: Linux x86_64, GCC 13.1.0; serial builds with two CPUs.
Base `3a1dbb62655edbd4fc556cb33df4325abc21ddc7`; head
`ecf41263ddffc791b01748cea3d480f26271c150`.
- Run the unchanged nine-case reference-count suite from
[nuttx-apps #4164](https://github.com/apache/nuttx-apps/pull/4164), exact
[commit
4f331da1729a](https://github.com/apache/nuttx-apps/tree/4f331da1729a724a57e530beb5bdcf18a49ddaa0/testing/fs/refstest),
twice per configuration. Baseline and branch each pass all 18 case runs.
The test files are local build inputs and are not included in this PR.
- Coverage: open/close/dup, dup2 replacement and self-dup, unlink with open
files, epoll reference release, dup3/CLOEXEC, task_spawn inheritance,
mmap/munmap, invalid descriptor error paths, and concurrent dup/close.
Each case cleans up temporary files/devices; an existing sentinel survives.
- A 64 KiB independent FS heap, FDCHECK and three descriptors per block:
another 18 case runs pass on the branch.
- Small sim size comparison uses identical configurations without the local
test app. The baseline artifact was built earlier in this session at the
same base and apps revision, and its saved configuration matches exactly.
- Protected qemu-armv7r:pnsh and kernel qemu-armv8a:knsh are built before
and after with matching configurations. GNU size text/data/bss totals:
| Build | Before [bytes] | After [bytes] | Delta [bytes] |
|---|---|---|---|
| sim | [550829, 2800, 12896] | [550757, 2800, 12896] | [-72, 0, 0] |
| protected | [161408, 1056, 13656] | [161512, 1056, 13552] | [104, 0, -104]
|
| kernel | [224640, 19200, 60472] | [224640, 19200, 60472] | [0, 0, 0] |
Section dumps are included below because linker padding can affect totals;
these results do not imply equal savings on other architectures or configs.
The GNU bss total may include .init_section padding rather than RAM alone:
- protected: .init_section padding delta -104 bytes; actual .bss delta +0
bytes.
- kernel: .init_section padding delta +0 bytes; actual .bss delta +0 bytes.
Make/CMake, OSTest, full-header/commit checkpatch and tested-HEAD checks
pass.
No real hardware, protected/kernel runtime or SMP was tested. The first
functional build encountered an old generated CMocka directory and tried
to apply its patches twice. The generated dependency and failure logs were
archived, and all final functional runs started from a clean dependency.
Reproduce the functional runs by adding the exact test directory linked above
to apps master, configuring sim:nsh, enabling TESTING_CMOCKA,
ALLOW_MIT_COMPONENTS, LIBC_REGEX, TESTING_FS_REFSTEST, FS_TMPFS,
DEBUG_ASSERTIONS and FS_RAMMAP, and setting
TESTING_FS_REFSTEST_MOUNTDIR="/refsdata". Mount tmpfs at /refsdata and run
cmocka_fs_refstest twice. Final functional builds disable coverage.
Testing logs before change:
<details>
<summary>Baseline reference tests</summary>
```text
rev 3a1dbb62655 fcntl: give O_RSYNC its own flag bit build rc=0
run rc=0
log=/home/mi/test/nuttx_apache/fs-upstream/pr-inode-ref-inline/refs-baseline/run.log
Error mount tmpfs '' on '/tmp' failed: 20
nsh> mount -t tmpfs /refsdata
nsh> echo preserve-existing > /refsdata/keep
nsh> cmocka_fs_refstest
[==========] tests: Running 9 test(s).
[ RUN ] test_nuttx_fs_refs01
[ OK ] test_nuttx_fs_refs01
[ RUN ] test_nuttx_fs_refs02
[ OK ] test_nuttx_fs_refs02
[ RUN ] test_nuttx_fs_refs03
[ OK ] test_nuttx_fs_refs03
[ RUN ] test_nuttx_fs_refs04
[ OK ] test_nuttx_fs_refs04
[ RUN ] test_nuttx_fs_refs05
[ OK ] test_nuttx_fs_refs05
[ RUN ] test_nuttx_fs_refs06
[ OK ] test_nuttx_fs_refs06
[ RUN ] test_nuttx_fs_refs07
[ OK ] test_nuttx_fs_refs07
[ RUN ] test_nuttx_fs_refs08
[ OK ] test_nuttx_fs_refs08
[ RUN ] test_nuttx_fs_refs09
[ OK ] test_nuttx_fs_refs09
[==========] tests: 9 test(s) run.
[ PASSED ] 9 test(s).
nsh> echo refs-first=$?
refs-first=0
nsh> cmocka_fs_refstest
[==========] tests: Running 9 test(s).
[ RUN ] test_nuttx_fs_refs01
[ OK ] test_nuttx_fs_refs01
[ RUN ] test_nuttx_fs_refs02
[ OK ] test_nuttx_fs_refs02
[ RUN ] test_nuttx_fs_refs03
[ OK ] test_nuttx_fs_refs03
[ RUN ] test_nuttx_fs_refs04
[ OK ] test_nuttx_fs_refs04
[ RUN ] test_nuttx_fs_refs05
[ OK ] test_nuttx_fs_refs05
[ RUN ] test_nuttx_fs_refs06
[ OK ] test_nuttx_fs_refs06
[ RUN ] test_nuttx_fs_refs07
[ OK ] test_nuttx_fs_refs07
[ RUN ] test_nuttx_fs_refs08
[ OK ] test_nuttx_fs_refs08
[ RUN ] test_nuttx_fs_refs09
[ OK ] test_nuttx_fs_refs09
[==========] tests: 9 test(s) run.
[ PASSED ] 9 test(s).
nsh> echo refs-second=$?
refs-second=0
nsh> ls -l /refsdata
/refsdata:
-rwxrwxrwx 18 2026-11-26 18:37 keep
nsh> cat /refsdata/keep
preserve-existing
nsh> ls /dev
/dev:
console
gpio0
gpio1
gpio2
gpio3
loop
null
oneshot
ram0
ram1
rtc0
zero
nsh> poweroff
```
</details>
Testing logs after change:
<details>
<summary>refs-branch</summary>
```text
rev ecf41263ddf fs/inode: inline inode_addref build rc=0
run rc=0
log=/home/mi/test/nuttx_apache/fs-upstream/pr-inode-ref-inline/refs-branch/run.log
Error mount tmpfs '' on '/tmp' failed: 20
nsh> mount -t tmpfs /refsdata
nsh> echo preserve-existing > /refsdata/keep
nsh> cmocka_fs_refstest
[==========] tests: Running 9 test(s).
[ RUN ] test_nuttx_fs_refs01
[ OK ] test_nuttx_fs_refs01
[ RUN ] test_nuttx_fs_refs02
[ OK ] test_nuttx_fs_refs02
[ RUN ] test_nuttx_fs_refs03
[ OK ] test_nuttx_fs_refs03
[ RUN ] test_nuttx_fs_refs04
[ OK ] test_nuttx_fs_refs04
[ RUN ] test_nuttx_fs_refs05
[ OK ] test_nuttx_fs_refs05
[ RUN ] test_nuttx_fs_refs06
[ OK ] test_nuttx_fs_refs06
[ RUN ] test_nuttx_fs_refs07
[ OK ] test_nuttx_fs_refs07
[ RUN ] test_nuttx_fs_refs08
[ OK ] test_nuttx_fs_refs08
[ RUN ] test_nuttx_fs_refs09
[ OK ] test_nuttx_fs_refs09
[==========] tests: 9 test(s) run.
[ PASSED ] 9 test(s).
nsh> echo refs-first=$?
refs-first=0
nsh> cmocka_fs_refstest
[==========] tests: Running 9 test(s).
[ RUN ] test_nuttx_fs_refs01
[ OK ] test_nuttx_fs_refs01
[ RUN ] test_nuttx_fs_refs02
[ OK ] test_nuttx_fs_refs02
[ RUN ] test_nuttx_fs_refs03
[ OK ] test_nuttx_fs_refs03
[ RUN ] test_nuttx_fs_refs04
[ OK ] test_nuttx_fs_refs04
[ RUN ] test_nuttx_fs_refs05
[ OK ] test_nuttx_fs_refs05
[ RUN ] test_nuttx_fs_refs06
[ OK ] test_nuttx_fs_refs06
[ RUN ] test_nuttx_fs_refs07
[ OK ] test_nuttx_fs_refs07
[ RUN ] test_nuttx_fs_refs08
[ OK ] test_nuttx_fs_refs08
[ RUN ] test_nuttx_fs_refs09
[ OK ] test_nuttx_fs_refs09
[==========] tests: 9 test(s) run.
[ PASSED ] 9 test(s).
nsh> echo refs-second=$?
refs-second=0
nsh> ls -l /refsdata
/refsdata:
-rwxrwxrwx 18 2026-11-26 18:38 keep
nsh> cat /refsdata/keep
preserve-existing
nsh> ls /dev
/dev:
console
gpio0
gpio1
gpio2
gpio3
loop
null
oneshot
ram0
ram1
rtc0
zero
nsh> poweroff
```
</details>
<details>
<summary>refs-private</summary>
```text
rev ecf41263ddf fs/inode: inline inode_addref build rc=0
run rc=0
log=/home/mi/test/nuttx_apache/fs-upstream/pr-inode-ref-inline/refs-private/run.log
Error mount tmpfs '' on '/tmp' failed: 20
nsh> mount -t tmpfs /refsdata
nsh> echo preserve-existing > /refsdata/keep
nsh> cmocka_fs_refstest
[==========] tests: Running 9 test(s).
[ RUN ] test_nuttx_fs_refs01
[ OK ] test_nuttx_fs_refs01
[ RUN ] test_nuttx_fs_refs02
[ OK ] test_nuttx_fs_refs02
[ RUN ] test_nuttx_fs_refs03
[ OK ] test_nuttx_fs_refs03
[ RUN ] test_nuttx_fs_refs04
[ OK ] test_nuttx_fs_refs04
[ RUN ] test_nuttx_fs_refs05
[ OK ] test_nuttx_fs_refs05
[ RUN ] test_nuttx_fs_refs06
[ OK ] test_nuttx_fs_refs06
[ RUN ] test_nuttx_fs_refs07
[ OK ] test_nuttx_fs_refs07
[ RUN ] test_nuttx_fs_refs08
[ OK ] test_nuttx_fs_refs08
[ RUN ] test_nuttx_fs_refs09
[ OK ] test_nuttx_fs_refs09
[==========] tests: 9 test(s) run.
[ PASSED ] 9 test(s).
nsh> echo refs-first=$?
refs-first=0
nsh> cmocka_fs_refstest
[==========] tests: Running 9 test(s).
[ RUN ] test_nuttx_fs_refs01
[ OK ] test_nuttx_fs_refs01
[ RUN ] test_nuttx_fs_refs02
[ OK ] test_nuttx_fs_refs02
[ RUN ] test_nuttx_fs_refs03
[ OK ] test_nuttx_fs_refs03
[ RUN ] test_nuttx_fs_refs04
[ OK ] test_nuttx_fs_refs04
[ RUN ] test_nuttx_fs_refs05
[ OK ] test_nuttx_fs_refs05
[ RUN ] test_nuttx_fs_refs06
[ OK ] test_nuttx_fs_refs06
[ RUN ] test_nuttx_fs_refs07
[ OK ] test_nuttx_fs_refs07
[ RUN ] test_nuttx_fs_refs08
[ OK ] test_nuttx_fs_refs08
[ RUN ] test_nuttx_fs_refs09
[ OK ] test_nuttx_fs_refs09
[==========] tests: 9 test(s) run.
[ PASSED ] 9 test(s).
nsh> echo refs-second=$?
refs-second=0
nsh> ls -l /refsdata
/refsdata:
-rwxrwxrwx 18 2026-11-26 18:39 keep
nsh> cat /refsdata/keep
preserve-existing
nsh> ls /dev
/dev:
console
gpio0
gpio1
gpio2
gpio3
loop
null
oneshot
ram0
ram1
rtc0
zero
nsh> poweroff
```
</details>
<details>
<summary>Final gate</summary>
```text
target : nuttx
branch : fs/inode-ref-inline
head : ecf41263ddffc791b01748cea3d480f26271c150
subject : fs/inode: inline inode_addref
commits : 1
base : 3a1dbb6265 (merge-base with upstream/master)
behind : 0 commits of upstream/master
nuttx : ecf41263dd
apps : a1b03f8926
options : CONFIG_FS_HEAPSIZE=65536 CONFIG_FDCHECK
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=3 CONFIG_DEBUG_ASSERTIONS
CONFIG_DEBUG_FULLOPT CONFIG_COVERAGE_NONE
host : Linux x86_64, gcc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0
checkpatch: rc=0
signer : jingfei <[email protected]>
commits missing your Signed-off-by: 0
make build: rc=0
warnings in changed files: 0
ostest: Exiting with status 0
cmake reconfigure: rc=0
cmake build: rc=0
worktree tracked changes after: 0
RESULT: PASS
```
</details>
<details>
<summary>Small sim baseline</summary>
```text
text data bss dec hex filename
550829 2800 12896 566525 8a4fd nuttx
```
</details>
<details>
<summary>Small sim branch</summary>
```text
text data bss dec hex filename
550757 2800 12896 566453 8a4b5 nuttx
```
</details>
<details>
<summary>protected-baseline</summary>
```text
qemu-armv7r:pnsh baseline build PASS
arm-none-eabi-gcc (Arm GNU Toolchain 13.2.rel1 (Build arm-13.7)) 13.2.1
20231009
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
text data bss dec hex filename
161408 1056 13656 176120 2aff8 nuttx
nuttx :
section size addr
.text 149128 0
.init_section 2424 149128
.ARM.exidx 8 151552
.rodata 12272 151568
.data 1056 1073741824
.bss 11232 1073742880
.comment 68 0
.ARM.attributes 49 0
.debug_line 498348 0
.debug_line_str 397 0
.debug_info 1987003 0
.debug_abbrev 321124 0
.debug_aranges 24376 0
.debug_str 53293 0
.debug_rnglists 27275 0
.debug_frame 43144 0
.debug_loclists 229076 0
Total 3360273
```
</details>
<details>
<summary>protected-branch</summary>
```text
qemu-armv7r:pnsh branch build PASS
arm-none-eabi-gcc (Arm GNU Toolchain 13.2.rel1 (Build arm-13.7)) 13.2.1
20231009
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
text data bss dec hex filename
161512 1056 13552 176120 2aff8 nuttx
nuttx :
section size addr
.text 149232 0
.init_section 2320 149232
.ARM.exidx 8 151552
.rodata 12272 151568
.data 1056 1073741824
.bss 11232 1073742880
.comment 68 0
.ARM.attributes 49 0
.debug_line 497862 0
.debug_line_str 397 0
.debug_info 1981902 0
.debug_abbrev 320758 0
.debug_aranges 24344 0
.debug_str 53270 0
.debug_rnglists 27281 0
.debug_frame 43112 0
.debug_loclists 229171 0
Total 3354334
```
</details>
<details>
<summary>kernel-baseline</summary>
```text
qemu-armv8a:knsh baseline build PASS
aarch64-none-elf-gcc (GCC) 13.4.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
text data bss dec hex filename
224640 19200 60472 304312 4a4b8 nuttx
nuttx :
section size addr
.text 201124 1076363264
.vector 2036 1076568064
.rodata 21480 1076572160
.data 2816 1076596736
.bss 60472 1076600832
.initstack 16384 1076666368
.comment 18 0
.debug_line 364971 0
.debug_line_str 18609 0
.debug_info 2500176 0
.debug_abbrev 380601 0
.debug_aranges 45824 0
.debug_str 50947 0
.debug_rnglists 46902 0
.debug_frame 77184 0
.debug_loclists 352588 0
Total 4142132
```
</details>
<details>
<summary>kernel-branch</summary>
```text
qemu-armv8a:knsh branch build PASS
aarch64-none-elf-gcc (GCC) 13.4.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
text data bss dec hex filename
224640 19200 60472 304312 4a4b8 nuttx
nuttx :
section size addr
.text 201124 1076363264
.vector 2036 1076568064
.rodata 21480 1076572160
.data 2816 1076596736
.bss 60472 1076600832
.initstack 16384 1076666368
.comment 18 0
.debug_line 364954 0
.debug_line_str 18586 0
.debug_info 2495118 0
.debug_abbrev 380251 0
.debug_aranges 45776 0
.debug_str 50947 0
.debug_rnglists 46911 0
.debug_frame 77128 0
.debug_loclists 352743 0
Total 4136744
```
</details>
## PR verification Self-Check
- [x] This PR introduces only one functional change.
- [x] I have updated all required description fields above.
- [x] My PR follows the contributing guidelines for scope, coding style and
testing.
- [ ] My PR is still work in progress (not ready for review).
- [x] My PR is ready for review and can be safely merged into the codebase.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]