You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "hujun260 (via GitHub)" <gi...@apache.org> on 2024/09/26 11:36:23 UTC

[PR] arch: inline up_switch_context,in arm arm64 [nuttx]

hujun260 opened a new pull request, #13644:
URL: https://github.com/apache/nuttx/pull/13644

   ## Summary
   inline up_switch_context,in arm arm64
   when a context switch occurs, up_switch_context is executed. In order to reduce the time taken for context switching, we inline the up_switch_context function.
   
   ## Impact
   arm,arm64
   
   ## Testing
   ostest
   


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch: inline up_switch_context,in arm arm64 [nuttx]

Posted by "hujun260 (via GitHub)" <gi...@apache.org>.
hujun260 commented on code in PR #13644:
URL: https://github.com/apache/nuttx/pull/13644#discussion_r1777030227


##########
arch/arm/include/irq.h:
##########
@@ -76,6 +77,17 @@
 
 #ifndef __ASSEMBLY__
 
+#ifndef up_switch_context
+#define up_switch_context(tcb, rtcb)                              \

Review Comment:
   If we use inline, we need to see the definition of struct tcb_s, but irq.h can't include sched/sched.h



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch: inline up_switch_context,in arm arm64 [nuttx]

Posted by "hujun260 (via GitHub)" <gi...@apache.org>.
hujun260 commented on PR #13644:
URL: https://github.com/apache/nuttx/pull/13644#issuecomment-2378180980

   > @hujun260 modifications in the context switch requires deep testing, only ostest (you didn't say which arch was used) is not enough. History shows it always introduces regression.
   
   I understand your concerns. We've tested this PR on multiple products internally.


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch: inline up_switch_context,in arm arm64 [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #13644:
URL: https://github.com/apache/nuttx/pull/13644#discussion_r1779374174


##########
arch/arm64/include/irq.h:
##########
@@ -423,6 +424,15 @@ static inline_function void up_set_current_regs(uint64_t *regs)
   __asm__ volatile ("msr " "tpidr_el1" ", %0" : : "r" (regs));
 }
 
+#define up_switch_context(tcb, rtcb)                              \

Review Comment:
   let's create a new patch to inline other arch too



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch: inline up_switch_context,in arm arm64 [nuttx]

Posted by "hujun260 (via GitHub)" <gi...@apache.org>.
hujun260 commented on code in PR #13644:
URL: https://github.com/apache/nuttx/pull/13644#discussion_r1777032077


##########
arch/arm/src/common/arm_switchcontext.c:
##########
@@ -1,91 +0,0 @@
-/****************************************************************************
- * arch/arm/src/common/arm_switchcontext.c
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.  The
- * ASF licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
- * License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
- * License for the specific language governing permissions and limitations
- * under the License.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <sched.h>
-#include <assert.h>
-#include <debug.h>
-#include <nuttx/arch.h>
-#include <nuttx/sched.h>
-
-#include "sched/sched.h"
-#include "group/group.h"
-#include "clock/clock.h"
-#include "arm_internal.h"
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: up_switch_context
- *
- * Description:
- *   A task is currently in the ready-to-run list but has been prepped
- *   to execute. Restore its context, and start execution.
- *
- * Input Parameters:
- *   tcb: Refers to the head task of the ready-to-run list
- *     which will be executed.
- *   rtcb: Refers to the running task which will be blocked.
- *
- ****************************************************************************/
-
-void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb)
-{
-  /* Update scheduler parameters */
-
-  nxsched_suspend_scheduler(rtcb);
-
-  /* Are we in an interrupt handler? */
-
-  if (up_interrupt_context())
-    {
-      /* Update scheduler parameters */
-
-      nxsched_resume_scheduler(tcb);

Review Comment:
   I added a commit for a dependency



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch: inline up_switch_context,in arm arm64 [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #13644:
URL: https://github.com/apache/nuttx/pull/13644


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch: inline up_switch_context,in arm arm64 [nuttx]

Posted by "hujun260 (via GitHub)" <gi...@apache.org>.
hujun260 commented on code in PR #13644:
URL: https://github.com/apache/nuttx/pull/13644#discussion_r1777030227


##########
arch/arm/include/irq.h:
##########
@@ -76,6 +77,17 @@
 
 #ifndef __ASSEMBLY__
 
+#ifndef up_switch_context
+#define up_switch_context(tcb, rtcb)                              \

Review Comment:
   If we use inline, we need to see the definition of struct tcb_s, but irq.h can't include nuttx/sched.h



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch: inline up_switch_context,in arm arm64 [nuttx]

Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on PR #13644:
URL: https://github.com/apache/nuttx/pull/13644#issuecomment-2377037650

   Please remove reference to VELAPLATFO-38287


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch: inline up_switch_context,in arm arm64 [nuttx]

Posted by "nuttxpr (via GitHub)" <gi...@apache.org>.
nuttxpr commented on PR #13644:
URL: https://github.com/apache/nuttx/pull/13644#issuecomment-2376726354

   [**\[Experimental Bot, please feedback here\]**](https://github.com/search?q=repo%3Aapache%2Fnuttx+13552&type=issues)
   
   
   
   **No, this PR does not meet the NuttX Requirements.**
   
   **Missing Information:**
   
   * **Summary:**
       *  Lacks a clear explanation of *why* inlining `up_switch_context` is necessary. What specific performance benefits are expected? 
       *  Doesn't specify which functional part of the code is being modified (e.g., scheduler, context switching mechanism).
   * **Impact:**
       *  **Impact on user:**  While you mention "arm, arm64", it's unclear if users need to make any code changes or configuration adjustments. 
       *  **Impact on build, hardware, documentation, security, compatibility:** All these sections are marked as "arm, arm64" which doesn't provide any meaningful information. You need to state "YES" or "NO" and provide descriptions if applicable.
   * **Testing:**
       *  **Build Host(s):**  Specify the operating system, CPU architecture, and compiler used for building NuttX.
       *  **Target(s):**  Be specific about the architecture (e.g., ARM Cortex-M4) and the board configuration used for testing.
       *  **Testing logs:** Provide actual testing logs before and after the change. "ostest" is not sufficient. Include relevant log output that demonstrates the performance improvement or any issues.
   
   **Recommendations:**
   
   1. **Explain the Rationale:**  Clearly articulate the reasons for inlining `up_switch_context`.  Provide specific benchmarks or performance data to justify the change.
   2. **Detailed Impact Assessment:** Analyze and describe the potential impact on all aspects mentioned (build, hardware, etc.). If there's no impact, state "NO" explicitly.
   3. **Thorough Testing:** Provide detailed testing information, including build host and target specifications, and relevant log snippets that showcase the change's effects. 
   
   By addressing these points, your PR will be better aligned with NuttX's requirements and easier for reviewers to evaluate. 
   


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch: inline up_switch_context,in arm arm64 [nuttx]

Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on code in PR #13644:
URL: https://github.com/apache/nuttx/pull/13644#discussion_r1776899675


##########
arch/arm/include/irq.h:
##########
@@ -76,6 +77,17 @@
 
 #ifndef __ASSEMBLY__
 
+#ifndef up_switch_context
+#define up_switch_context(tcb, rtcb)                              \

Review Comment:
   why not use inline function?



##########
arch/arm/src/common/arm_switchcontext.c:
##########
@@ -1,91 +0,0 @@
-/****************************************************************************
- * arch/arm/src/common/arm_switchcontext.c
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.  The
- * ASF licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
- * License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
- * License for the specific language governing permissions and limitations
- * under the License.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <sched.h>
-#include <assert.h>
-#include <debug.h>
-#include <nuttx/arch.h>
-#include <nuttx/sched.h>
-
-#include "sched/sched.h"
-#include "group/group.h"
-#include "clock/clock.h"
-#include "arm_internal.h"
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: up_switch_context
- *
- * Description:
- *   A task is currently in the ready-to-run list but has been prepped
- *   to execute. Restore its context, and start execution.
- *
- * Input Parameters:
- *   tcb: Refers to the head task of the ready-to-run list
- *     which will be executed.
- *   rtcb: Refers to the running task which will be blocked.
- *
- ****************************************************************************/
-
-void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb)
-{
-  /* Update scheduler parameters */
-
-  nxsched_suspend_scheduler(rtcb);
-
-  /* Are we in an interrupt handler? */
-
-  if (up_interrupt_context())
-    {
-      /* Update scheduler parameters */
-
-      nxsched_resume_scheduler(tcb);

Review Comment:
   how about resume/suspend trace?



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch: inline up_switch_context,in arm arm64 [nuttx]

Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on PR #13644:
URL: https://github.com/apache/nuttx/pull/13644#issuecomment-2377037296

   @hujun260 modifications in the context switch requires deep testing, only ostest (you didn't say which arch was used) is not enough. History shows it always introduces regression.


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org