Title: [249417] trunk/Source/WebCore
Revision
249417
Author
ysuz...@apple.com
Date
2019-09-02 22:59:35 -0700 (Mon, 02 Sep 2019)

Log Message

[WebCore] Resource usage accounting should accept non KERN_SUCCESS
https://bugs.webkit.org/show_bug.cgi?id=201409

Reviewed by Andreas Kling.

While iterating threads, we are not suspending these threads. Underlying threads can have gone
at any time and we will get non KERN_SUCCESS error code when a thread has gone. We should ignore
these threads.

* page/cocoa/ResourceUsageThreadCocoa.mm:
(WebCore::threadInfos):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (249416 => 249417)


--- trunk/Source/WebCore/ChangeLog	2019-09-03 01:55:27 UTC (rev 249416)
+++ trunk/Source/WebCore/ChangeLog	2019-09-03 05:59:35 UTC (rev 249417)
@@ -1,3 +1,17 @@
+2019-09-02  Yusuke Suzuki  <ysuz...@apple.com>
+
+        [WebCore] Resource usage accounting should accept non KERN_SUCCESS
+        https://bugs.webkit.org/show_bug.cgi?id=201409
+
+        Reviewed by Andreas Kling.
+
+        While iterating threads, we are not suspending these threads. Underlying threads can have gone
+        at any time and we will get non KERN_SUCCESS error code when a thread has gone. We should ignore
+        these threads.
+
+        * page/cocoa/ResourceUsageThreadCocoa.mm:
+        (WebCore::threadInfos):
+
 2019-09-02  Fujii Hironori  <hironori.fu...@sony.com>
 
         [SVG] fragment-only url 'url(#fragment)' should be resolved against the current document with regardless to HTML <base> element

Modified: trunk/Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm (249416 => 249417)


--- trunk/Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm	2019-09-03 01:55:27 UTC (rev 249416)
+++ trunk/Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm	2019-09-03 05:59:35 UTC (rev 249417)
@@ -87,6 +87,8 @@
     if (kr != KERN_SUCCESS)
         return { };
 
+    // Since we collect thread usage without suspending threads, threads retrieved by task_threads can have gone while iterating
+    // them to get usage information. If a thread has gone, a system call returns non KERN_SUCCESS, and we just ignore these threads.
     Vector<ThreadInfo> infos;
     for (mach_msg_type_number_t i = 0; i < threadCount; ++i) {
         MachSendRight sendRight = MachSendRight::adopt(threadList[i]);
@@ -94,7 +96,6 @@
         thread_info_data_t threadInfo;
         mach_msg_type_number_t threadInfoCount = THREAD_INFO_MAX;
         kr = thread_info(sendRight.sendRight(), THREAD_BASIC_INFO, reinterpret_cast<thread_info_t>(&threadInfo), &threadInfoCount);
-        ASSERT(kr == KERN_SUCCESS);
         if (kr != KERN_SUCCESS)
             continue;
 
@@ -101,7 +102,6 @@
         thread_identifier_info_data_t threadIdentifierInfo;
         mach_msg_type_number_t threadIdentifierInfoCount = THREAD_IDENTIFIER_INFO_COUNT;
         kr = thread_info(sendRight.sendRight(), THREAD_IDENTIFIER_INFO, reinterpret_cast<thread_info_t>(&threadIdentifierInfo), &threadIdentifierInfoCount);
-        ASSERT(kr == KERN_SUCCESS);
         if (kr != KERN_SUCCESS)
             continue;
 
@@ -108,7 +108,6 @@
         thread_extended_info_data_t threadExtendedInfo;
         mach_msg_type_number_t threadExtendedInfoCount = THREAD_EXTENDED_INFO_COUNT;
         kr = thread_info(sendRight.sendRight(), THREAD_EXTENDED_INFO, reinterpret_cast<thread_info_t>(&threadExtendedInfo), &threadExtendedInfoCount);
-        ASSERT(kr == KERN_SUCCESS);
         if (kr != KERN_SUCCESS)
             continue;
 
@@ -117,6 +116,7 @@
         if (!(threadBasicInfo->flags & TH_FLAGS_IDLE))
             usage = threadBasicInfo->cpu_usage / static_cast<float>(TH_USAGE_SCALE) * 100.0;
 
+        // FIXME: dispatch_queue_t can be destroyed concurrently while we are accessing to it here. We should not use it.
         String threadName = String(threadExtendedInfo.pth_name);
         String dispatchQueueName;
         if (threadIdentifierInfo.dispatch_qaddr) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to