mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-04-13 14:42:51 -07:00
server-Realtime_Priority: Remove patch set.
This functionality was introduced upstream by 945efda7fe4c95276a1c64a8d10368726d834937.
This commit is contained in:
parent
a381f356d6
commit
acb3c0bb3c
@ -1,4 +1,4 @@
|
||||
From 21bb952ef0c654659a5bdada0d092e6579b3fe18 Mon Sep 17 00:00:00 2001
|
||||
From da832ae3626406e9aee5f9f78bce01f2a0d49691 Mon Sep 17 00:00:00 2001
|
||||
From: Zebediah Figura <z.figura12@gmail.com>
|
||||
Date: Thu, 7 Jun 2018 20:09:59 -0500
|
||||
Subject: [PATCH] server: Create server objects for eventfd-based
|
||||
@ -15,7 +15,7 @@ Subject: [PATCH] server: Create server objects for eventfd-based
|
||||
create mode 100644 server/esync.h
|
||||
|
||||
diff --git a/server/Makefile.in b/server/Makefile.in
|
||||
index 4468ff018c4..87103cb2002 100644
|
||||
index 7e571ac2ba6..9632c4e694f 100644
|
||||
--- a/server/Makefile.in
|
||||
+++ b/server/Makefile.in
|
||||
@@ -11,6 +11,7 @@ SOURCES = \
|
||||
@ -381,7 +381,7 @@ index 00000000000..00f9e638d83
|
||||
+extern int do_esync(void);
|
||||
+void esync_init(void);
|
||||
diff --git a/server/main.c b/server/main.c
|
||||
index e556bea3a4b..5a0f0da155b 100644
|
||||
index e014ec535ff..052667b4c6b 100644
|
||||
--- a/server/main.c
|
||||
+++ b/server/main.c
|
||||
@@ -34,6 +34,7 @@
|
||||
@ -401,7 +401,7 @@ index e556bea3a4b..5a0f0da155b 100644
|
||||
+
|
||||
if (debug_level) fprintf( stderr, "wineserver: starting (pid=%ld)\n", (long) getpid() );
|
||||
set_current_time();
|
||||
init_scheduler();
|
||||
init_signals();
|
||||
diff --git a/server/protocol.def b/server/protocol.def
|
||||
index fa4ca4aaa9e..a9ee996a8ab 100644
|
||||
--- a/server/protocol.def
|
||||
|
@ -1,5 +1,4 @@
|
||||
Fixes: [36692] Many multi-threaded applications have poor performance due to heavy use of synchronization primitives
|
||||
Depends: server-Realtime_Priority
|
||||
Depends: ntdll-Junction_Points
|
||||
Depends: server-PeekMessage
|
||||
Depends: server-Signal_Thread
|
||||
|
@ -1,245 +0,0 @@
|
||||
From fdb30f0d27c1cad5bde71bc6c8f8d89333a982ef Mon Sep 17 00:00:00 2001
|
||||
From: Joakim Hernberg <jhernberg@alchemy.lu>
|
||||
Date: Tue, 31 Mar 2015 20:58:20 +0200
|
||||
Subject: [PATCH] wineserver: Draft to implement priority levels through POSIX
|
||||
scheduling policies on linux.
|
||||
|
||||
Changes by Sebastian Lackner <sebastian@fds-team.de>:
|
||||
* Move scheduler related logic into a separate file.
|
||||
* Use SCHED_RESET_ON_FORK to avoid leaking high priority threads.
|
||||
* Simplify logic to parse environment variables using a helper function.
|
||||
* Clean up error messages.
|
||||
---
|
||||
server/Makefile.in | 1 +
|
||||
server/main.c | 1 +
|
||||
server/scheduler.c | 166 +++++++++++++++++++++++++++++++++++++++++++++
|
||||
server/thread.c | 1 +
|
||||
server/thread.h | 5 ++
|
||||
5 files changed, 174 insertions(+)
|
||||
create mode 100644 server/scheduler.c
|
||||
|
||||
diff --git a/server/Makefile.in b/server/Makefile.in
|
||||
index 7e571ac2ba6..4468ff018c4 100644
|
||||
--- a/server/Makefile.in
|
||||
+++ b/server/Makefile.in
|
||||
@@ -30,6 +30,7 @@ SOURCES = \
|
||||
region.c \
|
||||
registry.c \
|
||||
request.c \
|
||||
+ scheduler.c \
|
||||
semaphore.c \
|
||||
serial.c \
|
||||
signal.c \
|
||||
diff --git a/server/main.c b/server/main.c
|
||||
index e014ec535ff..e556bea3a4b 100644
|
||||
--- a/server/main.c
|
||||
+++ b/server/main.c
|
||||
@@ -231,6 +231,7 @@ int main( int argc, char *argv[] )
|
||||
|
||||
if (debug_level) fprintf( stderr, "wineserver: starting (pid=%ld)\n", (long) getpid() );
|
||||
set_current_time();
|
||||
+ init_scheduler();
|
||||
init_signals();
|
||||
init_memory();
|
||||
init_directories( load_intl_file() );
|
||||
diff --git a/server/scheduler.c b/server/scheduler.c
|
||||
new file mode 100644
|
||||
index 00000000000..4a5d82b208d
|
||||
--- /dev/null
|
||||
+++ b/server/scheduler.c
|
||||
@@ -0,0 +1,166 @@
|
||||
+/*
|
||||
+ * Scheduler priority management
|
||||
+ *
|
||||
+ * Copyright (C) 2015 Joakim Hernberg
|
||||
+ * Copyright (C) 2015 Sebastian Lackner
|
||||
+ *
|
||||
+ * This library is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU Lesser General Public
|
||||
+ * License as published by the Free Software Foundation; either
|
||||
+ * version 2.1 of the License, or (at your option) any later version.
|
||||
+ *
|
||||
+ * This library is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ * Lesser General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU Lesser General Public
|
||||
+ * License along with this library; if not, write to the Free Software
|
||||
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
+ */
|
||||
+
|
||||
+#include "config.h"
|
||||
+
|
||||
+#define _GNU_SOURCE /* for SCHED_BATCH, SCHED_IDLE */
|
||||
+#include <assert.h>
|
||||
+#include <stdio.h>
|
||||
+#include <stdarg.h>
|
||||
+#ifdef HAVE_SYS_RESOURCE_H
|
||||
+# include <sys/resource.h>
|
||||
+#endif
|
||||
+#ifdef HAVE_SCHED_H
|
||||
+# include <sched.h>
|
||||
+#endif
|
||||
+#ifndef SCHED_RESET_ON_FORK
|
||||
+# define SCHED_RESET_ON_FORK 0x40000000
|
||||
+#endif
|
||||
+#ifndef SCHED_IDLE
|
||||
+ #define SCHED_IDLE 5
|
||||
+#endif
|
||||
+
|
||||
+#include "ntstatus.h"
|
||||
+#define WIN32_NO_STATUS
|
||||
+#include "winternl.h"
|
||||
+#include "thread.h"
|
||||
+
|
||||
+#if defined(__linux__) && defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_SCHED_H)
|
||||
+
|
||||
+static int thread_base_priority = -1;
|
||||
+
|
||||
+/* gets the priority value from an environment variable */
|
||||
+static int get_priority( const char *variable, int min, int max )
|
||||
+{
|
||||
+ const char *env;
|
||||
+ int val;
|
||||
+
|
||||
+ env = getenv( variable );
|
||||
+ if (!env) return -1;
|
||||
+
|
||||
+ val = atoi( env );
|
||||
+ if (val >= min && val <= max) return val;
|
||||
+ fprintf( stderr, "wineserver: %s should be between %d and %d\n", variable, min, max );
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+/* initializes the scheduler */
|
||||
+void init_scheduler( void )
|
||||
+{
|
||||
+ int min, max, priority;
|
||||
+
|
||||
+ min = sched_get_priority_min( SCHED_FIFO );
|
||||
+ max = sched_get_priority_max( SCHED_FIFO );
|
||||
+ if (min == -1 || max == -1)
|
||||
+ return;
|
||||
+
|
||||
+ /* change the wineserver priority */
|
||||
+ if ((priority = get_priority( "STAGING_RT_PRIORITY_SERVER", min, max )) != -1)
|
||||
+ {
|
||||
+ struct sched_param param;
|
||||
+ memset( ¶m, 0, sizeof(param) );
|
||||
+ param.sched_priority = priority;
|
||||
+ if (sched_setscheduler( 0, SCHED_FIFO | SCHED_RESET_ON_FORK, ¶m ) == -1 &&
|
||||
+ sched_setscheduler( 0, SCHED_FIFO, ¶m ) == -1)
|
||||
+ {
|
||||
+ fprintf( stderr, "wineserver: failed to change priority to SCHED_FIFO/%d\n",
|
||||
+ param.sched_priority );
|
||||
+ /* do not bother to check the rest */
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (debug_level) fprintf( stderr, "wineserver: changed priority to SCHED_FIFO/%d\n",
|
||||
+ param.sched_priority );
|
||||
+ }
|
||||
+
|
||||
+ /* determine base priority which will be used for all threads */
|
||||
+ if ((priority = get_priority( "STAGING_RT_PRIORITY_BASE", min, max - 4 )) != -1)
|
||||
+ {
|
||||
+ thread_base_priority = priority;
|
||||
+
|
||||
+ if (debug_level) fprintf( stderr, "wineserver: initialized thread base priority to %d\n",
|
||||
+ thread_base_priority );
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/* sets the scheduler priority of a windows thread */
|
||||
+void set_scheduler_priority( struct thread *thread )
|
||||
+{
|
||||
+ struct sched_param param;
|
||||
+ int policy;
|
||||
+
|
||||
+ if (thread_base_priority == -1) return;
|
||||
+ if (thread->unix_tid == -1) return;
|
||||
+
|
||||
+ memset( ¶m, 0, sizeof(param) );
|
||||
+ if (thread->priority >= THREAD_PRIORITY_TIME_CRITICAL)
|
||||
+ {
|
||||
+ policy = SCHED_FIFO;
|
||||
+ param.sched_priority = thread_base_priority + 4;
|
||||
+ }
|
||||
+ else if (thread->priority >= THREAD_PRIORITY_HIGHEST)
|
||||
+ {
|
||||
+ policy = SCHED_FIFO;
|
||||
+ param.sched_priority = thread_base_priority + 2;
|
||||
+ }
|
||||
+ else if (thread->priority >= THREAD_PRIORITY_ABOVE_NORMAL)
|
||||
+ {
|
||||
+ policy = SCHED_FIFO;
|
||||
+ param.sched_priority = thread_base_priority;
|
||||
+ }
|
||||
+ else if (thread->priority >= THREAD_PRIORITY_NORMAL)
|
||||
+ {
|
||||
+ policy = SCHED_OTHER;
|
||||
+ }
|
||||
+ else if (thread->priority >= THREAD_PRIORITY_LOWEST)
|
||||
+ {
|
||||
+ policy = SCHED_BATCH;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ policy = SCHED_IDLE;
|
||||
+ }
|
||||
+
|
||||
+ if (sched_setscheduler(thread->unix_tid, policy | SCHED_RESET_ON_FORK, ¶m) == -1 &&
|
||||
+ sched_setscheduler(thread->unix_tid, policy, ¶m) == -1)
|
||||
+ {
|
||||
+ static int once;
|
||||
+ if (debug_level || !once++)
|
||||
+ fprintf( stderr, "%04x: failed to change priority to %d/%d\n",
|
||||
+ thread->id, policy, param.sched_priority );
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (debug_level) fprintf( stderr, "%04x: changed priority to %d/%d\n",
|
||||
+ thread->id, policy, param.sched_priority );
|
||||
+}
|
||||
+
|
||||
+#else
|
||||
+
|
||||
+void init_scheduler( void )
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+void set_scheduler_priority( struct thread *thread )
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+#endif
|
||||
diff --git a/server/thread.c b/server/thread.c
|
||||
index 3c7e4541a09..d0d23b32d67 100644
|
||||
--- a/server/thread.c
|
||||
+++ b/server/thread.c
|
||||
@@ -683,6 +683,7 @@ unsigned int set_thread_priority( struct thread *thread, int priority_class, int
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
||||
thread->priority = priority;
|
||||
+ set_scheduler_priority( thread );
|
||||
|
||||
/* if thread is gone or hasn't started yet, this will be called again from init_thread with a unix_tid */
|
||||
if (thread->state == RUNNING && thread->unix_tid != -1)
|
||||
diff --git a/server/thread.h b/server/thread.h
|
||||
index 2b256be322f..972d98b6520 100644
|
||||
--- a/server/thread.h
|
||||
+++ b/server/thread.h
|
||||
@@ -146,4 +146,9 @@ static inline void set_win32_error( unsigned int err ) { set_error( 0xc0010000 |
|
||||
|
||||
static inline thread_id_t get_thread_id( struct thread *thread ) { return thread->id; }
|
||||
|
||||
+/* scheduler functions */
|
||||
+
|
||||
+extern void init_scheduler( void );
|
||||
+extern void set_scheduler_priority( struct thread *thread );
|
||||
+
|
||||
#endif /* __WINE_SERVER_THREAD_H */
|
||||
--
|
||||
2.47.2
|
||||
|
@ -1 +0,0 @@
|
||||
Fixes: Support for linux priority levels for faster performance
|
Loading…
x
Reference in New Issue
Block a user