TDF_NEEDRESCHED when extending pcb on x86

John Baldwin jhb at FreeBSD.org
Tue Mar 1 20:47:32 GMT 2005


On Monday 28 February 2005 07:06 pm, Peter Wemm wrote:
> On Monday 28 February 2005 02:57 pm, Denis Ustimenko wrote:
> > Hi, there!
> >
> > I've tried s3switch utility from ports on 5.2.1 and found that
> > i386_set_ioperm syscall doesn't work properly. The next code illustrates
> > the problem. It will get SIGBUS with very high probability.
> >
> > #include <sys/types.h>
> > #include <machine/sysarch.h>
> > #include <machine/cpufunc.h>
> >
> > int main()
> > {
> >          if ( i386_set_ioperm( 0x80, 1, 1)) {
> >                  perror("XXX");
> >                  return 1;
> >          }
> >          inb( 0x80);
> >          return 0;
> > }
> >
> > Now I have no 5.3 or CURRENT system but brief looking on code shows that
> > it should give the same result on them.
> > The problem occurs when we extend pcb and set TDF_NEEDRESCHED bit hoping
> > that thread will be rescheduled and new TSS will be loaded. But
> > sched_switch function skips cpu_switch when thread was not changed and
> > ltr is not executed.
>
> I think it would be better to fix the semantics of TDF_NEEDRESCHED.  I was
> thinking that mi_switch could negate the cpu_switch optimization if
> TDF_NEEDRESCHED was set.  That would avoid duplicating the internal
> knowledge of the pcb/tss/etc handling in this code.

Forcing a context switch is a rather round-about way of getting ltr to be 
executed though.  We already have intimate knowledge of TSS, etc. in this 
file anyway, so I wonder if just doing the ltr() directly is the better 
approach?

-- 
John Baldwin <jhb at FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org


More information about the freebsd-hackers mailing list