* Re: [PATCH] update fix X86_64 procfs provide stack information for threads
2009-11-03 9:06 ` Stefani Seibold
@ 2009-11-03 18:16 ` Ingo Molnar
2009-11-05 8:19 ` [PATCH] RFC x86_64 more accurate KSTK_ESP implementation Stefani Seibold
` (2 subsequent siblings)
3 siblings, 0 replies; 21+ messages in thread
From: Ingo Molnar @ 2009-11-03 18:16 UTC (permalink / raw)
To: Stefani Seibold
Cc: linux-kernel, Andrew Morton, Americo Wang, H. Peter Anvin,
Thomas Gleixner
* Stefani Seibold <stefani@seibold.net> wrote:
> Am Dienstag, den 03.11.2009, 09:28 +0100 schrieb Ingo Molnar:
> > > --- linux-2.6.32-rc5/arch/x86/include/asm/processor.h 2009-10-16 02:41:50.000000000 +0200
> > > +++ linux-2.6.32-rc5.new/arch/x86/include/asm/processor.h 2009-11-02 10:39:47.177909657 +0100
> > > @@ -1000,7 +1001,13 @@
> > > #define thread_saved_pc(t) (*(unsigned long *)((t)->thread.sp - 8))
> > >
> > > #define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.sp0 - 1)
> > > -#define KSTK_ESP(tsk) -1 /* sorry. doesn't work for syscall. */
> > > +
> > > +#ifdef CONFIG_IA32_EMULATION
> > > +extern unsigned long KSTK_ESP(struct task_struct *task);
> > > +#else
> > > +#define KSTK_ESP(task) ((task)->thread.usersp)
> > > +#endif
> > > +
> > > #endif /* CONFIG_X86_64 */
> > >
> > > extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
> > > --- linux-2.6.32-rc5/arch/x86/kernel/process_64.c 2009-10-16 02:41:50.000000000 +0200
> > > +++ linux-2.6.32-rc5.new/arch/x86/kernel/process_64.c 2009-11-02 10:48:23.614936810 +0100
> > > @@ -664,3 +669,11 @@
> > > return do_arch_prctl(current, code, addr);
> > > }
> > >
> > > +#ifdef CONFIG_IA32_EMULATION
> > > +unsigned long KSTK_ESP(struct task_struct *task)
> > > +{
> > > + return (test_tsk_thread_flag(task, TIF_IA32)) ? \
> > > + (task_pt_regs(task)->sp) : \
> > > + ((task)->thread.usersp);
> > > +}
> > > +#endif
> >
> > That's quite ugly. The KSTK_ESP() function should be unconditional and
> > the #ifdef should be eliminated. If CONFIG_IA32_EMULATION is turned off
> > (whichis rare) then TIF_IA32 wont be set so the function should work
> > fine.
> >
> > Thanks,
> >
> > Ingo
>
> Hi Ingo,
>
> come on, thats not fair. [...]
(Hacking the kernel is rarely 'fair' in the way you seem to be defining
it.)
> [...] This would be not the only piece of ugly code in the x86_64
> implementation. It is much better than the previous hack where
> KSTK_ESP always returns a wrong hard coded value. That is really
> ugly!!!!
>
> It took me 6 hours to analyze the x64_64 code, most of them written in
> assembler. I think it is a first solution, which makes the procfs
> stack information work on this architecture and that was the goal.
>
> I will remove the #ifdef's and repost the patch. Please accept this
> patch, which make the KSTP_ESP thing on x86_64 better as before.
>
> I am not a x64_64 bit hacker, i have not the knowledge to make a
> perfect solution for this architecture. Also i am not a full time
> kernel hacker, i have customers who wait for their projects.
The cleanup isnt really that hard at all, writng your mail probably took
more time. I didnt see you complain when we merged your original procfs
patch that introduced/exposed this whole issue:
d899bf7: procfs: provide stack information for threads
Fixing followup issues is standard part of the work-with-upstream
fairness equation.
Ingo
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH] RFC x86_64 more accurate KSTK_ESP implementation
2009-11-03 9:06 ` Stefani Seibold
2009-11-03 18:16 ` Ingo Molnar
@ 2009-11-05 8:19 ` Stefani Seibold
2009-11-05 11:08 ` Andi Kleen
2009-11-08 11:35 ` Ingo Molnar
2009-11-05 13:02 ` [PATCH] fix /proc/<pid>/stat stack pointer for kernel threads Stefani Seibold
2009-11-13 8:01 ` [tip:x86/urgent] fs: " Stefani Seibold
3 siblings, 2 replies; 21+ messages in thread
From: Stefani Seibold @ 2009-11-05 8:19 UTC (permalink / raw)
To: linux-kernel, Andrew Morton, H. Peter Anvin, Americo Wang,
Thomas Gleixner, Ingo Molnar, Andi Kleen
Hi,
this is a RFC for a more accurate KSTK_ESP implementation for the x86_64
architecture.
Because the usersp will be only updated by a context switch this value
is most of the time outdated. This patch update the per CPU variable
old_rsp in the device and timer interrupt too.
In my opinion this can be save done if the current stack pointer is
outside the kernel stack of the current task and the instruction pointer
is not inside the kernel.
The old_rsp value will be stored in usersp in case of a context switch.
The KSTK_ESP will get the value from old_rsp in case the task is the
current task, otherwise it will read usersp.
I know about the performance coast, so this is why i ask for comments.
Stefani
Signed-off-by: Stefani Seibold <stefani@seibold.net>
include/asm/processor.h | 4 +++-
kernel/apic/apic.c | 3 +++
kernel/irq_64.c | 1 +
kernel/process_64.c | 20 ++++++++++++++++++++
4 files changed, 27 insertions(+), 1 deletion(-)
--- linux-2.6.32-rc5.old/arch/x86/include/asm/processor.h 2009-10-16 02:41:50.000000000 +0200
+++ linux-2.6.32-rc5.new/arch/x86/include/asm/processor.h 2009-11-05 08:28:23.765300812 +0100
@@ -1000,7 +1000,7 @@
#define thread_saved_pc(t) (*(unsigned long *)((t)->thread.sp - 8))
#define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.sp0 - 1)
-#define KSTK_ESP(tsk) -1 /* sorry. doesn't work for syscall. */
+extern unsigned long KSTK_ESP(struct task_struct *task);
#endif /* CONFIG_X86_64 */
extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
@@ -1052,4 +1052,6 @@
return ratio;
}
+extern void update_usersp(struct pt_regs *regs);
+
#endif /* _ASM_X86_PROCESSOR_H */
--- linux-2.6.32-rc5.old/arch/x86/kernel/process_64.c 2009-10-16 02:41:50.000000000 +0200
+++ linux-2.6.32-rc5.new/arch/x86/kernel/process_64.c 2009-11-05 08:52:39.965227285 +0100
@@ -664,3 +664,23 @@
return do_arch_prctl(current, code, addr);
}
+void update_usersp(struct pt_regs *regs)
+{
+ unsigned long stk = (unsigned long)task_stack_page(current);
+ unsigned long stkp = (regs)->sp;
+
+ if (((stkp < stk) || (stkp >= stk + THREAD_SIZE))
+ && regs->ip < PAGE_OFFSET)
+ percpu_write(old_rsp, stkp);
+}
+
+unsigned long KSTK_ESP(struct task_struct *task)
+{
+ if (test_tsk_thread_flag(task, TIF_IA32))
+ return task_pt_regs(task)->sp;
+
+ if (task != current)
+ return task->thread.usersp;
+
+ return percpu_read(old_rsp);
+}
--- linux-2.6.32-rc5.old/arch/x86/kernel/irq_64.c 2009-10-16 02:41:50.000000000 +0200
+++ linux-2.6.32-rc5.new/arch/x86/kernel/irq_64.c 2009-11-04 22:29:55.762951577 +0100
@@ -53,6 +53,7 @@
struct irq_desc *desc;
stack_overflow_check(regs);
+ update_usersp(regs);
desc = irq_to_desc(irq);
if (unlikely(!desc))
--- linux-2.6.32-rc5.old/arch/x86/kernel/apic/apic.c 2009-10-16 02:41:50.000000000 +0200
+++ linux-2.6.32-rc5.new/arch/x86/kernel/apic/apic.c 2009-11-04 23:12:32.805086991 +0100
@@ -831,6 +831,9 @@
{
struct pt_regs *old_regs = set_irq_regs(regs);
+#ifndef CONFIG_X86_32
+ update_usersp(regs);
+#endif
/*
* NOTE! We'd better ACK the irq immediately,
* because timer handling can be slow.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] RFC x86_64 more accurate KSTK_ESP implementation
2009-11-05 8:19 ` [PATCH] RFC x86_64 more accurate KSTK_ESP implementation Stefani Seibold
@ 2009-11-05 11:08 ` Andi Kleen
2009-11-05 12:11 ` Stefani Seibold
2009-11-08 11:35 ` Ingo Molnar
1 sibling, 1 reply; 21+ messages in thread
From: Andi Kleen @ 2009-11-05 11:08 UTC (permalink / raw)
To: Stefani Seibold
Cc: linux-kernel, Andrew Morton, H. Peter Anvin, Americo Wang,
Thomas Gleixner, Ingo Molnar, Andi Kleen
> +void update_usersp(struct pt_regs *regs)
> +{
> + unsigned long stk = (unsigned long)task_stack_page(current);
> + unsigned long stkp = (regs)->sp;
> +
> + if (((stkp < stk) || (stkp >= stk + THREAD_SIZE))
> + && regs->ip < PAGE_OFFSET)
> + percpu_write(old_rsp, stkp);
This does not handle interrupt and exception stacks correctly.
Also regs->ip is never a safe check for running in user space,
because a program can set the IP to a arbitrary value for a one
instruction window.
The larger problem is also if the kernel moves to no-tick-for-non-idle
(which I guess will happen sooner or later) your method won't
work anyways, or again be arbitarily inaccurate. Even today 10ms
worst time inaccuracy for HZ=100 is rather bad, there can be a lot of stack
allocations in that time. And adding new dependencies on a regular
timer when everything else is moving away from that doesn't seem right.
Also I suspect this method won't work on preempt-rt without
additional tweaks.
-Andi
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] RFC x86_64 more accurate KSTK_ESP implementation
2009-11-05 11:08 ` Andi Kleen
@ 2009-11-05 12:11 ` Stefani Seibold
0 siblings, 0 replies; 21+ messages in thread
From: Stefani Seibold @ 2009-11-05 12:11 UTC (permalink / raw)
To: Andi Kleen
Cc: linux-kernel, Andrew Morton, H. Peter Anvin, Americo Wang,
Thomas Gleixner, Ingo Molnar
Am Donnerstag, den 05.11.2009, 12:08 +0100 schrieb Andi Kleen:
> > +void update_usersp(struct pt_regs *regs)
> > +{
> > + unsigned long stk = (unsigned long)task_stack_page(current);
> > + unsigned long stkp = (regs)->sp;
> > +
> > + if (((stkp < stk) || (stkp >= stk + THREAD_SIZE))
> > + && regs->ip < PAGE_OFFSET)
> > + percpu_write(old_rsp, stkp);
>
> This does not handle interrupt and exception stacks correctly.
>
> Also regs->ip is never a safe check for running in user space,
> because a program can set the IP to a arbitrary value for a one
> instruction window.
>
I think this doesn't matter, because i want only detect if it is save to
wrire the old_rsp value. There are only three places in the kernel where
this value will be writen, all of them are in the kernel. So checking if
the ip is in the kernel and the stack pointer points outside the kernel
stack of the current task will be enough. Or i am wrong?
> The larger problem is also if the kernel moves to no-tick-for-non-idle
> (which I guess will happen sooner or later) your method won't
> work anyways, or again be arbitarily inaccurate. Even today 10ms
> worst time inaccuracy for HZ=100 is rather bad, there can be a lot of stack
> allocations in that time. And adding new dependencies on a regular
> timer when everything else is moving away from that doesn't seem right.
The value is correct in case of on uni processor system. In an multi
core system it is a good approximation. A quick look into other
architectures shows that this is not a x86_64 issue. All architecture
give you only a snapshot.
But this is good enough for ps or /proc usage. If someone want an exact
value, then it is necessary to stop the task.
>
> Also I suspect this method won't work on preempt-rt without
> additional tweaks.
>
That is a other issue. Let us first fix and agree about the basics.
Stefani
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] RFC x86_64 more accurate KSTK_ESP implementation
2009-11-05 8:19 ` [PATCH] RFC x86_64 more accurate KSTK_ESP implementation Stefani Seibold
2009-11-05 11:08 ` Andi Kleen
@ 2009-11-08 11:35 ` Ingo Molnar
2009-11-08 12:51 ` Stefani Seibold
2009-11-08 19:37 ` Andi Kleen
1 sibling, 2 replies; 21+ messages in thread
From: Ingo Molnar @ 2009-11-08 11:35 UTC (permalink / raw)
To: Stefani Seibold
Cc: linux-kernel, Andrew Morton, H. Peter Anvin, Americo Wang,
Thomas Gleixner, Andi Kleen
* Stefani Seibold <stefani@seibold.net> wrote:
> Hi,
>
> this is a RFC for a more accurate KSTK_ESP implementation for the x86_64
> architecture.
>
> Because the usersp will be only updated by a context switch this value
> is most of the time outdated. This patch update the per CPU variable
> old_rsp in the device and timer interrupt too.
>
> In my opinion this can be save done if the current stack pointer is
> outside the kernel stack of the current task and the instruction pointer
> is not inside the kernel.
>
> The old_rsp value will be stored in usersp in case of a context switch.
>
> The KSTK_ESP will get the value from old_rsp in case the task is the
> current task, otherwise it will read usersp.
>
> I know about the performance coast, so this is why i ask for comments.
>
> Stefani
>
> Signed-off-by: Stefani Seibold <stefani@seibold.net>
>
> include/asm/processor.h | 4 +++-
> kernel/apic/apic.c | 3 +++
> kernel/irq_64.c | 1 +
> kernel/process_64.c | 20 ++++++++++++++++++++
> 4 files changed, 27 insertions(+), 1 deletion(-)
>
> --- linux-2.6.32-rc5.old/arch/x86/include/asm/processor.h 2009-10-16 02:41:50.000000000 +0200
> +++ linux-2.6.32-rc5.new/arch/x86/include/asm/processor.h 2009-11-05 08:28:23.765300812 +0100
> @@ -1000,7 +1000,7 @@
> #define thread_saved_pc(t) (*(unsigned long *)((t)->thread.sp - 8))
>
> #define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.sp0 - 1)
> -#define KSTK_ESP(tsk) -1 /* sorry. doesn't work for syscall. */
> +extern unsigned long KSTK_ESP(struct task_struct *task);
> #endif /* CONFIG_X86_64 */
>
> extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
> @@ -1052,4 +1052,6 @@
> return ratio;
> }
>
> +extern void update_usersp(struct pt_regs *regs);
> +
> #endif /* _ASM_X86_PROCESSOR_H */
> --- linux-2.6.32-rc5.old/arch/x86/kernel/process_64.c 2009-10-16 02:41:50.000000000 +0200
> +++ linux-2.6.32-rc5.new/arch/x86/kernel/process_64.c 2009-11-05 08:52:39.965227285 +0100
> @@ -664,3 +664,23 @@
> return do_arch_prctl(current, code, addr);
> }
>
> +void update_usersp(struct pt_regs *regs)
> +{
> + unsigned long stk = (unsigned long)task_stack_page(current);
> + unsigned long stkp = (regs)->sp;
Cleanliness: no need for that parenthesis.
> +
> + if (((stkp < stk) || (stkp >= stk + THREAD_SIZE))
> + && regs->ip < PAGE_OFFSET)
> + percpu_write(old_rsp, stkp);
> +}
that check for regs->ip looks imprecise - why dont you use the
user_mode_vm()?
It's true that the value itself is statistical, but still we dont want
to leak a kernel-space regs->sp reason - it's an information leak.
> +
> +unsigned long KSTK_ESP(struct task_struct *task)
> +{
> + if (test_tsk_thread_flag(task, TIF_IA32))
> + return task_pt_regs(task)->sp;
> +
> + if (task != current)
> + return task->thread.usersp;
> +
> + return percpu_read(old_rsp);
> +}
> --- linux-2.6.32-rc5.old/arch/x86/kernel/irq_64.c 2009-10-16 02:41:50.000000000 +0200
> +++ linux-2.6.32-rc5.new/arch/x86/kernel/irq_64.c 2009-11-04 22:29:55.762951577 +0100
> @@ -53,6 +53,7 @@
> struct irq_desc *desc;
>
> stack_overflow_check(regs);
> + update_usersp(regs);
>
>
> desc = irq_to_desc(irq);
> if (unlikely(!desc))
> --- linux-2.6.32-rc5.old/arch/x86/kernel/apic/apic.c 2009-10-16 02:41:50.000000000 +0200
> +++ linux-2.6.32-rc5.new/arch/x86/kernel/apic/apic.c 2009-11-04 23:12:32.805086991 +0100
> @@ -831,6 +831,9 @@
> {
> struct pt_regs *old_regs = set_irq_regs(regs);
>
> +#ifndef CONFIG_X86_32
> + update_usersp(regs);
> +#endif
Cleanliness: please eliminate this #ifdef by defining update_usersp() on
32-bit as well, as an empty inline function.
But, i dont like this patch because it adds overhead to the IRQ
fastpath.
I'd suggest a competely different method: why dont you use an IPI to
sample the SP whenever someone wants to read it from /proc and we see
that the task is running on a CPU right now?
Ingo
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] RFC x86_64 more accurate KSTK_ESP implementation
2009-11-08 11:35 ` Ingo Molnar
@ 2009-11-08 12:51 ` Stefani Seibold
2009-11-08 12:55 ` Ingo Molnar
2009-11-08 19:37 ` Andi Kleen
1 sibling, 1 reply; 21+ messages in thread
From: Stefani Seibold @ 2009-11-08 12:51 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Andrew Morton, H. Peter Anvin, Americo Wang,
Thomas Gleixner, Andi Kleen
Am Sonntag, den 08.11.2009, 12:35 +0100 schrieb Ingo Molnar:
> * Stefani Seibold <stefani@seibold.net> wrote:
>
> > +
> > + if (((stkp < stk) || (stkp >= stk + THREAD_SIZE))
> > + && regs->ip < PAGE_OFFSET)
> > + percpu_write(old_rsp, stkp);
> > +}
>
> that check for regs->ip looks imprecise - why dont you use the
> user_mode_vm()?
>
> It's true that the value itself is statistical, but still we dont want
> to leak a kernel-space regs->sp reason - it's an information leak.
>
Good idea. Much better ;-)
> > --- linux-2.6.32-rc5.old/arch/x86/kernel/irq_64.c 2009-10-16 02:41:50.000000000 +0200
> > +++ linux-2.6.32-rc5.new/arch/x86/kernel/irq_64.c 2009-11-04 22:29:55.762951577 +0100
> > @@ -53,6 +53,7 @@
> > struct irq_desc *desc;
> >
> > stack_overflow_check(regs);
> > + update_usersp(regs);
> >
> >
> > desc = irq_to_desc(irq);
> > if (unlikely(!desc))
> > --- linux-2.6.32-rc5.old/arch/x86/kernel/apic/apic.c 2009-10-16 02:41:50.000000000 +0200
> > +++ linux-2.6.32-rc5.new/arch/x86/kernel/apic/apic.c 2009-11-04 23:12:32.805086991 +0100
> > @@ -831,6 +831,9 @@
> > {
> > struct pt_regs *old_regs = set_irq_regs(regs);
> >
> > +#ifndef CONFIG_X86_32
> > + update_usersp(regs);
> > +#endif
>
> Cleanliness: please eliminate this #ifdef by defining update_usersp() on
> 32-bit as well, as an empty inline function.
>
> But, i dont like this patch because it adds overhead to the IRQ
> fastpath.
>
Agree, but i saw no other way.
> I'd suggest a competely different method: why dont you use an IPI to
> sample the SP whenever someone wants to read it from /proc and we see
> that the task is running on a CPU right now?
>
Sounds like a challenge, i like the idea. I will have a look on it...
Stefani
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] RFC x86_64 more accurate KSTK_ESP implementation
2009-11-08 12:51 ` Stefani Seibold
@ 2009-11-08 12:55 ` Ingo Molnar
2009-11-08 14:00 ` Stefani Seibold
0 siblings, 1 reply; 21+ messages in thread
From: Ingo Molnar @ 2009-11-08 12:55 UTC (permalink / raw)
To: Stefani Seibold
Cc: linux-kernel, Andrew Morton, H. Peter Anvin, Americo Wang,
Thomas Gleixner, Andi Kleen
* Stefani Seibold <stefani@seibold.net> wrote:
> > I'd suggest a competely different method: why dont you use an IPI to
> > sample the SP whenever someone wants to read it from /proc and we
> > see that the task is running on a CPU right now?
>
> Sounds like a challenge, i like the idea. I will have a look on it...
It's not a fastpath, so smp_function_call() ought to do the trick.
Ingo
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] RFC x86_64 more accurate KSTK_ESP implementation
2009-11-08 12:55 ` Ingo Molnar
@ 2009-11-08 14:00 ` Stefani Seibold
2009-11-08 16:34 ` H. Peter Anvin
0 siblings, 1 reply; 21+ messages in thread
From: Stefani Seibold @ 2009-11-08 14:00 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Andrew Morton, H. Peter Anvin, Americo Wang,
Thomas Gleixner, Andi Kleen
Am Sonntag, den 08.11.2009, 13:55 +0100 schrieb Ingo Molnar:
> * Stefani Seibold <stefani@seibold.net> wrote:
>
> > > I'd suggest a competely different method: why dont you use an IPI to
> > > sample the SP whenever someone wants to read it from /proc and we
> > > see that the task is running on a CPU right now?
> >
> > Sounds like a challenge, i like the idea. I will have a look on it...
>
> It's not a fastpath, so smp_function_call() ought to do the trick.
>
> Ingo
There is no function smp_function_call()...
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] RFC x86_64 more accurate KSTK_ESP implementation
2009-11-08 14:00 ` Stefani Seibold
@ 2009-11-08 16:34 ` H. Peter Anvin
0 siblings, 0 replies; 21+ messages in thread
From: H. Peter Anvin @ 2009-11-08 16:34 UTC (permalink / raw)
To: Stefani Seibold
Cc: Ingo Molnar, linux-kernel, Andrew Morton, Americo Wang,
Thomas Gleixner, Andi Kleen
On 11/08/2009 06:00 AM, Stefani Seibold wrote:
> Am Sonntag, den 08.11.2009, 13:55 +0100 schrieb Ingo Molnar:
>> * Stefani Seibold <stefani@seibold.net> wrote:
>>
>>>> I'd suggest a competely different method: why dont you use an IPI to
>>>> sample the SP whenever someone wants to read it from /proc and we
>>>> see that the task is running on a CPU right now?
>>>
>>> Sounds like a challenge, i like the idea. I will have a look on it...
>>
>> It's not a fastpath, so smp_function_call() ought to do the trick.
>
> There is no function smp_function_call()...
>
smp_call_function().
-hpa
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] RFC x86_64 more accurate KSTK_ESP implementation
2009-11-08 11:35 ` Ingo Molnar
2009-11-08 12:51 ` Stefani Seibold
@ 2009-11-08 19:37 ` Andi Kleen
1 sibling, 0 replies; 21+ messages in thread
From: Andi Kleen @ 2009-11-08 19:37 UTC (permalink / raw)
To: Ingo Molnar
Cc: Stefani Seibold, linux-kernel, Andrew Morton, H. Peter Anvin,
Americo Wang, Thomas Gleixner
Ingo Molnar <mingo@elte.hu> writes:
>
> I'd suggest a competely different method: why dont you use an IPI to
> sample the SP whenever someone wants to read it from /proc and we see
> that the task is running on a CPU right now?
Most of /proc tends to turn into a fast path when you run the right
monitoring tools unfortunately, which poll /proc at sometimes
quite high frequencies.
I suspect you'll slow something down significantly with this approach.
The only good way to avoid that would be to use a separate file, but again
if someone really wants it they can as well just use a ptrace()
based program from user space.
-Andi
--
ak@linux.intel.com -- Speaking for myself only.
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH] fix /proc/<pid>/stat stack pointer for kernel threads
2009-11-03 9:06 ` Stefani Seibold
2009-11-03 18:16 ` Ingo Molnar
2009-11-05 8:19 ` [PATCH] RFC x86_64 more accurate KSTK_ESP implementation Stefani Seibold
@ 2009-11-05 13:02 ` Stefani Seibold
2009-11-13 8:01 ` [tip:x86/urgent] fs: " Stefani Seibold
3 siblings, 0 replies; 21+ messages in thread
From: Stefani Seibold @ 2009-11-05 13:02 UTC (permalink / raw)
To: linux-kernel, Andrew Morton, Ingo Molnar
This patch fix a small issue for the stack pointer in /proc/<pid>/stat.
In case of a kernel thread the value of the stack pointer should be 0.
Signed-off-by: Stefani Seibold <stefani@seibold.net>
---
array.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- linux-2.6.32-rc5.old/fs/proc/array.c 2009-10-16 02:41:50.000000000 +0200
+++ linux-2.6.32-rc5.new/fs/proc/array.c 2009-11-05 13:46:58.770599144 +0100
@@ -571,7 +571,7 @@
rsslim,
mm ? mm->start_code : 0,
mm ? mm->end_code : 0,
- (permitted) ? task->stack_start : 0,
+ (permitted && mm) ? task->stack_start : 0,
esp,
eip,
/* The signal information here is obsolete.
^ permalink raw reply [flat|nested] 21+ messages in thread
* [tip:x86/urgent] fs: fix /proc/<pid>/stat stack pointer for kernel threads
2009-11-03 9:06 ` Stefani Seibold
` (2 preceding siblings ...)
2009-11-05 13:02 ` [PATCH] fix /proc/<pid>/stat stack pointer for kernel threads Stefani Seibold
@ 2009-11-13 8:01 ` Stefani Seibold
3 siblings, 0 replies; 21+ messages in thread
From: Stefani Seibold @ 2009-11-13 8:01 UTC (permalink / raw)
To: linux-kernel, Andrew Morton, Ingo Molnar
This patch fix a small issue for the stack pointer in /proc/<pid>/stat.
In case of a kernel thread the value of the printed stack pointer should be 0.
Signed-off-by: Stefani Seibold <stefani@seibold.net>
---
array.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- linux-2.6.32-rc5.old/fs/proc/array.c 2009-10-16 02:41:50.000000000 +0200
+++ linux-2.6.32-rc5.new/fs/proc/array.c 2009-11-05 13:46:58.770599144 +0100
@@ -571,7 +571,7 @@
rsslim,
mm ? mm->start_code : 0,
mm ? mm->end_code : 0,
- (permitted) ? task->stack_start : 0,
+ (permitted && mm) ? task->stack_start : 0,
esp,
eip,
/* The signal information here is obsolete.
^ permalink raw reply [flat|nested] 21+ messages in thread