mm/gup: fix gup_pud_range() for dax
Subsystems (2)
PATCH 1/1 mm/gup: fix gup_pud_range() for dax
From: John Starks <[email protected]>
For dax pud, pud_huge() returns true on x86. So the function works as long as hugetlb is configured. However, dax doesn't depend on hugetlb. Commit 414fd080d125 ("mm/gup: fix gup_pmd_range() for dax") fixed devmap-backed huge PMDs, but missed devmap-backed huge PUDs. Fix this as well.
--- mm/gup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/gup.c +1 -1
@@ -2687,7 +2687,7 @@ static int gup_pud_range(p4d_t *p4dp, p4d_t p4d, unsigned long addr, unsigned lo next =pud_addr_end (addr, end);if (unlikely (!pud_present (pud)))return 0 ; -if (unlikely (pud_huge (pud))) { +if (unlikely (pud_huge (pud) ||pud_devmap (pud))) {if (!gup_huge_pud (pud, pudp, addr, next, flags, pages, nr))return 0 ;
Signature · 1 line
2.25.1
Quoted 21 lines · Saurabh Sengar
From: John Starks <[email protected]>
For dax pud,
pud_huge()returns true on x86. So the function works as long as hugetlb is configured. However, dax doesn't depend on hugetlb. Commit414fd080d125("mm/gup: fixgup_pmd_range()for dax") fixed devmap-backed huge PMDs, but missed devmap-backed huge PUDs. Fix this as well.Fixes 414fd080d125 ("mm/gup: fix gup_pmd_range() for dax")Signed-off-by John Starks <[email protected]>Signed-off-by Saurabh Sengar <[email protected]>--- mm/gup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/gup.c +0
-0
mm/gup.c static int gup_pud_range(p4d_t *p4dp, p4d_t p4d, unsigned long addr, unsigned lo · line 2690
Quoted 5 lines
mm/gup.c +1
-1@@ -2687,7 +2687,7 @@ static int gup_pud_range(p4d_t *p4dp, p4d_t p4d, unsigned long addr, unsigned lo next =pud_addr_end (addr, end);if (unlikely (!pud_present (pud)))return 0 ; -if (unlikely (pud_huge (pud))) { +if (unlikely (pud_huge (pud) ||pud_devmap (pud))) {
Perhaps s/pud_huge/pud_leaf/ ?
Quoted 6 lines
mm/gup.c +0
-1if (!gup_huge_pud (pud, pudp, addr, next, flags, pages, nr))return 0 ; --2.25.1
Quoted 18 lines · Yu Zhao
Quoted 16 lines · Saurabh Sengar
From: John Starks <[email protected]>
For dax pud,
pud_huge()returns true on x86. So the function works as long as hugetlb is configured. However, dax doesn't depend on hugetlb. Commit414fd080d125("mm/gup: fixgup_pmd_range()for dax") fixed devmap-backed huge PMDs, but missed devmap-backed huge PUDs. Fix this as well.Fixes 414fd080d125 ("mm/gup: fix gup_pmd_range() for dax")Signed-off-by John Starks <[email protected]>Signed-off-by Saurabh Sengar <[email protected]>--- mm/gup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines
mm/gup.c static int gup_pud_range(p4d_t *p4dp, p4d_t p4d, unsigned long addr, unsigned lo · line 2690
Quoted 10 lines
mm/gup.c +1
-1@@ -2687,7 +2687,7 @@ static int gup_pud_range(p4d_t *p4dp, p4d_t p4d, unsigned long addr, unsigned lo next =pud_addr_end (addr, end);if (unlikely (!pud_present (pud)))return 0 ; -if (unlikely (pud_huge (pud))) { +if (unlikely (pud_huge (pud) ||pud_devmap (pud))) {Perhaps s/pud_huge/pud_leaf/ ?
Looks good to me but I am not sure the wider impact of this, I will let maintainers comment on it. Meanwhile I will send a V2 with more description of panic observed.
Quoted 7 lines
Quoted 7 lines
mm/gup.c +0
-1if (!gup_huge_pud (pud, pudp, addr, next, flags, pages, nr))return 0 ; --2.25.1