x86/mm/cpa-test: Ensure pfn isn't already in use
PATCH 1/1 x86/mm/cpa-test: Ensure pfn isn't already in use
Ensure pfn isn't already in use before assigning to addr[i]. Retry if in use. The subsequent pfns were checked against the bitmap, but not the initial selection.
This prevents some false positives on a machine with a small amount of RAM where pfn collisions are more likely to be seen.
A Xen HVM first showed:
[ 3640.227939] CPA ffff88800869c000: bad pte 800000000869c163 [ 3640.227982] CPA ffff88800104e000: bad pte 800000000104e161
Testing this patch with a Xen PV guest with one 192MB of RAM showed varying numbers of addresses like:
[ 2768.082971] CPA test 5 pfn 930d in use
Signed-off-by Jason Andryuk <[email protected]>
---
This could infinite loop on a machine with a small amount of RAM - is that worth handling? Just skip an in-use pfn instead?
--- arch/x86/mm/pat/cpa-test.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
arch/x86/mm/pat/cpa-test.c +8 -1
@@ -136,7 +136,14 @@ static int pageattr_test(void) failed +=print_split (&sa);for (i =0 ; i <NTEST ; i++) { -unsigned long pfn =get_random_u32_below (max_pfn_mapped); +unsigned long pfn; + + retry: + pfn =get_random_u32_below (max_pfn_mapped); +if (test_bit (pfn, bm)) { +pr_debug ("CPA test %d pfn %lx in use\n" , i, pfn); + goto retry; + } addr[i] = (unsigned long )__va (pfn <<PAGE_SHIFT ); len[i] =get_random_u32_below (NPAGES );
Signature · 1 line
2.43.0