-
Notifications
You must be signed in to change notification settings - Fork 253
feature: Complete madvise for System Allocator #845
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
Open
bibrak
wants to merge
4
commits into
intel:master
Choose a base branch
from
bibrak:madvise_xeKMD
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -299,28 +299,26 @@ bool DrmMemoryManager::setSharedSystemMemAdvise(const void *ptr, const size_t si | |
auto &drm = this->getDrm(rootDeviceIndex); | ||
auto ioctlHelper = drm.getIoctlHelper(); | ||
|
||
uint32_t attribute = 0; | ||
uint32_t attribute = ioctlHelper->getPreferredLocationAdvise(); | ||
uint64_t param = 0; | ||
|
||
uint64_t preferredLocation = 0; | ||
uint64_t policy = 0; | ||
|
||
switch (memAdviseOp) { | ||
case MemAdvise::setPreferredLocation: | ||
attribute = ioctlHelper->getPreferredLocationAdvise(); | ||
param = (static_cast<uint64_t>(-1) << 32) //-1 as currently not supported and ignored. This will be useful in multi device settings. | ||
| static_cast<uint64_t>(ioctlHelper->getDrmParamValue(DrmParam::memoryClassDevice)); | ||
break; | ||
case MemAdvise::clearPreferredLocation: | ||
// Assumes that the default location is VRAM, i.e. 1 == DrmParam::memoryClassDevice | ||
attribute = ioctlHelper->getPreferredLocationAdvise(); | ||
param = (static_cast<uint64_t>(-1) << 32) | static_cast<uint64_t>(ioctlHelper->getDrmParamValue(DrmParam::memoryClassDevice)); | ||
break; | ||
case MemAdvise::setSystemMemoryPreferredLocation: | ||
attribute = ioctlHelper->getPreferredLocationAdvise(); | ||
param = (static_cast<uint64_t>(-1) << 32) | static_cast<uint64_t>(ioctlHelper->getDrmParamValue(DrmParam::memoryClassSystem)); | ||
break; | ||
case MemAdvise::clearSystemMemoryPreferredLocation: | ||
attribute = ioctlHelper->getPreferredLocationAdvise(); | ||
param = (static_cast<uint64_t>(-1) << 32) | static_cast<uint64_t>(ioctlHelper->getDrmParamValue(DrmParam::memoryClassDevice)); | ||
break; | ||
case MemAdvise::clearSystemMemoryPreferredLocation: { | ||
// Assumes that the default location is VRAM, i.e. 1 == DrmParam::memoryAdviseLocationDevice | ||
preferredLocation = static_cast<uint64_t>(ioctlHelper->getDrmParamValue(DrmParam::memoryAdviseLocationDevice)); | ||
policy = static_cast<uint64_t>(ioctlHelper->getDrmParamValue(DrmParam::memoryAdviseMigrationPolicyAllPages)); | ||
param = (preferredLocation << 32) | policy; | ||
} break; | ||
case MemAdvise::setSystemMemoryPreferredLocation: { | ||
preferredLocation = static_cast<uint64_t>(ioctlHelper->getDrmParamValue(DrmParam::memoryAdviseLocationSystem)); | ||
policy = static_cast<uint64_t>(ioctlHelper->getDrmParamValue(DrmParam::memoryAdviseMigrationPolicySystemPages)); | ||
param = (preferredLocation << 32) | policy; | ||
} break; | ||
default: | ||
return false; | ||
} | ||
|
@@ -341,29 +339,10 @@ bool DrmMemoryManager::setSharedSystemAtomicAccess(const void *ptr, const size_t | |
auto &drm = this->getDrm(rootDeviceIndex); | ||
auto ioctlHelper = drm.getIoctlHelper(); | ||
|
||
uint32_t attribute = 0; | ||
uint64_t param = 0; | ||
uint32_t attribute = ioctlHelper->getAtomicAdvise(false); | ||
uint32_t atomicParam = ioctlHelper->getAtomicAccess(mode); | ||
|
||
switch (mode) { | ||
case AtomicAccessMode::device: | ||
attribute = ioctlHelper->getAtomicAdvise(false); | ||
param = (static_cast<uint64_t>(ioctlHelper->getDrmParamValue(DrmParam::atomicClassDevice)) << 32); | ||
break; | ||
case AtomicAccessMode::system: | ||
attribute = ioctlHelper->getAtomicAdvise(false); | ||
param = (static_cast<uint64_t>(ioctlHelper->getDrmParamValue(DrmParam::atomicClassGlobal)) << 32); | ||
break; | ||
case AtomicAccessMode::host: | ||
attribute = ioctlHelper->getAtomicAdvise(false); | ||
param = (static_cast<uint64_t>(ioctlHelper->getDrmParamValue(DrmParam::atomicClassSystem)) << 32); | ||
break; | ||
case AtomicAccessMode::none: | ||
attribute = ioctlHelper->getAtomicAdvise(false); | ||
param = (static_cast<uint64_t>(ioctlHelper->getDrmParamValue(DrmParam::atomicClassUndefined)) << 32); | ||
break; | ||
default: | ||
return false; | ||
} | ||
uint64_t param = (static_cast<uint64_t>(atomicParam) << 32) | 0; | ||
|
||
// Apply the shared system USM IOCTL to all the VMs of the device | ||
std::vector<uint32_t> vmIds; | ||
|
@@ -377,6 +356,23 @@ bool DrmMemoryManager::setSharedSystemAtomicAccess(const void *ptr, const size_t | |
return result; | ||
} | ||
|
||
AtomicAccessMode DrmMemoryManager::getSharedSystemAtomicAccess(const void *ptr, const size_t size, SubDeviceIdsVec &subDeviceIds, uint32_t rootDeviceIndex) { | ||
|
||
auto &drm = this->getDrm(rootDeviceIndex); | ||
auto ioctlHelper = drm.getIoctlHelper(); | ||
|
||
// Apply the shared system USM IOCTL to all the VMs of the device | ||
std::vector<uint32_t> vmIds; | ||
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. please use StackVec |
||
vmIds.reserve(subDeviceIds.size()); | ||
for (auto subDeviceId : subDeviceIds) { | ||
vmIds.push_back(drm.getVirtualMemoryAddressSpace(subDeviceId)); | ||
} | ||
|
||
auto result = ioctlHelper->getVmSharedSystemAtomicAttribute(reinterpret_cast<uint64_t>(ptr), size, vmIds); | ||
|
||
return result; | ||
} | ||
|
||
bool DrmMemoryManager::setAtomicAccess(GraphicsAllocation *gfxAllocation, size_t size, AtomicAccessMode mode, uint32_t rootDeviceIndex) { | ||
auto drmAllocation = static_cast<DrmAllocation *>(gfxAllocation); | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why we need to do those shifts after returning the value from iocthHelper?
IoctlHelper should rather do this translation internally if needed.
Also what is the point of | 0 ?
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.
ioctlHelper->getAtomicAccess(mode);
returns 32bit int. Therefore, it is needed to shift it to the left sinceparam
needs to be 64bit containing two 32bit values. I will remove the| 0
its not needed.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.
you can change it to 64 bit
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.
Its being used in many other places especially for legacy i915. That will require major refactoring.
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.
we need it anyway, as right now you need to do those shifts, which requires helper function