mbox series

[v4,0/2] riscv: introduce vDSO common flow

Message ID 1591712089-12904-1-git-send-email-vincent.chen@sifive.com (mailing list archive)
Headers show
Series riscv: introduce vDSO common flow | expand

Message

Vincent Chen June 9, 2020, 2:14 p.m. UTC
Even if RISC-V has supported the vDSO feature, the latency of the functions
for obtaining the system time is still expensive. It is because these
functions still trigger a corresponding system call in the process, which
slows down the response time. If we want to remove the system call to
reduce the latency, the kernel should have the ability to output the system
clock information to userspace. This patch introduces the vDSO common flow
to enable the kernel to achieve the above feature and uses "rdtime"
instruction to obtain the current time in the user space. Under this
condition, the latency cost by the ecall from U-mode to S-mode can be
eliminated. After applying this patch, the latency of gettimeofday()
measured on the HiFive unleashed board can be reduced by %61.


change since v3:
1. Fix build warnings reported by kbuild system

change since v2:
1. Fix build errors that occurred in the case of rv32 and nommu.

change since v1:
1. Modify the permission of vdso_data to read-only

Vincent Chen (2):
  riscv: use vDSO common flow to reduce the latency of the time-related
    functions
  riscv: set the permission of vdso_data to read-only

 arch/riscv/Kconfig                         |  4 ++
 arch/riscv/include/asm/clocksource.h       |  7 +++
 arch/riscv/include/asm/processor.h         | 12 +----
 arch/riscv/include/asm/vdso.h              |  2 +
 arch/riscv/include/asm/vdso/clocksource.h  |  8 +++
 arch/riscv/include/asm/vdso/gettimeofday.h | 79 ++++++++++++++++++++++++++++++
 arch/riscv/include/asm/vdso/processor.h    | 19 +++++++
 arch/riscv/include/asm/vdso/vsyscall.h     | 27 ++++++++++
 arch/riscv/kernel/time.c                   |  9 ++++
 arch/riscv/kernel/vdso.c                   | 24 +++++++--
 arch/riscv/kernel/vdso/Makefile            | 12 +++--
 arch/riscv/kernel/vdso/clock_getres.S      | 18 -------
 arch/riscv/kernel/vdso/clock_gettime.S     | 18 -------
 arch/riscv/kernel/vdso/gettimeofday.S      | 18 -------
 arch/riscv/kernel/vdso/vdso.lds.S          |  2 +
 arch/riscv/kernel/vdso/vgettimeofday.c     | 25 ++++++++++
 16 files changed, 213 insertions(+), 71 deletions(-)
 create mode 100644 arch/riscv/include/asm/clocksource.h
 create mode 100644 arch/riscv/include/asm/vdso/clocksource.h
 create mode 100644 arch/riscv/include/asm/vdso/gettimeofday.h
 create mode 100644 arch/riscv/include/asm/vdso/processor.h
 create mode 100644 arch/riscv/include/asm/vdso/vsyscall.h
 delete mode 100644 arch/riscv/kernel/vdso/clock_getres.S
 delete mode 100644 arch/riscv/kernel/vdso/clock_gettime.S
 delete mode 100644 arch/riscv/kernel/vdso/gettimeofday.S
 create mode 100644 arch/riscv/kernel/vdso/vgettimeofday.c

Comments

Palmer Dabbelt June 11, 2020, 2:50 a.m. UTC | #1
On Tue, 09 Jun 2020 07:14:47 PDT (-0700), vincent.chen@sifive.com wrote:
> Even if RISC-V has supported the vDSO feature, the latency of the functions
> for obtaining the system time is still expensive. It is because these
> functions still trigger a corresponding system call in the process, which
> slows down the response time. If we want to remove the system call to
> reduce the latency, the kernel should have the ability to output the system
> clock information to userspace. This patch introduces the vDSO common flow
> to enable the kernel to achieve the above feature and uses "rdtime"
> instruction to obtain the current time in the user space. Under this
> condition, the latency cost by the ecall from U-mode to S-mode can be
> eliminated. After applying this patch, the latency of gettimeofday()
> measured on the HiFive unleashed board can be reduced by %61.
>
>
> change since v3:
> 1. Fix build warnings reported by kbuild system
>
> change since v2:
> 1. Fix build errors that occurred in the case of rv32 and nommu.
>
> change since v1:
> 1. Modify the permission of vdso_data to read-only
>
> Vincent Chen (2):
>   riscv: use vDSO common flow to reduce the latency of the time-related
>     functions
>   riscv: set the permission of vdso_data to read-only
>
>  arch/riscv/Kconfig                         |  4 ++
>  arch/riscv/include/asm/clocksource.h       |  7 +++
>  arch/riscv/include/asm/processor.h         | 12 +----
>  arch/riscv/include/asm/vdso.h              |  2 +
>  arch/riscv/include/asm/vdso/clocksource.h  |  8 +++
>  arch/riscv/include/asm/vdso/gettimeofday.h | 79 ++++++++++++++++++++++++++++++
>  arch/riscv/include/asm/vdso/processor.h    | 19 +++++++
>  arch/riscv/include/asm/vdso/vsyscall.h     | 27 ++++++++++
>  arch/riscv/kernel/time.c                   |  9 ++++
>  arch/riscv/kernel/vdso.c                   | 24 +++++++--
>  arch/riscv/kernel/vdso/Makefile            | 12 +++--
>  arch/riscv/kernel/vdso/clock_getres.S      | 18 -------
>  arch/riscv/kernel/vdso/clock_gettime.S     | 18 -------
>  arch/riscv/kernel/vdso/gettimeofday.S      | 18 -------
>  arch/riscv/kernel/vdso/vdso.lds.S          |  2 +
>  arch/riscv/kernel/vdso/vgettimeofday.c     | 25 ++++++++++
>  16 files changed, 213 insertions(+), 71 deletions(-)
>  create mode 100644 arch/riscv/include/asm/clocksource.h
>  create mode 100644 arch/riscv/include/asm/vdso/clocksource.h
>  create mode 100644 arch/riscv/include/asm/vdso/gettimeofday.h
>  create mode 100644 arch/riscv/include/asm/vdso/processor.h
>  create mode 100644 arch/riscv/include/asm/vdso/vsyscall.h
>  delete mode 100644 arch/riscv/kernel/vdso/clock_getres.S
>  delete mode 100644 arch/riscv/kernel/vdso/clock_gettime.S
>  delete mode 100644 arch/riscv/kernel/vdso/gettimeofday.S
>  create mode 100644 arch/riscv/kernel/vdso/vgettimeofday.c

Thanks, these are on for-next.