From 01c2480eb37515145f00225ec8ecf7d252431d2a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 16 Jan 2021 14:48:32 +0100 Subject: [PATCH] Kernel+LibC+WindowServer: Remove unused thread/process boost mechanism The priority boosting mechanism has been broken for a very long time. Let's remove it from the codebase and we can bring it back the day someone feels like implementing it in a working way. :^) --- Kernel/API/Syscall.h | 2 -- Kernel/Process.h | 11 +------ Kernel/Syscalls/sched.cpp | 32 ------------------- Kernel/Thread.h | 4 --- Userland/Libraries/LibC/serenity.cpp | 12 ------- Userland/Libraries/LibC/serenity.h | 3 -- .../WindowServer/ClientConnection.cpp | 18 ----------- .../Services/WindowServer/ClientConnection.h | 3 -- .../Services/WindowServer/WindowManager.cpp | 12 ------- 9 files changed, 1 insertion(+), 96 deletions(-) diff --git a/Kernel/API/Syscall.h b/Kernel/API/Syscall.h index 0edf8a274d..ab30a5aa31 100644 --- a/Kernel/API/Syscall.h +++ b/Kernel/API/Syscall.h @@ -177,8 +177,6 @@ namespace Kernel { S(profiling_enable) \ S(profiling_disable) \ S(futex) \ - S(set_thread_boost) \ - S(set_process_boost) \ S(chroot) \ S(pledge) \ S(unveil) \ diff --git a/Kernel/Process.h b/Kernel/Process.h index ea87b1f3f8..946aee0594 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -350,8 +350,6 @@ public: int sys$profiling_enable(pid_t); int sys$profiling_disable(pid_t); int sys$futex(Userspace); - int sys$set_thread_boost(pid_t tid, int amount); - int sys$set_process_boost(pid_t, int amount); int sys$chroot(Userspace path, size_t path_length, int mount_flags); int sys$pledge(Userspace); int sys$unveil(Userspace); @@ -467,11 +465,6 @@ public: return m_big_lock; } - u32 priority_boost() const - { - return m_priority_boost; - } - Custody& root_directory(); Custody& root_directory_relative_to_global_root(); void set_root_directory(const Custody&); @@ -646,8 +639,6 @@ private: RefPtr m_alarm_timer; - u32 m_priority_boost { 0 }; - u32 m_promises { 0 }; u32 m_execpromises { 0 }; @@ -771,7 +762,7 @@ inline const LogStream& operator<<(const LogStream& stream, const Process& proce inline u32 Thread::effective_priority() const { - return m_priority + m_process->priority_boost() + m_priority_boost + m_extra_priority; + return m_priority + m_extra_priority; } #define REQUIRE_NO_PROMISES \ diff --git a/Kernel/Syscalls/sched.cpp b/Kernel/Syscalls/sched.cpp index f497a26ca0..12c16f7f92 100644 --- a/Kernel/Syscalls/sched.cpp +++ b/Kernel/Syscalls/sched.cpp @@ -104,36 +104,4 @@ int Process::sys$sched_getparam(pid_t pid, Userspace user_p return 0; } -int Process::sys$set_thread_boost(pid_t tid, int amount) -{ - REQUIRE_PROMISE(proc); - if (amount < 0 || amount > 20) - return -EINVAL; - ScopedSpinLock lock(g_scheduler_lock); - auto thread = Thread::from_tid(tid); - if (!thread) - return -ESRCH; - if (thread->state() == Thread::State::Dead || thread->state() == Thread::State::Dying) - return -ESRCH; - if (!is_superuser() && thread->process().uid() != euid()) - return -EPERM; - thread->set_priority_boost(amount); - return 0; -} - -int Process::sys$set_process_boost(pid_t pid, int amount) -{ - REQUIRE_PROMISE(proc); - if (amount < 0 || amount > 20) - return -EINVAL; - ScopedSpinLock lock(g_processes_lock); - auto process = Process::from_pid(pid); - if (!process || process->is_dead()) - return -ESRCH; - if (!is_superuser() && process->uid() != euid()) - return -EPERM; - process->m_priority_boost = amount; - return 0; -} - } diff --git a/Kernel/Thread.h b/Kernel/Thread.h index afae991906..98639e7f7a 100644 --- a/Kernel/Thread.h +++ b/Kernel/Thread.h @@ -102,9 +102,6 @@ public: void set_priority(u32 p) { m_priority = p; } u32 priority() const { return m_priority; } - void set_priority_boost(u32 boost) { m_priority_boost = boost; } - u32 priority_boost() const { return m_priority_boost; } - u32 effective_priority() const; void detach() @@ -1199,7 +1196,6 @@ private: String m_name; u32 m_priority { THREAD_PRIORITY_NORMAL }; u32 m_extra_priority { 0 }; - u32 m_priority_boost { 0 }; State m_stop_state { Invalid }; diff --git a/Userland/Libraries/LibC/serenity.cpp b/Userland/Libraries/LibC/serenity.cpp index 3168a39d4c..df5d5bfacc 100644 --- a/Userland/Libraries/LibC/serenity.cpp +++ b/Userland/Libraries/LibC/serenity.cpp @@ -60,18 +60,6 @@ int profiling_disable(pid_t pid) __RETURN_WITH_ERRNO(rc, rc, -1); } -int set_thread_boost(pid_t tid, int amount) -{ - int rc = syscall(SC_set_thread_boost, tid, amount); - __RETURN_WITH_ERRNO(rc, rc, -1); -} - -int set_process_boost(pid_t tid, int amount) -{ - int rc = syscall(SC_set_process_boost, tid, amount); - __RETURN_WITH_ERRNO(rc, rc, -1); -} - int futex(int32_t* userspace_address, int futex_op, int32_t value, const struct timespec* timeout) { Syscall::SC_futex_params params { userspace_address, futex_op, value, timeout }; diff --git a/Userland/Libraries/LibC/serenity.h b/Userland/Libraries/LibC/serenity.h index 16f370e27b..5ad28a5723 100644 --- a/Userland/Libraries/LibC/serenity.h +++ b/Userland/Libraries/LibC/serenity.h @@ -52,9 +52,6 @@ int profiling_disable(pid_t); #define THREAD_PRIORITY_HIGH 50 #define THREAD_PRIORITY_MAX 99 -int set_thread_boost(pid_t tid, int amount); -int set_process_boost(pid_t, int amount); - #define FUTEX_WAIT 1 #define FUTEX_WAKE 2 diff --git a/Userland/Services/WindowServer/ClientConnection.cpp b/Userland/Services/WindowServer/ClientConnection.cpp index 89d2ede079..3c8b10bfe7 100644 --- a/Userland/Services/WindowServer/ClientConnection.cpp +++ b/Userland/Services/WindowServer/ClientConnection.cpp @@ -770,24 +770,6 @@ OwnPtr ClientConnection::handle( return make(name); } -void ClientConnection::boost() -{ - // FIXME: Re-enable this when we have a solution for boosting. -#if 0 - if (set_process_boost(client_pid(), 10) < 0) - perror("boost: set_process_boost"); -#endif -} - -void ClientConnection::deboost() -{ - // FIXME: Re-enable this when we have a solution for boosting. -#if 0 - if (set_process_boost(client_pid(), 0) < 0) - perror("deboost: set_process_boost"); -#endif -} - OwnPtr ClientConnection::handle(const Messages::WindowServer::SetWindowBaseSizeAndSizeIncrement& message) { auto it = m_windows.find(message.window_id()); diff --git a/Userland/Services/WindowServer/ClientConnection.h b/Userland/Services/WindowServer/ClientConnection.h index 40aa3839a4..89aaa71aae 100644 --- a/Userland/Services/WindowServer/ClientConnection.h +++ b/Userland/Services/WindowServer/ClientConnection.h @@ -54,9 +54,6 @@ public: bool is_unresponsive() const { return m_unresponsive; } - void boost(); - void deboost(); - static ClientConnection* from_client_id(int client_id); static void for_each_client(Function); diff --git a/Userland/Services/WindowServer/WindowManager.cpp b/Userland/Services/WindowServer/WindowManager.cpp index 0d44b108f7..ebc4529372 100644 --- a/Userland/Services/WindowServer/WindowManager.cpp +++ b/Userland/Services/WindowServer/WindowManager.cpp @@ -1239,11 +1239,7 @@ void WindowManager::set_active_window(Window* window, bool make_input) auto* previously_active_window = m_active_window.ptr(); - ClientConnection* previously_active_client = nullptr; - ClientConnection* active_client = nullptr; - if (previously_active_window) { - previously_active_client = previously_active_window->client(); Core::EventLoop::current().post_event(*previously_active_window, make(Event::WindowDeactivated)); previously_active_window->invalidate(); m_active_window = nullptr; @@ -1253,7 +1249,6 @@ void WindowManager::set_active_window(Window* window, bool make_input) if (window) { m_active_window = *window; - active_client = m_active_window->client(); Core::EventLoop::current().post_event(*m_active_window, make(Event::WindowActivated)); m_active_window->invalidate(); if (auto* client = window->client()) { @@ -1265,13 +1260,6 @@ void WindowManager::set_active_window(Window* window, bool make_input) } else { MenuManager::the().set_current_menubar(nullptr); } - - if (active_client != previously_active_client) { - if (previously_active_client) - previously_active_client->deboost(); - if (active_client) - active_client->boost(); - } } void WindowManager::set_hovered_window(Window* window)