Skip to content

Commit f6c3e1a

Browse files
Ralph Campbellakpm00
authored andcommitted
mm/hmm: add a test for cross device private faults
Add a simple test case for when hmm_range_fault() is called with the HMM_PFN_REQ_FAULT flag and a device private PTE is found for a device other than the hmm_range::dev_private_owner. This should cause the page to be faulted back to system memory from the other device and the PFN returned in the output array. Also, remove a piece of code that unnecessarily unmaps part of the buffer. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ralph Campbell <[email protected]> Reviewed-by: Alistair Popple <[email protected]> Cc: Felix Kuehling <[email protected]> Cc: Philip Yang <[email protected]> Cc: Jason Gunthorpe <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 68deb82 commit f6c3e1a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tools/testing/selftests/vm/hmm-tests.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,9 +1603,19 @@ TEST_F(hmm2, double_map)
16031603
for (i = 0, ptr = buffer->mirror; i < size / sizeof(*ptr); ++i)
16041604
ASSERT_EQ(ptr[i], i);
16051605

1606-
/* Punch a hole after the first page address. */
1607-
ret = munmap(buffer->ptr + self->page_size, self->page_size);
1606+
/* Migrate pages to device 1 and try to read from device 0. */
1607+
ret = hmm_dmirror_cmd(self->fd1, HMM_DMIRROR_MIGRATE, buffer, npages);
1608+
ASSERT_EQ(ret, 0);
1609+
ASSERT_EQ(buffer->cpages, npages);
1610+
1611+
ret = hmm_dmirror_cmd(self->fd0, HMM_DMIRROR_READ, buffer, npages);
16081612
ASSERT_EQ(ret, 0);
1613+
ASSERT_EQ(buffer->cpages, npages);
1614+
ASSERT_EQ(buffer->faults, 1);
1615+
1616+
/* Check what device 0 read. */
1617+
for (i = 0, ptr = buffer->mirror; i < size / sizeof(*ptr); ++i)
1618+
ASSERT_EQ(ptr[i], i);
16091619

16101620
hmm_buffer_free(buffer);
16111621
}

0 commit comments

Comments
 (0)