SMP - lazy FPU
- when a process is migrated to a different CPU it may have an active FPU context in the processor registers. We must save it and migrate it together with the process.
This commit is contained in:
@@ -54,6 +54,9 @@ PUBLIC int do_clear(struct proc * caller, message * m_ptr)
|
||||
* and mark slot as FREE. Also mark saved fpu contents as not significant.
|
||||
*/
|
||||
RTS_SETFLAGS(rc, RTS_SLOT_FREE);
|
||||
|
||||
/* release FPU */
|
||||
release_fpu(rc);
|
||||
rc->p_misc_flags &= ~MF_FPU_INITIALIZED;
|
||||
|
||||
/* Release the process table slot. If this is a system process, also
|
||||
@@ -70,10 +73,6 @@ PUBLIC int do_clear(struct proc * caller, message * m_ptr)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* release FPU */
|
||||
if (fpu_owner == rc)
|
||||
release_fpu();
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,8 +46,7 @@ PUBLIC int do_exec(struct proc * caller, message * m_ptr)
|
||||
* will be initialized, when it's used next time. */
|
||||
rp->p_misc_flags &= ~MF_FPU_INITIALIZED;
|
||||
/* force reloading FPU if the current process is the owner */
|
||||
if (rp == fpu_owner)
|
||||
release_fpu();
|
||||
release_fpu(rp);
|
||||
return(OK);
|
||||
}
|
||||
#endif /* USE_EXEC */
|
||||
|
||||
@@ -53,10 +53,7 @@ PUBLIC int do_fork(struct proc * caller, message * m_ptr)
|
||||
map_ptr= (struct mem_map *) m_ptr->PR_MEM_PTR;
|
||||
|
||||
/* make sure that the FPU context is saved in parent before copy */
|
||||
if (fpu_owner == rpp) {
|
||||
disable_fpu_exception();
|
||||
save_fpu(rpp);
|
||||
}
|
||||
save_fpu(rpp);
|
||||
/* Copy parent 'proc' struct to child. And reinitialize some fields. */
|
||||
gen = _ENDPOINT_G(rpc->p_endpoint);
|
||||
#if (_MINIX_CHIP == _CHIP_INTEL)
|
||||
|
||||
@@ -43,10 +43,7 @@ PUBLIC int do_getmcontext(struct proc * caller, message * m_ptr)
|
||||
mc.mc_fpu_flags = 0;
|
||||
if (proc_used_fpu(rp)) {
|
||||
/* make sure that the FPU context is saved into proc structure first */
|
||||
if (fpu_owner == rp) {
|
||||
disable_fpu_exception();
|
||||
save_fpu(rp);
|
||||
}
|
||||
save_fpu(rp);
|
||||
mc.mc_fpu_flags = 0 | rp->p_misc_flags & MF_FPU_INITIALIZED;
|
||||
memcpy(&(mc.mc_fpu_state), rp->p_fpu_state.fpu_save_area_p,
|
||||
FPU_XFP_SIZE);
|
||||
@@ -92,8 +89,7 @@ PUBLIC int do_setmcontext(struct proc * caller, message * m_ptr)
|
||||
} else
|
||||
rp->p_misc_flags &= ~MF_FPU_INITIALIZED;
|
||||
/* force reloading FPU in either case */
|
||||
if (fpu_owner == rp)
|
||||
release_fpu();
|
||||
release_fpu(rp);
|
||||
#endif
|
||||
|
||||
return(OK);
|
||||
|
||||
@@ -60,8 +60,7 @@ PUBLIC int do_sigreturn(struct proc * caller, message * m_ptr)
|
||||
FPU_XFP_SIZE);
|
||||
rp->p_misc_flags |= MF_FPU_INITIALIZED; /* Restore math usage flag. */
|
||||
/* force reloading FPU */
|
||||
if (fpu_owner == rp)
|
||||
release_fpu();
|
||||
release_fpu(rp);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -46,10 +46,7 @@ PUBLIC int do_sigsend(struct proc * caller, message * m_ptr)
|
||||
#if (_MINIX_CHIP == _CHIP_INTEL)
|
||||
if(proc_used_fpu(rp)) {
|
||||
/* save the FPU context before saving it to the sig context */
|
||||
if (fpu_owner == rp) {
|
||||
disable_fpu_exception();
|
||||
save_fpu(rp);
|
||||
}
|
||||
save_fpu(rp);
|
||||
memcpy(&sc.sc_fpu_state, rp->p_fpu_state.fpu_save_area_p,
|
||||
FPU_XFP_SIZE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user