mm: fix up softleaf vs thp device-private in remove_migration_pmd()
Subsystems (2)
PATCH 1/1 mm: fix up softleaf vs thp device-private in remove_migration_pmd()
A fix-up in the thp device-private patch
mm/rmap: extend rmap and migration support device-private entries introduces conflicts with the softleaf series, this is a fix up patch to resolve the issue
--- mm/huge_memory.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
mm/huge_memory.c +1 -3
@@ -4760,7 +4760,7 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new)folio_get (folio); pmde =folio_mk_pmd (folio,READ_ONCE (vma->vm_page_prot)); -if (is_writable_migration_entry (entry)) +if (softleaf_is_migration_write (entry)) pmde =pmd_mkwrite (pmde, vma);if (folio_is_device_private (folio)) {
@@ -4777,8 +4777,6 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new)if (pmd_swp_soft_dirty (*pvmw->pmd)) pmde =pmd_mksoft_dirty (pmde); -if (softleaf_is_migration_write (entry)) - pmde =pmd_mkwrite (pmde, vma);if (pmd_swp_uffd_wp (*pvmw->pmd)) pmde =pmd_mkuffd_wp (pmde);if (!softleaf_is_migration_young (entry))
Signature · 1 line
2.51.1
PATCH 1/1 mm/huge_memory: fix override of entry in remove_migration_pmd
Recent changes exposed a BUG in remove_migration_pmd() where the migration entry was being overridden when the folio is device private.
Use scope local entry for creating the device private pmde. Make the pmde writable if the migration entry is writable by moving the check is_migration_write() prior to creating the device private entry.
--- mm/huge_memory.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
mm/huge_memory.c +5 -2
@@ -4698,7 +4698,12 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new)folio_get (folio); pmde =folio_mk_pmd (folio,READ_ONCE (vma->vm_page_prot)); +if (is_writable_migration_entry (entry)) + pmde =pmd_mkwrite (pmde, vma); +if (folio_is_device_private (folio)) { +swp_entry_t entry; +if (pmd_write (pmde)) entry =make_writable_device_private_entry (page_to_pfn (new));
@@ -4710,8 +4715,6 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new)if (pmd_swp_soft_dirty (*pvmw->pmd)) pmde =pmd_mksoft_dirty (pmde); -if (is_writable_migration_entry (entry)) - pmde =pmd_mkwrite (pmde, vma);if (pmd_swp_uffd_wp (*pvmw->pmd)) pmde =pmd_mkuffd_wp (pmde);if (!is_migration_entry_young (entry))
Signature · 1 line
2.51.1
Re: [PATCH] mm/huge_memory: fix override of entry in remove_migration_pmd
Quoted 33 lines · Balbir Singh
Recent changes exposed a BUG in
remove_migration_pmd()where the migration entry was being overridden when the folio is device private.Use scope local entry for creating the device private pmde. Make the pmde writable if the migration entry is writable by moving the check
is_migration_write()prior to creating the device private entry.Cc Andrew Morton <[email protected]>Cc David Hildenbrand <[email protected]>Cc Zi Yan <[email protected]>Cc Joshua Hahn <[email protected]>Cc Rakie Kim <[email protected]>Cc Byungchul Park <[email protected]>Cc Gregory Price <[email protected]>Cc Ying Huang <[email protected]>Cc Alistair Popple <[email protected]>Cc Oscar Salvador <[email protected]>Cc Lorenzo Stoakes <[email protected]>Cc Baolin Wang <[email protected]>Cc "Liam R. Howlett" <[email protected]>Cc Nico Pache <[email protected]>Cc Ryan Roberts <[email protected]>Cc Dev Jain <[email protected]>Cc Barry Song <[email protected]>Cc Lyude Paul <[email protected]>Cc Danilo Krummrich <[email protected]>Cc David Airlie <[email protected]>Cc Simona Vetter <[email protected]>Cc Ralph Campbell <[email protected]>Cc Mika Penttilä <[email protected]>Cc Matthew Brost <[email protected]>Cc Francois Dugast <[email protected]>
Quoted 6 lines
Signed-off-by Balbir Singh <[email protected]>Reviewed-by Lorenzo Stoakes <[email protected]>--- mm/huge_memory.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Hi, Andrew
This patch fixes a bug in mm/rmap: extend rmap and migration support device-private entries in the thp device-private series.
Thanks,
Balbir
David Hildenbrand (Red Hat)
maintainerRe: [PATCH] mm/huge_memory: fix override of entry in remove_migration_pmd
Quoted 41 lines · Balbir Singh
Quoted 33 lines · Balbir Singh
Recent changes exposed a BUG in
remove_migration_pmd()where the migration entry was being overridden when the folio is device private.Use scope local entry for creating the device private pmde. Make the pmde writable if the migration entry is writable by moving the check
is_migration_write()prior to creating the device private entry.Cc Andrew Morton <[email protected]>Cc David Hildenbrand <[email protected]>Cc Zi Yan <[email protected]>Cc Joshua Hahn <[email protected]>Cc Rakie Kim <[email protected]>Cc Byungchul Park <[email protected]>Cc Gregory Price <[email protected]>Cc Ying Huang <[email protected]>Cc Alistair Popple <[email protected]>Cc Oscar Salvador <[email protected]>Cc Lorenzo Stoakes <[email protected]>Cc Baolin Wang <[email protected]>Cc "Liam R. Howlett" <[email protected]>Cc Nico Pache <[email protected]>Cc Ryan Roberts <[email protected]>Cc Dev Jain <[email protected]>Cc Barry Song <[email protected]>Cc Lyude Paul <[email protected]>Cc Danilo Krummrich <[email protected]>Cc David Airlie <[email protected]>Cc Simona Vetter <[email protected]>Cc Ralph Campbell <[email protected]>Cc Mika Penttilä <[email protected]>Cc Matthew Brost <[email protected]>Cc Francois Dugast <[email protected]>Quoted 6 lines
Signed-off-by Balbir Singh <[email protected]>Reviewed-by Lorenzo Stoakes <[email protected]>--- mm/huge_memory.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Quoted 4 lines
Hi, Andrew
This patch fixes a bug in mm/rmap: extend rmap and migration support device-private entries in the thp device-private series.
When you resend, best to add under the "--" something like
"This fixup should be squashed into the patch "$NAMEOFCOMMIT" in mm/mm-unstable"
It is also helpful to call the patch then
"fixup: $NAMEOFCOMMIT"
So it's immediately clear that this is something to be squashed.
Signature · 3 lines
Cheers David
David Hildenbrand (Red Hat)
maintainerRe: [PATCH] mm/huge_memory: fix override of entry in remove_migration_pmd
In reply to Balbir SinghQuoted 57 lines · Balbir Singh
Recent changes exposed a BUG in
remove_migration_pmd()where the migration entry was being overridden when the folio is device private.Use scope local entry for creating the device private pmde. Make the pmde writable if the migration entry is writable by moving the check
is_migration_write()prior to creating the device private entry.Cc Andrew Morton <[email protected]>Cc David Hildenbrand <[email protected]>Cc Zi Yan <[email protected]>Cc Joshua Hahn <[email protected]>Cc Rakie Kim <[email protected]>Cc Byungchul Park <[email protected]>Cc Gregory Price <[email protected]>Cc Ying Huang <[email protected]>Cc Alistair Popple <[email protected]>Cc Oscar Salvador <[email protected]>Cc Lorenzo Stoakes <[email protected]>Cc Baolin Wang <[email protected]>Cc "Liam R. Howlett" <[email protected]>Cc Nico Pache <[email protected]>Cc Ryan Roberts <[email protected]>Cc Dev Jain <[email protected]>Cc Barry Song <[email protected]>Cc Lyude Paul <[email protected]>Cc Danilo Krummrich <[email protected]>Cc David Airlie <[email protected]>Cc Simona Vetter <[email protected]>Cc Ralph Campbell <[email protected]>Cc Mika Penttilä <[email protected]>Cc Matthew Brost <[email protected]>Cc Francois Dugast <[email protected]>Signed-off-by Balbir Singh <[email protected]>Reviewed-by Lorenzo Stoakes <[email protected]>--- mm/huge_memory.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)mm/huge_memory.c +5
-0@@ -4698,7 +4698,12 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new)folio_get (folio); pmde =folio_mk_pmd (folio,READ_ONCE (vma->vm_page_prot)); +if (is_writable_migration_entry (entry)) + pmde =pmd_mkwrite (pmde, vma); +if (folio_is_device_private (folio)) { +swp_entry_t entry; +if (pmd_write (pmde)) entry =make_writable_device_private_entry (page_to_pfn (new));
mm/huge_memory.c void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) · line 4720
Quoted 8 lines
mm/huge_memory.c +0
-2@@ -4710,8 +4715,6 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new)if (pmd_swp_soft_dirty (*pvmw->pmd)) pmde =pmd_mksoft_dirty (pmde); -if (is_writable_migration_entry (entry)) - pmde =pmd_mkwrite (pmde, vma);if (pmd_swp_uffd_wp (*pvmw->pmd)) pmde =pmd_mkuffd_wp (pmde);if (!is_migration_entry_young (entry))
There are more problems here: you cannot call pmd_mksoft_dirty() etc on something that is not a present pmd! We have pmd_swp_mksoft_dirty() and friends for that.
So you'll have to completely split both paths.
Signature · 3 lines
Cheers David
Re: [PATCH] mm/huge_memory: fix override of entry in remove_migration_pmd
Quoted 67 lines · David Hildenbrand (Red Hat)
Quoted 56 lines · Balbir Singh
Recent changes exposed a BUG in
remove_migration_pmd()where the migration entry was being overridden when the folio is device private.Use scope local entry for creating the device private pmde. Make the pmde writable if the migration entry is writable by moving the check
is_migration_write()prior to creating the device private entry.Cc Andrew Morton <[email protected]>Cc David Hildenbrand <[email protected]>Cc Zi Yan <[email protected]>Cc Joshua Hahn <[email protected]>Cc Rakie Kim <[email protected]>Cc Byungchul Park <[email protected]>Cc Gregory Price <[email protected]>Cc Ying Huang <[email protected]>Cc Alistair Popple <[email protected]>Cc Oscar Salvador <[email protected]>Cc Lorenzo Stoakes <[email protected]>Cc Baolin Wang <[email protected]>Cc "Liam R. Howlett" <[email protected]>Cc Nico Pache <[email protected]>Cc Ryan Roberts <[email protected]>Cc Dev Jain <[email protected]>Cc Barry Song <[email protected]>Cc Lyude Paul <[email protected]>Cc Danilo Krummrich <[email protected]>Cc David Airlie <[email protected]>Cc Simona Vetter <[email protected]>Cc Ralph Campbell <[email protected]>Cc Mika Penttilä <[email protected]>Cc Matthew Brost <[email protected]>Cc Francois Dugast <[email protected]>Signed-off-by Balbir Singh <[email protected]>Reviewed-by Lorenzo Stoakes <[email protected]>---
mm/huge_memory.c| 7 +++++--1 file changed, 5 insertions(+), 2 deletions(-)mm/huge_memory.c +4
-0@@ -4698,7 +4698,12 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) folio_get(folio); pmde = folio_mk_pmd(folio, READ_ONCE(vma->vm_page_prot)); + if (is_writable_migration_entry(entry)) + pmde = pmd_mkwrite(pmde, vma); + if (folio_is_device_private(folio)) { + swp_entry_t entry; + if (pmd_write(pmde))entry =
make_writable_device_private_entry( page_to_pfn(new));mm/huge_memory.c void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) · line 4719
Quoted 7 lines
mm/huge_memory.c +0
-2@@ -4710,8 +4715,6 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) if (pmd_swp_soft_dirty(*pvmw->pmd)) pmde = pmd_mksoft_dirty(pmde); - if (is_writable_migration_entry(entry)) - pmde = pmd_mkwrite(pmde, vma); if (pmd_swp_uffd_wp(*pvmw->pmd)) pmde = pmd_mkuffd_wp(pmde); if (!is_migration_entry_young(entry))There are more problems here: you cannot call
pmd_mksoft_dirty()etc on something that is not a present pmd! We havepmd_swp_mksoft_dirty()and friends for that.
Quoted 2 lines
So you'll have to completely split both paths.
I'll follow the pattern of remove_migration_pte(), where all the device private handling and that of pte_swp_soft_dirty and pte_swp_mkuffd_wp is done at the every end after migration processing.
Thanks for the review! That might also take up any softleaf fix-up's required, I'll check
Balbir
Balbir
Quoted 50 lines · Balbir Singh
A fix-up in the thp device-private patch
mm/rmap: extend rmap and migration support device-private entries introduces conflicts with the softleaf series, this is a fix up patch to resolve the issueCc Andrew Morton <[email protected]>Cc David Hildenbrand <[email protected]>Cc Zi Yan <[email protected]>Cc Joshua Hahn <[email protected]>Cc Rakie Kim <[email protected]>Cc Byungchul Park <[email protected]>Cc Gregory Price <[email protected]>Cc Ying Huang <[email protected]>Cc Alistair Popple <[email protected]>Cc Oscar Salvador <[email protected]>Cc Lorenzo Stoakes <[email protected]>Cc Baolin Wang <[email protected]>Cc "Liam R. Howlett" <[email protected]>Cc Nico Pache <[email protected]>Cc Ryan Roberts <[email protected]>Cc Dev Jain <[email protected]>Cc Barry Song <[email protected]>Cc Lyude Paul <[email protected]>Cc Danilo Krummrich <[email protected]>Cc David Airlie <[email protected]>Cc Simona Vetter <[email protected]>Cc Ralph Campbell <[email protected]>Cc Mika Penttilä <[email protected]>Cc Matthew Brost <[email protected]>Cc Francois Dugast <[email protected]>Signed-off-by Balbir Singh <[email protected]>--- mm/huge_memory.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)mm/huge_memory.c +1
-1@@ -4760,7 +4760,7 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new)folio_get (folio); pmde =folio_mk_pmd (folio,READ_ONCE (vma->vm_page_prot)); -if (is_writable_migration_entry (entry)) +if (softleaf_is_migration_write (entry)) pmde =pmd_mkwrite (pmde, vma);if (folio_is_device_private (folio)) {
mm/huge_memory.c void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) · line 4782
Quoted 8 lines
mm/huge_memory.c +0
-2@@ -4777,8 +4777,6 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new)if (pmd_swp_soft_dirty (*pvmw->pmd)) pmde =pmd_mksoft_dirty (pmde); -if (softleaf_is_migration_write (entry)) - pmde =pmd_mkwrite (pmde, vma);if (pmd_swp_uffd_wp (*pvmw->pmd)) pmde =pmd_mkuffd_wp (pmde);if (!softleaf_is_migration_young (entry))
Hi, Andrew
This is the fixup for the rebase issue that might occur after applying
the previous patch to fixup mm/rmap: extend rmap and migration support device-private entries. I've not done fixs up rebases as a separate patch, but I resolved the conflict in favour of the existing patch and applied this on top of the series.
Balbir