Skip to contentSkip to conversation

x86_64 RESTORE_CONTEXT missing '\n'

PATCH In review Dave Jiang 9 participants 17 messages Mar 7, 2007 – Apr 24, 2007

lore
Share & tools
lore

Dave Jiang

author
#0 lore raw

PATCH 1/1 x86_64 RESTORE_CONTEXT missing '\n'

The RESTORE_CONTEXT macro is missing the '\n' at the end. It was removed in the previous patch that touched system.h. It causes compile failure if any inline asm is added after the macro. Discovered this when playing with kgdb.

---

 include/asm-x86_64/system.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

---

include/asm-x86_64/system.h +1 -1
index bd376bc..cbb8579 100644
@@ -15,7 +15,7 @@
 
 /* frame pointer must be last for get_wchan */
 #define SAVE_CONTEXT    "pushf ; pushq %%rbp ; movq %%rsi,%%rbp\n\t"
-#define RESTORE_CONTEXT "movq %%rbp,%%rsi ; popq %%rbp ; popf\t"
+#define RESTORE_CONTEXT "movq %%rbp,%%rsi ; popq %%rbp ; popf\n\t"
 
 #define __EXTRA_CLOBBER  \
 	,"rcx","rbx","rdx","r8","r9","r10","r11","r12","r13","r14","r15"
#1 lore raw
Quoted 5 lines · Dave Jiang

The RESTORE_CONTEXT macro is missing the '\n' at the end. It was removed in the previous patch that touched system.h. It causes compile failure if any inline asm is added after the macro. Discovered this when playing with kgdb.

We went through this several times. kgdb has no business to poke into kernel private macros like this and it shouldn't do that. So fixing kgdb to not require touching the context switch is the right change.

-Andi

author
#2 lore raw
Quoted 6 lines · Andi Kleen
Quoted 4 lines · Dave Jiang

The RESTORE_CONTEXT macro is missing the '\n' at the end. It was removed in the previous patch that touched system.h. It causes compile failure if any inline asm is added after the macro. Discovered this when playing with kgdb.

Quoted 6 lines

We went through this several times. kgdb has no business to poke into kernel private macros like this and it shouldn't do that. So fixing kgdb to not require touching the context switch is the right change.

-Andi

In spite of kgdb, shouldn't it have that \n anyways in case some other code gets added in the future after the macro? Or are you saying that there should never be any code ever after that macro?

Signature · 6 lines
------------------------------------------------------
Dave Jiang
Software Engineer
MontaVista Software, Inc.
http://www.mvista.com
------------------------------------------------------
#3 lore raw
Quoted 3 lines · Dave Jiang

In spite of kgdb, shouldn't it have that \n anyways in case some other code gets added in the future after the macro? Or are you saying that there should never be any code ever after that macro?

Sure if there is mainline code added after that macro we add the \n. But only if it makes sense to add code there, which it didn't in kgdb.

-Andi

#4 lore raw
Quoted 8 lines · Andi Kleen
Quoted 3 lines · Dave Jiang

In spite of kgdb, shouldn't it have that \n anyways in case some other code gets added in the future after the macro? Or are you saying that there should never be any code ever after that macro?

Sure if there is mainline code added after that macro we add the \n. But only if it makes sense to add code there, which it didn't in kgdb.

Was that because with recent enough tools and config options there was enough annotations so GDB could finally figure out where things had stopped? Thanks.

Signature · 1 line
Tom Rini
#5 lore raw

Permanent Kgdb integration into the kernel - lets get with it.

Quoted 7 lines · Tom Rini
Quoted 6 lines · Andi Kleen
Quoted 3 lines · Dave Jiang

In spite of kgdb, shouldn't it have that \n anyways in case some other code gets added in the future after the macro? Or are you saying that there should never be any code ever after that macro?

Quoted 6 lines
Quoted 2 lines

Sure if there is mainline code added after that macro we add the \n. But only if it makes sense to add code there, which it didn't in kgdb.

Was that because with recent enough tools and config options there was enough annotations so GDB could finally figure out where things had stopped? Thanks.

The reason Linus said he didn't allow George's kgdb mm patch to be integrating into the kernel a year or two ago was that Amit and George had significantly different implementations. So Amit, Tom, George, and the rest of the kgdb development gang worked together and came up with a unified version that we now support on SourceForge.

Tom rolled up a mm patch back in December for Andrew and then the integration process stopped. I suggest we work together on getting the kgdb patch back into the mm series and permanently into the kernel like the kexec code and then we can avoid this kernel development obfuscation.

-piet

Quoted 1 line
Signature · 4 lines
Piet Delaney                                    Phone: (408) 200-5256
Blue Lane Technologies                          Fax:   (408) 200-5299
10450 Bubb Rd.
Cupertino, Ca. 95014                            Email: [email protected]
#6 lore raw

Re: Permanent Kgdb integration into the kernel - lets get with it.

Quoted 21 lines · On Thu, 08 Mar 2007 14:24:10 -0800 Piet Delaney wrote:
Quoted 7 lines · Tom Rini
Quoted 6 lines · Andi Kleen
Quoted 3 lines · Dave Jiang

In spite of kgdb, shouldn't it have that \n anyways in case some other code gets added in the future after the macro? Or are you saying that there should never be any code ever after that macro?

Quoted 6 lines
Quoted 2 lines

Sure if there is mainline code added after that macro we add the \n. But only if it makes sense to add code there, which it didn't in kgdb.

Was that because with recent enough tools and config options there was enough annotations so GDB could finally figure out where things had stopped? Thanks.

The reason Linus said he didn't allow George's kgdb mm patch to be integrating into the kernel a year or two ago was that Amit and George had significantly different implementations. So Amit, Tom, George, and the rest of the kgdb development gang worked together and came up with a unified version that we now support on SourceForge.

Quoted 5 lines

Tom rolled up a mm patch back in December for Andrew and then the integration process stopped. I suggest we work together on getting the kgdb patch back into the mm series and permanently into the kernel like the kexec code and then we can avoid this kernel development obfuscation.

Hi,
Is there any movement on this?

Thanks,
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

#7 lore raw

Re: Permanent Kgdb integration into the kernel - lets get with it.

Hello.

Quoted 14 lines · Randy Dunlap
Quoted 13 lines
Quoted 10 lines
Quoted 6 lines
Quoted 3 lines

In spite of kgdb, shouldn't it have that \n anyways in case some other code gets added in the future after the macro? Or are you saying that there should never be any code ever after that macro?

Sure if there is mainline code added after that macro we add the \n. But only if it makes sense to add code there, which it didn't in kgdb.

Was that because with recent enough tools and config options there was enough annotations so GDB could finally figure out where things had stopped? Thanks.

The reason Linus said he didn't allow George's kgdb mm patch to be integrating into the kernel a year or two ago was that Amit and
George had significantly different implementations. So Amit, Tom, George, and the rest of the kgdb development gang worked together and came up with a unified version that we now support on SourceForge.

Quoted 8 lines
Quoted 5 lines

Tom rolled up a mm patch back in December for Andrew and then the integration process stopped. I suggest we work together on getting the kgdb patch back into the mm series and permanently into the kernel like the kexec code and then we can avoid this kernel development obfuscation.

Hi,
Is there any movement on this?

Jason Wessel has taken up KGDB maintenance for upstream. We're now working on merging the several diverse trees together.

WBR, Sergei

#8 lore raw

Re: Permanent Kgdb integration into the kernel - lets get with it.

Quoted 24 lines · Sergei Shtylyov

Hello.

Quoted 19 lines · Randy Dunlap
Quoted 19 lines
Quoted 10 lines
Quoted 6 lines
Quoted 3 lines

In spite of kgdb, shouldn't it have that \n anyways in case some other code gets added in the future after the macro? Or are you saying that there should never be any code ever after that macro?

Sure if there is mainline code added after that macro we add the \n. But only if it makes sense to add code there, which it didn't in kgdb.

Was that because with recent enough tools and config options there was enough annotations so GDB could finally figure out where things had stopped? Thanks.

The reason Linus said he didn't allow George's kgdb mm patch to be integrating into the kernel a year or two ago was that Amit and
George had significantly different implementations. So Amit, Tom, George, and the rest of the kgdb development gang worked together and came up with a unified version that we now support on SourceForge.

Tom rolled up a mm patch back in December for Andrew and then the integration process stopped. I suggest we work together on getting the kgdb patch back into the mm series and permanently into the kernel like the kexec code and then we can avoid this kernel development obfuscation.

Quoted 7 lines
Quoted 2 lines

Hi,
Is there any movement on this?

Jason Wessel has taken up KGDB maintenance for upstream. We're now
working on merging the several diverse trees together.

WBR, Sergei

at kgdb.sf.net or where is the work being done?

Thanks,

Signature · 2 lines
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
#9 lore raw

Re: Permanent Kgdb integration into the kernel - lets get with it.

Quoted 20 lines · Randy Dunlap
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 10 lines
Quoted 6 lines
Quoted 3 lines

In spite of kgdb, shouldn't it have that \n anyways in case some other code gets added in the future after the macro? Or are you saying that there should never be any code ever after that macro?

Sure if there is mainline code added after that macro we add the \n. But only if it makes sense to add code there, which it didn't in kgdb.

Was that because with recent enough tools and config options there was enough annotations so GDB could finally figure out where things had stopped? Thanks.

The reason Linus said he didn't allow George's kgdb mm patch to be integrating into the kernel a year or two ago was that Amit and
George had significantly different implementations. So Amit, Tom, George, and the rest of the kgdb development gang worked together and came up with a unified version that we now support on SourceForge.

Tom rolled up a mm patch back in December for Andrew and then the integration process stopped. I suggest we work together on getting the kgdb patch back into the mm series and permanently into the kernel like the kexec code and then we can avoid this kernel development obfuscation.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Hi,
Is there any movement on this?

Jason Wessel has taken up KGDB maintenance for upstream. We're now
working on merging the several diverse trees together.

at kgdb.sf.net or where is the work being done?

Currently, 2.6.21 branch is in SF CVS but unfortunately it's not yet in sync with (abandoned) Tom Rini's trees.

Quoted 1 line

Thanks,

WBR, Sergei

#10 lore raw

Re: Permanent Kgdb integration into the kernel - lets get with it.

In reply to Randy Dunlap
Quoted 2 lines

Is there any movement on this?

I'm open to reasonable patches for the hooks at least. If that is done then the actual kgdb code can be reviewed and considered eventually too.

But just having the hooks in would make it easy enough to use anyways (no patching, just dropping in of new files, or even loading of it as a module into any kernel)

When I did the original x86-64 kgdb port this worked nicely -- kgdb could work with just the standard die notifiers and a simple change in the serial console code.

The recent kgdb seems to need much more changes again though.

However every time when I suggested this (fixing the hooks first and submitting the really needed changes piece by piece) there didn't seem to be any interest from the various kgdb maintainers.

So my impression currently is that they're not interested in merging.

Another problem is that kgdb is moving more and more away from mainline by adding various weird hacks and workarounds in random code that just make merging harder.

Before anything could be considered for merging that all would need to be cleaned up.

-Andi

#11 lore raw

Re: Permanent Kgdb integration into the kernel - lets get with it.

Quoted 5 lines · Andi Kleen
Quoted 2 lines

Is there any movement on this?

I'm open to reasonable patches for the hooks at least. If that is done then the actual kgdb code can be reviewed and considered eventually too.

Would you be open to adding to that set of hooks the ones needed to get KDB working as a loadable module? Keith, would that be possible?

Thanks,
Robin

#12 lore raw

Re: Permanent Kgdb integration into the kernel - lets get with it.

In reply to Randy Dunlap
Quoted 23 lines · Randy Dunlap
Quoted 21 lines · On Thu, 08 Mar 2007 14:24:10 -0800 Piet Delaney wrote:
Quoted 7 lines · Tom Rini
Quoted 6 lines · Andi Kleen
Quoted 3 lines · Dave Jiang

In spite of kgdb, shouldn't it have that \n anyways in case some other code gets added in the future after the macro? Or are you saying that there should never be any code ever after that macro?

Quoted 6 lines
Quoted 2 lines

Sure if there is mainline code added after that macro we add the \n. But only if it makes sense to add code there, which it didn't in kgdb.

Was that because with recent enough tools and config options there was enough annotations so GDB could finally figure out where things had stopped? Thanks.

The reason Linus said he didn't allow George's kgdb mm patch to be integrating into the kernel a year or two ago was that Amit and George had significantly different implementations. So Amit, Tom, George, and the rest of the kgdb development gang worked together and came up with a unified version that we now support on SourceForge.

Quoted 8 lines
Quoted 5 lines

Tom rolled up a mm patch back in December for Andrew and then the integration process stopped. I suggest we work together on getting the kgdb patch back into the mm series and permanently into the kernel like the kexec code and then we can avoid this kernel development obfuscation.

Hi,
Is there any movement on this?

Hi Randy:

Jason Wessel <[email protected]> is currently leading yet another attempt at getting kgdb permanently into the kernel. Jason has a linux2_6_21 patch on SourceForge:

http://kgdb.cvs.sourceforge.net/kgdb/kgdb-2/8250.patch?view=log&pathrev=linux2_6_21_uprev

and has been working with Sergei Shtylyov <[email protected]> recently on getting KGDBOE Netpoll patches that got lost around the time of Tom's attempt. Just on Monday there were a dozen posting to the source forge mailing list:

[email protected]

on this effort.

I'd like to see a git repository on kernel.org that is used to update the mainstream kernel. Unfortunately getting accounts on kernel.org is next to impossible. If Jason doesn't have one yet it would be nice to offer him one for the kgdb developers to use.

I agree with Andi that the kgdb code seems to be getting more complicated that needed thought I don't find the hooks offensive. Here I keep my kgdb hooks completely under #ifdef KGDB, so there is absolutely no difference to the kernel when KGDB isn't configured. I also like having debug printks, similar to the SOCK_DEBUG() macros, to make it easy to watch kgdb internals in action. Ya can't run kgdb on itself.

I find these blemish's a minor concern compared to the damage/lost of not integrating kgdb into the kernel permanently. When developers can't rely on using kgdb for easy development they tend to write code without consideration for what it's like using their code with the debugger. Linux is making a major headway into $100 embedded systems; the recent use in the Linksys WRT54GL (DD-WRT) and Engenius EOC-3220 for example. Making kgdb easily accessible will make the viability of using Linux for embedded system greatly increased, IMHO.

Perhaps with a bit of support from the kernel.org folks we could get the kgdb patch, with all of it's blemishes, into Andrews 2.6.21-rc7-mm1 patch. Accounts on kernel.org for kgdb developers would be a modest effort. I find the CVS patch framework rather clumsy and would rather follow the KISS principle and just use git repositories like the rest of the kernel developers appear to be using.

-piet

Quoted 5 lines

Thanks,
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

Signature · 4 lines
Piet Delaney                                    Phone: (408) 200-5256
Blue Lane Technologies                          Fax:   (408) 200-5299
10450 Bubb Rd.
Cupertino, Ca. 95014                            Email: [email protected]
#13 lore raw

Re: Permanent Kgdb integration into the kernel - lets get with it.

Quoted 17 lines · On Fri, 20 Apr 2007 15:51:35 -0700 Piet Delaney <[email protected]> wrote:
Quoted 1 line

Is there any movement on this?

Hi Randy:

Jason Wessel <[email protected]> is currently leading yet another attempt at getting kgdb permanently into the kernel. Jason has a linux2_6_21 patch on SourceForge:

http://kgdb.cvs.sourceforge.net/kgdb/kgdb-2/8250.patch?view=log&pathrev=linux2_6_21_uprev

and has been working with Sergei Shtylyov <[email protected]> recently on getting KGDBOE Netpoll patches that got lost around the time of Tom's attempt. Just on Monday there were a dozen posting to the source forge mailing list:

Quoted 3 lines

[email protected]

on this effort.

Unfortunately there doesn't seem to be anything there which I can autopull into the -mm tree. I'm presently set up for quilt trees in open directories and for git trees. I could add plain-old-gzipped-diffs or whatever.

Quoted 4 lines

I'd like to see a git repository on kernel.org that is used to update the mainstream kernel. Unfortunately getting accounts on kernel.org is next to impossible. If Jason doesn't have one yet it would be nice to offer him one for the kgdb developers to use.

This seems to be to do with some silly spamfilter issue or something. I sent an email off-list.

Quoted 4 lines

I agree with Andi that the kgdb code seems to be getting more complicated that needed thought I don't find the hooks offensive. Here I keep my kgdb hooks completely under #ifdef KGDB, so there is absolutely no difference to the kernel when KGDB isn't configured.

We can address that sort of thing via review: you send send the diffs out, we read them and comment on them. We do this 100 times a day - it is simply a non-issue, as long as there's actually someone who has the time/effort/inclination to push this feature to completion, which is what kgdb has sadly lacked for the past decade or so.

Quoted 4 lines

I also like having debug printks, similar to the SOCK_DEBUG() macros, to make it easy to watch kgdb internals in action. Ya can't run kgdb on itself.

Quoted 8 lines

I find these blemish's a minor concern compared to the damage/lost of not integrating kgdb into the kernel permanently. When developers can't rely on using kgdb for easy development they tend to write code without consideration for what it's like using their code with the debugger. Linux is making a major headway into $100 embedded systems; the recent use in the Linksys WRT54GL (DD-WRT) and Engenius EOC-3220 for example. Making kgdb easily accessible will make the viability of using Linux for embedded system greatly increased, IMHO.

Lots of people want kgdb. One person is famously less keen on it, but we'll be able to talk him around, as long as the patches aren't daft.

Quoted 6 lines

Perhaps with a bit of support from the kernel.org folks we could get the kgdb patch, with all of it's blemishes, into Andrews 2.6.21-rc7-mm1 patch. Accounts on kernel.org for kgdb developers would be a modest effort. I find the CVS patch framework rather clumsy and would rather follow the KISS principle and just use git repositories like the rest of the kernel developers appear to be using.

Yes, a git tree on k.org is appropriate - let's make that happen.

But beware that it will need to be updated pretty reguarly, and it'll need to be against Linux-tree-of-the-day, please. The x86 code continues to change at a tremendous rate (I count 204 x86 patches queued for 2.6.22), and kgdb supports lots of other architectures too.

So whoever is signed up to maintain this will have quite a bit of messy maintaneance to do during the getting-it-ready phase. This will of course be minimised by being VERY careful to mimimise the impact of the patchset on the existing code.

And if/when it is merged, there will be quite a bit of tricky maintenance work to do, if my experience of the kgdb stub is anything to go by.

There inevitably will be long-term low-level impact upon the arch maintainers too. But that's OK, because the way to merge this feature is to put the arch-neutral core into the tree first, and to then send each per-arch patch to the relevant arch maintainer for merging. That way, they get to decide whether they wish to take on the burden of participating in its long-term maintenance.

#14 lore raw

Re: Permanent Kgdb integration into the kernel - lets get with it.

Quoted 3 lines

Lots of people want kgdb. One person is famously less keen on it, but we'll be able to talk him around, as long as the patches aren't daft.

The big question is if the kgdb developers seriously want mainline. At least in the past this definitely wasn't the case.

If they're not open to change requests from mainline reviewers we don't even need to bother to start the whole exercise.

Just putting their stuff onto korg isn't enough.

-Andi

#15 lore raw

Re: Permanent Kgdb integration into the kernel - lets get with it. (Dave: How do FreeBSD folks maintain the KGDB stub?)

Quoted 5 lines · Andi Kleen
Quoted 2 lines

Lots of people want kgdb. One person is famously less keen on it, but we'll be able to talk him around, as long as the patches aren't daft.

The big question is if the kgdb developers seriously want mainline. At least in the past this definitely wasn't the case.

I haven't seen any email from kgdb developers saying they didn't want kgdb to be part of mainline.

Happen to have any e-mail demonstrating that?

It's appears to me that:

1. Jason Wessel is putting a lot of effort at that right now.

2. Tom Rini worked hard at this just a few months ago.

3. George Anzinger was working hard at this a year or two with the mm series and as likely disappointed when it wasn't put into the mainline. As I recall the reason Linus gave was that there were two competing patches and he wanted that be resolved before integrating it into the mainline. So George worked with Amit at SourceForge over that past year or two and it's now integrated.

Quoted 3 lines

If they're not open to change requests from mainline reviewers we don't even need to bother to start the whole exercise.

What issue are there of have been that your referring to?

Once KGDB is part of KORG can't it's maintenance and support be a kernel wide responsibility. If someone breaks kgdb shouldn't that be backed out until the KORG developers fixes the problem? Centralizing the responsibility for KGDB seems like mistake. I doubt the FreeBSD folks rip out the KGDB support of a kernel hacker breaks KGDB and then leaves a group of KGDB developers to sort out the problem. Seems it should be cough as a mm patch with Andrew tossing out the patch if it breaks KGDB. Kgdb developers could try to give Andrew a heads up if this occurs and he didn't notice it.

Once KGDB is integrated the maintenance should be minimal and changes that break KGDB are likely best addressed by the developer that just broke it. At least that what I'd think is an optimal approach. Perhaps Dave O'Brien could tell us how the FreeBSD folks take care for KGDB.

Quoted 2 lines

Just putting their stuff onto korg isn't enough.

Yep, and once it's integrated into korg it should finally become a permanent part of the kernel and I suspect maintained by all kernel developers. New KGDB features could be developed at SourceForge but maintaining kernel coherence seems like a global responsibility. Like running fault injection on your code before checking it in.

Maybe I'm totally out to lunch on this; perhaps Dave O'Brien can straighten me our if I'm wrong or the Linux kernel core responsibility paradigm are incompatible with this.

I'd prefer Linux being just as good as NetBSD with Debugging support; current presentations like:

	http://foss.in/2005/slides/netbsd-linux.pdf

show our current support as being much worse. Let's fix it.

You developed a kgdb proxy for Keith Owens kdb and I suspect you would like to have KGDB being part of the kernel mainline as long as it's done well. I doubt anyone would argue with that.

Perhaps it's possible to eventually setup KGDB so it can be debugged with kdb. Once KGDB is mainline that are plenty of issues that can be addressed; for example taking a kernel core dump after dropping into kgdb and having the registers show up correctly in Dave Anderson's crash utility.

-piet

Quoted 2 lines

-Andi

Signature · 4 lines
Piet Delaney                                    Phone: (408) 200-5256
Blue Lane Technologies                          Fax:   (408) 200-5299
10450 Bubb Rd.
Cupertino, Ca. 95014                            Email: [email protected]
#16 lore raw
In reply to Tom Rini
Quoted 7 lines · Tom Rini
Quoted 6 lines · Andi Kleen
Quoted 3 lines · Dave Jiang

In spite of kgdb, shouldn't it have that \n anyways in case some other code gets added in the future after the macro? Or are you saying that there should never be any code ever after that macro?

Quoted 6 lines
Quoted 2 lines

Sure if there is mainline code added after that macro we add the \n. But only if it makes sense to add code there, which it didn't in kgdb.

Was that because with recent enough tools and config options there was enough annotations so GDB could finally figure out where things had stopped?

The x86 kernels are fully dwarf2 annotiated yes.

-Andi