Context Switching is Broken
Context switching is broken. The man page for context is example code that doesn't work, but should. Does a bug report need to be submitted?
Thanks
Herman
Quoted 2 lines · Herman Swartz
Context switching is broken. The man page for context is example code that doesn't work, but should. Does a bug report need to be submitted?
$ man context No manual entry for context
?
Quoted 9 lines · Herman Swartz
Quoted 2 lines
Context switching is broken. The man page for context is example code that doesn't work, but should. Does a bug report need to be submitted?
$ man context No manual entry for context?
Quite. man makecontext has a fairly scary example, maybe that's it.
Will
Quoted 11 lines · Will Deacon
Quoted 9 lines · Herman Swartz
Quoted 2 lines
Context switching is broken. The man page for context is example code that doesn't work, but should. Does a bug report need to be submitted?
$ man context No manual entry for context?
Quite. man makecontext has a fairly scary example, maybe that's it.
In which case it's a question for libc people - the kernel has nothing to do with makecontext, getcontext, setcontext and swapcontext.
I believe for glibc, these are simply unimplemented on ARM, and linking a program which uses makecontext with glibc would result in the linker issuing:
warning: makecontext is not implemented and will always fail
Same for the other three functions.
Quoted 11 lines · Russell King - ARM Linux
Quoted 9 lines · Will Deacon
Quoted 7 lines · Herman Swartz
Quoted 2 lines
Context switching is broken. The man page for context is example code that doesn't work, but should. Does a bug report need to be submitted?
$ man context No manual entry for contextQuite. man makecontext has a fairly scary example, maybe that's it.
Quoted 8 lines
In which case it's a question for libc people - the kernel has nothing
to do with makecontext, getcontext, setcontext and swapcontext.I believe for glibc, these are simply unimplemented on ARM, and linking a program which uses makecontext with glibc would result in the linker issuing:
warning: makecontext is not implemented and will always fail
Indeed on ARM:
martin:~$ make makecontext cc makecontext.c -o makecontext /tmp/ccnapqW4.o: In function `main': makecontext.c:(.text+0x110): warning: warning: getcontext is not implemented and will always fail makecontext.c:(.text+0x164): warning: warning: makecontext is not implemented and will always fail /tmp/ccnapqW4.o: In function `func1': makecontext.c:(.text+0x24): warning: warning: swapcontext is not implemented and will always fail $ ./makecontext Function not inplemented. $
so?
M
Martin,
Looks like you took the example code out of the man page and tried to compile. This is what I get to. Look at my email sent a few minutes ago.
Thanks
HermanI
----- Original Message ----
From: Martin Guy <[email protected]>
To: Russell King - ARM Linux <[email protected]>
Cc: Will Deacon <[email protected]>; Herman Swartz <[email protected]>; linux-arm-kernel at lists.infradead.org
Sent: Thu, June 10, 2010 4:36:39 PM
Subject: Re: Context Switching is Broken
Quoted 11 lines · Russell King - ARM Linux
On Thu, Jun 10, 2010 at 03:16:49PM +0100, Will Deacon wrote:
? > > On Thu, Jun 10, 2010 at 04:11:35AM -0700, Herman Swartz wrote:
? > > > Context switching is broken. The man page for context is example code ? > > > that doesn't work, but should. Does a bug report need to be submitted? ? > >
? > > $ man context
? > > No manual entry for context
? > >Quoted 1 line
Quite. man makecontext has a fairly scary example, maybe that's it.
Quoted 8 lines
In which case it's a question for libc people - the kernel has nothing ? to do with makecontext, getcontext, setcontext and swapcontext.
? I believe for glibc, these are simply unimplemented on ARM, and linking ? a program which uses makecontext with glibc would result in the linker ? issuing:
? warning: makecontext is not implemented and will always fail
Indeed on ARM:
martin:~$ make makecontext cc? ? makecontext.c? -o makecontext /tmp/ccnapqW4.o: In function `main': makecontext.c:(.text+0x110): warning: warning: getcontext is not implemented and will always fail makecontext.c:(.text+0x164): warning: warning: makecontext is not implemented and will always fail /tmp/ccnapqW4.o: In function `func1': makecontext.c:(.text+0x24): warning: warning: swapcontext is not implemented and will always fail $ ./makecontext Function not inplemented. $
so?
? ? M
Hermann
While context switching works fine - any Unix system would have a hard time working without it - these four esoteric system calls are not implemented in the ARM port of Linux. If you'd like to modify the linux source code to implement them, I'm sure the community would be happy to review the patches for inclusion in the next version of the kernel.
They seem to be implemented on x86 processors if you need them.
M
Quoted 6 lines · Martin Guy
While context switching works fine - any Unix system would have a hard time working without it - these four esoteric system calls are not implemented in the ARM port of Linux. If you'd like to modify the linux source code to implement them, I'm sure the community would be happy to review the patches for inclusion in the next version of the kernel.
If you read what I said:
"I believe for glibc, these are simply unimplemented on ARM, and linking a program which uses makecontext with glibc would result in the linker issuing:"
These calls are nothing to do with the kernel. They're a subject purely for glibc. So there's no modification to the Linux kernel source code which could effect their implementation.
esoteric "confined to and understandable by only an enlightened inner circle"
Sounds like there was a decision made during porting not to include these calls because they weren't considered useful enough.
What is the chance of requesting this to be included, along with other mods,?in the next release of the kernel for ARM?
The Sheeva PLUG is a neat/thrifty little box that runs 7X24. Unlike other computers laying around the house. :-)
JNOS is an Amateur Radio?packet radio communications program for TCP/IP running many?time dependent?segments.
Here is a requested?segment of the code:
/* Now do the context switch.
???? * This technique was inspired by Rob, PE1CHL, and is a bit tricky. ???? *
???? * If the old process has gone away, simply load the new process's ???? * environment. Otherwise, save the current process's state. Then if ???? * this is still the old process, load the new environment. Since the ???? * new task will "think" it's returning from the setjmp() with a return ???? * value of 1, the comparison with 0 will bypass the longjmp(), which ???? * would otherwise cause an infinite loop.
???? */
??? /* i_state isn't needed --- the signal mask is part of the context */ ??? if (oldproc == NULLPROC)
??????? setcontext(&Curproc->env);
??? else
??????? swapcontext(&oldproc->env, &Curproc->env);
??? /* At this point, we're running in the newly dispatched task */ ??? tmp = Curproc->retval;
??? Curproc->retval = 0;
??? /* Also restore the true interrupt state here, in case the longjmp ???? * DOES restore the interrupt state saved at the time of the setjmp(). ???? * This is the case with Turbo-C's setjmp/longjmp.
???? */
??? restore(Curproc->i_state);
??? return tmp;
}
----- Original Message ----
From: Martin Guy <[email protected]>
To: Herman Swartz <[email protected]>
Cc: Russell King - ARM Linux <[email protected]>; Will Deacon <[email protected]>; linux-arm-kernel at lists.infradead.org
Sent: Thu, June 10, 2010 5:29:12 PM
Subject: Re: Context Switching is Broken
Hermann
While context switching works fine - any Unix system would have a hard time working without it - these four esoteric system calls are not implemented in the ARM port of Linux. If you'd like to modify the linux source code to implement them, I'm sure the community would be happy to review the patches for inclusion in the next version of the kernel.
They seem to be implemented on x86 processors if you need them.
? ? M
Yes, the kernel has the functions, because the kernel uses them in it's operation. The glibc needs to implement these calls to the kernel. Do I have that right?
Herman
----- Original Message ----
From: Russell King - ARM Linux <[email protected]>
To: Martin Guy <[email protected]>
Cc: Herman Swartz <[email protected]>; Will Deacon <[email protected]>; linux-arm-kernel at lists.infradead.org
Sent: Thu, June 10, 2010 6:59:30 PM
Subject: Re: Context Switching is Broken
Quoted 6 lines · Martin Guy
While context switching works fine - any Unix system would have a hard time working without it - these four esoteric system calls are not implemented in the ARM port of Linux. If you'd like to modify the linux source code to implement them, I'm sure the community would be happy to review the patches for inclusion in the next version of the kernel.
If you read what I said:
"I believe for glibc, these are simply unimplemented on ARM, and linking a program which uses makecontext with glibc would result in the linker issuing:"
These calls are nothing to do with the kernel.? They're a subject purely for glibc.? So there's no modification to the Linux kernel source code which could effect their implementation.
Quoted 3 lines · Herman Swartz
Yes, the kernel has the functions, because the kernel uses them in it's operation. The glibc needs to implement these calls to the kernel. Do I have that right?
No. The kernel's context switching is entirely different to the "context switching" that you're talking about here.
As I've said twice - and I'm not going to repeat it a third time - this has nothing to do with the kernel and everything to do with glibc.
You can see this from the i386 version of setcontext(), which can be found in the glibc source code:
sysdeps/unix/sysv/linux/i386/setcontext.S
The only call this code makes to the kernel is to set the processes signal mask - which ARM has provided since day 1, and is used for many things other than providing this support. So there's nothing to add to the kernel.
What's missing is the glibc support code. Not the kernel code.
You need to talk to glibc people about this, not kernel people.