Skip to content

Commit

Permalink
Merge branch 'nibanks/kernel-platform-worker' into dev/daiki/winkerne…
Browse files Browse the repository at this point in the history
…l_merging_exp
  • Loading branch information
ami-GS committed Nov 27, 2024
2 parents f277b67 + 3569672 commit f6bc45c
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 10 deletions.
5 changes: 1 addition & 4 deletions src/core/worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,10 @@ QuicWorkerInitialize(
Worker->ExecutionContext.NextTimeUs = UINT64_MAX;
Worker->ExecutionContext.Ready = TRUE;

#ifndef _KERNEL_MODE // Not supported on kernel mode
if (ExecProfile != QUIC_EXECUTION_PROFILE_TYPE_MAX_THROUGHPUT) {
Worker->IsExternal = TRUE;
CxPlatAddExecutionContext(&MsQuicLib.WorkerPool, &Worker->ExecutionContext, PartitionIndex);
} else
#endif // _KERNEL_MODE
{
} else {
uint16_t ThreadFlags;
switch (ExecProfile) {
default:
Expand Down
4 changes: 4 additions & 0 deletions src/inc/quic_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,13 @@ typedef struct CXPLAT_WORKER_POOL {

} CXPLAT_WORKER_POOL;

_IRQL_requires_max_(PASSIVE_LEVEL)
void
CxPlatWorkerPoolInit(
_In_ CXPLAT_WORKER_POOL* WorkerPool
);

_IRQL_requires_max_(PASSIVE_LEVEL)
void
CxPlatWorkerPoolUninit(
_In_ CXPLAT_WORKER_POOL* WorkerPool
Expand Down Expand Up @@ -519,13 +521,15 @@ typedef struct CXPLAT_EXECUTION_CONTEXT {

} CXPLAT_EXECUTION_CONTEXT;

_IRQL_requires_max_(PASSIVE_LEVEL)
void
CxPlatAddExecutionContext(
_In_ CXPLAT_WORKER_POOL* WorkerPool,
_Inout_ CXPLAT_EXECUTION_CONTEXT* Context,
_In_ uint16_t Index // Into the execution config processor array
);

_IRQL_requires_max_(PASSIVE_LEVEL)
void
CxPlatWakeExecutionContext(
_In_ CXPLAT_EXECUTION_CONTEXT* Context
Expand Down
5 changes: 5 additions & 0 deletions src/inc/quic_platform_winkernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ typedef struct CXPLAT_SQE {
XDP_OVERLAPPED Overlapped;
} CXPLAT_SQE;

_IRQL_requires_max_(PASSIVE_LEVEL)
inline
BOOLEAN
CxPlatEventQInitialize(
Expand All @@ -526,6 +527,7 @@ CxPlatEventQInitialize(
return TRUE;
}

_IRQL_requires_max_(PASSIVE_LEVEL)
inline
void
CxPlatEventQCleanup(
Expand All @@ -537,6 +539,7 @@ CxPlatEventQCleanup(
CxPlatLockUninitialize(&queue->Lock);
}

_IRQL_requires_max_(PASSIVE_LEVEL)
inline
BOOLEAN
CxPlatEventQAssociateHandle(
Expand Down Expand Up @@ -578,6 +581,7 @@ CxPlatEventQEnqueue(
return TRUE;
}

_IRQL_requires_max_(PASSIVE_LEVEL)
inline
uint32_t
CxPlatEventQDequeue(
Expand Down Expand Up @@ -617,6 +621,7 @@ CxPlatEventQDequeue(
return EventsDequeued;
}

_IRQL_requires_max_(PASSIVE_LEVEL)
inline
void
CxPlatEventQReturn(
Expand Down
5 changes: 5 additions & 0 deletions src/platform/datapath_winkernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,11 @@ DataPathInitialize(
goto Exit;
}

if (!CxPlatWorkerPoolLazyStart(WorkerPool, Config)) {
Status = QUIC_STATUS_OUT_OF_MEMORY;
goto Exit;
}

DatapathLength =
sizeof(CXPLAT_DATAPATH) +
CxPlatProcCount() * sizeof(CXPLAT_DATAPATH_PROC_CONTEXT);
Expand Down
2 changes: 1 addition & 1 deletion src/platform/platform.kernel.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
<ClCompile Include="datapath_raw_socket_common.c" />
<ClCompile Include="datapath_raw_socket_win.c" />
<ClCompile Include="datapath_raw_xdp_winkernel.c" />
<ClCompile Include="platform_worker.c" />
<ClCompile Include="hashtable.c" />
<ClCompile Include="pcp.c" />
<ClCompile Include="platform_winkernel.c" />
<ClCompile Include="platform_worker.c" />
<ClCompile Include="storage_winkernel.c" />
<ClCompile Include="tls_schannel.c" />
<ClCompile Include="toeplitz.c" />
Expand Down
3 changes: 2 additions & 1 deletion src/platform/platform_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,9 @@ CxPlatCryptUninitialize(

//
// Platform Worker APIs
//
//

_IRQL_requires_max_(PASSIVE_LEVEL)
BOOLEAN
CxPlatWorkerPoolLazyStart(
_In_ CXPLAT_WORKER_POOL* WorkerPool,
Expand Down
14 changes: 10 additions & 4 deletions src/platform/platform_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ typedef struct QUIC_CACHEALIGN CXPLAT_WORKER {

CXPLAT_THREAD_CALLBACK(CxPlatWorkerThread, Context);

_IRQL_requires_max_(PASSIVE_LEVEL)
void
CxPlatWorkerPoolInit(
_In_ CXPLAT_WORKER_POOL* WorkerPool
Expand Down Expand Up @@ -323,7 +324,7 @@ CxPlatWorkerPoolUninit(
CxPlatLockUninitialize(&WorkerPool->WorkerLock);
}

#ifndef _KERNEL_MODE
#ifndef _KERNEL_MODE // Not supported on kernel mode

#define DYNAMIC_POOL_PROCESSING_PERIOD 1000000 // 1 second
#define DYNAMIC_POOL_PRUNE_COUNT 8
Expand Down Expand Up @@ -387,7 +388,7 @@ CxPlatProcessDynamicPoolAllocators(
CxPlatLockRelease(&Worker->ECLock);
}

#endif
#endif // _KERNEL_MODE

CXPLAT_EVENTQ*
CxPlatWorkerPoolGetEventQ(
Expand All @@ -400,6 +401,7 @@ CxPlatWorkerPoolGetEventQ(
return &WorkerPool->Workers[Index].EventQ;
}

_IRQL_requires_max_(PASSIVE_LEVEL)
void
CxPlatAddExecutionContext(
_In_ CXPLAT_WORKER_POOL* WorkerPool,
Expand All @@ -426,6 +428,7 @@ CxPlatAddExecutionContext(
}
}

_IRQL_requires_max_(PASSIVE_LEVEL)
void
CxPlatWakeExecutionContext(
_In_ CXPLAT_EXECUTION_CONTEXT* Context
Expand All @@ -437,6 +440,7 @@ CxPlatWakeExecutionContext(
}
}

_IRQL_requires_max_(PASSIVE_LEVEL)
void
CxPlatUpdateExecutionContexts(
_In_ CXPLAT_WORKER* Worker
Expand All @@ -458,6 +462,7 @@ CxPlatUpdateExecutionContexts(
}
}

_IRQL_requires_max_(PASSIVE_LEVEL)
void
CxPlatRunExecutionContexts(
_In_ CXPLAT_WORKER* Worker,
Expand Down Expand Up @@ -515,6 +520,7 @@ CxPlatRunExecutionContexts(
}
}

_IRQL_requires_max_(PASSIVE_LEVEL)
BOOLEAN
CxPlatProcessEvents(
_In_ CXPLAT_WORKER* Worker,
Expand Down Expand Up @@ -599,12 +605,12 @@ CXPLAT_THREAD_CALLBACK(CxPlatWorkerThread, Context)
State.NoWorkCount = 0;
}

#ifndef _KERNEL_MODE
#ifndef _KERNEL_MODE // Unnecessary on kernel mode
if (State.TimeNow - State.LastPoolProcessTime > DYNAMIC_POOL_PROCESSING_PERIOD) {
CxPlatProcessDynamicPoolAllocators(Worker);
State.LastPoolProcessTime = State.TimeNow;
}
#endif
#endif // _KERNEL_MODE
}

Shutdown:
Expand Down

0 comments on commit f6bc45c

Please sign in to comment.