linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/1] Provide the frequency of time CSR via hwprobe
@ 2024-07-02  3:37 Yunhui Cui
  2024-07-02  3:37 ` [PATCH v4] RISC-V: " Yunhui Cui
  0 siblings, 1 reply; 5+ messages in thread
From: Yunhui Cui @ 2024-07-02  3:37 UTC (permalink / raw)
  To: punit.agrawal, sunilvl, jesse, jrtc27, corbet, paul.walmsley,
	palmer, aou, cleger, evan, conor.dooley, cuiyunhui, costa.shul,
	andy.chiu, samitolvanen, linux-doc, linux-riscv, linux-kernel

Some applications (e.g., DPDK) use the time counter for basic performance
analysis as well as fine grained time-keeping. So we need export the time CSR
frequency to userspace by hwporbe syscall.

Changes:
v1->v2:
Modify "mtime" to "time CSR".

v2->v3:
Rebase "RISCV_HWPROBE_MAX_KEY 7" to "RISCV_HWPROBE_MAX_KEY 8" from
Jesse.

v3->v4:
1. Update the commit log from Punit.

2. Because RISCV_HWPROBE_MAX_KEY in
https://git.kernel.org/pub/scm/linux/kernel/git/palmer/linux.git/tree/arch/riscv/include/asm/hwprobe.h?h=for-next is 6,
so keep RISCV_HWPROBE_MAX_KEY to 7

Palmer Dabbelt (1):
  RISC-V: Provide the frequency of time CSR via hwprobe

 Documentation/arch/riscv/hwprobe.rst  | 2 ++
 arch/riscv/include/asm/hwprobe.h      | 2 +-
 arch/riscv/include/uapi/asm/hwprobe.h | 1 +
 arch/riscv/kernel/sys_hwprobe.c       | 5 +++++
 4 files changed, 9 insertions(+), 1 deletion(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v4] RISC-V: Provide the frequency of time CSR via hwprobe
  2024-07-02  3:37 [PATCH v4 0/1] Provide the frequency of time CSR via hwprobe Yunhui Cui
@ 2024-07-02  3:37 ` Yunhui Cui
  2024-07-10  9:39   ` Punit Agrawal
  2024-07-25 13:20   ` patchwork-bot+linux-riscv
  0 siblings, 2 replies; 5+ messages in thread
From: Yunhui Cui @ 2024-07-02  3:37 UTC (permalink / raw)
  To: punit.agrawal, sunilvl, jesse, jrtc27, corbet, paul.walmsley,
	palmer, aou, cleger, evan, conor.dooley, cuiyunhui, costa.shul,
	andy.chiu, samitolvanen, linux-doc, linux-riscv, linux-kernel
  Cc: Palmer Dabbelt, Anup Patel

From: Palmer Dabbelt <palmer@rivosinc.com>

The RISC-V architecture makes a real time counter CSR (via RDTIME
instruction) available for applications in U-mode but there is no
architected mechanism for an application to discover the frequency
the counter is running at. Some applications (e.g., DPDK) use the
time counter for basic performance analysis as well as fine grained
time-keeping.

Add support to the hwprobe system call to export the time CSR
frequency to code running in U-mode.

Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
Reviewed-by: Evan Green <evan@rivosinc.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Acked-by: Punit Agrawal <punit.agrawal@bytedance.com>
---
 Documentation/arch/riscv/hwprobe.rst  | 2 ++
 arch/riscv/include/asm/hwprobe.h      | 2 +-
 arch/riscv/include/uapi/asm/hwprobe.h | 1 +
 arch/riscv/kernel/sys_hwprobe.c       | 5 +++++
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/Documentation/arch/riscv/hwprobe.rst b/Documentation/arch/riscv/hwprobe.rst
index 25d783be2878..e99008fc4501 100644
--- a/Documentation/arch/riscv/hwprobe.rst
+++ b/Documentation/arch/riscv/hwprobe.rst
@@ -257,3 +257,5 @@ The following keys are defined:
 
 * :c:macro:`RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE`: An unsigned int which
   represents the size of the Zicboz block in bytes.
+
+* :c:macro:`RISCV_HWPROBE_KEY_TIME_CSR_FREQ`: Frequency (in Hz) of `time CSR`.
diff --git a/arch/riscv/include/asm/hwprobe.h b/arch/riscv/include/asm/hwprobe.h
index 630507dff5ea..150a9877b0af 100644
--- a/arch/riscv/include/asm/hwprobe.h
+++ b/arch/riscv/include/asm/hwprobe.h
@@ -8,7 +8,7 @@
 
 #include <uapi/asm/hwprobe.h>
 
-#define RISCV_HWPROBE_MAX_KEY 6
+#define RISCV_HWPROBE_MAX_KEY 7
 
 static inline bool riscv_hwprobe_key_is_valid(__s64 key)
 {
diff --git a/arch/riscv/include/uapi/asm/hwprobe.h b/arch/riscv/include/uapi/asm/hwprobe.h
index 920fc6a586c9..8094b45fe16f 100644
--- a/arch/riscv/include/uapi/asm/hwprobe.h
+++ b/arch/riscv/include/uapi/asm/hwprobe.h
@@ -79,6 +79,7 @@ struct riscv_hwprobe {
 #define		RISCV_HWPROBE_MISALIGNED_UNSUPPORTED	(4 << 0)
 #define		RISCV_HWPROBE_MISALIGNED_MASK		(7 << 0)
 #define RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE	6
+#define RISCV_HWPROBE_KEY_TIME_CSR_FREQ	7
 /* Increase RISCV_HWPROBE_MAX_KEY when adding items. */
 
 /* Flags */
diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwprobe.c
index 3d1aa13a0bb2..45f32a60b9c3 100644
--- a/arch/riscv/kernel/sys_hwprobe.c
+++ b/arch/riscv/kernel/sys_hwprobe.c
@@ -8,6 +8,7 @@
 #include <asm/cacheflush.h>
 #include <asm/cpufeature.h>
 #include <asm/hwprobe.h>
+#include <asm/delay.h>
 #include <asm/sbi.h>
 #include <asm/switch_to.h>
 #include <asm/uaccess.h>
@@ -232,6 +233,10 @@ static void hwprobe_one_pair(struct riscv_hwprobe *pair,
 			pair->value = riscv_cboz_block_size;
 		break;
 
+	case RISCV_HWPROBE_KEY_TIME_CSR_FREQ:
+		pair->value = riscv_timebase;
+		break;
+
 	/*
 	 * For forward compatibility, unknown keys don't fail the whole
 	 * call, but get their element key set to -1 and value set to 0
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v4] RISC-V: Provide the frequency of time CSR via hwprobe
  2024-07-02  3:37 ` [PATCH v4] RISC-V: " Yunhui Cui
@ 2024-07-10  9:39   ` Punit Agrawal
  2024-07-22 21:05     ` Punit Agrawal
  2024-07-25 13:20   ` patchwork-bot+linux-riscv
  1 sibling, 1 reply; 5+ messages in thread
From: Punit Agrawal @ 2024-07-10  9:39 UTC (permalink / raw)
  To: paul.walmsley, palmer
  Cc: punit.agrawal, sunilvl, jesse, jrtc27, corbet, aou, cleger, evan,
	conor.dooley, costa.shul, andy.chiu, samitolvanen, linux-doc,
	linux-riscv, linux-kernel, Anup Patel, Yunhui Cui, Palmer Dabbelt

Hi,

Yunhui Cui <cuiyunhui@bytedance.com> writes:

> From: Palmer Dabbelt <palmer@rivosinc.com>
>
> The RISC-V architecture makes a real time counter CSR (via RDTIME
> instruction) available for applications in U-mode but there is no
> architected mechanism for an application to discover the frequency
> the counter is running at. Some applications (e.g., DPDK) use the
> time counter for basic performance analysis as well as fine grained
> time-keeping.
>
> Add support to the hwprobe system call to export the time CSR
> frequency to code running in U-mode.
>
> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
> Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
> Reviewed-by: Evan Green <evan@rivosinc.com>
> Reviewed-by: Anup Patel <anup@brainfault.org>
> Acked-by: Punit Agrawal <punit.agrawal@bytedance.com>
> ---
>  Documentation/arch/riscv/hwprobe.rst  | 2 ++
>  arch/riscv/include/asm/hwprobe.h      | 2 +-
>  arch/riscv/include/uapi/asm/hwprobe.h | 1 +
>  arch/riscv/kernel/sys_hwprobe.c       | 5 +++++
>  4 files changed, 9 insertions(+), 1 deletion(-)

The commit looks ready to be merged. Will this picked up for the 6.11
release?

Once this is merged, we can send out the DPDK change relying on the
newly added key.

Thanks,
Punit

[...]


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4] RISC-V: Provide the frequency of time CSR via hwprobe
  2024-07-10  9:39   ` Punit Agrawal
@ 2024-07-22 21:05     ` Punit Agrawal
  0 siblings, 0 replies; 5+ messages in thread
From: Punit Agrawal @ 2024-07-22 21:05 UTC (permalink / raw)
  To: palmer, Palmer Dabbelt
  Cc: paul.walmsley, costa.shul, aou, samitolvanen, corbet, Anup Patel,
	linux-doc, linux-kernel, jesse, conor.dooley, Yunhui Cui,
	andy.chiu, cleger, linux-riscv, jrtc27, evan, Punit Agrawal

Punit Agrawal <punit.agrawal@bytedance.com> writes:

> Hi,
>
> Yunhui Cui <cuiyunhui@bytedance.com> writes:
>
>> From: Palmer Dabbelt <palmer@rivosinc.com>
>>
>> The RISC-V architecture makes a real time counter CSR (via RDTIME
>> instruction) available for applications in U-mode but there is no
>> architected mechanism for an application to discover the frequency
>> the counter is running at. Some applications (e.g., DPDK) use the
>> time counter for basic performance analysis as well as fine grained
>> time-keeping.
>>
>> Add support to the hwprobe system call to export the time CSR
>> frequency to code running in U-mode.
>>
>> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
>> Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
>> Reviewed-by: Evan Green <evan@rivosinc.com>
>> Reviewed-by: Anup Patel <anup@brainfault.org>
>> Acked-by: Punit Agrawal <punit.agrawal@bytedance.com>
>> ---
>>  Documentation/arch/riscv/hwprobe.rst  | 2 ++
>>  arch/riscv/include/asm/hwprobe.h      | 2 +-
>>  arch/riscv/include/uapi/asm/hwprobe.h | 1 +
>>  arch/riscv/kernel/sys_hwprobe.c       | 5 +++++
>>  4 files changed, 9 insertions(+), 1 deletion(-)
>
> The commit looks ready to be merged. Will this picked up for the 6.11
> release?
>
> Once this is merged, we can send out the DPDK change relying on the
> newly added key.

I see the first part of RISC-V patches got merged for 6.11. Any chance
for this patch to still make it for this cycle?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4] RISC-V: Provide the frequency of time CSR via hwprobe
  2024-07-02  3:37 ` [PATCH v4] RISC-V: " Yunhui Cui
  2024-07-10  9:39   ` Punit Agrawal
@ 2024-07-25 13:20   ` patchwork-bot+linux-riscv
  1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+linux-riscv @ 2024-07-25 13:20 UTC (permalink / raw)
  To: Yunhui Cui
  Cc: linux-riscv, punit.agrawal, sunilvl, jesse, jrtc27, corbet,
	paul.walmsley, palmer, aou, cleger, evan, conor.dooley,
	costa.shul, andy.chiu, samitolvanen, linux-doc, linux-kernel,
	palmer, anup

Hello:

This patch was applied to riscv/linux.git (for-next)
by Palmer Dabbelt <palmer@rivosinc.com>:

On Tue,  2 Jul 2024 11:37:31 +0800 you wrote:
> From: Palmer Dabbelt <palmer@rivosinc.com>
> 
> The RISC-V architecture makes a real time counter CSR (via RDTIME
> instruction) available for applications in U-mode but there is no
> architected mechanism for an application to discover the frequency
> the counter is running at. Some applications (e.g., DPDK) use the
> time counter for basic performance analysis as well as fine grained
> time-keeping.
> 
> [...]

Here is the summary with links:
  - [v4] RISC-V: Provide the frequency of time CSR via hwprobe
    https://git.kernel.org/riscv/c/2709e400c2e0

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-07-25 13:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-02  3:37 [PATCH v4 0/1] Provide the frequency of time CSR via hwprobe Yunhui Cui
2024-07-02  3:37 ` [PATCH v4] RISC-V: " Yunhui Cui
2024-07-10  9:39   ` Punit Agrawal
2024-07-22 21:05     ` Punit Agrawal
2024-07-25 13:20   ` patchwork-bot+linux-riscv

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).