From: Raj Vishwanathan <raj.vishwanathan@gmail.com>
To: opensbi@lists.infradead.org
Subject: [PATCH v2] Align SBI trap registers to a nice boundary for performance reasons.
Date: Thu, 6 Feb 2025 11:22:40 -0800 [thread overview]
Message-ID: <20250206192240.142107-1-Raj.Vishwanathan@gmail.com> (raw)
In-Reply-To: <20250109235219.2568-1-cfu@mips.com>
Align SBI_TRAP_CONTEXT_SIZE to a multiple of 16 bytes. If it is not
aligned to 16 bytes for RV64, it can create performance problems.
Aligning it correctly can fix the performance issues.
Signed-off-by: Raj Vishwanathan <Raj.Vishwanathan@gmail.com>
--
Test: Performance issues seen and fix Verified on FPGA.
Other methods.
Run qemu with monitor to check the SP during cpu_in
and cpu_out.
Add sbi_printf to the function sbi_trap_handler to check
the alignment of sbi_trap_context
---
include/sbi/sbi_trap.h | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/include/sbi/sbi_trap.h b/include/sbi/sbi_trap.h
index d5182bf..82e9c08 100644
--- a/include/sbi/sbi_trap.h
+++ b/include/sbi/sbi_trap.h
@@ -112,13 +112,16 @@
/** Size (in bytes) of sbi_trap_info */
#define SBI_TRAP_INFO_SIZE SBI_TRAP_INFO_OFFSET(last)
+/** Stack pointer is aligned to 16 bytes */
+#define STACK_BOUNDARY 16
+#define ALIGN_TO_BOUNDARY(x,a) (((x) + (a) - 1) & ~((a) - 1))
+
/** Size (in bytes) of sbi_trap_context */
-#define SBI_TRAP_CONTEXT_SIZE (SBI_TRAP_REGS_SIZE + \
- SBI_TRAP_INFO_SIZE + \
- __SIZEOF_POINTER__)
+#define SBI_TRAP_CONTEXT_SIZE ALIGN_TO_BOUNDARY((SBI_TRAP_REGS_SIZE + \
+ SBI_TRAP_INFO_SIZE + \
+ __SIZEOF_POINTER__),STACK_BOUNDARY)
#ifndef __ASSEMBLER__
-
#include <sbi/sbi_types.h>
#include <sbi/sbi_scratch.h>
--
2.43.0
next prev parent reply other threads:[~2025-02-06 19:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-09 23:52 [PATCH] Add a dummy register to sbi_trap_regs Chao-ying Fu
2025-01-10 0:30 ` Jessica Clarke
2025-01-10 1:44 ` Chao-ying Fu
2025-02-06 19:22 ` Raj Vishwanathan [this message]
2025-02-08 5:34 ` [PATCH v2] Align SBI trap registers to a nice boundary for performance reasons Samuel Holland
2025-02-10 22:54 ` [EXTERNAL]Re: " Raj Vishwanathan
2025-02-10 22:47 ` Raj Vishwanathan
2025-02-11 2:49 ` Xiang W
2025-02-11 4:48 ` Anup Patel
2025-02-11 21:46 ` [PATCH v2] include: sbi: Align SBI trap registers to a nice boundary Raj Vishwanathan
2025-02-12 4:00 ` Anup Patel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250206192240.142107-1-Raj.Vishwanathan@gmail.com \
--to=raj.vishwanathan@gmail.com \
--cc=opensbi@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox