Skip to content

Commit

Permalink
arm64: optimise for arm64_switchcontext
Browse files Browse the repository at this point in the history
       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 <hujun5@xiaomi.com>
  • Loading branch information
hujun260 committed May 13, 2024
1 parent e67df47 commit 67e5fe2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 89 deletions.
3 changes: 1 addition & 2 deletions arch/arm64/src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/src/common/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 13 additions & 5 deletions arch/arm64/src/common/arm64_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
# include <nuttx/arch.h>
# include <sys/types.h>
# include <stdint.h>
# include <syscall.h>
#endif

#include "arm64_arch.h"
Expand Down Expand Up @@ -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
****************************************************************************/
Expand Down Expand Up @@ -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);
Expand Down
81 changes: 0 additions & 81 deletions arch/arm64/src/common/arm64_task_sched.c

This file was deleted.

0 comments on commit 67e5fe2

Please sign in to comment.