Title: [291203] trunk/Source
- Revision
- 291203
- Author
- [email protected]
- Date
- 2022-03-11 18:33:04 -0800 (Fri, 11 Mar 2022)
Log Message
IPC thread's QOS should match the sending thread's QOS when calling sendSync()
https://bugs.webkit.org/show_bug.cgi?id=237800
<rdar://problem/90061548>
Reviewed by Geoffrey Garen.
Source/WebKit:
IPC thread's QOS should match the sending thread's QOS when calling sendSync(), since it blocks the calling thread.
* Platform/IPC/Connection.cpp:
(IPC::Connection::sendSyncMessage):
Source/WTF:
Add function to get the QoS of the current thread.
* wtf/Threading.cpp:
(WTF::toQOS):
(WTF::Thread::currentThreadQOS):
* wtf/Threading.h:
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (291202 => 291203)
--- trunk/Source/WTF/ChangeLog 2022-03-12 02:23:42 UTC (rev 291202)
+++ trunk/Source/WTF/ChangeLog 2022-03-12 02:33:04 UTC (rev 291203)
@@ -1,3 +1,18 @@
+2022-03-11 Chris Dumez <[email protected]>
+
+ IPC thread's QOS should match the sending thread's QOS when calling sendSync()
+ https://bugs.webkit.org/show_bug.cgi?id=237800
+ <rdar://problem/90061548>
+
+ Reviewed by Geoffrey Garen.
+
+ Add function to get the QoS of the current thread.
+
+ * wtf/Threading.cpp:
+ (WTF::toQOS):
+ (WTF::Thread::currentThreadQOS):
+ * wtf/Threading.h:
+
2022-03-11 Elliott Williams <[email protected]>
[Xcode] "Nest Headers" script phases copy headers incorrectly on Catalyst
Modified: trunk/Source/WTF/wtf/Threading.cpp (291202 => 291203)
--- trunk/Source/WTF/wtf/Threading.cpp 2022-03-12 02:23:42 UTC (rev 291202)
+++ trunk/Source/WTF/wtf/Threading.cpp 2022-03-12 02:33:04 UTC (rev 291203)
@@ -401,6 +401,38 @@
}
#if HAVE(QOS_CLASSES)
+static Thread::QOS toQOS(qos_class_t qosClass)
+{
+ switch (qosClass) {
+ case QOS_CLASS_USER_INTERACTIVE:
+ return Thread::QOS::UserInteractive;
+ case QOS_CLASS_USER_INITIATED:
+ return Thread::QOS::UserInitiated;
+ case QOS_CLASS_UTILITY:
+ return Thread::QOS::Utility;
+ case QOS_CLASS_BACKGROUND:
+ return Thread::QOS::Background;
+ case QOS_CLASS_UNSPECIFIED:
+ case QOS_CLASS_DEFAULT:
+ default:
+ return Thread::QOS::Default;
+ }
+}
+#endif
+
+auto Thread::currentThreadQOS() -> QOS
+{
+#if HAVE(QOS_CLASSES)
+ qos_class_t qos = QOS_CLASS_DEFAULT;
+ int relativePriority;
+ pthread_get_qos_class_np(pthread_self(), &qos, &relativePriority);
+ return toQOS(qos);
+#else
+ return QOS::Default;
+#endif
+}
+
+#if HAVE(QOS_CLASSES)
static qos_class_t globalMaxQOSclass { QOS_CLASS_UNSPECIFIED };
void Thread::setGlobalMaxQOSClass(qos_class_t maxClass)
Modified: trunk/Source/WTF/wtf/Threading.h (291202 => 291203)
--- trunk/Source/WTF/wtf/Threading.h 2022-03-12 02:23:42 UTC (rev 291202)
+++ trunk/Source/WTF/wtf/Threading.h 2022-03-12 02:33:04 UTC (rev 291203)
@@ -195,6 +195,7 @@
// relativePriority is a value in the range [-15, 0] where a lower value indicates a lower priority.
WTF_EXPORT_PRIVATE static void setCurrentThreadIsUserInteractive(int relativePriority = 0);
WTF_EXPORT_PRIVATE static void setCurrentThreadIsUserInitiated(int relativePriority = 0);
+ WTF_EXPORT_PRIVATE static QOS currentThreadQOS();
#if HAVE(QOS_CLASSES)
WTF_EXPORT_PRIVATE static void setGlobalMaxQOSClass(qos_class_t);
Modified: trunk/Source/WebKit/ChangeLog (291202 => 291203)
--- trunk/Source/WebKit/ChangeLog 2022-03-12 02:23:42 UTC (rev 291202)
+++ trunk/Source/WebKit/ChangeLog 2022-03-12 02:33:04 UTC (rev 291203)
@@ -1,3 +1,16 @@
+2022-03-11 Chris Dumez <[email protected]>
+
+ IPC thread's QOS should match the sending thread's QOS when calling sendSync()
+ https://bugs.webkit.org/show_bug.cgi?id=237800
+ <rdar://problem/90061548>
+
+ Reviewed by Geoffrey Garen.
+
+ IPC thread's QOS should match the sending thread's QOS when calling sendSync(), since it blocks the calling thread.
+
+ * Platform/IPC/Connection.cpp:
+ (IPC::Connection::sendSyncMessage):
+
2022-03-11 Simon Fraser <[email protected]>
Move RemoteLayerBackingStore flusher creation into RemoteLayerBackingStoreCollection
Modified: trunk/Source/WebKit/Platform/IPC/Connection.cpp (291202 => 291203)
--- trunk/Source/WebKit/Platform/IPC/Connection.cpp 2022-03-12 02:23:42 UTC (rev 291202)
+++ trunk/Source/WebKit/Platform/IPC/Connection.cpp 2022-03-12 02:33:04 UTC (rev 291203)
@@ -652,8 +652,11 @@
encoder->setShouldMaintainOrderingWithAsyncMessages();
auto messageName = encoder->messageName();
- sendMessage(WTFMove(encoder), sendOptions);
+ // Since sync IPC is blocking the current thread, make sure we use the same priority for the IPC sending thread
+ // as the current thread.
+ sendMessage(WTFMove(encoder), sendOptions, Thread::currentThreadQOS());
+
// Then wait for a reply. Waiting for a reply could involve dispatching incoming sync messages, so
// keep an extra reference to the connection here in case it's invalidated.
Ref<Connection> protect(*this);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes