e_hwc_window_queue: lower priority of copy threads 26/319926/1
authorJoonbum Ko <joonbum.ko@samsung.com>
Tue, 5 Nov 2024 04:18:25 +0000 (13:18 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Tue, 5 Nov 2024 08:31:48 +0000 (17:31 +0900)
 - When calling ecore_thread_feedback_run() with try_no_queue set to true,
  the priority is set to EINA_THREAD_URGENT(+5) inside the eina_thread.
   In this case, the priority of the copy_thread may be too high,
  causing a priority inversion problem.

 - If try_no_queue is false, it becomes EINA_THREAD_BACKGROUND,
  so the priority becomes too low.

 - Therefore, try_no_queue was kept as true and the priority was modified
  to be lowered again when the thread job was performed.

Change-Id: I627082a480835064995a40bc0fe192a9938dc1df
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
src/bin/displaymgr/e_hwc_window_queue.c

index f0df67da9609dc8a5c36a754e52cbd0204e76cf5..c6491df00628efcca0711f6c90cae4b0d9b3db53 100644 (file)
@@ -1281,6 +1281,24 @@ _e_hwc_window_queue_pending_copy_thread_check_and_run(void)
    return EINA_TRUE;
 }
 
+static void
+_copy_thread_priority_lower()
+{
+   pthread_t self = pthread_self();
+   struct sched_param params;
+   int pol;
+   int err = pthread_getschedparam(self, &pol, &params);
+   if (err != 0)
+     {
+        EHWQERR("fail to get pthread param", NULL, NULL, NULL);
+        return;
+     }
+
+   // lower the priority that was raised by 5 in ecore_thread_feedback_run
+   params.sched_priority -= 5;
+   pthread_setschedparam(self, pol, &params);
+}
+
 static void
 _e_hwc_window_queue_copy_thread_run_cb(void *data, Ecore_Thread *thread)
 {
@@ -1289,7 +1307,10 @@ _e_hwc_window_queue_copy_thread_run_cb(void *data, Ecore_Thread *thread)
    if (!(copy_thread_data = data)) return;
 
    if (thread)
-     eina_thread_name_set(eina_thread_self(), "hwc_copy_thread");
+     {
+        eina_thread_name_set(eina_thread_self(), "hwc_copy_thread");
+        _copy_thread_priority_lower();
+     }
 
    EHWQINF("Copy buffer tdata:%p src:%p dst:%p",
            NULL,