History log of /freebsd-10-stable/sys/sys/proc.h
Revision Date Author Comments
# 318743 23-May-2017 badger

move p_sigqueue to the end of struct proc

In order to preserve KBI in stable branches, replace the existing
p_sigqueue slot with padding and move the expanded (as of r315949)
p_sigqueue to the end of the struct.

This is a repeat of r317529 (which concerned td_sigqueue in struct
thread) for p_sigqueue in struct proc.

Virtualbox modules (and possibly others) are affected without this fix.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D10843


# 318192 11-May-2017 jhb

MFC 313407,313449: Copy ELF machine/flags from binaries to core dumps.

313407:
Copy the e_machine and e_flags fields from the binary into an ELF core dump.

In the kernel, cache the machine and flags fields from ELF header to use in
the ELF header of a core dump. For gcore, the copy these fields over from
the ELF header in the binary.

This matters for platforms which encode ABI information in the flags field
(such as o32 vs n32 on MIPS).

313449:
Trim trailing whitespace (mostly introduced in r313407).

Sponsored by: DARPA / AFRL


# 317529 27-Apr-2017 badger

Move td_sigqueue to the end of struct thread

In order to preserve KBI in stable branches, replace the existing
td_sigqueue slot with padding and move the expanded (as of r315949)
td_sigqueue to the end of the struct.

Reported by: jhb
Suggested by: kib
Reviewed by: jhb, kib, vangyzen
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D10515


# 316841 14-Apr-2017 avg

MFC r315851: move thread switch tracing from mi_switch to sched_switch


# 304905 27-Aug-2016 kib

MFC r303426:
Rewrite subr_sleepqueue.c use of callouts to not depend on the
specifics of callout KPI.


# 304619 22-Aug-2016 jhb

MFC 302379: Correct locking annotation for p_comm.

p_comm is changed during exec, it is not read-only after fork.


# 304613 22-Aug-2016 markj

MFC r304440, r304487:
Fix some handling of P2_PTRACE_FSTP.


# 304499 19-Aug-2016 jhb

MFC 303001: Add PTRACE_VFORK to trace vfork events.

First, PL_FLAG_FORKED events now also set a PL_FLAG_VFORKED flag when
the new child was created via vfork() rather than fork(). Second, a
new PL_FLAG_VFORK_DONE event can now be enabled via the PTRACE_VFORK
event mask. This new stop is reported after the vfork parent resumes
due to the child calling exit or exec. Debuggers can use this stop to
reinsert breakpoints in the vfork parent process before it resumes.


# 304190 15-Aug-2016 kib

MFC r303423:
Force SIGSTOP to be the first signal reported after the attach.


# 304188 15-Aug-2016 jhb

MFC 302900,302902,302921,303461,304009:
Add a mask of optional ptrace() events.

302900:
Add a test for user signal delivery.

This test verifies we get the correct ptrace event details when a signal
is posted to a traced process from userland.

302902:
Add a mask of optional ptrace() events.

ptrace() now stores a mask of optional events in p_ptevents. Currently
this mask is a single integer, but it can be expanded into an array of
integers in the future.

Two new ptrace requests can be used to manipulate the event mask:
PT_GET_EVENT_MASK fetches the current event mask and PT_SET_EVENT_MASK
sets the current event mask.

The current set of events include:
- PTRACE_EXEC: trace calls to execve().
- PTRACE_SCE: trace system call entries.
- PTRACE_SCX: trace syscam call exits.
- PTRACE_FORK: trace forks and auto-attach to new child processes.
- PTRACE_LWP: trace LWP events.

The S_PT_SCX and S_PT_SCE events in the procfs p_stops flags have
been replaced by PTRACE_SCE and PTRACE_SCX. PTRACE_FORK replaces
P_FOLLOW_FORK and PTRACE_LWP replaces P2_LWP_EVENTS.

The PT_FOLLOW_FORK and PT_LWP_EVENTS ptrace requests remain for
compatibility but now simply toggle corresponding flags in the
event mask.

While here, document that PT_SYSCALL, PT_TO_SCE, and PT_TO_SCX both
modify the event mask and continue the traced process.

302921:
Rename PTRACE_SYSCALL to LINUX_PTRACE_SYSCALL.

303461:
Note that not all optional ptrace events use SIGTRAP.

New child processes attached due to PTRACE_FORK use SIGSTOP instead of
SIGTRAP. All other ptrace events use SIGTRAP.

304009:
Remove description of P_FOLLOWFORK as this flag was removed.


# 304017 12-Aug-2016 jhb

MFC 292894,292896: Add ptrace(2) reporting for LWP events.

292894:
Add ptrace(2) reporting for LWP events.

Add two new LWPINFO flags: PL_FLAG_BORN and PL_FLAG_EXITED for reporting
thread creation and destruction. Newly created threads will stop to report
PL_FLAG_BORN before returning to userland and exiting threads will stop to
report PL_FLAG_EXIT before exiting completely. Both of these events are
only enabled and reported if PT_LWP_EVENTS is enabled on a process.

292896:
Document the recently added support for ptrace(2) LWP events.


# 303591 31-Jul-2016 kib

MFC r303424:
Fix typo in comment.


# 302066 21-Jun-2016 bdrewery

MFC r297156,r297157,r297158,r297159,r297161,r297172,r297200,r297201,r297202,
r297203,r297256:

r297156:
Track filemon usage via a proc.p_filemon pointer rather than its own lists.
r297157:
Stop tracking stat(2).
r297158:
Consolidate open(2) and openat(2) code.
r297159:
Use curthread for vn_fullpath.
r297161:
Attempt to use the namecache for openat(2) path resolution.
r297172:
Consolidate common link(2) logic.
r297200:
Follow-up r297156: Close the log in filemon_dtr rather than in the last
reference.
r297201:
Return any log write failure encountered when closing the filemon fd.
r297202:
Remove unused done argument to copyinstr(9).
r297203:
Handle copyin failures.
r297256:
Remove unneeded return left from refactoring.

Relnotes: yes (filemon stability/performance updates)
Sponsored by: EMC / Isilon Storage Division


# 300060 17-May-2016 pfg

MFC r298931, r298981, r299375:

Minor spelling fixes in:
sys/dev, sys/sys

Many of these have user-visible strings.


# 293489 09-Jan-2016 dchagin

MFC r283381:

In preparation for switching linuxulator to the use the native 1:1
threads add per thread emulator state data.


# 293473 09-Jan-2016 dchagin

To facillitate an upcoming Linuxulator merging partially
MFC r275121 (by kib). Only merge the syntax changes from r275121,
PROC_*LOCK() macros still lock the same proc spinlock.

The process spin lock currently has the following distinct uses:

- Threads lifetime cycle, in particular, counting of the threads in
the process, and interlocking with process mutex and thread lock.
The main reason of this is that turnstile locks are after thread
locks, so you e.g. cannot unlock blockable mutex (think process
mutex) while owning thread lock.

- Virtual and profiling itimers, since the timers activation is done
from the clock interrupt context. Replace the p_slock by p_itimmtx
and PROC_ITIMLOCK().

- Profiling code (profil(2)), for similar reason. Replace the p_slock
by p_profmtx and PROC_PROFLOCK().

- Resource usage accounting. Need for the spinlock there is subtle,
my understanding is that spinlock blocks context switching for the
current thread, which prevents td_runtime and similar fields from
changing (updates are done at the mi_switch()). Replace the p_slock
by p_statmtx and PROC_STATLOCK().

Discussed with: kib


# 293314 07-Jan-2016 mjg

MFC r292440:

proc: fix a race which could result in dereference of bad p_pgrp pointer on
fork

During fork p_starcopy - p_endcopy area of a process is populated with bcopy
with only proc lock held. Another forking thread can find such a process and
proceed to access p_pgrp included in said area.

Fix the problem by moving the field outside. It is being properly assigned
later.


# 289780 22-Oct-2015 jhb

MFC 287386,288949,288993:
Export current system call code and argument count for system call entry
and exit events. To preserve the ABI, the new fields are moved to the
end of struct thread in these branches (unlike HEAD) and explicitly copied
when new threads are created. In addition, the new tests are only added
in 10.

r287386:
Export current system call code and argument count for system call entry
and exit events. procfs stop events for system call tracing report these
values (argument count for system call entry and code for system call exit),
but ptrace() does not provide this information. (Note that while the system
call code can be determined in an ABI-specific manner during system call
entry, it is not generally available during system call exit.)

The values are exported via new fields at the end of struct ptrace_lwpinfo
available via PT_LWPINFO.

r288949:
Fix various edge cases related to system call tracing.
- Always set td_dbg_sc_* when P_TRACED is set on system call entry
even if the debugger is not tracing system call entries. This
ensures the fields are valid when reporting other stops that
occur at system call boundaries such as for PT_FOLLOW_FORKS or
when only tracing system call exits.
- Set TDB_SCX when reporting the stop for a new child process in
fork_return(). This causes the event to be reported as a system
call exit.
- Report a system call exit event in fork_return() for new threads in
a traced process.
- Copy td_dbg_sc_* to new threads instead of zeroing. This ensures
that td_dbg_sc_code in particular will report the system call that
created the new thread or process when it reports a system call
exit event in fork_return().
- Add new ptrace tests to verify that new child processes and threads
report system call exit events with a valid pl_syscall_code via
PT_LWPINFO.

r288993:
Document the recently added pl_syscall_* fields in struct ptrace_lwpinfo.


# 286843 17-Aug-2015 ed

MFC r285715:

Add an API for easily creating userspace threads in kernelspace.

This change refactors the existing create_thread() function to be more
generic. It replaces almost all of its arguments by a callback that can
be used to extract the thread ID and copy it out to the right place, but
also to perform additional initialization steps, such as setting the
trapframe. This also makes the difference between thr_new() and
thr_create() more clear in my opinion.

This function is going to be used by the CloudABI compatibility layer.

It looks like the OpenSolaris compatibility framework already provides a
function called thread_create(). Rename this function to
do_thread_create() and use a macro to deal with the namespacing
conflict. A similar approach is already used for thread_exit().


# 284199 10-Jun-2015 kib

MFC r283600:
Perform SU cleanup in the AST handler. Do not sleep waiting for SU cleanup
while owning vnode lock.

On MFC, for KBI stability, td_su member was moved to the end of the
struct thread.


# 283279 22-May-2015 kib

MFC r282944:
Decrement p_boundary_count in the single-threading thread, during making
other thread runnable. This guarantees that upon return from the
thread_single_end(), p_boundary_count is zero.


# 277698 25-Jan-2015 kib

MFC r277322:
Add procctl(2) PROC_TRACE_CTL command to enable or disable debugger
attachment to the process.


# 277379 19-Jan-2015 kib

MFC r277055:
Revert r263475: TDP_DEVMEMIO no longer needed.


# 276686 05-Jan-2015 kib

Merge reaper facility.

MFC r270443 (by mjg):
Properly reparent traced processes when the tracer dies.

MFC r273452 (by mjg):
Plug unnecessary PRS_NEW check in kern_procctl.

MFC 275800:
Add a facility for non-init process to declare itself the reaper of
the orphaned descendants.

MFC r275821:
Add missed break.

MFC r275846 (by mckusick):
Add some additional clarification and fix a few gammer nits.

MFC r275847 (by bdrewery):
Bump Dd for r275846.


# 276272 26-Dec-2014 kib

MFC r275745:
Add facility to stop all userspace processes.

MFC r275753:
Fix gcc build.

MFC r275820:
Add missed break.


# 275794 15-Dec-2014 kib

MFC r275616:
Thread waiting for the vfork(2)-ed child to exec or exit, must allow
for the suspension.

MFC r275683 (by andreast):
Fix build for powerpc(32|64) kernels.

MFC r275686 (by andreast):
Fix kernel build for booke.

r275639 (by andrew) is not merged, since arm/arm/syscall.c is not
present on the stable/10 branch, and arm/arm/trap.c already includes
sys/kernel.h.


# 271372 10-Sep-2014 kib

MFC r271000:
Delay the return from thread_single(SINGLE_EXIT) until all threads are
really destroyed by thread_stash() after the last switch out.

MFC r271007:
Retire thread_unthread().

MFC r271008:
Style.

Approved by: re (marius)


# 270264 21-Aug-2014 kib

MFC r269656:
Implement and use proc_realparent(9).

MFC r270024 (by markj):
Correct the order of arguments passed to LIST_INSERT_AFTER().

For merge, the p_treeflag member of struct proc was moved to the end
of the structure, to keep KBI intact.


# 266582 23-May-2014 kib

MFC r266464:
In execve(2), postpone the free of old vmspace until the threads are resumed
and exited.


# 263875 28-Mar-2014 kib

MFC r263475:
Fix two issues with /dev/mem access on amd64, both causing kernel page
faults.

First, for accesses to direct map region should check for the limit by
which direct map is instantiated.

Second, for accesses to the kernel map, use a new thread private flag
TDP_DEVMEMIO, which instructs vm_fault() to return error when fault
happens on the MAP_ENTRY_NOFAULT entry, instead of panicing.

MFC r263498:
Add change forgotten in r263475. Make dmaplimit accessible outside
amd64/pmap.c.


# 260385 06-Jan-2014 scottl

MFC Alexander Motin's GEOM direct dispatch work:

r256603:
Introduce new function devstat_end_transaction_bio_bt(), adding new argument
to specify present time. Use this function to move binuptime() out of lock,
substantially reducing lock congestion when slow timecounter is used.

r256606:
Move g_io_deliver() out of the lock, as required for direct dispatch.
Move g_destroy_bio() out too to reduce lock scope even more.

r256607:
Fix passing uninitialized bio_resid argument to g_trace().

r256610:
Add unmapped I/O support to GEOM RAID.

r256830:
Restore BIO_UNMAPPED and BIO_TRANSIENT_MAPPING in biodonne() when unmapping
temporary mapped buffer. That fixes double unmap if biodone() called twice
for the same BIO (but with different done methods).

r256880:
Merge GEOM direct dispatch changes from the projects/camlock branch.

When safety requirements are met, it allows to avoid passing I/O requests
to GEOM g_up/g_down thread, executing them directly in the caller context.
That allows to avoid CPU bottlenecks in g_up/g_down threads, plus avoid
several context switches per I/O.

r259247:
Fix bug introduced at r256607. We have to recalculate bp_resid here since
sizes of original and completed requests may differ due to end of media.

Testing of the stable/10 merge was done by Netflix, but all of the credit
goes to Alexander and iX Systems.

Submitted by: mav
Sponsored by: iX Systems


# 286843 17-Aug-2015 ed

MFC r285715:

Add an API for easily creating userspace threads in kernelspace.

This change refactors the existing create_thread() function to be more
generic. It replaces almost all of its arguments by a callback that can
be used to extract the thread ID and copy it out to the right place, but
also to perform additional initialization steps, such as setting the
trapframe. This also makes the difference between thr_new() and
thr_create() more clear in my opinion.

This function is going to be used by the CloudABI compatibility layer.

It looks like the OpenSolaris compatibility framework already provides a
function called thread_create(). Rename this function to
do_thread_create() and use a macro to deal with the namespacing
conflict. A similar approach is already used for thread_exit().


# 284199 10-Jun-2015 kib

MFC r283600:
Perform SU cleanup in the AST handler. Do not sleep waiting for SU cleanup
while owning vnode lock.

On MFC, for KBI stability, td_su member was moved to the end of the
struct thread.


# 283279 22-May-2015 kib

MFC r282944:
Decrement p_boundary_count in the single-threading thread, during making
other thread runnable. This guarantees that upon return from the
thread_single_end(), p_boundary_count is zero.


# 277698 25-Jan-2015 kib

MFC r277322:
Add procctl(2) PROC_TRACE_CTL command to enable or disable debugger
attachment to the process.


# 277379 19-Jan-2015 kib

MFC r277055:
Revert r263475: TDP_DEVMEMIO no longer needed.


# 276686 05-Jan-2015 kib

Merge reaper facility.

MFC r270443 (by mjg):
Properly reparent traced processes when the tracer dies.

MFC r273452 (by mjg):
Plug unnecessary PRS_NEW check in kern_procctl.

MFC 275800:
Add a facility for non-init process to declare itself the reaper of
the orphaned descendants.

MFC r275821:
Add missed break.

MFC r275846 (by mckusick):
Add some additional clarification and fix a few gammer nits.

MFC r275847 (by bdrewery):
Bump Dd for r275846.


# 276272 26-Dec-2014 kib

MFC r275745:
Add facility to stop all userspace processes.

MFC r275753:
Fix gcc build.

MFC r275820:
Add missed break.


# 275794 15-Dec-2014 kib

MFC r275616:
Thread waiting for the vfork(2)-ed child to exec or exit, must allow
for the suspension.

MFC r275683 (by andreast):
Fix build for powerpc(32|64) kernels.

MFC r275686 (by andreast):
Fix kernel build for booke.

r275639 (by andrew) is not merged, since arm/arm/syscall.c is not
present on the stable/10 branch, and arm/arm/trap.c already includes
sys/kernel.h.


# 271372 10-Sep-2014 kib

MFC r271000:
Delay the return from thread_single(SINGLE_EXIT) until all threads are
really destroyed by thread_stash() after the last switch out.

MFC r271007:
Retire thread_unthread().

MFC r271008:
Style.

Approved by: re (marius)


# 270264 21-Aug-2014 kib

MFC r269656:
Implement and use proc_realparent(9).

MFC r270024 (by markj):
Correct the order of arguments passed to LIST_INSERT_AFTER().

For merge, the p_treeflag member of struct proc was moved to the end
of the structure, to keep KBI intact.


# 266582 23-May-2014 kib

MFC r266464:
In execve(2), postpone the free of old vmspace until the threads are resumed
and exited.


# 263875 28-Mar-2014 kib

MFC r263475:
Fix two issues with /dev/mem access on amd64, both causing kernel page
faults.

First, for accesses to direct map region should check for the limit by
which direct map is instantiated.

Second, for accesses to the kernel map, use a new thread private flag
TDP_DEVMEMIO, which instructs vm_fault() to return error when fault
happens on the MAP_ENTRY_NOFAULT entry, instead of panicing.

MFC r263498:
Add change forgotten in r263475. Make dmaplimit accessible outside
amd64/pmap.c.


# 260385 06-Jan-2014 scottl

MFC Alexander Motin's GEOM direct dispatch work:

r256603:
Introduce new function devstat_end_transaction_bio_bt(), adding new argument
to specify present time. Use this function to move binuptime() out of lock,
substantially reducing lock congestion when slow timecounter is used.

r256606:
Move g_io_deliver() out of the lock, as required for direct dispatch.
Move g_destroy_bio() out too to reduce lock scope even more.

r256607:
Fix passing uninitialized bio_resid argument to g_trace().

r256610:
Add unmapped I/O support to GEOM RAID.

r256830:
Restore BIO_UNMAPPED and BIO_TRANSIENT_MAPPING in biodonne() when unmapping
temporary mapped buffer. That fixes double unmap if biodone() called twice
for the same BIO (but with different done methods).

r256880:
Merge GEOM direct dispatch changes from the projects/camlock branch.

When safety requirements are met, it allows to avoid passing I/O requests
to GEOM g_up/g_down thread, executing them directly in the caller context.
That allows to avoid CPU bottlenecks in g_up/g_down threads, plus avoid
several context switches per I/O.

r259247:
Fix bug introduced at r256607. We have to recalculate bp_resid here since
sizes of original and completed requests may differ due to end of media.

Testing of the stable/10 merge was done by Netflix, but all of the credit
goes to Alexander and iX Systems.

Submitted by: mav
Sponsored by: iX Systems