Change the second (and last) argument of cpu_set_upcall(). Previously

we were passing in a void* representing the PCB of the parent thread.
Now we pass a pointer to the parent thread itself.
The prime reason for this change is to allow cpu_set_upcall() to copy
(parts of) the trapframe instead of having it done in MI code in each
caller of cpu_set_upcall(). Copying the trapframe cannot always be
done with a simply bcopy() or may not always be optimal that way. On
ia64 specifically the trapframe contains information that is specific
to an entry into the kernel and can only be used by the corresponding
exit from the kernel. A trapframe copied verbatim from another frame
is in most cases useless without some additional normalization.

Note that this change removes the assignment to td->td_frame in some
implementations of cpu_set_upcall(). The assignment is redundant.
A previous call to cpu_thread_setup() already did the exact same
assignment. An added benefit of removing the redundant assignment is
that we can now change td_pcb without nasty side-effects.

This change officially marks the ability on ia64 for 1:1 threading.

Not tested on: amd64, powerpc
Compile & boot tested on: alpha, sparc64
Functionally tested on: i386, ia64
This commit is contained in:
Marcel Moolenaar 2003-06-04 21:13:21 +00:00
parent ba90ccc69a
commit 11e0f8e16d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=115858
10 changed files with 21 additions and 22 deletions

View file

@ -262,7 +262,7 @@ cpu_thread_setup(struct thread *td)
}
void
cpu_set_upcall(struct thread *td, void *pcb)
cpu_set_upcall(struct thread *td, struct thread *td0)
{
struct pcb *pcb2;
@ -282,7 +282,7 @@ cpu_set_upcall(struct thread *td, void *pcb)
* at this time (see the matching comment below for
* more analysis) (need a good safe default).
*/
bcopy(pcb, pcb2, sizeof(*pcb2));
bcopy(td0->td_pcb, pcb2, sizeof(*pcb2));
/*
* Create a new fresh stack for the new thread.
@ -291,7 +291,7 @@ cpu_set_upcall(struct thread *td, void *pcb)
* The contexts are filled in at the time we actually DO the
* upcall as only then do we know which KSE we got.
*/
td->td_frame = (struct trapframe *)((caddr_t)pcb2) - 1;
bcopy(td0->td_frame, td->td_frame, sizeof(struct trapframe));
/*
* Arrange for continuation at fork_return(), which

View file

@ -320,7 +320,7 @@ cpu_thread_setup(struct thread *td)
* such as those generated in thread_userret() itself.
*/
void
cpu_set_upcall(struct thread *td, void *pcb)
cpu_set_upcall(struct thread *td, struct thread *td0)
{
struct pcb *pcb2;
@ -338,7 +338,7 @@ cpu_set_upcall(struct thread *td, void *pcb)
* at this time (see the matching comment below for
* more analysis) (need a good safe default).
*/
bcopy(pcb, pcb2, sizeof(*pcb2));
bcopy(td0->td_pcb, pcb2, sizeof(*pcb2));
/*
* Create a new fresh stack for the new thread.
@ -348,7 +348,7 @@ cpu_set_upcall(struct thread *td, void *pcb)
* The contexts are filled in at the time we actually DO the
* upcall as only then do we know which KSE we got.
*/
td->td_frame = (struct trapframe *)((caddr_t)pcb2 - 16) - 1;
bcopy(td0->td_frame, td->td_frame, sizeof(struct trapframe));
/*
* Set registers for trampoline to user mode. Leave space for the

View file

@ -120,24 +120,24 @@ cpu_thread_setup(struct thread *td)
}
void
cpu_set_upcall(struct thread *td, void *pcb0)
cpu_set_upcall(struct thread *td, struct thread *td0)
{
struct pcb *pcb;
struct trapframe *tf;
pcb = td->td_pcb;
KASSERT(pcb != NULL, ("foo"));
bcopy(pcb0, pcb, sizeof(*pcb));
tf = td->td_frame;
KASSERT(tf != NULL, ("foo"));
bcopy(td0->td_frame, tf, sizeof(*tf));
tf->tf_length = sizeof(struct trapframe);
tf->tf_flags = FRAME_SYSCALL;
tf->tf_special.ndirty = 0;
tf->tf_scratch.gr8 = 0;
tf->tf_scratch.gr9 = 1;
tf->tf_scratch.gr10 = 0;
pcb = td->td_pcb;
KASSERT(pcb != NULL, ("foo"));
bcopy(td0->td_pcb, pcb, sizeof(*pcb));
pcb->pcb_special.bspstore = td->td_kstack;
pcb->pcb_special.pfs = 0;
pcb->pcb_current_pmap = vmspace_pmap(td->td_proc->p_vmspace);

View file

@ -1373,8 +1373,7 @@ thread_schedule_upcall(struct thread *td, struct kse_upcall *ku)
(unsigned) RANGEOF(struct thread, td_startcopy, td_endcopy));
thread_link(td2, ku->ku_ksegrp);
/* inherit blocked thread's context */
bcopy(td->td_frame, td2->td_frame, sizeof(struct trapframe));
cpu_set_upcall(td2, td->td_pcb);
cpu_set_upcall(td2, td);
/* Let the new thread become owner of the upcall */
ku->ku_owner = td2;
td2->td_upcall = ku;

View file

@ -156,7 +156,6 @@ thr_create(struct thread *td, struct thr_create_args *uap)
PROC_LOCK(td->td_proc);
td0->td_sigmask = td->td_sigmask;
PROC_UNLOCK(td->td_proc);
bcopy(td->td_frame, td0->td_frame, sizeof(struct trapframe));
td0->td_ucred = crhold(td->td_ucred);
/* Initialize our kse structure. */
@ -165,7 +164,7 @@ thr_create(struct thread *td, struct thr_create_args *uap)
RANGEOF(struct kse, ke_startzero, ke_endzero));
/* Set up our machine context. */
cpu_set_upcall(td0, td->td_pcb);
cpu_set_upcall(td0, td);
error = set_mcontext(td0, &ctx.uc_mcontext);
if (error != 0) {
kse_free(ke0);

View file

@ -1373,8 +1373,7 @@ thread_schedule_upcall(struct thread *td, struct kse_upcall *ku)
(unsigned) RANGEOF(struct thread, td_startcopy, td_endcopy));
thread_link(td2, ku->ku_ksegrp);
/* inherit blocked thread's context */
bcopy(td->td_frame, td2->td_frame, sizeof(struct trapframe));
cpu_set_upcall(td2, td->td_pcb);
cpu_set_upcall(td2, td);
/* Let the new thread become owner of the upcall */
ku->ku_owner = td2;
td2->td_upcall = ku;

View file

@ -278,7 +278,7 @@ cpu_thread_setup(struct thread *td)
}
void
cpu_set_upcall(struct thread *td, void *pcb)
cpu_set_upcall(struct thread *td, struct thread *td0)
{
return;

View file

@ -278,7 +278,7 @@ cpu_thread_setup(struct thread *td)
}
void
cpu_set_upcall(struct thread *td, void *pcb)
cpu_set_upcall(struct thread *td, struct thread *td0)
{
return;

View file

@ -147,12 +147,14 @@ cpu_thread_setup(struct thread *td)
}
void
cpu_set_upcall(struct thread *td, void *v)
cpu_set_upcall(struct thread *td, struct thread *td0)
{
struct trapframe *tf;
struct frame *fr;
struct pcb *pcb;
bcopy(td0->td_frame, td->td_frame, sizeof(struct trapframe));
pcb = td->td_pcb;
tf = td->td_frame;
fr = (struct frame *)tf - 1;

View file

@ -885,7 +885,7 @@ void ksegrp_stash(struct ksegrp *kg);
struct kse *kse_alloc(void);
void kse_free(struct kse *ke);
void kse_stash(struct kse *ke);
void cpu_set_upcall(struct thread *td, void *pcb);
void cpu_set_upcall(struct thread *td, struct thread *td0);
void cpu_set_upcall_kse(struct thread *td, struct kse_upcall *ku);
void cpu_thread_clean(struct thread *);
void cpu_thread_exit(struct thread *);