Rebase against 449b8c7e9212d0a80e28babff20f2755b7370872.

This commit is contained in:
Zebediah Figura
2020-06-22 17:21:09 -05:00
parent 102af10c89
commit 6274392d27
12 changed files with 84 additions and 798 deletions

View File

@@ -1,4 +1,4 @@
From 7dcc94642b6771f949fa2ff747a2f992e862157d Mon Sep 17 00:00:00 2001
From e9a9468200f7f0b42e806822d1c5519cae3d4f9c Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 5 Aug 2017 03:39:37 +0200
Subject: [PATCH] ntdll: Use fast CS functions for threadpool locking.
@@ -8,7 +8,7 @@ Subject: [PATCH] ntdll: Use fast CS functions for threadpool locking.
1 file changed, 48 insertions(+), 48 deletions(-)
diff --git a/dlls/ntdll/threadpool.c b/dlls/ntdll/threadpool.c
index 451d441f5725..253a13002950 100644
index 84286fbee90..0c7a454c705 100644
--- a/dlls/ntdll/threadpool.c
+++ b/dlls/ntdll/threadpool.c
@@ -1279,7 +1279,7 @@ static void CALLBACK timerqueue_thread_proc( void *param )
@@ -29,7 +29,7 @@ index 451d441f5725..253a13002950 100644
TRACE( "terminating timer queue thread\n" );
RtlExitUserThread( 0 );
@@ -1399,7 +1399,7 @@ static NTSTATUS tp_timerqueue_lock( struct threadpool_object *timer )
@@ -1398,7 +1398,7 @@ static NTSTATUS tp_timerqueue_lock( struct threadpool_object *timer )
timer->u.timer.period = 0;
timer->u.timer.window_length = 0;
@@ -38,7 +38,7 @@ index 451d441f5725..253a13002950 100644
/* Make sure that the timerqueue thread is running. */
if (!timerqueue.thread_running)
@@ -1420,7 +1420,7 @@ static NTSTATUS tp_timerqueue_lock( struct threadpool_object *timer )
@@ -1419,7 +1419,7 @@ static NTSTATUS tp_timerqueue_lock( struct threadpool_object *timer )
timerqueue.objcount++;
}
@@ -47,7 +47,7 @@ index 451d441f5725..253a13002950 100644
return status;
}
@@ -1433,7 +1433,7 @@ static void tp_timerqueue_unlock( struct threadpool_object *timer )
@@ -1432,7 +1432,7 @@ static void tp_timerqueue_unlock( struct threadpool_object *timer )
{
assert( timer->type == TP_OBJECT_TYPE_TIMER );
@@ -56,7 +56,7 @@ index 451d441f5725..253a13002950 100644
if (timer->u.timer.timer_initialized)
{
/* If timer was pending, remove it. */
@@ -1452,7 +1452,7 @@ static void tp_timerqueue_unlock( struct threadpool_object *timer )
@@ -1451,7 +1451,7 @@ static void tp_timerqueue_unlock( struct threadpool_object *timer )
timer->u.timer.timer_initialized = FALSE;
}
@@ -65,7 +65,7 @@ index 451d441f5725..253a13002950 100644
}
/***********************************************************************
@@ -1470,7 +1470,7 @@ static void CALLBACK waitqueue_thread_proc( void *param )
@@ -1469,7 +1469,7 @@ static void CALLBACK waitqueue_thread_proc( void *param )
TRACE( "starting wait queue thread\n" );
@@ -74,7 +74,7 @@ index 451d441f5725..253a13002950 100644
for (;;)
{
@@ -1507,10 +1507,10 @@ static void CALLBACK waitqueue_thread_proc( void *param )
@@ -1506,10 +1506,10 @@ static void CALLBACK waitqueue_thread_proc( void *param )
/* All wait objects have been destroyed, if no new wait objects are created
* within some amount of time, then we can shutdown this thread. */
assert( num_handles == 0 );
@@ -87,7 +87,7 @@ index 451d441f5725..253a13002950 100644
if (status == STATUS_TIMEOUT && !bucket->objcount)
break;
@@ -1518,9 +1518,9 @@ static void CALLBACK waitqueue_thread_proc( void *param )
@@ -1517,9 +1517,9 @@ static void CALLBACK waitqueue_thread_proc( void *param )
else
{
handles[num_handles] = bucket->update_event;
@@ -99,7 +99,7 @@ index 451d441f5725..253a13002950 100644
if (status >= STATUS_WAIT_0 && status < STATUS_WAIT_0 + num_handles)
{
@@ -1593,7 +1593,7 @@ static void CALLBACK waitqueue_thread_proc( void *param )
@@ -1592,7 +1592,7 @@ static void CALLBACK waitqueue_thread_proc( void *param )
if (!--waitqueue.num_buckets)
assert( list_empty( &waitqueue.buckets ) );
@@ -108,7 +108,7 @@ index 451d441f5725..253a13002950 100644
TRACE( "terminating wait queue thread\n" );
@@ -1622,7 +1622,7 @@ static NTSTATUS tp_waitqueue_lock( struct threadpool_object *wait )
@@ -1621,7 +1621,7 @@ static NTSTATUS tp_waitqueue_lock( struct threadpool_object *wait )
wait->u.wait.timeout = 0;
wait->u.wait.handle = INVALID_HANDLE_VALUE;
@@ -117,7 +117,7 @@ index 451d441f5725..253a13002950 100644
/* Try to assign to existing bucket if possible. */
LIST_FOR_EACH_ENTRY( bucket, &waitqueue.buckets, struct waitqueue_bucket, bucket_entry )
@@ -1678,7 +1678,7 @@ static NTSTATUS tp_waitqueue_lock( struct threadpool_object *wait )
@@ -1677,7 +1677,7 @@ static NTSTATUS tp_waitqueue_lock( struct threadpool_object *wait )
}
out:
@@ -126,7 +126,7 @@ index 451d441f5725..253a13002950 100644
return status;
}
@@ -1689,7 +1689,7 @@ static void tp_waitqueue_unlock( struct threadpool_object *wait )
@@ -1688,7 +1688,7 @@ static void tp_waitqueue_unlock( struct threadpool_object *wait )
{
assert( wait->type == TP_OBJECT_TYPE_WAIT );
@@ -135,7 +135,7 @@ index 451d441f5725..253a13002950 100644
if (wait->u.wait.bucket)
{
struct waitqueue_bucket *bucket = wait->u.wait.bucket;
@@ -1701,7 +1701,7 @@ static void tp_waitqueue_unlock( struct threadpool_object *wait )
@@ -1700,7 +1700,7 @@ static void tp_waitqueue_unlock( struct threadpool_object *wait )
NtSetEvent( bucket->update_event, NULL );
}
@@ -144,7 +144,7 @@ index 451d441f5725..253a13002950 100644
}
static void CALLBACK ioqueue_thread_proc( void *param )
@@ -1956,7 +1956,7 @@ static NTSTATUS tp_threadpool_lock( struct threadpool **out, TP_CALLBACK_ENVIRON
@@ -1955,7 +1955,7 @@ static NTSTATUS tp_threadpool_lock( struct threadpool **out, TP_CALLBACK_ENVIRON
pool = default_threadpool;
}
@@ -153,7 +153,7 @@ index 451d441f5725..253a13002950 100644
/* Make sure that the threadpool has at least one thread. */
if (!pool->num_workers)
@@ -1970,7 +1970,7 @@ static NTSTATUS tp_threadpool_lock( struct threadpool **out, TP_CALLBACK_ENVIRON
@@ -1969,7 +1969,7 @@ static NTSTATUS tp_threadpool_lock( struct threadpool **out, TP_CALLBACK_ENVIRON
pool->objcount++;
}
@@ -162,7 +162,7 @@ index 451d441f5725..253a13002950 100644
if (status != STATUS_SUCCESS)
return status;
@@ -1986,9 +1986,9 @@ static NTSTATUS tp_threadpool_lock( struct threadpool **out, TP_CALLBACK_ENVIRON
@@ -1985,9 +1985,9 @@ static NTSTATUS tp_threadpool_lock( struct threadpool **out, TP_CALLBACK_ENVIRON
*/
static void tp_threadpool_unlock( struct threadpool *pool )
{
@@ -174,7 +174,7 @@ index 451d441f5725..253a13002950 100644
tp_threadpool_release( pool );
}
@@ -2125,10 +2125,10 @@ static void tp_object_initialize( struct threadpool_object *object, struct threa
@@ -2124,10 +2124,10 @@ static void tp_object_initialize( struct threadpool_object *object, struct threa
struct threadpool_group *group = object->group;
InterlockedIncrement( &group->refcount );
@@ -263,28 +263,28 @@ index 451d441f5725..253a13002950 100644
- RtlEnterCriticalSection( &pool->cs );
+ enter_critical_section( &pool->cs );
pool->num_busy_workers--;
for (;;)
{
@@ -2361,7 +2361,7 @@ static void CALLBACK threadpool_worker_proc( void *param )
while ((ptr = threadpool_get_next_item( pool )))
@@ -2359,7 +2359,7 @@ static void CALLBACK threadpool_worker_proc( void *param )
/* Leave critical section and do the actual callback. */
object->num_associated_callbacks++;
object->num_running_callbacks++;
pool->num_busy_workers++;
- RtlLeaveCriticalSection( &pool->cs );
+ leave_critical_section( &pool->cs );
/* Initialize threadpool instance struct. */
callback_instance = (TP_CALLBACK_INSTANCE *)&instance;
@@ -2465,7 +2465,7 @@ static void CALLBACK threadpool_worker_proc( void *param )
@@ -2463,7 +2463,7 @@ static void CALLBACK threadpool_worker_proc( void *param )
}
skip_cleanup:
- RtlEnterCriticalSection( &pool->cs );
+ enter_critical_section( &pool->cs );
assert(pool->num_busy_workers);
pool->num_busy_workers--;
/* Simple callbacks are automatically shutdown after execution. */
@@ -2507,7 +2507,7 @@ static void CALLBACK threadpool_worker_proc( void *param )
@@ -2506,7 +2506,7 @@ static void CALLBACK threadpool_worker_proc( void *param )
}
}
pool->num_workers--;
@@ -293,7 +293,7 @@ index 451d441f5725..253a13002950 100644
TRACE( "terminating worker thread for pool %p\n", pool );
tp_threadpool_release( pool );
@@ -2747,7 +2747,7 @@ NTSTATUS WINAPI TpCallbackMayRunLong( TP_CALLBACK_INSTANCE *instance )
@@ -2746,7 +2746,7 @@ NTSTATUS WINAPI TpCallbackMayRunLong( TP_CALLBACK_INSTANCE *instance )
return STATUS_SUCCESS;
pool = object->pool;
@@ -302,7 +302,7 @@ index 451d441f5725..253a13002950 100644
/* Start new worker threads if required. */
if (pool->num_busy_workers >= pool->num_workers)
@@ -2762,7 +2762,7 @@ NTSTATUS WINAPI TpCallbackMayRunLong( TP_CALLBACK_INSTANCE *instance )
@@ -2761,7 +2761,7 @@ NTSTATUS WINAPI TpCallbackMayRunLong( TP_CALLBACK_INSTANCE *instance )
}
}
@@ -311,7 +311,7 @@ index 451d441f5725..253a13002950 100644
this->may_run_long = TRUE;
return status;
}
@@ -2843,13 +2843,13 @@ VOID WINAPI TpDisassociateCallback( TP_CALLBACK_INSTANCE *instance )
@@ -2842,13 +2842,13 @@ VOID WINAPI TpDisassociateCallback( TP_CALLBACK_INSTANCE *instance )
return;
pool = object->pool;
@@ -327,7 +327,7 @@ index 451d441f5725..253a13002950 100644
this->associated = FALSE;
}
@@ -2901,7 +2901,7 @@ VOID WINAPI TpReleaseCleanupGroupMembers( TP_CLEANUP_GROUP *group, BOOL cancel_p
@@ -2900,7 +2900,7 @@ VOID WINAPI TpReleaseCleanupGroupMembers( TP_CLEANUP_GROUP *group, BOOL cancel_p
TRACE( "%p %u %p\n", group, cancel_pending, userdata );
@@ -336,7 +336,7 @@ index 451d441f5725..253a13002950 100644
/* Unset group, increase references, and mark objects for shutdown */
LIST_FOR_EACH_ENTRY_SAFE( object, next, &this->members, struct threadpool_object, group_entry )
@@ -2927,7 +2927,7 @@ VOID WINAPI TpReleaseCleanupGroupMembers( TP_CLEANUP_GROUP *group, BOOL cancel_p
@@ -2926,7 +2926,7 @@ VOID WINAPI TpReleaseCleanupGroupMembers( TP_CLEANUP_GROUP *group, BOOL cancel_p
list_init( &members );
list_move_tail( &members, &this->members );
@@ -345,7 +345,7 @@ index 451d441f5725..253a13002950 100644
/* Cancel pending callbacks if requested */
if (cancel_pending)
@@ -3041,10 +3041,10 @@ VOID WINAPI TpSetPoolMaxThreads( TP_POOL *pool, DWORD maximum )
@@ -3040,10 +3040,10 @@ VOID WINAPI TpSetPoolMaxThreads( TP_POOL *pool, DWORD maximum )
TRACE( "%p %u\n", pool, maximum );
@@ -358,7 +358,7 @@ index 451d441f5725..253a13002950 100644
}
/***********************************************************************
@@ -3057,7 +3057,7 @@ BOOL WINAPI TpSetPoolMinThreads( TP_POOL *pool, DWORD minimum )
@@ -3056,7 +3056,7 @@ BOOL WINAPI TpSetPoolMinThreads( TP_POOL *pool, DWORD minimum )
TRACE( "%p %u\n", pool, minimum );
@@ -367,7 +367,7 @@ index 451d441f5725..253a13002950 100644
while (this->num_workers < minimum)
{
@@ -3072,7 +3072,7 @@ BOOL WINAPI TpSetPoolMinThreads( TP_POOL *pool, DWORD minimum )
@@ -3071,7 +3071,7 @@ BOOL WINAPI TpSetPoolMinThreads( TP_POOL *pool, DWORD minimum )
this->max_workers = max( this->min_workers, this->max_workers );
}
@@ -376,7 +376,7 @@ index 451d441f5725..253a13002950 100644
return !status;
}
@@ -3088,7 +3088,7 @@ VOID WINAPI TpSetTimer( TP_TIMER *timer, LARGE_INTEGER *timeout, LONG period, LO
@@ -3087,7 +3087,7 @@ VOID WINAPI TpSetTimer( TP_TIMER *timer, LARGE_INTEGER *timeout, LONG period, LO
TRACE( "%p %p %u %u\n", timer, timeout, period, window_length );
@@ -385,7 +385,7 @@ index 451d441f5725..253a13002950 100644
assert( this->u.timer.timer_initialized );
this->u.timer.timer_set = timeout != NULL;
@@ -3148,7 +3148,7 @@ VOID WINAPI TpSetTimer( TP_TIMER *timer, LARGE_INTEGER *timeout, LONG period, LO
@@ -3147,7 +3147,7 @@ VOID WINAPI TpSetTimer( TP_TIMER *timer, LARGE_INTEGER *timeout, LONG period, LO
this->u.timer.timer_pending = TRUE;
}
@@ -394,7 +394,7 @@ index 451d441f5725..253a13002950 100644
if (submit_timer)
tp_object_submit( this, FALSE );
@@ -3165,7 +3165,7 @@ VOID WINAPI TpSetWait( TP_WAIT *wait, HANDLE handle, LARGE_INTEGER *timeout )
@@ -3164,7 +3164,7 @@ VOID WINAPI TpSetWait( TP_WAIT *wait, HANDLE handle, LARGE_INTEGER *timeout )
TRACE( "%p %p %p\n", wait, handle, timeout );
@@ -403,7 +403,7 @@ index 451d441f5725..253a13002950 100644
assert( this->u.wait.bucket );
this->u.wait.handle = handle;
@@ -3209,7 +3209,7 @@ VOID WINAPI TpSetWait( TP_WAIT *wait, HANDLE handle, LARGE_INTEGER *timeout )
@@ -3208,7 +3208,7 @@ VOID WINAPI TpSetWait( TP_WAIT *wait, HANDLE handle, LARGE_INTEGER *timeout )
NtSetEvent( bucket->update_event, NULL );
}
@@ -413,5 +413,5 @@ index 451d441f5725..253a13002950 100644
if (submit_wait)
tp_object_submit( this, FALSE );
--
2.26.2
2.27.0