You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2024/05/14 19:03:15 UTC
(nuttx) branch master updated: arm64: optimise for arm64_switchcontext We can save execution time by inline arm64_fullcontextrestore and arm64_switchcontext
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 6c1b900e82 arm64: optimise for arm64_switchcontext We can save execution time by inline arm64_fullcontextrestore and arm64_switchcontext
6c1b900e82 is described below
commit 6c1b900e8247ffafa89e4807deef8fa4e86c06ff
Author: hujun5 <hu...@xiaomi.com>
AuthorDate: Mon Dec 11 21:02:36 2023 +0800
arm64: optimise for arm64_switchcontext
We can save execution time by
inline arm64_fullcontextrestore and arm64_switchcontext
test:
We can use qemu for testing.
compiling
make distclean -j20; ./tools/configure.sh -l qemu-armv8a:nsh_smp ;make -j20
running
qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic -machine virt,virtualization=on,gic-version=3 -net none -chardev stdio,id=con,mux=on -serial chardev:con -mon chardev=con,mode=readline -kernel ./nuttx
Signed-off-by: hujun5 <hu...@xiaomi.com>
---
arch/arm64/src/common/CMakeLists.txt | 3 +-
arch/arm64/src/common/Make.defs | 2 +-
arch/arm64/src/common/arm64_internal.h | 18 +++++--
arch/arm64/src/common/arm64_task_sched.c | 81 --------------------------------
4 files changed, 15 insertions(+), 89 deletions(-)
diff --git a/arch/arm64/src/common/CMakeLists.txt b/arch/arm64/src/common/CMakeLists.txt
index 319677de30..3358c52b7b 100644
--- a/arch/arm64/src/common/CMakeLists.txt
+++ b/arch/arm64/src/common/CMakeLists.txt
@@ -34,8 +34,7 @@ list(APPEND SRCS arm64_initialize.c arm64_initialstate.c arm64_boot.c)
list(APPEND SRCS arm64_nputs.c arm64_idle.c arm64_copystate.c
arm64_createstack.c)
list(APPEND SRCS arm64_releasestack.c arm64_stackframe.c arm64_usestack.c)
-list(APPEND SRCS arm64_task_sched.c arm64_exit.c arm64_fork.c
- arm64_switchcontext.c)
+list(APPEND SRCS arm64_exit.c arm64_fork.c arm64_switchcontext.c)
list(APPEND SRCS arm64_schedulesigaction.c arm64_sigdeliver.c)
list(APPEND SRCS arm64_getintstack.c arm64_registerdump.c)
list(APPEND SRCS arm64_perf.c arm64_tcbinfo.c)
diff --git a/arch/arm64/src/common/Make.defs b/arch/arm64/src/common/Make.defs
index 4bb12ec7eb..00cb0b7099 100644
--- a/arch/arm64/src/common/Make.defs
+++ b/arch/arm64/src/common/Make.defs
@@ -45,7 +45,7 @@ endif
CMN_CSRCS = arm64_initialize.c arm64_initialstate.c arm64_boot.c
CMN_CSRCS += arm64_nputs.c arm64_idle.c arm64_copystate.c arm64_createstack.c
CMN_CSRCS += arm64_releasestack.c arm64_stackframe.c arm64_usestack.c
-CMN_CSRCS += arm64_task_sched.c arm64_exit.c arm64_fork.c arm64_switchcontext.c
+CMN_CSRCS += arm64_exit.c arm64_fork.c arm64_switchcontext.c
CMN_CSRCS += arm64_schedulesigaction.c arm64_sigdeliver.c
CMN_CSRCS += arm64_getintstack.c arm64_registerdump.c
CMN_CSRCS += arm64_perf.c arm64_tcbinfo.c
diff --git a/arch/arm64/src/common/arm64_internal.h b/arch/arm64/src/common/arm64_internal.h
index 8d82fa0837..b05ff81044 100644
--- a/arch/arm64/src/common/arm64_internal.h
+++ b/arch/arm64/src/common/arm64_internal.h
@@ -32,6 +32,7 @@
# include <nuttx/arch.h>
# include <sys/types.h>
# include <stdint.h>
+# include <syscall.h>
#endif
#include "arm64_arch.h"
@@ -116,6 +117,18 @@
# define SMP_STACK_WORDS (SMP_STACK_SIZE >> 2)
#endif
+/* Context switching */
+
+#define arm64_fullcontextrestore(restoreregs) \
+ do \
+ { \
+ sys_call1(SYS_restore_context, (uintptr_t)restoreregs); \
+ } \
+ while (1)
+
+#define arm64_switchcontext(saveregs, restoreregs) \
+ sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs)
+
/****************************************************************************
* Public Types
****************************************************************************/
@@ -267,11 +280,6 @@ int arm64_psci_init(const char *method);
void __start(void);
void arm64_secondary_start(void);
-/* Context switching */
-
-void arm64_fullcontextrestore(uint64_t *restoreregs) noreturn_function;
-void arm64_switchcontext(uint64_t **saveregs, uint64_t *restoreregs);
-
/* Signal handling **********************************************************/
void arm64_sigdeliver(void);
diff --git a/arch/arm64/src/common/arm64_task_sched.c b/arch/arm64/src/common/arm64_task_sched.c
deleted file mode 100644
index 69f27df8c1..0000000000
--- a/arch/arm64/src/common/arm64_task_sched.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
- * arch/arm64/src/common/arm64_task_sched.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 <stdbool.h>
-#include <sched.h>
-#include <debug.h>
-#include <assert.h>
-#include <nuttx/arch.h>
-#include <nuttx/sched.h>
-#include <arch/syscall.h>
-
-#include "sched/sched.h"
-#include "group/group.h"
-#include "arm64_internal.h"
-#include "arm64_fatal.h"
-
-#ifdef CONFIG_ARCH_FPU
-#include "arm64_fpu.h"
-#endif
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: arm64_fullcontextrestore
- *
- * Description:
- * Restore the current thread context. Full prototype is:
- *
- * void arm64_fullcontextrestore(uint64_t *restoreregs) noreturn_function;
- *
- * Returned Value:
- * None
- *
- ****************************************************************************/
-
-void arm64_fullcontextrestore(uint64_t *restoreregs)
-{
- sys_call1(SYS_restore_context, (uintptr_t)restoreregs);
-
- __builtin_unreachable();
-}
-
-/****************************************************************************
- * Name: arm64_switchcontext
- *
- * Description:
- * Save the current thread context and restore the specified context.
- *
- * Returned Value:
- * None
- *
- ****************************************************************************/
-
-void arm64_switchcontext(uint64_t **saveregs, uint64_t *restoreregs)
-{
- sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs);
-}