Repository navigation
kernel: optimize C906 memmove and unaligned usercopy - #484
Conversation
Build outputsCompared with the build of main at 14fde0e. 13 changed, 0 added, 0 removed of 570 outputs.
|
dormancygrace
left a comment
There was a problem hiding this comment.
I found no correctness defect in either assembly patch.
What I checked:
- Both patches apply with zero fuzz to the 7.3
memmove.Sanduaccess.S, and both files assemble. - I read memmove by hand for every overlap direction and the 0, 1, 2–7, word and 64-byte paths. Each block is loaded before it is stored, and no access leaves
[src,src+n)or[dst,dst+n). - In usercopy, every faulting access leaves
a0/a1un-advanced, so the bytewise retry returns an exact residual..Lbulk_faultrestorest0, andt5/t6(SUM andra) are untouched. - The exception-table entry count stays at 23. The new block fits the 44-byte region.
My comments are about the contract with 0045, test coverage and documentation.
Three open PR chains currently claim the same kernel patch numbers: this one (0052/0053), #492 (0052/0053) and #501/#503 (0052/0053). Whichever merges second has to renumber.
dormancygrace
left a comment
There was a problem hiding this comment.
Independent review found no runtime defect in the final scalar implementations. Clarified the C906 hardware and usercopy placement contracts, corrected stale usercopy documentation and expanded memmove guard tests in fe2c0da. Production assembly is unchanged apart from comments. Zero-fuzz Linux 7.3 patch application, 92,880 RISC-V QEMU guard/overlap checks, an overread negative control and integrated platform/config/CPU-profile tests pass. Original live-kernel evidence remains attributed to its measured revision. All 15 final-head CI checks, including firmware, passed; head and main were rechecked immediately before merging.
Optimize kernel memmove and misaligned usercopy for NanoKVM's SG2002/C906.
memmove uses scalar 64-byte blocks, word copies and bounded short head/tail accesses. Each overlapping block is loaded before storing; the destination return value, early-boot PI aliases and aligned short entry are preserved.
Usercopy replaces shifted-word reconstruction with native misaligned scalar loads. Its normal short and aligned paths retain their exact instructions and addresses. Faults retry the accessible prefix bytewise and return an exact residual while preserving SUM ownership. No CPU dispatch or vector/FP state is needed for this target.
Validation:
All main measurements are retained, including aligned socket outliers of +9.78% and +8.86% at 2920/3776 bytes. A subsequent baseline/candidate control with eight aligned buffer placements and three processes did not reproduce those slowdowns. Larger socket results vary between runs; no guaranteed aligned-socket, whole-system, browser-ISO or FPS gain is claimed.
Includes live-kernel verifiers, transfer benchmarks and complete process medians: memmove results, usercopy results.
Review clarification: both patches explicitly require native SG2002/C906 misaligned accesses; the 44-byte usercopy region is a qualified placement contract. Production assembly is unchanged by review corrections. The extended guard verifier passes 92,880 checks with the actual RISC-V memmove under a QEMU mmap/guard harness, and detects an injected overread. This does not replace the original live-kernel qualification recorded above.