Skip to content

Commit

Permalink
netkvm: fix affinity of poll handlers
Browse files Browse the repository at this point in the history
https://issues.redhat.com/browse/RHEL-33334
Fix wrong affinity assignment.

Signed-off-by: Yuri Benditovich <[email protected]>
  • Loading branch information
ybendito authored and YanVugenfirer committed May 7, 2024
1 parent 5fd4ffb commit 657ad7e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
3 changes: 2 additions & 1 deletion NetKVM/Common/ndis56common.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static bool FORCEINLINE CheckOSNdisVersion(UCHAR osmajor, UCHAR osminor)
typedef struct _PARANDIS_ADAPTER PARANDIS_ADAPTER;

void ParaNdisPollNotify(PARANDIS_ADAPTER *, UINT Index, const char *Origin);
void ParaNdisPollSetAffinity(PARANDIS_ADAPTER *, const CCHAR *Indices, CCHAR Size);
void ParaNdisPollSetAffinity(PARANDIS_ADAPTER *);
void RxPoll(PARANDIS_ADAPTER* pContext, UINT BundleIndex, NDIS_POLL_RECEIVE_DATA& RxData);

#include "ParaNdis-SM.h"
Expand Down Expand Up @@ -186,6 +186,7 @@ struct NdisPollHandler
void Unregister();
void EnableNotification(BOOLEAN Enable);
void HandlePoll(NDIS_POLL_DATA* PollData);
bool UpdateAffinity(const PROCESSOR_NUMBER&);
};

struct CPUPathBundle : public CPlacementAllocatable {
Expand Down
5 changes: 1 addition & 4 deletions NetKVM/wlh/ParaNdis6_RSS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,10 +567,7 @@ NDIS_STATUS ParaNdis6_RSSSetParameters( PARANDIS_ADAPTER *pContext,
SetDeviceRSSSettings(pContext);
if (pContext->bPollModeEnabled)
{
ParaNdisPollSetAffinity(
pContext,
RSSParameters->RSSScalingSettings.QueueIndirectionTable,
RSSParameters->ReceiveQueuesNumber);
ParaNdisPollSetAffinity(pContext);
}
}

Expand Down
38 changes: 24 additions & 14 deletions NetKVM/wlh/ParaNdis_Poll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,37 @@ static void UpdatePollAffinities(PPARANDIS_ADAPTER pContext)
DPrintf(0, "updated #%d affinities\n", done);
}

void ParaNdisPollSetAffinity(PARANDIS_ADAPTER* pContext, const CCHAR* Indices, CCHAR Size)
bool NdisPollHandler::UpdateAffinity(const PROCESSOR_NUMBER& Number)
{
if (Number.Group != m_ProcessorNumber.Group || Number.Number != m_ProcessorNumber.Number)
{
m_ProcessorNumber = Number;
m_UpdateAffinity = true;
DPrintf(POLL_PRINT_LEVEL, "[%s] #%d => %d:%d\n", __FUNCTION__, m_Index, Number.Group, Number.Number);
return true;
}
return false;
}

void ParaNdisPollSetAffinity(PARANDIS_ADAPTER* pContext)
{
bool needUpdate = false;
for (CCHAR i = 0; i < Size && i < ARRAYSIZE(pContext->PollHandlers); ++i)
const auto& rssSettings = pContext->RSSParameters.ActiveRSSScalingSettings;

for (ULONG i = 0; i <= rssSettings.RSSHashMask; ++i)
{
LONG index = Indices[i];
if (index >= 0)
CCHAR index = rssSettings.QueueIndirectionTable[i];
const PROCESSOR_NUMBER& procNo = rssSettings.IndirectionTable[i];
if (index < ARRAYSIZE(pContext->PollHandlers))
{
PROCESSOR_NUMBER number;
if (KeGetProcessorNumberFromIndex(index, &number) == STATUS_SUCCESS)
NdisPollHandler* poll = &pContext->PollHandlers[index];
if (poll->UpdateAffinity(procNo))
{
NdisPollHandler* poll = &pContext->PollHandlers[i];
if (number.Group != poll->m_ProcessorNumber.Group || number.Number != poll->m_ProcessorNumber.Number)
{
poll->m_ProcessorNumber = number;
poll->m_UpdateAffinity = true;
needUpdate = true;
}
needUpdate = true;
}
}
}

if (needUpdate)
{
NDIS_HANDLE hwo = NdisAllocateIoWorkItem(pContext->MiniportHandle);
Expand Down Expand Up @@ -139,7 +149,7 @@ void NdisPollHandler::HandlePoll(NDIS_POLL_DATA* PollData)

#else

void ParaNdisPollSetAffinity(PARANDIS_ADAPTER*, const CCHAR*, CCHAR)
void ParaNdisPollSetAffinity(PARANDIS_ADAPTER*)
{
}

Expand Down

0 comments on commit 657ad7e

Please sign in to comment.