-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VirtualAlloc and affinity settings #71
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -119,6 +119,9 @@ CxPlatLogAssert( | |||||||||||||||||
#define CXPLAT_ALLOC_PAGED(Size, Tag) ExAllocatePool2(POOL_FLAG_PAGED | POOL_FLAG_UNINITIALIZED, Size, Tag) | ||||||||||||||||||
#define CXPLAT_ALLOC_NONPAGED(Size, Tag) ExAllocatePool2(POOL_FLAG_NON_PAGED | POOL_FLAG_UNINITIALIZED, Size, Tag) | ||||||||||||||||||
#define CXPLAT_FREE(Mem, Tag) ExFreePoolWithTag((void*)Mem, Tag) | ||||||||||||||||||
#define CXPLAT_VIRTUAL_ALLOC(Size, TypeFlags, ProtectionFlags, Tag) \ | ||||||||||||||||||
CXPLAT_ALLOC_NONPAGED(Size, Tag) | ||||||||||||||||||
#define CXPLAT_VIRTUAL_FREE(Mem, Size, Type, Tag) CXPLAT_FREE(Mem, Tag); | ||||||||||||||||||
|
||||||||||||||||||
#define CxPlatZeroMemory RtlZeroMemory | ||||||||||||||||||
#define CxPlatCopyMemory RtlCopyMemory | ||||||||||||||||||
|
@@ -603,6 +606,38 @@ CxPlatThreadCreate( | |||||||||||||||||
typedef ULONG_PTR CXPLAT_THREAD_ID; | ||||||||||||||||||
#define CxPlatCurThreadID() ((CXPLAT_THREAD_ID)PsGetCurrentThreadId()) | ||||||||||||||||||
|
||||||||||||||||||
inline | ||||||||||||||||||
BOOLEAN | ||||||||||||||||||
CxPlatSetThreadNodeAffinity( | ||||||||||||||||||
LONG NodeAffinity | ||||||||||||||||||
) | ||||||||||||||||||
{ | ||||||||||||||||||
GROUP_AFFINITY group; | ||||||||||||||||||
|
||||||||||||||||||
KeQueryNodeActiveAffinity((USHORT)NodeAffinity, &group, NULL); | ||||||||||||||||||
KeSetSystemGroupAffinityThread(&group, NULL); | ||||||||||||||||||
|
||||||||||||||||||
return TRUE; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
inline | ||||||||||||||||||
BOOLEAN | ||||||||||||||||||
CxPlatSetThreadGroupAffinity( | ||||||||||||||||||
LONG GroupNumber, | ||||||||||||||||||
DWORD_PTR CpuAffinity | ||||||||||||||||||
) | ||||||||||||||||||
{ | ||||||||||||||||||
GROUP_AFFINITY group = {0}; | ||||||||||||||||||
|
||||||||||||||||||
group.Mask = CpuAffinity; | ||||||||||||||||||
group.Group = (USHORT)GroupNumber; | ||||||||||||||||||
|
||||||||||||||||||
KeSetSystemGroupAffinityThread(&group, NULL); | ||||||||||||||||||
Comment on lines
+630
to
+635
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And make the similar changes to user mode. |
||||||||||||||||||
|
||||||||||||||||||
return TRUE; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
Comment on lines
+639
to
+640
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
nit: only 1 trailing blank newline |
||||||||||||||||||
// | ||||||||||||||||||
// Crypto Interfaces | ||||||||||||||||||
// | ||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -146,6 +146,9 @@ CxPlatFree( | |||
#define CXPLAT_ALLOC_PAGED(Size, Tag) CxPlatAlloc(Size, Tag) | ||||
#define CXPLAT_ALLOC_NONPAGED(Size, Tag) CxPlatAlloc(Size, Tag) | ||||
#define CXPLAT_FREE(Mem, Tag) CxPlatFree((void*)Mem, Tag) | ||||
#define CXPLAT_VIRTUAL_ALLOC(Size, TypeFlags, ProtectionFlags, Tag) \ | ||||
VirtualAlloc(NULL, Size, TypeFlags, ProtectionFlags) | ||||
#define CXPLAT_VIRTUAL_FREE(Mem, Size, Type, Tag) VirtualFree(Mem, Size, Type); | ||||
|
||||
#define CxPlatZeroMemory RtlZeroMemory | ||||
#define CxPlatCopyMemory RtlCopyMemory | ||||
|
@@ -597,6 +600,46 @@ CxPlatThreadWaitWithTimeout( | |||
typedef uint32_t CXPLAT_THREAD_ID; | ||||
#define CxPlatCurThreadID() GetCurrentThreadId() | ||||
|
||||
inline | ||||
BOOLEAN | ||||
CxPlatSetThreadNodeAffinity( | ||||
LONG NodeAffinity | ||||
) | ||||
{ | ||||
GROUP_AFFINITY group; | ||||
|
||||
if (!GetNumaNodeProcessorMaskEx((USHORT)NodeAffinity, &group)) { | ||||
CXPLAT_DBG_ASSERT(FALSE); | ||||
return FALSE; | ||||
} | ||||
if (!SetThreadGroupAffinity(GetCurrentThread(), &group, NULL)) { | ||||
CXPLAT_DBG_ASSERT(FALSE); | ||||
return FALSE; | ||||
} | ||||
|
||||
return TRUE; | ||||
} | ||||
|
||||
inline | ||||
BOOLEAN | ||||
CxPlatSetThreadGroupAffinity( | ||||
LONG GroupNumber, | ||||
DWORD_PTR CpuAffinity | ||||
) | ||||
{ | ||||
GROUP_AFFINITY group = {0}; | ||||
|
||||
group.Mask = CpuAffinity; | ||||
group.Group = (WORD)GroupNumber; | ||||
if (!SetThreadGroupAffinity(GetCurrentThread(), &group, NULL)) { | ||||
CXPLAT_DBG_ASSERT(FALSE); | ||||
return FALSE; | ||||
} | ||||
|
||||
return TRUE; | ||||
} | ||||
|
||||
|
||||
Comment on lines
+641
to
+642
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
nit: only 1 trailing blank newline |
||||
// | ||||
// Crypto Interfaces | ||||
// | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not use Windows style all caps types like
LONG
.