public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stefani Seibold <stefani@seibold.net>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Americo Wang <xiyou.wangcong@gmail.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] update fix X86_64 procfs provide stack information for threads
Date: Tue, 03 Nov 2009 10:06:24 +0100	[thread overview]
Message-ID: <1257239184.4889.15.camel@wall-e> (raw)
In-Reply-To: <20091103082843.GA27676@elte.hu>

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. 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.

Greeting,
Stefani



  reply	other threads:[~2009-11-03  9:06 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-03  7:31 [PATCH] update fix X86_64 procfs provide stack information for threads Stefani Seibold
2009-11-03  8:28 ` Ingo Molnar
2009-11-03  9:06   ` Stefani Seibold [this message]
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 11:08       ` Andi Kleen
2009-11-05 12:11         ` Stefani Seibold
2009-11-08 11:35       ` Ingo Molnar
2009-11-08 12:51         ` Stefani Seibold
2009-11-08 12:55           ` Ingo Molnar
2009-11-08 14:00             ` Stefani Seibold
2009-11-08 16:34               ` H. Peter Anvin
2009-11-08 19:37         ` Andi Kleen
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
2009-11-04 11:17 ` [PATCH] update fix X86_64 procfs provide stack information for threads Andi Kleen
2009-11-04 11:50   ` Stefani Seibold
2009-11-04 12:00     ` Andi Kleen
2009-11-04 12:22       ` Stefani Seibold
2009-11-04 15:42       ` Stefani Seibold
2009-11-04 22:21       ` Stefani Seibold

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=1257239184.4889.15.camel@wall-e \
    --to=stefani@seibold.net \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --cc=xiyou.wangcong@gmail.com \
    /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