casaroli opened a new pull request, #3956:
URL: https://github.com/apache/nuttx-apps/pull/3956

   ## Summary
   
   The `pipe-rw` test of `benchmarks/osperf` wrote to `pipefd[0]` and read from 
`pipefd[1]`. `pipefd[0]` is the read end and `pipefd[1]` is the write end, so 
both calls failed with `EACCES` and the test measured two failed system calls. 
osperf did not check the return values, so the failure was not visible.
   
   The two commits:
   
   - **benchmarks/osperf: Fix nxstyle errors.** Six missing blank lines after 
declarations. The errors are older than the fix, but the CI checks the whole 
file. No functional change.
   - **benchmarks/osperf: Use the correct ends of the pipe in pipe-rw.** Write 
to `pipefd[1]` and read from `pipefd[0]`. `pipe-rw` now checks the results of 
`write()` and `read()` and prints them with `errno` when one of them does not 
transfer one byte.
   
   ## Impact
   
   - osperf only: `pipe-rw` now measures one write and one read of one byte. 
The other osperf tests do not change. `poll-write` already uses the correct 
ends.
   - All build modes and architectures: the change is in portable application 
code. osperf uses kernel interfaces (`enter_critical_section()`, 
`perf_gettime()`, `work_queue()`), so it runs only in the flat build.
   - Not a breaking change. No documentation change: the osperf page in 
Documentation/ does not describe the tests.
   
   ## Testing
   
   qemu-armv8a:nsh (flat, arm64, QEMU with HVF) with `CONFIG_PIPES`, 
`CONFIG_BENCHMARK_OSPERF`, `CONFIG_ARCH_PERF_EVENTS` and 
`CONFIG_TESTING_OSTEST`, nuttx master 1b0691e870d, nuttx-apps master 54374b3b2. 
Each run: `osperf -c 20` (all tests), `osperf -c 20 pipe-rw`, then ostest.
   
   | run | failure prints | `pipe-rw` avg, all tests | `pipe-rw` avg, alone | 
ostest |
   | --- | --- | --- | --- | --- |
   | master | none (no check) | 12000 ns (min 0) | 14400 ns | status 0 |
   | this PR | none | 44800 ns | 32000 ns | status 0 |
   | this PR, ends swapped back (test only) | 40: `pipe-rw: write -1, read -1, 
errno 13` | 23200 ns | 13600 ns | status 0 |
   
   The third run puts the wrong ends back in a local copy of this PR. The new 
check then prints one line per iteration (20 for each command), which shows 
that both calls fail with `EACCES`. With this PR there is no print, so each 
`write()` and `read()` transfers one byte. The timer step under HVF is 16 us 
and the host had other load, so the times are coarse; a write and a read of the 
correct ends take about two timer steps.
   
   Builds: qemu-armv8a:nsh (make) and qemu-armv8a:nsh_smp (CMake, the defconfig 
that enables osperf). qemu-armv8a:knsh (kernel) builds osperf, but the program 
cannot load there, on master and with this PR, because of the kernel interfaces 
above.
   
   `tools/checkpatch.sh -c -u -m -g` passes.
   


-- 
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]

Reply via email to