Skip to content

Commit f73c9b5

Browse files
committed
mi_switch.9: Remove cpu_switch, cpu_throw
cpu_machdep.9 was added to document cpu_*, but cpu_switch and cpu_throw were already documented in mi_switch.9, and MLINKed. cpu_machdep.9 seems like the correct place for this, so remove them from mi_switch.9. Some of the removed text was stale, although there are few notes that ought to be added to cpu_machdep.9 in a future commit. Reported by: tools/pkgbase/metalog_reader.lua Reviewed by: jhb Sponsored by: The FreeBSD Foundation Fixes: 9c87cbb ("cpu_machdep.9: New manpage describing the semantics of several cpu_*") Differential Revision: https://reviews.freebsd.org/D48360
1 parent 6ba2c03 commit f73c9b5

File tree

2 files changed

+4
-66
lines changed

2 files changed

+4
-66
lines changed

share/man/man9/Makefile

-2
Original file line numberDiff line numberDiff line change
@@ -1594,8 +1594,6 @@ MLINKS+=microuptime.9 binuptime.9 \
15941594
microuptime.9 getsbinuptime.9 \
15951595
microuptime.9 nanouptime.9 \
15961596
microuptime.9 sbinuptime.9
1597-
MLINKS+=mi_switch.9 cpu_switch.9 \
1598-
mi_switch.9 cpu_throw.9
15991597
MLINKS+=mod_cc.9 CCV.9 \
16001598
mod_cc.9 DECLARE_CC_MODULE.9
16011599
MLINKS+=mtx_pool.9 mtx_pool_alloc.9 \

share/man/man9/mi_switch.9

+4-64
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,17 @@
3131
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3232
.\" POSSIBILITY OF SUCH DAMAGE.
3333
.\"
34-
.Dd January 9, 2023
34+
.Dd January 7, 2025
3535
.Dt MI_SWITCH 9
3636
.Os
3737
.Sh NAME
38-
.Nm mi_switch ,
39-
.Nm cpu_switch ,
40-
.Nm cpu_throw
38+
.Nm mi_switch
4139
.Nd switch to another thread context
4240
.Sh SYNOPSIS
4341
.In sys/param.h
4442
.In sys/proc.h
4543
.Ft void
4644
.Fn mi_switch "int flags"
47-
.Ft void
48-
.Fn cpu_switch "struct thread *oldtd" "struct thread *newtd" "struct mtx *lock"
49-
.Ft void
50-
.Fn cpu_throw "struct thread *oldtd" "struct thread *newtd"
5145
.Sh DESCRIPTION
5246
The
5347
.Fn mi_switch
@@ -168,63 +162,9 @@ running thread
168162
.Fa oldtd
169163
to the chosen thread
170164
.Fa newtd .
171-
First, it saves the context of
172-
.Fa oldtd
173-
to its Process Control Block
174-
.Po
175-
PCB,
176-
.Vt struct pcb
177-
.Pc ,
178-
pointed at by
179-
.Va oldtd->td_pcb .
180-
The function then updates important per-CPU state such as the
181-
.Dv curthread
182-
variable, and activates
183-
.Fa newtd\&'s
184-
virtual address space using its associated
185-
.Xr pmap 9
186-
structure.
187-
Finally, it reads in the saved context from
188-
.Fa newtd\&'s
189-
PCB.
190-
CPU instruction flow continues in the new thread context, on
191-
.Fa newtd\&'s
192-
kernel stack.
193-
The return from
194-
.Fn cpu_switch
195-
can be understood as a completion of the function call initiated by
196-
.Fa newtd
197-
when it was previously switched out, at some point in the distant (relative to
198-
CPU time) past.
199-
.Pp
200-
The
201-
.Fa mtx
202-
argument to
203-
.Fn cpu_switch
204-
is used to pass the mutex which will be stored as
205-
.Fa oldtd\&'s
206-
thread lock at the moment that
207-
.Fa oldtd
208-
is completely switched out.
209-
This is an implementation detail of
210-
.Fn sched_switch .
211-
.Pp
212-
.Fn cpu_throw
213-
is similar to
214-
.Fn cpu_switch
215-
except that it does not save the context of the old thread.
216-
This function is useful when the kernel does not have an old thread
217-
context to save, such as when CPUs other than the boot CPU perform their
218-
first task switch, or when the kernel does not care about the state of the
219-
old thread, such as in
220-
.Xr thread_exit 9
221-
when the kernel terminates the current thread and switches into a new
222-
thread,
223-
.Fa newtd .
224-
The
225-
.Fa oldtd
226-
argument is unused.
227165
.Sh SEE ALSO
166+
.Xr cpu_switch 9 ,
167+
.Xr cpu_throw 9 ,
228168
.Xr critical_exit 9 ,
229169
.Xr issignal 9 ,
230170
.Xr kern_yield 9 ,

0 commit comments

Comments
 (0)