arm64: add architecture specified current_pt_regs
Subsystems (2)
PATCH 1/1 arm64: add architecture specified current_pt_regs
From: zhizhou <[email protected]>
This patch is based on the implementation of arm. The generic current_pt_regs is implemented with current->stack. It need to access memory that would be too expensive.
--- arch/arm64/include/asm/ptrace.h | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/include/asm/ptrace.h +4 -0
@@ -185,5 +185,9 @@ static inline int valid_user_regs(struct user_pt_regs *regs)extern unsigned long profile_pc (struct pt_regs *regs); +#define current_pt_regs (void) ({ (struct pt_regs *) \ + ((current_stack_pointer | (THREAD_SIZE - 1)) - 0xf) - 1; \ +}) +#endif /* __ASSEMBLY__ */ #endif
Signature · 1 line
2.5.0
Catalin Marinas
maintainerQuoted 5 lines · Zhi-zhou Zhang
From: zhizhou <[email protected]>
This patch is based on the implementation of arm. The generic
current_pt_regsis implemented withcurrent->stack. It need to access memory that would be too expensive.
Do you have any performance numbers?
arch/arm64/include/asm/ptrace.h static inline int valid_user_regs(struct user_pt_regs *regs) · line 190
Quoted 11 lines
arch/arm64/include/asm/ptrace.h +3
-0@@ -185,5 +185,9 @@ static inline int valid_user_regs(struct user_pt_regs *regs)extern unsigned long profile_pc (struct pt_regs *regs); +#define current_pt_regs (void) ({ (struct pt_regs *) \ + ((current_stack_pointer | (THREAD_SIZE - 1)) - 0xf) - 1; \ +})
I don't think this works well with the separate IRQ stack that we merged in 4.5-rc1. current_thread_info() explicitly uses "sp_el0" while current_stack_pointer is just "sp" (though I don't think we ever use current_pt_regs in interrupt context).
Signature · 1 line
Catalin
Quoted 9 lines · Catalin Marinas
Quoted 5 lines · Zhi-zhou Zhang
From: zhizhou <[email protected]>
This patch is based on the implementation of arm. The generic
current_pt_regsis implemented withcurrent->stack. It need to access memory that would be too expensive.Do you have any performance numbers?
I'm using QEMU, so no. Actually this macro isn't heavily used. I just think using the generic
implementation is not very nice. It get task_struct from sp_el0, then get stack(which is
equal to sp_el0) from task_struct. There are two unnecessary memory accesses.
Quoted 10 lines
Quoted 10 lines
arch/arm64/include/asm/ptrace.h +0
-0@@ -185,5 +185,9 @@ static inline int valid_user_regs(struct user_pt_regs *regs)extern unsigned long profile_pc (struct pt_regs *regs);
Quoted 9 lines
arch/arm64/include/asm/ptrace.h static inline int valid_user_regs(struct user_pt_regs *regs) · line 190
Quoted 3 lines
arch/arm64/include/asm/ptrace.h +3
-0+#define current_pt_regs (void) ({ (struct pt_regs *) \ + ((current_stack_pointer | (THREAD_SIZE - 1)) - 0xf) - 1; \ +})I don't think this works well with the separate IRQ stack that we merged in 4.5-rc1.
current_thread_info()explicitly uses "sp_el0" whilecurrent_stack_pointeris just "sp" (though I don't think we ever usecurrent_pt_regsin interrupt context).
Thank you, that's a problem. So how about write it like this?
arch/arm64/include/asm/ptrace.h +0 -0
@@ -185,5 +185,10 @@ static inline int valid_user_regs(struct
user_pt_regs *regs)
extern unsigned long profile_pc(struct pt_regs *regs);
+#define current_pt_regs(void) ({ (struct pt_regs *) \
+ (((unsigned long)current_thread_info() | \
+ (THREAD_SIZE - 1)) - 0xf) - 1; \+})
+
#endif /* __ASSEMBLY__ */
#endif
Quoted 2 lines
--
Catalin
Signature · 2 lines
Regards, Zhi-zhou
Quoted 10 lines · Zhi-zhou
Quoted 8 lines · Catalin Marinas
Quoted 5 lines · Zhi-zhou Zhang
From: zhizhou <[email protected]>
This patch is based on the implementation of arm. The generic
current_pt_regsis implemented withcurrent->stack. It need to access memory that would be too expensive.
Quoted 7 lines
Quoted 1 line
Do you have any performance numbers?
I'm using QEMU, so no. Actually this macro isn't heavily used. I just think using the generic
implementation is not very nice. It gettask_structfromsp_el0, then get stack(which is
equal tosp_el0) fromtask_struct. There are two unnecessary memory accesses.
I'd much rather use the generic implementation unless there's a compelling reason not to. "I think it's not very nice" doesn't really cut it for me!
Will
Quoted 13 lines · Will Deacon
Quoted 12 lines · Zhi-zhou
Quoted 9 lines · Catalin Marinas
Quoted 5 lines · Zhi-zhou Zhang
From: zhizhou <[email protected]>
This patch is based on the implementation of arm. The generic
current_pt_regsis implemented withcurrent->stack. It need to access memory that would be too expensive.Do you have any performance numbers?
Quoted 8 lines
Quoted 5 lines
I'm using QEMU, so no. Actually this macro isn't heavily used. I just think using the generic
implementation is not very nice. It gettask_structfromsp_el0, then get stack(which is
equal tosp_el0) fromtask_struct. There are two unnecessary memory accesses.I'd much rather use the generic implementation unless there's a compelling reason not to. "I think it's not very nice" doesn't really cut it for me!
Refer to memory twice may incur cache eviction. I'm really a newbie to kernel. Anyway, I have a look at kernel and I'm very curious what's the 'compelling reason' of 16 architectures implement their own current_pt_regs?
Quoted 2 lines
Will
Signature · 2 lines
Regards, Zhizhou