Skip to content

Pre-fault destination buffer to respect NUMA mempolicy - #36

Open
yunjeongmun wants to merge 1 commit into
intel:mainfrom
skhynix:fix/prefault
Open

yunjeongmun wants to merge 1 commit into
intel:mainfrom
skhynix:fix/prefault

Conversation

@yunjeongmun

@yunjeongmun yunjeongmun commented Sep 21, 2026 •

Copy link
Copy Markdown

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

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant