]> git.saurik.com Git - apple/libpthread.git/commitdiff
libpthread-416.40.3.tar.gz macos-10151 v416.40.3
authorApple <opensource@apple.com>
Tue, 24 Mar 2020 21:06:25 +0000 (21:06 +0000)
committerApple <opensource@apple.com>
Tue, 24 Mar 2020 21:06:25 +0000 (21:06 +0000)
kern/kern_synch.c
private/qos_private.h
src/qos.c

index 583bea2a65e55148dea51649f7c849c338c249f2..930abc0a30e9c2e0e37748b1974368d7a962c104 100644 (file)
@@ -686,7 +686,6 @@ again:
                pthread_kern->psynch_wait_update_owner(kwq, kwq->kw_owner,
                                &kwq->kw_turnstile);
                ksyn_wqunlock(kwq);
-               _kwq_cleanup_old_owner(&old_owner);
                goto out;
        }
 
@@ -723,9 +722,8 @@ again:
                old_owner = _kwq_set_owner(kwq, current_thread(), 0);
                pthread_kern->psynch_wait_update_owner(kwq, kwq->kw_owner,
                                &kwq->kw_turnstile);
-               
+
                ksyn_wqunlock(kwq);
-               _kwq_cleanup_old_owner(&old_owner);
                *retval = updatebits;
                goto out;
        }
@@ -769,6 +767,7 @@ again:
                pthread_kern->thread_deallocate_safe(tid_th);
                tid_th = THREAD_NULL;
        }
+       assert(old_owner == THREAD_NULL);
        error = ksyn_wait(kwq, KSYN_QUEUE_WRITE, mgen, ins_flags, 0, 0,
                        psynch_mtxcontinue, kThreadWaitPThreadMutex);
        // ksyn_wait drops wait queue lock
@@ -778,6 +777,9 @@ out:
        if (tid_th) {
                thread_deallocate(tid_th);
        }
+       if (old_owner) {
+               thread_deallocate(old_owner);
+       }
        return error;
 }
 
index 6068a822c068662ccbf438a6d77a81a1145e9821..4ec532c55b29734713d951cd3ef1f9c77f181db0 100644 (file)
 #define __QOS_AVAILABLE_10_11 __API_AVAILABLE(macos(10.11), ios(9.0), tvos(9.0), watchos(2.0))
 #undef __QOS_AVAILABLE_10_12
 #define __QOS_AVAILABLE_10_12 __API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
+#undef __QOS_AVAILABLE_10_15_1
+#define __QOS_AVAILABLE_10_15_1 __API_AVAILABLE(macos(10.15.1), ios(13.2), tvos(13.2), watchos(6.2))
 #endif
 #endif
 
+// This enum matches workq_set_self_flags in
+// xnu's workqueue_internal.h.
 __QOS_ENUM(_pthread_set_flags, unsigned int,
    _PTHREAD_SET_SELF_QOS_FLAG __QOS_AVAILABLE_10_10 = 0x1,
    _PTHREAD_SET_SELF_VOUCHER_FLAG __QOS_AVAILABLE_10_10 = 0x2,
    _PTHREAD_SET_SELF_FIXEDPRIORITY_FLAG __QOS_AVAILABLE_10_11 = 0x4,
    _PTHREAD_SET_SELF_TIMESHARE_FLAG __QOS_AVAILABLE_10_11 = 0x8,
    _PTHREAD_SET_SELF_WQ_KEVENT_UNBIND __QOS_AVAILABLE_10_12 = 0x10,
+   _PTHREAD_SET_SELF_ALTERNATE_AMX __QOS_AVAILABLE_10_15_1 = 0x20,
 );
 
 #undef __QOS_ENUM
@@ -153,6 +158,13 @@ __API_AVAILABLE(macos(10.10), ios(8.0))
 int
 pthread_set_timeshare_self(void);
 
+// Set self to avoid running on the same AMX as
+// other work in this group.
+// Only allowed on non-workqueue pthreads
+__API_AVAILABLE(macos(10.15.1), ios(13.2), tvos(13.2), watchos(6.2))
+int
+pthread_prefer_alternate_amx_self(void);
+
 /*!
  * @const PTHREAD_MAX_PARALLELISM_PHYSICAL
  * Flag that can be used with pthread_qos_max_parallelism() and
index 8aef21b45edd816916007f854cfbc0d8ac8fb4b0..039b06baa73c5afffa0d215eb2ad5f05c241bdc4 100644 (file)
--- a/src/qos.c
+++ b/src/qos.c
@@ -208,7 +208,8 @@ _pthread_qos_class_encode_workqueue(int queue_priority, unsigned long flags)
 
 #define _PTHREAD_SET_SELF_OUTSIDE_QOS_SKIP \
                (_PTHREAD_SET_SELF_QOS_FLAG | _PTHREAD_SET_SELF_FIXEDPRIORITY_FLAG | \
-                _PTHREAD_SET_SELF_TIMESHARE_FLAG)
+                _PTHREAD_SET_SELF_TIMESHARE_FLAG | \
+                _PTHREAD_SET_SELF_ALTERNATE_AMX)
 
 int
 _pthread_set_properties_self(_pthread_set_flags_t flags,
@@ -256,6 +257,13 @@ pthread_set_timeshare_self(void)
        return _pthread_set_properties_self(_PTHREAD_SET_SELF_TIMESHARE_FLAG, 0, 0);
 }
 
+int
+pthread_prefer_alternate_amx_self(void)
+{
+       return _pthread_set_properties_self(_PTHREAD_SET_SELF_ALTERNATE_AMX, 0, 0);
+}
+
+
 pthread_override_t
 pthread_override_qos_class_start_np(pthread_t thread,  qos_class_t qc, int relpri)
 {