-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers/serial/serial.c: only adapt readv api to avoid block on secound read in readv() #15604
base: master
Are you sure you want to change the base?
Conversation
[Experimental Bot, please feedback here] No, this PR does not fully meet the NuttX requirements. While it provides a summary of the changes, it lacks crucial information. Here's a breakdown of what's missing:
In summary: The PR needs to provide a more thorough explanation of the why, a detailed impact assessment (even if it's minimal), and significantly more robust testing information including actual log output. Without these details, it's difficult to assess the correctness and impact of the changes. |
51782af
to
de2054d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it actually improve the performance much? otherwise, i'm against it.
as far as we want to support readv/writev, it's simpler always to use iovecs.
the original plan was that eventually deprecate read/write in file_operations.
this change would make it impossible.
while nonblock trick might be ok for the serial driver, it is not so generic.
eg. it won't work for files which needs to preserve data boundaries or files
which needs to provide read/write atomicity.
This patch provides 2 optimizations
The advantage of nuttx rtos is that which could run on a chip with a very low frequency (50MHz). On the critical path, we need to further reduce the interference of complex frameworks. You will find that many people in the community are working on inline function and simplifying the function call process. Each cycle is very important for MCU devices |
Linux experts don't understand the hard real-time requirements, which is why key scheduling performance of nuttx is better than ThreadX. |
i guess we should avoid talking too much bad about other projects in a forum like this. |
correctness, simplicity, code size, maintainability, etc are also important. also, i'm not sure about your "too complicated" claim. |
To be honest, this is also why it took 20 years for PREEMPT_RT to be merged into the master branch, and even then, PREEMPT_RT still fails to meet the requirements of determinism and hard real time system. |
I don't have a device and time. I just analyzed the code path and found that the current read/write scenario has additional overhead (uio) compared to the previous one. 90% of the business code will not use interfaces like readv/writev. Why do everyone need to use uio to generate additional function calls? |
while it might be true fro you business code, it depends.
to have uniform kernel api and eventually reduce code footprint. |
just curious; are you using read/write in a hard-realtime logic? |
Let's first discuss #15603 , which has better branch for write/read and writev/readv |
Hard real-time CPUs do not use vfs, only debugging and diagnostics case. |
ok. so, your comments about hard realtime are not directly related to this PR. what a relief. |
No, we should try to reduce the CPU usage in debug mode as much as possible. |
it's about general performance improvement, not hard-realtime, isn't it? |
Real-time performance is the result of optimization of each subsystem |
ok. i guess we are just using different definitions of hard-realtime. |
to improve the performance Signed-off-by: chao an <[email protected]>
…nd read in readv() Signed-off-by: chao an <[email protected]>
@yamt do you have more suggestion for this patch? |
I have seen that there is quite some discussion about the use of read/readv and write/writev. Why does NuttX use uio for readv/writev instead of the classic iovec and iovcnt ? |
@@ -1005,8 +962,7 @@ static ssize_t uart_readv(FAR struct file *filep, FAR struct uio *uio) | |||
{ | |||
if (recvd > 0) | |||
{ | |||
static const char zero = '\0'; | |||
uio_copyfrom(uio, recvd, &zero, 1); | |||
*buffer-- = '\0'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't this break BS/DEL on iov boundaries?
because IMO raw iovec array is quite complex to deal with correctly, especially when it needs to be done in every drivers. |
I can't understand why it is complex to deal with raw iovec correctly. But I can imagine that there are drivers where it is easier/better to write readv/writev on top of read/write, while there are others where it is easier/better to write read/write on top of readv/writev. Maybe all drivers should provide read/write AND readv/writev and the driver implementation can decide what the best approach is to provide the functionality. |
Summary
drivers/serial/serial.c: only adapt readv api to avoid block on secound read in readv()
fs/vfs: skip uio logic if only 1 iovcnt in slot
to improve the performance
Signed-off-by: chao an [email protected]
Impact
N/A
Testing
sim/nsh