Pre-fault destination buffer to respect NUMA mempolicy - #36
Open
yunjeongmun wants to merge 1 commit into
Open
yunjeongmun wants to merge 1 commit into
yunjeongmun wants to merge 1 commit into
Conversation
DSA page faults triggered by descriptors submitted from user space are serviced in kworker context, where the allocating task's mempolicy is not applied. When running under numactl, this causes destination pages to be allocated from whatever node the kworker happens to run on, silently ignoring the requested policy. Add dsa_prefault_buffer() and call it on the destination buffer before DSA submission in dto_memset() and dto_memcpymove(). The helper uses madvise(MADV_POPULATE_WRITE) to populate the pages in the calling task's context, where numactl's mempolicy is honored. On older kernels without MADV_POPULATE_*, fall back to a manual read-modify-write sweep over the pages. Before (numactl --interleave 2,3 ignored, pages land on node 0/1): $ numactl -i 2,3 ./memcpy_test --size 2g --thread 10 $ numastat -c -p memcpy_test Per-node process memory usage (in MBs) PID Node 0 Node 1 Node 2 Node 3 Total --------------- ------ ------ ------ ------ ----- 33358 (watch) 1 3 0 0 3 54868 (memcpy_te 8200 12282 10240 10240 40963 55112 (watch) 0 1 0 0 1 55113 (sh) 0 2 0 0 2 --------------- ------ ------ ------ ------ ----- Total 8202 12287 10240 10240 40969 After (numactl --interleave 2,3 respected, pages only on node 2/3): $ numactl -i 2,3 ./memcpy_test --size 2g --thread 10 $ numastat -c -p memcpy_test Per-node process memory usage (in MBs) PID Node 0 Node 1 Node 2 Node 3 Total --------------- ------ ------ ------ ------ ----- 33358 (watch) 1 3 0 0 3 54436 (memcpy_te 0 2 20480 20480 40963 54547 (watch) 0 1 0 0 1 54548 (sh) 0 2 0 0 2 --------------- ------ ------ ------ ------ ----- Total 1 8 20480 20480 40969 Suggested-by: Honggyu Kim <honggyu.kim@sk.com> Signed-off-by: Yunjeong Mun <yunjeong.mun@sk.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
DSA page faults triggered by descriptors submitted from user space are serviced in kworker context, where the allocating task's mempolicy is not applied. When running under numactl, this causes destination pages to be allocated from whatever node the kworker happens to run on, silently ignoring the requested policy.
Add dsa_prefault_buffer() and call it on the destination buffer before DSA submission in dto_memset() and dto_memcpymove(). The helper uses madvise(MADV_POPULATE_WRITE) to populate the pages in the calling task's context, where numactl's mempolicy is honored. On older kernels without MADV_POPULATE_*, fall back to a manual read-modify-write sweep over the pages.
Before (numactl --interleave 2,3 ignored, pages land on node 0/1):
After (numactl --interleave 2,3 respected, pages only on node 2/3):
Suggested-by: Honggyu Kim honggyu.kim@sk.com
Signed-off-by: Yunjeong Mun yunjeong.mun@sk.com