From 40d552f6ad011c6bce26de55dcb29ecc37abb5e3 Mon Sep 17 00:00:00 2001 From: Nick Banks Date: Thu, 29 Aug 2024 15:26:16 -0400 Subject: [PATCH 1/8] Prototype Prunable Pool Allocator --- src/generated/linux/platform_worker.c.clog.h | 22 ++++++ .../linux/platform_worker.c.clog.h.lttng.h | 19 +++++ src/inc/quic_platform.h | 34 ++++++++- src/manifest/clog.sidecar | 17 +++++ src/platform/datapath_winuser.c | 10 ++- src/platform/platform_internal.h | 2 +- src/platform/platform_worker.c | 71 +++++++++++++++++++ 7 files changed, 169 insertions(+), 6 deletions(-) diff --git a/src/generated/linux/platform_worker.c.clog.h b/src/generated/linux/platform_worker.c.clog.h index e2141b3aa0..533ae2a751 100644 --- a/src/generated/linux/platform_worker.c.clog.h +++ b/src/generated/linux/platform_worker.c.clog.h @@ -18,6 +18,10 @@ #define _clog_MACRO_QuicTraceLogInfo 1 #define QuicTraceLogInfo(a, ...) _clog_CAT(_clog_ARGN_SELECTOR(__VA_ARGS__), _clog_CAT(_,a(#a, __VA_ARGS__))) #endif +#ifndef _clog_MACRO_QuicTraceLogVerbose +#define _clog_MACRO_QuicTraceLogVerbose 1 +#define QuicTraceLogVerbose(a, ...) _clog_CAT(_clog_ARGN_SELECTOR(__VA_ARGS__), _clog_CAT(_,a(#a, __VA_ARGS__))) +#endif #ifndef _clog_MACRO_QuicTraceEvent #define _clog_MACRO_QuicTraceEvent 1 #define QuicTraceEvent(a, ...) _clog_CAT(_clog_ARGN_SELECTOR(__VA_ARGS__), _clog_CAT(_,a(#a, __VA_ARGS__))) @@ -61,6 +65,24 @@ tracepoint(CLOG_PLATFORM_WORKER_C, PlatformWorkerThreadStop , arg2);\ +/*---------------------------------------------------------- +// Decoder Ring for PlatformWorkerProcessPools +// [ lib][%p] Processing pools +// QuicTraceLogVerbose( + PlatformWorkerProcessPools, + "[ lib][%p] Processing pools", + Worker); +// arg2 = arg2 = Worker = arg2 +----------------------------------------------------------*/ +#ifndef _clog_3_ARGS_TRACE_PlatformWorkerProcessPools +#define _clog_3_ARGS_TRACE_PlatformWorkerProcessPools(uniqueId, encoded_arg_string, arg2)\ +tracepoint(CLOG_PLATFORM_WORKER_C, PlatformWorkerProcessPools , arg2);\ + +#endif + + + + /*---------------------------------------------------------- // Decoder Ring for AllocFailure // Allocation of '%s' failed. (%llu bytes) diff --git a/src/generated/linux/platform_worker.c.clog.h.lttng.h b/src/generated/linux/platform_worker.c.clog.h.lttng.h index 7f82dccbd4..db19ead56e 100644 --- a/src/generated/linux/platform_worker.c.clog.h.lttng.h +++ b/src/generated/linux/platform_worker.c.clog.h.lttng.h @@ -39,6 +39,25 @@ TRACEPOINT_EVENT(CLOG_PLATFORM_WORKER_C, PlatformWorkerThreadStop, +/*---------------------------------------------------------- +// Decoder Ring for PlatformWorkerProcessPools +// [ lib][%p] Processing pools +// QuicTraceLogVerbose( + PlatformWorkerProcessPools, + "[ lib][%p] Processing pools", + Worker); +// arg2 = arg2 = Worker = arg2 +----------------------------------------------------------*/ +TRACEPOINT_EVENT(CLOG_PLATFORM_WORKER_C, PlatformWorkerProcessPools, + TP_ARGS( + const void *, arg2), + TP_FIELDS( + ctf_integer_hex(uint64_t, arg2, (uint64_t)arg2) + ) +) + + + /*---------------------------------------------------------- // Decoder Ring for AllocFailure // Allocation of '%s' failed. (%llu bytes) diff --git a/src/inc/quic_platform.h b/src/inc/quic_platform.h index f7bb776fd4..ec69b62dee 100644 --- a/src/inc/quic_platform.h +++ b/src/inc/quic_platform.h @@ -431,13 +431,43 @@ typedef struct QUIC_EXECUTION_CONFIG QUIC_EXECUTION_CONFIG; typedef struct CXPLAT_EXECUTION_CONTEXT CXPLAT_EXECUTION_CONTEXT; typedef struct CXPLAT_EXECUTION_STATE { - uint64_t TimeNow; // in microseconds - uint64_t LastWorkTime; // in microseconds + uint64_t TimeNow; // in microseconds + uint64_t LastWorkTime; // in microseconds + uint64_t LastPoolProcessTime; // in microseconds uint32_t WaitTime; uint32_t NoWorkCount; CXPLAT_THREAD_ID ThreadID; } CXPLAT_EXECUTION_STATE; +// +// Supports more dynamic operations, but must be submitted to the platform worker +// to manage. +// +typedef struct CXPLAT_POOL_EX { +#ifdef __cplusplus + struct CXPLAT_POOL _; +#else + struct CXPLAT_POOL; +#endif + CXPLAT_LIST_ENTRY Link; + void* Owner; +} CXPLAT_POOL_EX; + +#ifndef _KERNEL_MODE // Not supported on kernel mode + +void +CxPlatAddDynamicPoolAllocator( + _Inout_ CXPLAT_POOL_EX* Pool, + _In_ uint16_t Index // Into the execution config processor array + ); + +void +CxPlatRemoveDynamicPoolAllocator( + _Inout_ CXPLAT_POOL_EX* Pool + ); + +#endif + // // Returns FALSE when it's time to cleanup. // diff --git a/src/manifest/clog.sidecar b/src/manifest/clog.sidecar index 226b674417..e32b9e39f5 100644 --- a/src/manifest/clog.sidecar +++ b/src/manifest/clog.sidecar @@ -8745,6 +8745,18 @@ "splitArgs": [], "macroName": "QuicTraceLogWarning" }, + "PlatformWorkerProcessPools": { + "ModuleProperites": {}, + "TraceString": "[ lib][%p] Processing pools", + "UniqueId": "PlatformWorkerProcessPools", + "splitArgs": [ + { + "DefinationEncoding": "p", + "MacroVariableName": "arg2" + } + ], + "macroName": "QuicTraceLogVerbose" + }, "PlatformWorkerThreadStart": { "ModuleProperites": {}, "TraceString": "[ lib][%p] Worker start", @@ -15936,6 +15948,11 @@ "TraceID": "PlatformThreadCreateFailed", "EncodingString": "[ lib] pthread_create failed, retrying without affinitization" }, + { + "UniquenessHash": "3f46cbc3-c609-dab4-07c9-fbe956e68f5c", + "TraceID": "PlatformWorkerProcessPools", + "EncodingString": "[ lib][%p] Processing pools" + }, { "UniquenessHash": "5c3773e2-ef60-26b9-4b3c-d433ca2656df", "TraceID": "PlatformWorkerThreadStart", diff --git a/src/platform/datapath_winuser.c b/src/platform/datapath_winuser.c index cb1d9f5619..357700af68 100644 --- a/src/platform/datapath_winuser.c +++ b/src/platform/datapath_winuser.c @@ -957,7 +957,10 @@ DataPathInitialize( FALSE, RecvDatagramLength, QUIC_POOL_DATA, - &Datapath->Partitions[i].RecvDatagramPool); + (CXPLAT_POOL*)&Datapath->Partitions[i].RecvDatagramPool); + CxPlatAddDynamicPoolAllocator( + &Datapath->Partitions[i].RecvDatagramPool, + i); CxPlatPoolInitializeEx( FALSE, @@ -1020,7 +1023,8 @@ CxPlatProcessorContextRelease( CxPlatPoolUninitialize(&DatapathProc->LargeSendBufferPool); CxPlatPoolUninitialize(&DatapathProc->RioSendBufferPool); CxPlatPoolUninitialize(&DatapathProc->RioLargeSendBufferPool); - CxPlatPoolUninitialize(&DatapathProc->RecvDatagramPool); + CxPlatRemoveDynamicPoolAllocator(&DatapathProc->RecvDatagramPool); + CxPlatPoolUninitialize((CXPLAT_POOL*)&DatapathProc->RecvDatagramPool); CxPlatPoolUninitialize(&DatapathProc->RioRecvPool); CxPlatDataPathRelease(DatapathProc->Datapath); } @@ -2465,7 +2469,7 @@ CxPlatSocketAllocRxIoBlock( if (SocketProc->Parent->UseRio) { OwningPool = &DatapathProc->RioRecvPool; } else { - OwningPool = &DatapathProc->RecvDatagramPool; + OwningPool = (CXPLAT_POOL*)&DatapathProc->RecvDatagramPool; } IoBlock = CxPlatPoolAlloc(OwningPool); diff --git a/src/platform/platform_internal.h b/src/platform/platform_internal.h index 6e4675eb14..a99ac6d776 100644 --- a/src/platform/platform_internal.h +++ b/src/platform/platform_internal.h @@ -260,7 +260,7 @@ typedef struct QUIC_CACHEALIGN CXPLAT_DATAPATH_PROC { // Pool of receive datagram contexts and buffers to be shared by all sockets // on this core. // - CXPLAT_POOL RecvDatagramPool; + CXPLAT_POOL_EX RecvDatagramPool; // // Pool of RIO receive datagram contexts and buffers to be shared by all diff --git a/src/platform/platform_worker.c b/src/platform/platform_worker.c index 9ea1ac620c..6343a8a19e 100644 --- a/src/platform/platform_worker.c +++ b/src/platform/platform_worker.c @@ -52,6 +52,11 @@ typedef struct QUIC_CACHEALIGN CXPLAT_WORKER { // CXPLAT_LOCK ECLock; + // + // List of dynamic pools to manage. + // + CXPLAT_LIST_ENTRY DynamicPoolList; + // // Execution contexts that are waiting to be added to CXPLAT_WORKER::ExecutionContexts. // @@ -160,6 +165,7 @@ CxPlatWorkersLazyStart( CxPlatZeroMemory(CxPlatWorkers, WorkersSize); for (uint32_t i = 0; i < CxPlatWorkerCount; ++i) { CxPlatLockInitialize(&CxPlatWorkers[i].ECLock); + CxPlatListInitializeHead(&CxPlatWorkers[i].DynamicPoolList); CxPlatWorkers[i].InitializedECLock = TRUE; CxPlatWorkers[i].IdealProcessor = ProcessorList ? ProcessorList[i] : (uint16_t)i; CXPLAT_DBG_ASSERT(CxPlatWorkers[i].IdealProcessor < CxPlatProcCount()); @@ -288,6 +294,7 @@ CxPlatWorkersUninit( CxPlatSqeCleanup(&CxPlatWorkers[i].EventQ, &CxPlatWorkers[i].ShutdownSqe); #endif // CXPLAT_SQE_INIT CxPlatEventQCleanup(&CxPlatWorkers[i].EventQ); + CXPLAT_DBG_ASSERT(CxPlatListIsEmpty(&CxPlatWorkers[i].DynamicPoolList)); CxPlatLockUninitialize(&CxPlatWorkers[i].ECLock); } @@ -300,6 +307,65 @@ CxPlatWorkersUninit( CxPlatLockUninitialize(&CxPlatWorkerLock); } +#define DYNAMIC_POOL_PROCESSING_TIME 1000000 // 1 second +#define DYNAMIC_POOL_PRUNE_COUNT 8 + +void +CxPlatAddDynamicPoolAllocator( + _Inout_ CXPLAT_POOL_EX* Pool, + _In_ uint16_t Index // Into the execution config processor array + ) +{ + CXPLAT_WORKER* Worker = &CxPlatWorkers[Index]; + Pool->Owner = Worker; + CxPlatLockAcquire(&Worker->ECLock); + CxPlatListInsertTail(&CxPlatWorkers[Index].DynamicPoolList, &Pool->Link); + CxPlatLockRelease(&Worker->ECLock); +} + +void +CxPlatRemoveDynamicPoolAllocator( + _Inout_ CXPLAT_POOL_EX* Pool + ) +{ + CXPLAT_WORKER* Worker = (CXPLAT_WORKER*)Pool->Owner; + CxPlatLockAcquire(&Worker->ECLock); + CxPlatListEntryRemove(&Pool->Link); + CxPlatLockRelease(&Worker->ECLock); +} + +void +CxPlatProcessDynamicPoolAllocator( + _Inout_ CXPLAT_POOL_EX* Pool + ) +{ + for (uint32_t i = 0; i < DYNAMIC_POOL_PRUNE_COUNT; ++i) { + void* Entry = InterlockedPopEntrySList(&Pool->ListHead); + if (!Entry) break; + Pool->Free(Entry, Pool->Tag, (CXPLAT_POOL*)Pool); + } +} + +void +CxPlatProcessDynamicPoolAllocators( + _In_ CXPLAT_WORKER* Worker + ) +{ + QuicTraceLogVerbose( + PlatformWorkerProcessPools, + "[ lib][%p] Processing pools", + Worker); + + CxPlatLockAcquire(&Worker->ECLock); + CXPLAT_LIST_ENTRY* Entry = Worker->DynamicPoolList.Flink; + while (Entry != &Worker->DynamicPoolList) { + CXPLAT_POOL_EX* Pool = CXPLAT_CONTAINING_RECORD(Entry, CXPLAT_POOL_EX, Link); + Entry = Entry->Flink; + CxPlatProcessDynamicPoolAllocator(Pool); + } + CxPlatLockRelease(&Worker->ECLock); +} + CXPLAT_EVENTQ* CxPlatWorkerGetEventQ( _In_ uint16_t Index @@ -504,6 +570,11 @@ CXPLAT_THREAD_CALLBACK(CxPlatWorkerThread, Context) CxPlatSchedulerYield(); State.NoWorkCount = 0; } + + if (State.TimeNow - State.LastPoolProcessTime > DYNAMIC_POOL_PROCESSING_TIME) { + CxPlatProcessDynamicPoolAllocators(Worker); + State.LastPoolProcessTime = State.TimeNow; + } } Shutdown: From f47f8484909fa06a89d1ba455ba4f88a3e478c97 Mon Sep 17 00:00:00 2001 From: Nick Banks Date: Fri, 30 Aug 2024 16:41:24 -0400 Subject: [PATCH 2/8] Fixes --- src/inc/quic_platform_posix.h | 20 ++++++++++++++++++++ src/inc/quic_platform_winuser.h | 14 ++++++++++++++ src/platform/inline.c | 5 +++++ src/platform/platform_worker.c | 20 +++++++++++++------- src/platform/unittest/DataPathTest.cpp | 6 ------ 5 files changed, 52 insertions(+), 13 deletions(-) diff --git a/src/inc/quic_platform_posix.h b/src/inc/quic_platform_posix.h index 7d0eaf125c..bb57a2ee9b 100644 --- a/src/inc/quic_platform_posix.h +++ b/src/inc/quic_platform_posix.h @@ -585,6 +585,26 @@ CxPlatPoolFree( } } +inline +BOOLEAN +CxPlatPoolPrune( + _Inout_ CXPLAT_POOL* Pool + ) +{ + CxPlatLockAcquire(&Pool->Lock); + void* Entry = CxPlatListPopEntry(&Pool->ListHead); + if (Entry != NULL) { + CXPLAT_FRE_ASSERT(Pool->ListDepth > 0); + Pool->ListDepth--; + } + CxPlatLockRelease(&Pool->Lock); + if (Entry == NULL) { + return FALSE; + } + CxPlatFree(Entry, Pool->Tag); + return TRUE; +} + // // Reference Count Interface // diff --git a/src/inc/quic_platform_winuser.h b/src/inc/quic_platform_winuser.h index 9c3f418cc5..a8583f7d1f 100644 --- a/src/inc/quic_platform_winuser.h +++ b/src/inc/quic_platform_winuser.h @@ -465,6 +465,20 @@ CxPlatPoolFree( } } +inline +BOOLEAN +CxPlatPoolPrune( + _Inout_ CXPLAT_POOL* Pool + ) +{ + void* Entry = InterlockedPopEntrySList(&Pool->ListHead); + if (Entry == NULL) { + return FALSE; + } + Pool->Free(Entry, Pool->Tag, Pool); + return TRUE; +} + #define CxPlatZeroMemory RtlZeroMemory #define CxPlatCopyMemory RtlCopyMemory #define CxPlatMoveMemory RtlMoveMemory diff --git a/src/platform/inline.c b/src/platform/inline.c index e7d09525a9..6b4d075bda 100644 --- a/src/platform/inline.c +++ b/src/platform/inline.c @@ -55,6 +55,11 @@ CxPlatPoolFree( _In_ void* Entry ); +BOOLEAN +CxPlatPoolPrune( + _Inout_ CXPLAT_POOL* Pool + ); + void CxPlatListInitializeHead( _Out_ CXPLAT_LIST_ENTRY* ListHead diff --git a/src/platform/platform_worker.c b/src/platform/platform_worker.c index 6343a8a19e..5281263da6 100644 --- a/src/platform/platform_worker.c +++ b/src/platform/platform_worker.c @@ -307,8 +307,8 @@ CxPlatWorkersUninit( CxPlatLockUninitialize(&CxPlatWorkerLock); } -#define DYNAMIC_POOL_PROCESSING_TIME 1000000 // 1 second -#define DYNAMIC_POOL_PRUNE_COUNT 8 +#define DYNAMIC_POOL_PROCESSING_PERIOD 1000000 // 1 second +#define DYNAMIC_POOL_PRUNE_COUNT 8 void CxPlatAddDynamicPoolAllocator( @@ -340,10 +340,15 @@ CxPlatProcessDynamicPoolAllocator( ) { for (uint32_t i = 0; i < DYNAMIC_POOL_PRUNE_COUNT; ++i) { - void* Entry = InterlockedPopEntrySList(&Pool->ListHead); - if (!Entry) break; - Pool->Free(Entry, Pool->Tag, (CXPLAT_POOL*)Pool); + if (!CxPlatPoolPrune((CXPLAT_POOL*)Pool)) { + return; + } } + + QuicTraceLogVerbose( + PlatformPrunePool, + "[ lib][%p] Pruned pool", + Pool); } void @@ -445,7 +450,6 @@ CxPlatRunExecutionContexts( #if DEBUG // Debug statistics ++Worker->EcPollCount; #endif - State->TimeNow = CxPlatTimeUs64(); uint64_t NextTime = UINT64_MAX; CXPLAT_SLIST_ENTRY** EC = &Worker->ExecutionContexts; @@ -554,9 +558,11 @@ CXPLAT_THREAD_CALLBACK(CxPlatWorkerThread, Context) #if DEBUG // Debug statistics ++Worker->LoopCount; #endif + State.TimeNow = CxPlatTimeUs64(); CxPlatRunExecutionContexts(Worker, &State); if (State.WaitTime && InterlockedFetchAndClearBoolean(&Worker->Running)) { + State.TimeNow = CxPlatTimeUs64(); CxPlatRunExecutionContexts(Worker, &State); // Run once more to handle race conditions } @@ -571,7 +577,7 @@ CXPLAT_THREAD_CALLBACK(CxPlatWorkerThread, Context) State.NoWorkCount = 0; } - if (State.TimeNow - State.LastPoolProcessTime > DYNAMIC_POOL_PROCESSING_TIME) { + if (State.TimeNow - State.LastPoolProcessTime > DYNAMIC_POOL_PROCESSING_PERIOD) { CxPlatProcessDynamicPoolAllocators(Worker); State.LastPoolProcessTime = State.TimeNow; } diff --git a/src/platform/unittest/DataPathTest.cpp b/src/platform/unittest/DataPathTest.cpp index 911d0f3fb4..dec4110f84 100644 --- a/src/platform/unittest/DataPathTest.cpp +++ b/src/platform/unittest/DataPathTest.cpp @@ -696,12 +696,6 @@ TEST_F(DataPathTest, InitializeInvalid) ASSERT_EQ(QUIC_STATUS_INVALID_PARAMETER, Datapath.GetInitStatus()); ASSERT_EQ(nullptr, Datapath.Datapath); } - if (!UseDuoNic) { - QUIC_EXECUTION_CONFIG Config = { QUIC_EXECUTION_CONFIG_FLAG_XDP, 0, 1, {0} }; - CxPlatDataPath Datapath(&EmptyUdpCallbacks, nullptr, 0, &Config); - ASSERT_EQ(QUIC_STATUS_NOT_SUPPORTED, Datapath.GetInitStatus()); - ASSERT_EQ(nullptr, Datapath.Datapath); - } } TEST_F(DataPathTest, UdpBind) From 6e7da4fa15e9a2375bf5220ff7ab3eb8c72711cb Mon Sep 17 00:00:00 2001 From: Nick Banks Date: Fri, 30 Aug 2024 16:53:21 -0400 Subject: [PATCH 3/8] wip --- src/platform/platform_worker.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/platform/platform_worker.c b/src/platform/platform_worker.c index 5281263da6..682e9fce8f 100644 --- a/src/platform/platform_worker.c +++ b/src/platform/platform_worker.c @@ -343,12 +343,11 @@ CxPlatProcessDynamicPoolAllocator( if (!CxPlatPoolPrune((CXPLAT_POOL*)Pool)) { return; } + QuicTraceLogVerbose( + PlatformPrunePool, + "[ lib][%p] Pruned pool", + Pool); } - - QuicTraceLogVerbose( - PlatformPrunePool, - "[ lib][%p] Pruned pool", - Pool); } void From 0224157ea40b83e876b26fabe0c1f35c0ca8c97c Mon Sep 17 00:00:00 2001 From: Nick Banks Date: Sat, 31 Aug 2024 11:59:59 -0400 Subject: [PATCH 4/8] Improvements --- src/inc/quic_platform.h | 6 +----- src/platform/datapath_winuser.c | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/inc/quic_platform.h b/src/inc/quic_platform.h index ec69b62dee..2aed77674c 100644 --- a/src/inc/quic_platform.h +++ b/src/inc/quic_platform.h @@ -444,11 +444,7 @@ typedef struct CXPLAT_EXECUTION_STATE { // to manage. // typedef struct CXPLAT_POOL_EX { -#ifdef __cplusplus - struct CXPLAT_POOL _; -#else - struct CXPLAT_POOL; -#endif + struct CXPLAT_POOL Base; CXPLAT_LIST_ENTRY Link; void* Owner; } CXPLAT_POOL_EX; diff --git a/src/platform/datapath_winuser.c b/src/platform/datapath_winuser.c index 357700af68..ef7568a9c8 100644 --- a/src/platform/datapath_winuser.c +++ b/src/platform/datapath_winuser.c @@ -957,7 +957,7 @@ DataPathInitialize( FALSE, RecvDatagramLength, QUIC_POOL_DATA, - (CXPLAT_POOL*)&Datapath->Partitions[i].RecvDatagramPool); + &Datapath->Partitions[i].RecvDatagramPool.Base); CxPlatAddDynamicPoolAllocator( &Datapath->Partitions[i].RecvDatagramPool, i); @@ -1024,7 +1024,7 @@ CxPlatProcessorContextRelease( CxPlatPoolUninitialize(&DatapathProc->RioSendBufferPool); CxPlatPoolUninitialize(&DatapathProc->RioLargeSendBufferPool); CxPlatRemoveDynamicPoolAllocator(&DatapathProc->RecvDatagramPool); - CxPlatPoolUninitialize((CXPLAT_POOL*)&DatapathProc->RecvDatagramPool); + CxPlatPoolUninitialize(&DatapathProc->RecvDatagramPool.Base); CxPlatPoolUninitialize(&DatapathProc->RioRecvPool); CxPlatDataPathRelease(DatapathProc->Datapath); } @@ -2469,7 +2469,7 @@ CxPlatSocketAllocRxIoBlock( if (SocketProc->Parent->UseRio) { OwningPool = &DatapathProc->RioRecvPool; } else { - OwningPool = (CXPLAT_POOL*)&DatapathProc->RecvDatagramPool; + OwningPool = &DatapathProc->RecvDatagramPool.Base; } IoBlock = CxPlatPoolAlloc(OwningPool); From 8b0c8bedc3f9419e10181b7af285ed547fdf816a Mon Sep 17 00:00:00 2001 From: Nick Banks Date: Sat, 31 Aug 2024 12:10:57 -0400 Subject: [PATCH 5/8] Initialize execution state --- src/core/worker.c | 2 +- src/perf/lib/Tcp.cpp | 2 +- src/platform/platform_worker.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/worker.c b/src/core/worker.c index 1132642953..105dbab2ae 100644 --- a/src/core/worker.c +++ b/src/core/worker.c @@ -773,7 +773,7 @@ CXPLAT_THREAD_CALLBACK(QuicWorkerThread, Context) CXPLAT_EXECUTION_CONTEXT* EC = &Worker->ExecutionContext; CXPLAT_EXECUTION_STATE State = { - 0, CxPlatTimeUs64(), UINT32_MAX, 0, CxPlatCurThreadID() + 0, 0, 0, UINT32_MAX, 0, CxPlatCurThreadID() }; QuicTraceEvent( diff --git a/src/perf/lib/Tcp.cpp b/src/perf/lib/Tcp.cpp index 62158a142e..171acad9de 100644 --- a/src/perf/lib/Tcp.cpp +++ b/src/perf/lib/Tcp.cpp @@ -288,7 +288,7 @@ CXPLAT_THREAD_CALLBACK(TcpWorker::WorkerThread, Context) { TcpWorker* This = (TcpWorker*)Context; CXPLAT_EXECUTION_STATE DummyState = { - 0, CxPlatTimeUs64(), UINT32_MAX, 0, CxPlatCurThreadID() + 0, 0, 0, UINT32_MAX, 0, CxPlatCurThreadID() }; while (DoWork(This, &DummyState)) { if (!InterlockedFetchAndClearBoolean(&This->ExecutionContext.Ready)) { diff --git a/src/platform/platform_worker.c b/src/platform/platform_worker.c index 682e9fce8f..2d974d95bf 100644 --- a/src/platform/platform_worker.c +++ b/src/platform/platform_worker.c @@ -547,7 +547,7 @@ CXPLAT_THREAD_CALLBACK(CxPlatWorkerThread, Context) Worker->ThreadStarted = TRUE; #endif - CXPLAT_EXECUTION_STATE State = { 0, CxPlatTimeUs64(), UINT32_MAX, 0, CxPlatCurThreadID() }; + CXPLAT_EXECUTION_STATE State = { 0, 0, 0, UINT32_MAX, 0, CxPlatCurThreadID() }; Worker->Running = TRUE; From ebf1a2912092023834d7addc75192142932fb60d Mon Sep 17 00:00:00 2001 From: Nick Banks Date: Sat, 31 Aug 2024 12:13:29 -0400 Subject: [PATCH 6/8] Remove unnecessary log --- src/platform/platform_worker.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/platform/platform_worker.c b/src/platform/platform_worker.c index 2d974d95bf..c9bc45d2c3 100644 --- a/src/platform/platform_worker.c +++ b/src/platform/platform_worker.c @@ -343,10 +343,6 @@ CxPlatProcessDynamicPoolAllocator( if (!CxPlatPoolPrune((CXPLAT_POOL*)Pool)) { return; } - QuicTraceLogVerbose( - PlatformPrunePool, - "[ lib][%p] Pruned pool", - Pool); } } From e2cb9738764b9baae8dcba0fca2d3dae39ae703b Mon Sep 17 00:00:00 2001 From: Nick Banks Date: Sat, 31 Aug 2024 12:22:41 -0400 Subject: [PATCH 7/8] Fix kernel --- src/inc/quic_platform.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/inc/quic_platform.h b/src/inc/quic_platform.h index 2aed77674c..f17adb2845 100644 --- a/src/inc/quic_platform.h +++ b/src/inc/quic_platform.h @@ -439,18 +439,18 @@ typedef struct CXPLAT_EXECUTION_STATE { CXPLAT_THREAD_ID ThreadID; } CXPLAT_EXECUTION_STATE; +#ifndef _KERNEL_MODE // Not supported on kernel mode + // // Supports more dynamic operations, but must be submitted to the platform worker // to manage. // typedef struct CXPLAT_POOL_EX { - struct CXPLAT_POOL Base; + CXPLAT_POOL Base; CXPLAT_LIST_ENTRY Link; void* Owner; } CXPLAT_POOL_EX; -#ifndef _KERNEL_MODE // Not supported on kernel mode - void CxPlatAddDynamicPoolAllocator( _Inout_ CXPLAT_POOL_EX* Pool, From d1f97ad40e8102927c6027d26753a67afe98d072 Mon Sep 17 00:00:00 2001 From: Nick Banks Date: Thu, 5 Sep 2024 09:07:51 -0400 Subject: [PATCH 8/8] Fix merge breaks --- src/inc/quic_platform.h | 1 + src/platform/datapath_winuser.c | 1 + src/platform/platform_worker.c | 7 +++++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/inc/quic_platform.h b/src/inc/quic_platform.h index 609f60bf8c..ceaa6cdcd8 100644 --- a/src/inc/quic_platform.h +++ b/src/inc/quic_platform.h @@ -483,6 +483,7 @@ typedef struct CXPLAT_POOL_EX { void CxPlatAddDynamicPoolAllocator( + _In_ CXPLAT_WORKER_POOL* WorkerPool, _Inout_ CXPLAT_POOL_EX* Pool, _In_ uint16_t Index // Into the execution config processor array ); diff --git a/src/platform/datapath_winuser.c b/src/platform/datapath_winuser.c index 0248fbd933..2078533eed 100644 --- a/src/platform/datapath_winuser.c +++ b/src/platform/datapath_winuser.c @@ -964,6 +964,7 @@ DataPathInitialize( QUIC_POOL_DATA, &Datapath->Partitions[i].RecvDatagramPool.Base); CxPlatAddDynamicPoolAllocator( + Datapath->WorkerPool, &Datapath->Partitions[i].RecvDatagramPool, i); diff --git a/src/platform/platform_worker.c b/src/platform/platform_worker.c index 7ac174ee2f..1c071c47a2 100644 --- a/src/platform/platform_worker.c +++ b/src/platform/platform_worker.c @@ -317,14 +317,17 @@ CxPlatWorkerPoolUninit( void CxPlatAddDynamicPoolAllocator( + _In_ CXPLAT_WORKER_POOL* WorkerPool, _Inout_ CXPLAT_POOL_EX* Pool, _In_ uint16_t Index // Into the execution config processor array ) { - CXPLAT_WORKER* Worker = &CxPlatWorkers[Index]; + CXPLAT_DBG_ASSERT(WorkerPool); + CXPLAT_FRE_ASSERT(Index < WorkerPool->WorkerCount); + CXPLAT_WORKER* Worker = &WorkerPool->Workers[Index]; Pool->Owner = Worker; CxPlatLockAcquire(&Worker->ECLock); - CxPlatListInsertTail(&CxPlatWorkers[Index].DynamicPoolList, &Pool->Link); + CxPlatListInsertTail(&Worker->DynamicPoolList, &Pool->Link); CxPlatLockRelease(&Worker->ECLock); }