mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-04-14 14:41:42 +03:00
Use relaxed atomics to access the process madvise pid fd
Relaxed atomics already provide sequentially consistent access to single location data structures.
This commit is contained in:
parent
16c5abd1cd
commit
c45b6223e5
1 changed files with 5 additions and 5 deletions
10
src/pages.c
10
src/pages.c
|
|
@ -646,7 +646,7 @@ init_process_madvise(void) {
|
|||
static bool
|
||||
pages_purge_process_madvise_impl(
|
||||
void *vec, size_t vec_len, size_t total_bytes) {
|
||||
int pid_fd = atomic_load_i(&process_madvise_pidfd, ATOMIC_SEQ_CST);
|
||||
int pid_fd = atomic_load_i(&process_madvise_pidfd, ATOMIC_RELAXED);
|
||||
while (pid_fd == -1) {
|
||||
int newfd = syscall(SYS_pidfd_open, getpid(), 0);
|
||||
if (newfd == -1) {
|
||||
|
|
@ -654,8 +654,8 @@ pages_purge_process_madvise_impl(
|
|||
}
|
||||
if (!atomic_compare_exchange_strong_i(&process_madvise_pidfd,
|
||||
&pid_fd, newfd,
|
||||
ATOMIC_SEQ_CST,
|
||||
ATOMIC_SEQ_CST)) {
|
||||
ATOMIC_RELAXED,
|
||||
ATOMIC_RELAXED)) {
|
||||
/* Someone else set the fd, so we close ours */
|
||||
assert(pid_fd != -1);
|
||||
close(newfd);
|
||||
|
|
@ -671,9 +671,9 @@ pages_purge_process_madvise_impl(
|
|||
|
||||
void pages_postfork_child(void) {
|
||||
/* Reset the file descriptor we inherited from parent process */
|
||||
int pid_fd = atomic_load_i(&process_madvise_pidfd, ATOMIC_SEQ_CST);
|
||||
int pid_fd = atomic_load_i(&process_madvise_pidfd, ATOMIC_RELAXED);
|
||||
if (pid_fd != -1) {
|
||||
atomic_store_i(&process_madvise_pidfd, -1, ATOMIC_SEQ_CST);
|
||||
atomic_store_i(&process_madvise_pidfd, -1, ATOMIC_RELAXED);
|
||||
close(pid_fd);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue