Skip to content

Commit

Permalink
Support Thread Affinity for Execution Config (#4614)
Browse files Browse the repository at this point in the history
  • Loading branch information
nibanks authored Nov 6, 2024
1 parent 8167833 commit 709d700
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/core/worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,13 @@ QuicWorkerInitialize(
break;
}

if (MsQuicLib.ExecutionConfig && MsQuicLib.ExecutionConfig->Flags & QUIC_EXECUTION_CONFIG_FLAG_HIGH_PRIORITY) {
ThreadFlags |= CXPLAT_THREAD_FLAG_HIGH_PRIORITY;
if (MsQuicLib.ExecutionConfig) {
if (MsQuicLib.ExecutionConfig->Flags & QUIC_EXECUTION_CONFIG_FLAG_HIGH_PRIORITY) {
ThreadFlags |= CXPLAT_THREAD_FLAG_HIGH_PRIORITY;
}
if (MsQuicLib.ExecutionConfig->Flags & QUIC_EXECUTION_CONFIG_FLAG_AFFINITIZE) {
ThreadFlags |= CXPLAT_THREAD_FLAG_SET_AFFINITIZE;
}
}

CXPLAT_THREAD_CONFIG ThreadConfig = {
Expand Down
1 change: 1 addition & 0 deletions src/cs/lib/msquic_generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ internal enum QUIC_EXECUTION_CONFIG_FLAGS
XDP = 0x0004,
NO_IDEAL_PROC = 0x0008,
HIGH_PRIORITY = 0x0010,
AFFINITIZE = 0x0020,
}

internal unsafe partial struct QUIC_EXECUTION_CONFIG
Expand Down
1 change: 1 addition & 0 deletions src/inc/msquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ typedef enum QUIC_EXECUTION_CONFIG_FLAGS {
QUIC_EXECUTION_CONFIG_FLAG_XDP = 0x0004,
QUIC_EXECUTION_CONFIG_FLAG_NO_IDEAL_PROC = 0x0008,
QUIC_EXECUTION_CONFIG_FLAG_HIGH_PRIORITY = 0x0010,
QUIC_EXECUTION_CONFIG_FLAG_AFFINITIZE = 0x0020,
#endif
} QUIC_EXECUTION_CONFIG_FLAGS;

Expand Down
3 changes: 1 addition & 2 deletions src/perf/lib/PerfClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ PerfClient::Init(
WorkerCount = CxPlatProcCount();
TryGetVariableUnitValue(argc, argv, "threads", &WorkerCount);
TryGetVariableUnitValue(argc, argv, "workers", &WorkerCount);
TryGetValue(argc, argv, "affinitize", &AffinitizeWorkers);

#ifdef QUIC_COMPARTMENT_ID
TryGetValue(argc, argv, "comp", &CompartmentId);
Expand Down Expand Up @@ -326,7 +325,7 @@ PerfClient::Start(
// Configure and start all the workers.
//
uint16_t ThreadFlags =
AffinitizeWorkers ?
PerfDefaultAffinitizeThreads ?
(uint16_t)CXPLAT_THREAD_FLAG_SET_AFFINITIZE :
(uint16_t)CXPLAT_THREAD_FLAG_SET_IDEAL_PROC;
if (PerfDefaultHighPriority) {
Expand Down
1 change: 0 additions & 1 deletion src/perf/lib/PerfClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ struct PerfClient {
uint8_t IncrementTarget {TRUE};
// Local execution parameters
uint32_t WorkerCount;
uint8_t AffinitizeWorkers {FALSE};
uint8_t SpecificLocalAddresses {FALSE};
#ifdef QUIC_COMPARTMENT_ID
uint16_t CompartmentId {UINT16_MAX};
Expand Down
1 change: 1 addition & 0 deletions src/perf/lib/SecNetPerf.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ extern QUIC_CONGESTION_CONTROL_ALGORITHM PerfDefaultCongestionControl;
extern uint8_t PerfDefaultEcnEnabled;
extern uint8_t PerfDefaultQeoAllowed;
extern uint8_t PerfDefaultHighPriority;
extern uint8_t PerfDefaultAffinitizeThreads;

extern CXPLAT_DATAPATH* Datapath;

Expand Down
7 changes: 7 additions & 0 deletions src/perf/lib/SecNetPerfMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ QUIC_CONGESTION_CONTROL_ALGORITHM PerfDefaultCongestionControl = QUIC_CONGESTION
uint8_t PerfDefaultEcnEnabled = false;
uint8_t PerfDefaultQeoAllowed = false;
uint8_t PerfDefaultHighPriority = false;
uint8_t PerfDefaultAffinitizeThreads = false;

#ifdef _KERNEL_MODE
volatile int BufferCurrent;
Expand Down Expand Up @@ -181,6 +182,12 @@ QuicMainStart(
Config->Flags |= QUIC_EXECUTION_CONFIG_FLAG_HIGH_PRIORITY;
SetConfig = true;
}

TryGetValue(argc, argv, "affinitize", &PerfDefaultAffinitizeThreads);
if (PerfDefaultHighPriority) {
Config->Flags |= QUIC_EXECUTION_CONFIG_FLAG_AFFINITIZE;
SetConfig = true;
}
#endif // _KERNEL_MODE

if (TryGetValue(argc, argv, "pollidle", &Config->PollingIdleTimeoutUs)) {
Expand Down
3 changes: 3 additions & 0 deletions src/platform/platform_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ CxPlatWorkerPoolLazyStart(
if (Config->Flags & QUIC_EXECUTION_CONFIG_FLAG_HIGH_PRIORITY) {
ThreadFlags |= CXPLAT_THREAD_FLAG_HIGH_PRIORITY;
}
if (Config->Flags & QUIC_EXECUTION_CONFIG_FLAG_AFFINITIZE) {
ThreadFlags |= CXPLAT_THREAD_FLAG_SET_AFFINITIZE;
}
}

CXPLAT_THREAD_CONFIG ThreadConfig = {
Expand Down

0 comments on commit 709d700

Please sign in to comment.