History log of /src/sys/kern/subr_pcu.c |
Revision | | Date | Author | Comments |
1.28 |
| 09-Apr-2023 |
riastradh | kern: KASSERT(A && B) -> KASSERT(A); KASSERT(B)
|
1.27 |
| 26-Oct-2022 |
riastradh | sys/pcu.h: New home for extern pcu_ops_md_defs.
XXX Should split sys/pcu.h up into the part that sys/lwp.h needs, which triggers rebuild of entire kernel, and the parts needed only by subr_pcu.c and by MD FP/SIMD state management logic.
|
1.26 |
| 08-Feb-2022 |
riastradh | kern: Mark some functions __diagused to pacify clang.
These functions are called only in KASSERT. This shouldn't be a problem since the recent change to make KASSERT compile (but not run) the expression, via sizeof, so the functions are referenced -- which I did in order to avoid having #ifdefs and regular build breakage because someone forgot to build with or without DIAGNOSTIC. But apparently clang decided to make it a problem.
Maybe we should just set -Wno-unneeded-internal-declaration -- not clear it flags any real problems, but it takes effort to research because apparently clang has no documentation about what else it does or why anyone decided this is objectionable enough to turn it on by default. (The only documentation it seems to have, two example warning messages with no elaboration at <https://releases.llvm.org/13.0.0/tools/clang/docs/DiagnosticsReference.html#wunneeded-internal-declaration>, seems to indicate it is mixed up with warning about static non-inline functions in header files.)
|
1.25 |
| 01-Jan-2022 |
christos | Always declare function used in KASSERT
|
1.24 |
| 07-Aug-2020 |
christos | pcu_available_p is only used in KASSERT(), fix non-diagnostic build.
|
1.23 |
| 01-Aug-2020 |
riastradh | Teach pcu(9) about LW_SYSTEM_FPU -- kthreads with fpu enabled.
|
1.22 |
| 06-Jun-2020 |
thorpej | Relax the KASSERT() in pcu_discard_all() to allow non-curlwp if it is in LSIDL state, which can happen if the new LWP is exiting before it's ever run, e.g. if an error occurs in _lwp_create(2).
|
1.21 |
| 16-Oct-2017 |
bouyer | branches: 1.21.8; PR port-arm/52603: There is a race here, as seen on arm with FPU: LWP L is running but not on CPU, has its FPU state on CPU2 which has not been released yet, so fpexc still has VFP_FPEXC_EN set in the PCB copy.
LWP L is scheduled on CPU1, CPU1 calls cpu_switchto() for L in mi_switch(). cpu_switchto() will set VFP_FPEXC_EN in the FPU's fpexc register per the PCB fpexc copy.
Before CPU1 calls pcu_switchpoint() for L, CPU2 calls pcu_do_op(PCU_CMD_SAVE | PCU_CMD_RELEASE) for L because it still holds its FPU state and wants to load another lwp. This cause VFP_FPEXC_EN to be cleared in the PCB copy, but not in CPU1's register. L's l_pcu_cpu is set to NULL.
When CPU1 calls pcu_switchpoint() for L it see l_pcu_cpu is NULL, and doesn't call the release callback.
Now CPU1 has its FPU enabled but with the wrong FPU state.
Fix by releasing the PCU even if l_pcu_cpu is NULL.
|
1.20 |
| 16-Mar-2017 |
chs | branches: 1.20.6; allow pcu_save() and pcu_discard() to be called on other threads, ptrace needs to use it that way.
|
1.19 |
| 25-May-2014 |
rmind | branches: 1.19.4; 1.19.8; 1.19.12; pcu: replace xcall(9) used for messaging with ipi(9). This provides a better performance of the PCU (e.g. FPU) state synchronisation.
|
1.18 |
| 16-May-2014 |
rmind | pcu(9): - Remove PCU_KERNEL (hi matt!) and significantly simplify the code. This experimental feature was tried on ARM did not meet the expectations. It may be revived one day, but it should be done in a much simpler way. - Add a message structure for xcall function, pass the LWP ower and thus optimise a race condition: if LWP is discarding its state on a remote CPU, but another LWP already did it - do not cause an unecessary re-faulting. - Reduce the variety of flags for PCU operations (only PCU_VALID and PCU_REENABLE are used now), pass them only to the pcu_state_load(). - Rename pcu_used_p() to pcu_valid_p(); hopefully it is less confusing. - pcu_save_all_on_cpu: SPL ought to be used here. - Update and improve the pcu(9) man page; it needs wizd(8) though.
|
1.17 |
| 23-Jan-2014 |
skrll | branches: 1.17.2; Pass PCU_LOADED to pcu_state_load in the "this CPU already has our PCU state loaded" of pcu_load.
ok, gimpy@ and rmind@
|
1.16 |
| 26-Nov-2013 |
rmind | Switch XC_HIGHPRI to run at IPL_SOFTSERIAL i.e. the highest software level. Adjust pcu(9) to this xcall(9) change. This may fix the problems after x86 FPU was converted to use PCU, since it avoids heavy contention at the lower levels (particularly, IPL_SOFTNET). This is a good illustration why software interrupts should generally avoid any blocking on locks.
|
1.15 |
| 22-Aug-2013 |
drochner | -extend the pcu(9) API by a function which saves all context on the current CPU, and use it if a CPU is taken offline -add a bool argument to pcu_discard which tells whether the internal "LWP has used the coprocessor" flag should be set or reset. The flag is reported by pcu_used_p(). If set, future accesses should use the state stored in the PCB. If reset, it should be reset to default. The former case is useful for setmcontext(). With that, it should not be necessary anymore to manage the "FPU used" state by an additional MD variable.
approved by matt
|
1.14 |
| 31-Dec-2012 |
matt | branches: 1.14.2; Remove a debugging printf
|
1.13 |
| 26-Dec-2012 |
matt | Add support for kernel-based code to use a PCU. (for memory to memory copies or in_cksum or ...)
|
1.12 |
| 30-Aug-2012 |
matt | branches: 1.12.2; KASSERT -> KASSERTMSG
|
1.11 |
| 18-Apr-2012 |
yamt | comment
|
1.10 |
| 27-Sep-2011 |
jym | branches: 1.10.2; 1.10.6; Modify *ASSERTMSG() so they are now used as variadic macros. The main goal is to provide routines that do as KASSERT(9) says: append a message to the panic format string when the assertion triggers, with optional arguments.
Fix call sites to reflect the new definition.
Discussed on tech-kern@. See http://mail-index.netbsd.org/tech-kern/2011/09/07/msg011427.html
|
1.9 |
| 13-Jun-2011 |
matt | Deal with PCU state when performing coredumps. As the kernel moves each LWP into LSSUSPENDED state, have that LWP save its PCU state for the coredump and release its PCU status since its probably going to be exiting very soon. Make pcu_save_all tolerate for being called for non-curlwp if that lwp belongs to the same process, has a state of LSSUSPENDED, and no PCUs are in use.
Make the MD coredump code use pcu_save_all(l) since it'll need to save all the PCU state anyways and can take advantage of the above tests.
|
1.8 |
| 07-Jun-2011 |
matt | Make pcu_save_all and pcu_discard_all KASSERTs accept LW_SYSTEM threads since kthread_create will call lwp_create with lwp0 which may not be curlwp.
|
1.7 |
| 06-Jun-2011 |
matt | Add some more MI hook points for PCU. Discard the PCU state at lwp_exit and at exec time. Before forking, save the PCU state so that cpu_lwp_fork doesn't have. Remove MD code which did that before.
|
1.6 |
| 02-May-2011 |
matt | branches: 1.6.2; 1.6.4; Don't call pcu_do_op in pcu_load to save current context, use pcu_cpu_op instead (since it will deal with ci->ci_pcu_curlwp[id] being NULL).
|
1.5 |
| 02-May-2011 |
matt | A little more constification
|
1.4 |
| 02-May-2011 |
rmind | Extend PCU: - Add pcu_ops_t::pcu_state_release() operation for PCU_RELEASE case. - Add pcu_switchpoint() to perform release operation on context switch. - Sprinkle const, misc. Also, sync MIPS with changes.
Per discussions with matt@.
|
1.3 |
| 19-Feb-2011 |
matt | branches: 1.3.2; 1.3.4; Default PCU_UNIT_COUNT to 0. If 0, don't compile the contents of subr_pcu.c and don't include the pcu related members into struct lwp.
|
1.2 |
| 17-Feb-2011 |
matt | Add a bool to pcu_state_save which indicates whether the PCU is going to be released after the save is done.
|
1.1 |
| 17-Feb-2011 |
rmind | Add PCU (Per-CPU Unit) - an interface to manage synchronization of any per CPU context tied with an LWP. Main use - lazy FPU handling on SMP.
Requested by matt@, will be used on mips64. Note: implementation will be improved to use IPIs before adopting on x86. OK ad@.
|
1.3.4.4 |
| 12-Jun-2011 |
rmind | sync with head
|
1.3.4.3 |
| 31-May-2011 |
rmind | sync with head
|
1.3.4.2 |
| 05-Mar-2011 |
rmind | sync with head
|
1.3.4.1 |
| 19-Feb-2011 |
rmind | file subr_pcu.c was added on branch rmind-uvmplock on 2011-03-05 20:55:19 +0000
|
1.3.2.2 |
| 05-Mar-2011 |
bouyer | Sync with HEAD
|
1.3.2.1 |
| 19-Feb-2011 |
bouyer | file subr_pcu.c was added on branch bouyer-quota2 on 2011-03-05 15:10:40 +0000
|
1.6.4.2 |
| 06-Jun-2011 |
jruoho | Sync with HEAD.
|
1.6.4.1 |
| 02-May-2011 |
jruoho | file subr_pcu.c was added on branch jruoho-x86intr on 2011-06-06 09:09:35 +0000
|
1.6.2.1 |
| 23-Jun-2011 |
cherry | Catchup with rmind-uvmplock merge.
|
1.10.6.1 |
| 29-Apr-2012 |
mrg | sync to latest -current.
|
1.10.2.4 |
| 22-May-2014 |
yamt | sync with head.
for a reference, the tree before this commit was tagged as yamt-pagecache-tag8.
this commit was splitted into small chunks to avoid a limitation of cvs. ("Protocol error: too many arguments")
|
1.10.2.3 |
| 23-Jan-2013 |
yamt | sync with head
|
1.10.2.2 |
| 30-Oct-2012 |
yamt | sync with head
|
1.10.2.1 |
| 23-May-2012 |
yamt | sync with head.
|
1.12.2.3 |
| 03-Dec-2017 |
jdolecek | update from HEAD
|
1.12.2.2 |
| 20-Aug-2014 |
tls | Rebase to HEAD as of a few days ago.
|
1.12.2.1 |
| 25-Feb-2013 |
tls | resync with head
|
1.14.2.2 |
| 18-May-2014 |
rmind | sync with head
|
1.14.2.1 |
| 28-Aug-2013 |
rmind | sync with head
|
1.17.2.1 |
| 10-Aug-2014 |
tls | Rebase.
|
1.19.12.1 |
| 21-Apr-2017 |
bouyer | Sync with HEAD
|
1.19.8.1 |
| 20-Mar-2017 |
pgoyette | Sync with HEAD
|
1.19.4.1 |
| 28-Aug-2017 |
skrll | Sync with HEAD
|
1.20.6.2 |
| 07-Jun-2020 |
martin | Pull up following revision(s) (requested by thorpej in ticket #949):
sys/kern/subr_pcu.c: revision 1.22
Relax the KASSERT() in pcu_discard_all() to allow non-curlwp if it is in LSIDL state, which can happen if the new LWP is exiting before it's ever run, e.g. if an error occurs in _lwp_create(2).
|
1.20.6.1 |
| 24-Oct-2017 |
snj | Pull up following revision(s) (requested by bouyer in ticket #326): sys/arch/arm/vfp/vfp_init.c: revision 1.54-1.55 sys/kern/subr_pcu.c: revision 1.21 PR port-arm/52603: There is a race here, as seen on arm with FPU: LWP L is running but not on CPU, has its FPU state on CPU2 which has not been released yet, so fpexc still has VFP_FPEXC_EN set in the PCB copy. LWP L is scheduled on CPU1, CPU1 calls cpu_switchto() for L in mi_switch(). cpu_switchto() will set VFP_FPEXC_EN in the FPU's fpexc register per the PCB fpexc copy. Before CPU1 calls pcu_switchpoint() for L, CPU2 calls pcu_do_op(PCU_CMD_SAVE | PCU_CMD_RELEASE) for L because it still holds its FPU state and wants to load another lwp. This cause VFP_FPEXC_EN to be cleared in the PCB copy, but not in CPU1's register. L's l_pcu_cpu is set to NULL. When CPU1 calls pcu_switchpoint() for L it see l_pcu_cpu is NULL, and doesn't call the release callback. Now CPU1 has its FPU enabled but with the wrong FPU state. Fix by releasing the PCU even if l_pcu_cpu is NULL. -- In the REENABLE case, make sur the fpexc copy in the pcb also has VFP_FPEXC_EN set. Otherwise we could trap on every context switch even if the CPU already has the VFP state. -- We KASSERT((fregs->vfp_fpexc & VFP_FPEXC_EN) == 0) just before, so enabled is always false. remove.
|
1.21.8.1 |
| 07-Jun-2020 |
martin | Pull up following revision(s) (requested by thorpej in ticket #949):
sys/kern/subr_pcu.c: revision 1.22
Relax the KASSERT() in pcu_discard_all() to allow non-curlwp if it is in LSIDL state, which can happen if the new LWP is exiting before it's ever run, e.g. if an error occurs in _lwp_create(2).
|