-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
riscv: g_current_regs is only used to determine if we are in irq #13561
Conversation
with other functionalities removed. reason: by doing this we can reduce context switch time, When we exit from an interrupt handler, we directly use tcb->xcp.regs before text data bss dec hex filename 138805 337 24256 163398 27e46 nuttx after text data bss dec hex filename 138499 337 24240 163076 27d04 nuttx szie change -322 Signed-off-by: hujun5 <[email protected]>
[Experimental Bot, please feedback here] The PR Summary and Testing sections appear to meet NuttX requirements, but the Impact section needs more detail. Here's a breakdown and suggestions for improvement: Good:
Needs Improvement:
Example of Improved Impact Section
By providing specific details in the Impact section, you make it easier for reviewers to assess the risks and benefits of your change and ensure it aligns with NuttX standards. |
I noticed that rv-virt:knsh crashes now.
|
Yep I see the same error in the Daily Auto Test for
Milk-V Duo S SBC (SG2000) also fails to boot:
|
… switch is required This commit fixes the regression from apache#13561 Change-Id: Ifb0623c0c60f7da55c762926e93cd1708c421ce6
… switch is required This commit fixes the regression from apache#13561 Signed-off-by: hujun5 <[email protected]>
… switch is required This commit fixes the regression from apache#13561 Signed-off-by: hujun5 <[email protected]>
… switch is required This commit fixes the regression from #13561 Signed-off-by: hujun5 <[email protected]>
This commit fixes the regression from apache#13561 In order to determine whether a context switch has occurred, we can use g_running_task to store the current regs. This allows us to compare the current register state with the previously stored state to identify if a context switch has taken place. Signed-off-by: hujun5 <[email protected]>
This commit fixes the regression from apache#13561 In order to determine whether a context switch has occurred, we can use g_running_task to store the current regs. This allows us to compare the current register state with the previously stored state to identify if a context switch has taken place. Signed-off-by: hujun5 <[email protected]>
This commit fixes the regression from apache#13561 In order to determine whether a context switch has occurred, we can use g_running_task to store the current regs. This allows us to compare the current register state with the previously stored state to identify if a context switch has taken place. Signed-off-by: hujun5 <[email protected]>
This commit fixes the regression from apache#13561 In order to determine whether a context switch has occurred, we can use g_running_task to store the current regs. This allows us to compare the current register state with the previously stored state to identify if a context switch has taken place. We added a percpu variable to hold the current context that needs to be returned, because the running tcb->xcp.regs often changes and is not suitable for preserving the context. Signed-off-by: hujun5 <[email protected]>
This commit fixes the regression from apache#13561 In order to determine whether a context switch has occurred, we can use g_running_task to store the current regs. This allows us to compare the current register state with the previously stored state to identify if a context switch has taken place. Signed-off-by: hujun5 <[email protected]>
This commit fixes the regression from apache#13561 In order to determine whether a context switch has occurred, we can use g_running_task to store the current regs. This allows us to compare the current register state with the previously stored state to identify if a context switch has taken place. Signed-off-by: hujun5 <[email protected]>
This commit fixes the regression from apache#13561 In order to determine whether a context switch has occurred, we can use g_running_task to store the current regs. This allows us to compare the current register state with the previously stored state to identify if a context switch has taken place. Signed-off-by: hujun5 <[email protected]>
This commit fixes the regression from #13561 In order to determine whether a context switch has occurred, we can use g_running_task to store the current regs. This allows us to compare the current register state with the previously stored state to identify if a context switch has taken place. Signed-off-by: hujun5 <[email protected]>
This commit fixes the regression from apache#13561 In order to determine whether a context switch has occurred, we can use g_running_task to store the current regs. This allows us to compare the current register state with the previously stored state to identify if a context switch has taken place. Signed-off-by: hujun5 <[email protected]>
This commit fixes the regression from apache#13561 In order to determine whether a context switch has occurred, we can use g_running_task to store the current regs. This allows us to compare the current register state with the previously stored state to identify if a context switch has taken place. Signed-off-by: hujun5 <[email protected]>
This commit fixes the regression from apache#13561 In order to determine whether a context switch has occurred, we can use g_running_task to store the current regs. This allows us to compare the current register state with the previously stored state to identify if a context switch has taken place. Signed-off-by: hujun5 <[email protected]>
This commit fixes the regression from apache#13561 In order to determine whether a context switch has occurred, we can use g_running_task to store the current regs. This allows us to compare the current register state with the previously stored state to identify if a context switch has taken place. Signed-off-by: hujun5 <[email protected]>
Why
When a context switch occurs currently, the context before the interrupt is fetched from the global variable g_current_regs and then stored in the corresponding tcb->xcp.regs. Subsequently, the new context is assigned to g_current_regs. When returning from the interrupt context, the context is retrieved from g_current_regs and used.
In reality, we do not necessarily require this intermediate variable g_current_regs to accomplish a context switch. Eliminating it avoids multiple assignments, especially during multiple context switches within interrupts, which can lead to repeated assignments.
All we need is to work directly with the context of the currently running task. This approach enhances the speed of context switching, reduces the code base, and optimizes signal handling logic. By simply leveraging the context of the active task, we can streamline the process and improve overall efficiency.
reason:
by doing this we can reduce context switch time,
When we exit from an interrupt handler, we directly use tcb->xcp.regs
Missing Information:
Related Issues: none
NuttX Apps Impact: none
Impact
Is a new feature added? NO
Is an existing feature changed? yes
g_current_regs is only used to determine if we are in irq with other functionalities removed.
We need to use up_interrupt_context for interrupt identification instead of relying on up_current_regs for that purpose.
before
text data bss dec hex filename
138805 337 24256 163398 27e46 nuttx
after
text data bss dec hex filename
138499 337 24240 163076 27d04 nuttx
size -322
Testing
Build Host:
OS: Ubuntu 20.04
CPU: x86_64
Compiler: GCC 9.4.0
Target:
Arch: riscv
logs:
NO change