Skip to content

Commit

Permalink
sched: use this_task replace nxsched_self
Browse files Browse the repository at this point in the history
reason:
We can reduce a function call to improve performance.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
  • Loading branch information
hujun260 committed Sep 3, 2024
1 parent f084685 commit 56de6a1
Show file tree
Hide file tree
Showing 34 changed files with 87 additions and 69 deletions.
8 changes: 4 additions & 4 deletions arch/arm/src/armv6-m/arm_svcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ int arm_svcall(int irq, void *context, void *arg)
#ifdef CONFIG_LIB_SYSCALL
case SYS_syscall_return:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();
int index = (int)rtcb->xcp.nsyscalls - 1;

/* Make sure that there is a saved syscall return address. */
Expand Down Expand Up @@ -334,7 +334,7 @@ int arm_svcall(int irq, void *context, void *arg)
#ifdef CONFIG_BUILD_PROTECTED
case SYS_signal_handler:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();

/* Remember the caller's return address */

Expand Down Expand Up @@ -376,7 +376,7 @@ int arm_svcall(int irq, void *context, void *arg)
#ifdef CONFIG_BUILD_PROTECTED
case SYS_signal_handler_return:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();

/* Set up to return to the kernel-mode signal dispatching logic. */

Expand All @@ -401,7 +401,7 @@ int arm_svcall(int irq, void *context, void *arg)
default:
{
#ifdef CONFIG_LIB_SYSCALL
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();
int index = rtcb->xcp.nsyscalls;

/* Verify that the SYS call number is within range */
Expand Down
5 changes: 3 additions & 2 deletions arch/arm/src/armv7-a/arm_addrenv_shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "mmu.h"
#include "addrenv.h"
#include "pgalloc.h"
#include "sched/sched.h"

#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_ARCH_VMA_MAPPING)

Expand Down Expand Up @@ -65,7 +66,7 @@

int up_shmat(uintptr_t *pages, unsigned int npages, uintptr_t vaddr)
{
struct tcb_s *tcb = nxsched_self();
struct tcb_s *tcb = this_task();
struct arch_addrenv_s *addrenv;
uintptr_t *l1entry;
uint32_t *l2table;
Expand Down Expand Up @@ -188,7 +189,7 @@ int up_shmat(uintptr_t *pages, unsigned int npages, uintptr_t vaddr)

int up_shmdt(uintptr_t vaddr, unsigned int npages)
{
struct tcb_s *tcb = nxsched_self();
struct tcb_s *tcb = this_task();
struct arch_addrenv_s *addrenv;
uintptr_t *l1entry;
uint32_t *l2table;
Expand Down
3 changes: 2 additions & 1 deletion arch/arm/src/armv7-a/arm_pgalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

#include "mmu.h"
#include "pgalloc.h"
#include "sched/sched.h"

#ifdef CONFIG_BUILD_KERNEL

Expand Down Expand Up @@ -182,7 +183,7 @@ static int get_pgtable(arch_addrenv_t *addrenv, uintptr_t vaddr)

uintptr_t pgalloc(uintptr_t brkaddr, unsigned int npages)
{
struct tcb_s *tcb = nxsched_self();
struct tcb_s *tcb = this_task();
struct arch_addrenv_s *addrenv;
uint32_t *l2table;
irqstate_t flags;
Expand Down
8 changes: 4 additions & 4 deletions arch/arm/src/armv7-a/arm_syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ uint32_t *arm_syscall(uint32_t *regs)
#ifdef CONFIG_LIB_SYSCALL
case SYS_syscall_return:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();
int index = (int)rtcb->xcp.nsyscalls - 1;

/* Make sure that there is a saved SYSCALL return address. */
Expand Down Expand Up @@ -386,7 +386,7 @@ uint32_t *arm_syscall(uint32_t *regs)

case SYS_signal_handler:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();

/* Remember the caller's return address */

Expand Down Expand Up @@ -463,7 +463,7 @@ uint32_t *arm_syscall(uint32_t *regs)

case SYS_signal_handler_return:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();

/* Set up to return to the kernel-mode signal dispatching logic. */

Expand Down Expand Up @@ -500,7 +500,7 @@ uint32_t *arm_syscall(uint32_t *regs)
default:
{
#ifdef CONFIG_LIB_SYSCALL
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();
int index = rtcb->xcp.nsyscalls;

/* Verify that the SYS call number is within range */
Expand Down
8 changes: 4 additions & 4 deletions arch/arm/src/armv7-m/arm_svcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ int arm_svcall(int irq, void *context, void *arg)
#ifdef CONFIG_LIB_SYSCALL
case SYS_syscall_return:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();
int index = (int)rtcb->xcp.nsyscalls - 1;

/* Make sure that there is a saved syscall return address. */
Expand Down Expand Up @@ -343,7 +343,7 @@ int arm_svcall(int irq, void *context, void *arg)
#ifdef CONFIG_BUILD_PROTECTED
case SYS_signal_handler:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();

/* Remember the caller's return address */

Expand Down Expand Up @@ -385,7 +385,7 @@ int arm_svcall(int irq, void *context, void *arg)
#ifdef CONFIG_BUILD_PROTECTED
case SYS_signal_handler_return:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();

/* Set up to return to the kernel-mode signal dispatching logic. */

Expand All @@ -410,7 +410,7 @@ int arm_svcall(int irq, void *context, void *arg)
default:
{
#ifdef CONFIG_LIB_SYSCALL
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();
int index = rtcb->xcp.nsyscalls;

/* Verify that the SYS call number is within range */
Expand Down
8 changes: 4 additions & 4 deletions arch/arm/src/armv7-r/arm_syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ uint32_t *arm_syscall(uint32_t *regs)
#ifdef CONFIG_LIB_SYSCALL
case SYS_syscall_return:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();
int index = (int)rtcb->xcp.nsyscalls - 1;

/* Make sure that there is a saved SYSCALL return address. */
Expand Down Expand Up @@ -382,7 +382,7 @@ uint32_t *arm_syscall(uint32_t *regs)

case SYS_signal_handler:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();

/* Remember the caller's return address */

Expand Down Expand Up @@ -459,7 +459,7 @@ uint32_t *arm_syscall(uint32_t *regs)

case SYS_signal_handler_return:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();

/* Set up to return to the kernel-mode signal dispatching logic. */

Expand Down Expand Up @@ -496,7 +496,7 @@ uint32_t *arm_syscall(uint32_t *regs)
default:
{
#ifdef CONFIG_LIB_SYSCALL
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();
int index = rtcb->xcp.nsyscalls;

/* Verify that the SYS call number is within range */
Expand Down
8 changes: 4 additions & 4 deletions arch/arm/src/armv8-m/arm_svcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ int arm_svcall(int irq, void *context, void *arg)
#ifdef CONFIG_LIB_SYSCALL
case SYS_syscall_return:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();
int index = (int)rtcb->xcp.nsyscalls - 1;

/* Make sure that there is a saved syscall return address. */
Expand Down Expand Up @@ -343,7 +343,7 @@ int arm_svcall(int irq, void *context, void *arg)
#ifdef CONFIG_BUILD_PROTECTED
case SYS_signal_handler:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();

/* Remember the caller's return address */

Expand Down Expand Up @@ -385,7 +385,7 @@ int arm_svcall(int irq, void *context, void *arg)
#ifdef CONFIG_BUILD_PROTECTED
case SYS_signal_handler_return:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();

/* Set up to return to the kernel-mode signal dispatching logic. */

Expand All @@ -411,7 +411,7 @@ int arm_svcall(int irq, void *context, void *arg)
default:
{
#ifdef CONFIG_LIB_SYSCALL
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();
int index = rtcb->xcp.nsyscalls;

/* Verify that the SYS call number is within range */
Expand Down
8 changes: 4 additions & 4 deletions arch/arm/src/armv8-r/arm_syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ uint32_t *arm_syscall(uint32_t *regs)
#ifdef CONFIG_LIB_SYSCALL
case SYS_syscall_return:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();
int index = (int)rtcb->xcp.nsyscalls - 1;

/* Make sure that there is a saved SYSCALL return address. */
Expand Down Expand Up @@ -382,7 +382,7 @@ uint32_t *arm_syscall(uint32_t *regs)

case SYS_signal_handler:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();

/* Remember the caller's return address */

Expand Down Expand Up @@ -459,7 +459,7 @@ uint32_t *arm_syscall(uint32_t *regs)

case SYS_signal_handler_return:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();

/* Set up to return to the kernel-mode signal dispatching logic. */

Expand Down Expand Up @@ -496,7 +496,7 @@ uint32_t *arm_syscall(uint32_t *regs)
default:
{
#ifdef CONFIG_LIB_SYSCALL
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();
int index = rtcb->xcp.nsyscalls;

/* Verify that the SYS call number is within range */
Expand Down
5 changes: 3 additions & 2 deletions arch/arm64/src/common/arm64_addrenv_shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <nuttx/irq.h>
#include <nuttx/pgalloc.h>

#include "sched/sched.h"
#include "addrenv.h"
#include "barriers.h"
#include "pgalloc.h"
Expand Down Expand Up @@ -65,7 +66,7 @@

int up_shmat(uintptr_t *pages, unsigned int npages, uintptr_t vaddr)
{
struct tcb_s *tcb = nxsched_self();
struct tcb_s *tcb = this_task();
struct arch_addrenv_s *addrenv = &tcb->addrenv_own->addrenv;

/* Sanity checks */
Expand Down Expand Up @@ -99,7 +100,7 @@ int up_shmat(uintptr_t *pages, unsigned int npages, uintptr_t vaddr)

int up_shmdt(uintptr_t vaddr, unsigned int npages)
{
struct tcb_s *tcb = nxsched_self();
struct tcb_s *tcb = this_task();
struct arch_addrenv_s *addrenv = &tcb->addrenv_own->addrenv;

/* Sanity checks */
Expand Down
3 changes: 2 additions & 1 deletion arch/arm64/src/common/arm64_pgalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <nuttx/pgalloc.h>
#include <nuttx/sched.h>

#include "sched/sched.h"
#include "addrenv.h"
#include "barriers.h"
#include "pgalloc.h"
Expand Down Expand Up @@ -89,7 +90,7 @@

uintptr_t pgalloc(uintptr_t brkaddr, unsigned int npages)
{
struct tcb_s *tcb = nxsched_self();
struct tcb_s *tcb = this_task();
struct arch_addrenv_s *addrenv;
uintptr_t ptlast;
uintptr_t paddr;
Expand Down
4 changes: 2 additions & 2 deletions arch/arm64/src/common/arm64_syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ int arm64_syscall(uint64_t *regs)

case SYS_signal_handler:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();

/* Remember the caller's return address */

Expand Down Expand Up @@ -377,7 +377,7 @@ int arm64_syscall(uint64_t *regs)

case SYS_signal_handler_return:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();

/* Set up to return to the kernel-mode signal dispatching logic. */

Expand Down
4 changes: 2 additions & 2 deletions arch/mips/src/mips32/mips_swint0.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ int mips_swint0(int irq, void *context, void *arg)
#ifdef CONFIG_BUILD_KERNEL
case SYS_syscall_return:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();
int index = (int)rtcb->xcp.nsyscalls - 1;

/* Make sure that there is a saved syscall return address. */
Expand Down Expand Up @@ -232,7 +232,7 @@ int mips_swint0(int irq, void *context, void *arg)
default:
{
#ifdef CONFIG_BUILD_KERNEL
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();
int index = rtcb->xcp.nsyscalls;

/* Verify that the SYS call number is within range */
Expand Down
4 changes: 2 additions & 2 deletions arch/misoc/src/lm32/lm32_swint.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ int lm32_swint(int irq, void *context, void *arg)
#ifdef CONFIG_BUILD_KERNEL
case SYS_syscall_return:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();
int index = (int)rtcb->xcp.nsyscalls - 1;

/* Make sure that there is a saved syscall return address. */
Expand Down Expand Up @@ -230,7 +230,7 @@ int lm32_swint(int irq, void *context, void *arg)
default:
{
#ifdef CONFIG_BUILD_KERNEL
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();
int index = rtcb->xcp.nsyscalls;

/* Verify that the SYS call number is within range */
Expand Down
4 changes: 2 additions & 2 deletions arch/misoc/src/minerva/minerva_swint.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ int minerva_swint(int irq, void *context, void *arg)
#ifdef CONFIG_BUILD_KERNEL
case SYS_syscall_return:
{
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();
int index = (int)rtcb->xcp.nsyscalls - 1;

/* Make sure that there is a saved syscall return address. */
Expand Down Expand Up @@ -200,7 +200,7 @@ int minerva_swint(int irq, void *context, void *arg)
default:
{
#ifdef CONFIG_BUILD_KERNEL
struct tcb_s *rtcb = nxsched_self();
struct tcb_s *rtcb = this_task();
int index = rtcb->xcp.nsyscalls;

/* Verify that the SYS call number is within range */
Expand Down
4 changes: 2 additions & 2 deletions arch/risc-v/src/common/riscv_addrenv_shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

int up_shmat(uintptr_t *pages, unsigned int npages, uintptr_t vaddr)
{
struct tcb_s *tcb = nxsched_self();
struct tcb_s *tcb = this_task();
struct arch_addrenv_s *addrenv = &tcb->addrenv_own->addrenv;

/* Sanity checks */
Expand Down Expand Up @@ -100,7 +100,7 @@ int up_shmat(uintptr_t *pages, unsigned int npages, uintptr_t vaddr)

int up_shmdt(uintptr_t vaddr, unsigned int npages)
{
struct tcb_s *tcb = nxsched_self();
struct tcb_s *tcb = this_task();
struct arch_addrenv_s *addrenv = &tcb->addrenv_own->addrenv;

/* Sanity checks */
Expand Down
Loading

0 comments on commit 56de6a1

Please sign in to comment.