Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1337294 > unrolled thread
| Started by | Zhi-zhou Zhang <zhizhou.zh@gmail.com> |
|---|---|
| First post | 2016-02-18 12:50 +0100 |
| Last post | 2016-02-19 13:10 +0100 |
| Articles | 5 — 5 participants |
Back to article view | Back to linux.kernel
[PATCH] arm64: add architecture specified current_pt_regs Zhi-zhou Zhang <zhizhou.zh@gmail.com> - 2016-02-18 12:50 +0100
Re: [PATCH] arm64: add architecture specified current_pt_regs Catalin Marinas <catalin.marinas@arm.com> - 2016-02-18 13:00 +0100
Re: [PATCH] arm64: add architecture specified current_pt_regs Zhi-zhou <zhizhou.zh@gmail.com> - 2016-02-19 03:40 +0100
Re: [PATCH] arm64: add architecture specified current_pt_regs Will Deacon <will.deacon@arm.com> - 2016-02-19 11:40 +0100
Re: [PATCH] arm64: add architecture specified current_pt_regs Zhizhou Zhang <zhizhou.zh@gmail.com> - 2016-02-19 13:10 +0100
| From | Zhi-zhou Zhang <zhizhou.zh@gmail.com> |
|---|---|
| Date | 2016-02-18 12:50 +0100 |
| Subject | [PATCH] arm64: add architecture specified current_pt_regs |
| Message-ID | <r3vfQ-4SJ-7@gated-at.bofh.it> |
From: zhizhou <zhizhou.zh@gmail.com>
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.
Signed-off-by: zhizhou <zhizhou.zh@gmail.com>
---
arch/arm64/include/asm/ptrace.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h
index e9e5467..1865d54 100644
--- a/arch/arm64/include/asm/ptrace.h
+++ b/arch/arm64/include/asm/ptrace.h
@@ -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
--
2.5.0
[toc] | [next] | [standalone]
| From | Catalin Marinas <catalin.marinas@arm.com> |
|---|---|
| Date | 2016-02-18 13:00 +0100 |
| Message-ID | <r3vpv-4Wo-1@gated-at.bofh.it> |
| In reply to | #1337294 |
On Thu, Feb 18, 2016 at 07:48:35PM +0800, Zhi-zhou Zhang wrote:
> From: zhizhou <zhizhou.zh@gmail.com>
>
> 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.
Do you have any performance numbers?
> diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h
> index e9e5467..1865d54 100644
> --- a/arch/arm64/include/asm/ptrace.h
> +++ b/arch/arm64/include/asm/ptrace.h
> @@ -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).
--
Catalin
[toc] | [prev] | [next] | [standalone]
| From | Zhi-zhou <zhizhou.zh@gmail.com> |
|---|---|
| Date | 2016-02-19 03:40 +0100 |
| Message-ID | <r3J97-6Cc-3@gated-at.bofh.it> |
| In reply to | #1337295 |
On Thu, Feb 18, 2016 at 7:58 PM, Catalin Marinas
<catalin.marinas@arm.com> wrote:
>
> On Thu, Feb 18, 2016 at 07:48:35PM +0800, Zhi-zhou Zhang wrote:
> > From: zhizhou <zhizhou.zh@gmail.com>
> >
> > 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.
>
> 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.
>
>
> > diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h
> > index e9e5467..1865d54 100644
> > --- a/arch/arm64/include/asm/ptrace.h
> > +++ b/arch/arm64/include/asm/ptrace.h
> > @@ -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).
>
Thank you, that's a problem. So how about write it like this?
diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h
index e9e5467..b68e01c 100644
--- a/arch/arm64/include/asm/ptrace.h
+++ b/arch/arm64/include/asm/ptrace.h
@@ -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
> --
> Catalin
--
Regards,
Zhi-zhou
[toc] | [prev] | [next] | [standalone]
| From | Will Deacon <will.deacon@arm.com> |
|---|---|
| Date | 2016-02-19 11:40 +0100 |
| Message-ID | <r3QDE-3H6-3@gated-at.bofh.it> |
| In reply to | #1337843 |
On Fri, Feb 19, 2016 at 10:30:09AM +0800, Zhi-zhou wrote: > On Thu, Feb 18, 2016 at 7:58 PM, Catalin Marinas > <catalin.marinas@arm.com> wrote: > > > > On Thu, Feb 18, 2016 at 07:48:35PM +0800, Zhi-zhou Zhang wrote: > > > From: zhizhou <zhizhou.zh@gmail.com> > > > > > > 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. > > > > 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. 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
[toc] | [prev] | [next] | [standalone]
| From | Zhizhou Zhang <zhizhou.zh@gmail.com> |
|---|---|
| Date | 2016-02-19 13:10 +0100 |
| Message-ID | <r3S2L-4Vi-37@gated-at.bofh.it> |
| In reply to | #1338038 |
On Fri, Feb 19, 2016 at 6:32 PM, Will Deacon <will.deacon@arm.com> wrote: > On Fri, Feb 19, 2016 at 10:30:09AM +0800, Zhi-zhou wrote: >> On Thu, Feb 18, 2016 at 7:58 PM, Catalin Marinas >> <catalin.marinas@arm.com> wrote: >> > >> > On Thu, Feb 18, 2016 at 07:48:35PM +0800, Zhi-zhou Zhang wrote: >> > > From: zhizhou <zhizhou.zh@gmail.com> >> > > >> > > 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. >> > >> > 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. > > 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? > > Will -- Regards, Zhizhou
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web