| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This basically adds makes use of the C99 restrict keyword, and also
adds some 'const's to four threading functions: pthread_mutexattr_gettype(),
pthread_mutexattr_getprioceiling(), pthread_mutexattr_getprotocol(), and
pthread_mutex_getprioceiling. The changes are in accordance to POSIX/SUSv4-2018.
Hinted by: DragonFlyBSD
Relnotes: yes
MFC after: 1 month
Differential Revision: D16722
Notes:
svn path=/head/; revision=337992
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using mis-identified many licenses so this was mostly a manual - error
prone - task.
The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
Notes:
svn path=/head/; revision=326219
|
| |
|
|
|
|
|
| |
Sponsored by: The FreeBSD Foundation
Notes:
svn path=/head/; revision=297706
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
breaking the ABI. Special value is stored in the lock pointer to
indicate shared lock, and offline page in the shared memory is
allocated to store the actual lock.
Reviewed by: vangyzen (previous version)
Discussed with: deischen, emaste, jhb, rwatson,
Martin Simmons <martin@lispworks.com>
Tested by: pho
Sponsored by: The FreeBSD Foundation
Notes:
svn path=/head/; revision=296162
|
| |
|
|
|
|
|
| |
Obtained from: cpi-llvm project
Notes:
svn path=/head/; revision=285278
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(or loading a dso linked to libthr.so into process which was not
linked against threading library).
- Remove libthr interposers of the libc functions, including
__error(). Instead, functions calls are indirected through the
interposing table, similar to how pthread stubs in libc are already
done. Libc by default points either to syscall trampolines or to
existing libc implementations. On libthr load, libthr rewrites the
pointers to the cancellable implementations already in libthr. The
interposition table is separate from pthreads stubs indirection
table to not pull pthreads stubs into static binaries.
- Postpone the malloc(3) internal mutexes initialization until libthr
is loaded. This avoids recursion between calloc(3) and static
pthread_mutex_t initialization.
- Reinstall signal handlers with wrapper on libthr load. The
_rtld_is_dlopened(3) is used to avoid useless calls to sigaction(2)
when libthr is statically referenced from the main binary.
In the process, fix openat(2), swapcontext(2) and setcontext(2)
interposing. The libc symbols were exported at different versions
than libthr interposers. Export both libc and libthr versions from
libc now, with default set to the higher version from libthr.
Remove unused and disconnected swapcontext(3) userspace implementation
from libc/gen.
No objections from: deischen
Tested by: pho, antoine (exp-run) (previous versions)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Notes:
svn path=/head/; revision=276630
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Stack creation code is changed to call _rtld_get_stack_prot() to get
the stack protection right. There is a race where thread is created
during dlopen() of dso that requires executable stacks. Then,
_rtld_get_stack_prot() may return PROT_READ | PROT_WRITE, but thread
is still not linked into the thread list. In this case, the callback
misses the thread stack, and rechecks the required protection
afterward.
Reviewed by: davidxu
Notes:
svn path=/head/; revision=217191
|
| |
|
|
|
|
|
|
|
| |
defer-mode cancellation works, asynchrnous mode does not work because
it lacks of libuwind's support. stack unwinding is not enabled unless
LIBTHR_UNWIND_STACK is defined in Makefile.
Notes:
svn path=/head/; revision=212630
|
| |
|
|
| |
Notes:
svn path=/head/; revision=212536
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
some cases we want to improve:
1) if a thread signal got a signal while in cancellation point,
it is possible the TDP_WAKEUP may be eaten by signal handler
if the handler called some interruptibly system calls.
2) In signal handler, we want to disable cancellation.
3) When thread holding some low level locks, it is better to
disable signal, those code need not to worry reentrancy,
sigprocmask system call is avoided because it is a bit expensive.
The signal handler wrapper works in this way:
1) libthr installs its signal handler if user code invokes sigaction
to install its handler, the user handler is recorded in internal
array.
2) when a signal is delivered, libthr's signal handler is invoke,
libthr checks if thread holds some low level lock or is in critical
region, if it is true, the signal is buffered, and all signals are
masked, once the thread leaves critical region, correct signal
mask is restored and buffered signal is processed.
3) before user signal handler is invoked, cancellation is temporarily
disabled, after user signal handler is returned, cancellation state
is restored, and pending cancellation is rescheduled.
Notes:
svn path=/head/; revision=212076
|
| |
|
|
|
|
|
| |
time in kernel(avoid VM lookup).
Notes:
svn path=/head/; revision=178647
|
| |
|
|
|
|
|
|
|
| |
for some const dequalifiers that needs more careful investigation.
Ok'ed by: davidxu
Notes:
svn path=/head/; revision=178446
|
| |
|
|
|
|
|
| |
for it, since the new thread will reduce it by itself.
Notes:
svn path=/head/; revision=177379
|
| |
|
|
|
|
|
| |
- Use a different sigmask variable name to avoid confusing.
Notes:
svn path=/head/; revision=177378
|
| |
|
|
|
|
|
|
|
|
|
| |
_thr_suspend_check() which messes sigmask saved in thread structure.
- Don't suspend a thread has force_exit set.
- In pthread_exit(), if there is a suspension flag set, wake up waiting-
thread after setting PS_DEAD, this causes waiting-thread to break loop
in suspend_common().
Notes:
svn path=/head/; revision=177337
|
| |
|
|
|
|
|
| |
be masked when it is resumed.
Notes:
svn path=/head/; revision=177231
|
| |
|
|
|
|
|
|
|
| |
that there might be starvations, but because we have already locked the
thread, the cpuset settings will always be done before the new thread
does real-world work.
Notes:
svn path=/head/; revision=176860
|
| |
|
|
|
|
|
|
|
|
| |
we set scheduling parameters and cpu binding fully in userland, and
because default scheduling policy is SCHED_RR (time-sharing), we set
default sched_inherit to PTHREAD_SCHED_INHERIT, this saves a system
call.
Notes:
svn path=/head/; revision=176817
|
| |
|
|
|
|
|
|
|
|
|
| |
however if current thread is executing cancellation handler, signal
SIGCANCEL may have already been blocked, this is unexpected, unblock the
signal in new thread if this happens.
MFC after: 1 week
Notes:
svn path=/head/; revision=176784
|
| |
|
|
| |
Notes:
svn path=/head/; revision=176781
|
| |
|
|
|
|
|
|
| |
- Rename _thr_smp_cpus to boolean variable _thr_is_smp.
- Define CPU_SPINWAIT macro for each arch, only X86 supports it.
Notes:
svn path=/head/; revision=165241
|
| |
|
|
|
|
|
| |
reduce overheads of cancellation points.
Notes:
svn path=/head/; revision=164583
|
| |
|
|
| |
Notes:
svn path=/head/; revision=162499
|
| |
|
|
|
|
|
|
|
| |
into pthread structure to keep track of locked PTHREAD_PRIO_PROTECT mutex,
no real mutex code is changed, the mutex locking and unlocking code should
has same performance as before.
Notes:
svn path=/head/; revision=161681
|
| |
|
|
|
|
|
|
| |
written application is frequently changing thread priority for SCHED_OTHER
policy.
Notes:
svn path=/head/; revision=160331
|
| |
|
|
|
|
|
| |
pthread functions.
Notes:
svn path=/head/; revision=160321
|
| |
|
|
| |
Notes:
svn path=/head/; revision=160287
|
| |
|
|
| |
Notes:
svn path=/head/; revision=157457
|
| |
|
|
|
|
|
|
|
|
|
|
| |
to make it work, turnstile like mechanism to support priority
propagating and other realtime scheduling options in kernel
should be available to userland mutex, for the moment, I just
want to make libthr be simple and efficient thread library.
Discussed with: deischen, julian
Notes:
svn path=/head/; revision=157194
|
| |
|
|
|
|
|
| |
decreased if thread can not be created.
Notes:
svn path=/head/; revision=154113
|
| |
|
|
|
|
|
|
|
|
| |
operation, the caller is blocked util target threads are really
suspended, also avoid suspending a thread when it is holding a
critical lock.
Fix a bug in _thr_ref_delete which tests a never set flag.
Notes:
svn path=/head/; revision=154055
|
| |
|
|
| |
Notes:
svn path=/head/; revision=153496
|
| |
|
|
|
|
|
| |
replacing THR_FLAGS_SUSPENDED with THR_FLAGS_NEED_SUSPEND.
Notes:
svn path=/head/; revision=151199
|
| |
|
|
|
|
|
| |
while here.
Notes:
svn path=/head/; revision=149691
|
| |
|
|
|
|
|
| |
is no longer needed.
Notes:
svn path=/head/; revision=145436
|
| |
|
|
|
|
|
| |
events are reported.
Notes:
svn path=/head/; revision=144921
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
1. fast simple type mutex.
2. __thread tls works.
3. asynchronous cancellation works ( using signal ).
4. thread synchronization is fully based on umtx, mainly, condition
variable and other synchronization objects were rewritten by using
umtx directly. those objects can be shared between processes via
shared memory, it has to change ABI which does not happen yet.
5. default stack size is increased to 1M on 32 bits platform, 2M for
64 bits platform.
As the result, some mysql super-smack benchmarks show performance is
improved massivly.
Okayed by: jeff, mtm, rwatson, scottl
Notes:
svn path=/head/; revision=144518
|
| |
|
|
|
|
|
|
| |
itself before it can execute any other code, so new thread should be
created with all signals are masked until after fsbase is set.
Notes:
svn path=/head/; revision=134051
|
| |
|
|
|
|
|
| |
debugging.
Notes:
svn path=/head/; revision=131588
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
pointer to the corresponding struct thread to the thread ID (lwpid_t)
assigned to that thread. The primary reason for this change is that
libthr now internally uses the same ID as the debugger and the kernel
when referencing to a kernel thread. This allows us to implement the
support for debugging without additional translations and/or mappings.
To preserve the ABI, the 1:1 threading syscalls, including the umtx
locking API have not been changed to work on a lwpid_t. Instead the
1:1 threading syscalls operate on long and the umtx locking API has
not been changed except for the contested bit. Previously this was
the least significant bit. Now it's the most significant bit. Since
the contested bit should not be tested by userland, this change is
not expected to be visible. Just to be sure, UMTX_CONTESTED has been
removed from <sys/umtx.h>.
Reviewed by: mtm@
ABI preservation tested on: i386, ia64
Notes:
svn path=/head/; revision=131431
|
| |
|
|
|
|
|
| |
instead of asking the kernel to do it when we create the thread.
Notes:
svn path=/head/; revision=131337
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
followed are: Only 3 functions (pthread_cancel, pthread_setcancelstate,
pthread_setcanceltype) are required to be async-signal-safe by POSIX. None of
the rest of the pthread api is required to be async-signal-safe. This means
that only the three mentioned functions are safe to use from inside
signal handlers.
However, there are certain system/libc calls that are
cancellation points that a caller may call from within a signal handler,
and since they are cancellation points calls have to be made into libthr
to test for cancellation and exit the thread if necessary. So, the
cancellation test and thread exit code paths must be async-signal-safe
as well. A summary of the changes follows:
o Almost all of the code paths that masked signals, as well as locking the
pthread structure now lock only the pthread structure.
o Signals are masked (and left that way) as soon as a thread enters
pthread_exit().
o The active and dead threads locks now explicitly require that signals
are masked.
o Access to the isdead field of the pthread structure is protected by both
the active and dead list locks for writing. Either one is sufficient for
reading.
o The thread state and type fields have been combined into one three-state
switch to make it easier to read without requiring a lock. It doesn't need
a lock for writing (and therefore for reading either) because only the
current thread can write to it and it is an integer value.
o The thread state field of the pthread structure has been eliminated. It
was an unnecessary field that mostly duplicated the flags field, but
required additional locking that would make a lot more code paths require
signal masking. Any truly unique values (such as PS_DEAD) have been
reborn as separate members of the pthread structure.
o Since the mutex and condvar pthread functions are not async-signal-safe
there is no need to muck about with the wait queues when handling
a signal ...
o ... which also removes the need for wrapping signal handlers and sigaction(2).
o The condvar and mutex async-cancellation code had to be revised as a result
of some of these changes, which resulted in semi-unrelated changes which
would have been difficult to work on as a separate commit, so they are
included as well.
The only part of the changes I am worried about is related to locking for
the pthread joining fields. But, I will take a closer look at them once this
mega-patch is committed.
Notes:
svn path=/head/; revision=129484
|
| |
|
|
|
|
|
|
| |
in-line. If the exiting thread cannot release a resource, then
the next thread to exit will release it.
Notes:
svn path=/head/; revision=127523
|
| |
|
|
| |
Notes:
svn path=/head/; revision=125964
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
o Remove some code duplication between _thread_init(), which is run once
to initialize libthr and the intitial thread, and pthread_create(), which
initializes newly created threads, into a new function called from both
places: init_td_common()
o Move initialization of certain parts of libthr into a separate
function. These include:
- Active threads list and it's lock
- Dead threads list and it's lock & condition variable
- Naming and insertion of the initial thread into the
active threads list.
Notes:
svn path=/head/; revision=123859
|
| |
|
|
|
|
|
|
|
|
|
| |
problems: (1) The wrong flag was being checked for in the attribute
(2) The pthread's state was not being set to indicate it was
suspended.
Noticed by: Igor Sysoev <is@rambler-co.ru>
Notes:
svn path=/head/; revision=123542
|
| |
|
|
|
|
|
|
|
| |
the scope of the active thread list lock.
Approved by: re/jhb
Notes:
svn path=/head/; revision=115386
|
| |
|
|
|
|
|
|
|
|
| |
lock. It's not really necessary and we don't need the added complexity
or potential for deadlocks.
Approved by: re/blanket libthr
Notes:
svn path=/head/; revision=115315
|
| |
|
|
|
|
|
|
|
| |
threads per process has been reached. Return EAGAIN, as per spec.
Approved by: re/blanket libthr
Notes:
svn path=/head/; revision=115313
|
| |
|
|
|
|
|
|
|
|
| |
Modify the thread creation and thread searching routine
to lock the thread lists with the new locks instead of GIANT_LOCK.
Approved by: re/blanket libthr
Notes:
svn path=/head/; revision=115306
|