/proc/PID/smaps: Add PMD migration entry parsing
Subsystems (3)
PATCH 1/1 /proc/PID/smaps: Add PMD migration entry parsing
From: Huang Ying <[email protected]>
Now, when read /proc/PID/smaps, the PMD migration entry in page table is simply ignored. To improve the accuracy of /proc/PID/smaps, its parsing and processing is added.
--- fs/proc/task_mmu.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
fs/proc/task_mmu.c +12 -4
@@ -548,8 +548,17 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr,bool locked = !!(vma->vm_flags &VM_LOCKED );struct page *page; -/* FOLL_DUMP will return -EFAULT on huge zero page */ - page =follow_trans_huge_pmd (vma, addr, pmd,FOLL_DUMP ); +if (pmd_present (*pmd)) { +/* FOLL_DUMP will return -EFAULT on huge zero page */ + page =follow_trans_huge_pmd (vma, addr, pmd,FOLL_DUMP ); + }else if (unlikely (is_swap_pmd (*pmd))) { +swp_entry_t entry =pmd_to_swp_entry (*pmd); + +VM_BUG_ON (!is_migration_entry (entry)); + page =migration_entry_to_page (entry); + }else { +return ; + }if (IS_ERR_OR_NULL (page))return ;if (PageAnon (page))
@@ -578,8 +587,7 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, ptl =pmd_trans_huge_lock (pmd, vma);if (ptl) { -if (pmd_present (*pmd)) -smaps_pmd_entry (pmd, addr, walk); +smaps_pmd_entry (pmd, addr, walk);spin_unlock (ptl); goto out; }
Signature · 1 line
2.25.0
Quoted 25 lines · Ying
From: Huang Ying <[email protected]>
Now, when read
/proc/PID/smaps, the PMD migration entry in page table is simply ignored. To improve the accuracy of/proc/PID/smaps, its parsing and processing is added.Signed-off-by "Huang, Ying" <[email protected]>Cc Andrea Arcangeli <[email protected]>Cc Kirill A. Shutemov <[email protected]>Cc Zi Yan <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Alexey Dobriyan <[email protected]>Cc Michal Hocko <[email protected]>Cc Konstantin Khlebnikov <[email protected]>Cc "Jérôme Glisse" <[email protected]>Cc Yang Shi <[email protected]>--- fs/proc/task_mmu.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)fs/proc/task_mmu.c +0
-0
fs/proc/task_mmu.c static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr, · line 549
Quoted 2 lines
fs/proc/task_mmu.c +0
-0@@ -548,8 +548,17 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr,bool locked = !!(vma->vm_flags &VM_LOCKED );struct page *page;
struct page *page = NULL;
fs/proc/task_mmu.c static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr, · line 558
Quoted 11 lines
fs/proc/task_mmu.c +8
-2-/* FOLL_DUMP will return -EFAULT on huge zero page */ - page =follow_trans_huge_pmd (vma, addr, pmd,FOLL_DUMP ); +if (pmd_present (*pmd)) { +/* FOLL_DUMP will return -EFAULT on huge zero page */ + page =follow_trans_huge_pmd (vma, addr, pmd,FOLL_DUMP ); + }else if (unlikely (is_swap_pmd (*pmd))) { +swp_entry_t entry =pmd_to_swp_entry (*pmd); + +VM_BUG_ON (!is_migration_entry (entry)); + page =migration_entry_to_page (entry);
if (is_migration_entry(entry))
page = migration_entry_to_page(entry);Seems safer and doesn't add much code.
Quoted 17 lines
fs/proc/task_mmu.c +4
-2+ }else { +return ; + }if (IS_ERR_OR_NULL (page))return ;if (PageAnon (page))@@ -578,8 +587,7 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, ptl =pmd_trans_huge_lock (pmd, vma);if (ptl) { -if (pmd_present (*pmd)) -smaps_pmd_entry (pmd, addr, walk); +smaps_pmd_entry (pmd, addr, walk);spin_unlock (ptl); goto out; }
Quoted 21 lines · Konstantin Khlebnikov
Quoted 20 lines · Ying
From: Huang Ying <[email protected]>
Now, when read
/proc/PID/smaps, the PMD migration entry in page table is simply ignored. To improve the accuracy of/proc/PID/smaps, its parsing and processing is added.Signed-off-by "Huang, Ying" <[email protected]>Cc Andrea Arcangeli <[email protected]>Cc Kirill A. Shutemov <[email protected]>Cc Zi Yan <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Alexey Dobriyan <[email protected]>Cc Michal Hocko <[email protected]>Cc Konstantin Khlebnikov <[email protected]>Cc "Jérôme Glisse" <[email protected]>Cc Yang Shi <[email protected]>--- fs/proc/task_mmu.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
Quoted 9 lines
fs/proc/task_mmu.c static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr, · line 549
Quoted 7 lines
fs/proc/task_mmu.c +0
-0@@ -548,8 +548,17 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr,bool locked = !!(vma->vm_flags &VM_LOCKED );struct page *page;struct page *page = NULL;
Looks good. Will do this in the next version.
Quoted 14 lines
fs/proc/task_mmu.c static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr, · line 558
Quoted 10 lines
fs/proc/task_mmu.c +8
-1-/* FOLL_DUMP will return -EFAULT on huge zero page */ - page =follow_trans_huge_pmd (vma, addr, pmd,FOLL_DUMP ); + if (pmd_present(*pmd)) { +/* FOLL_DUMP will return -EFAULT on huge zero page */ + page =follow_trans_huge_pmd (vma, addr, pmd,FOLL_DUMP ); + } else if (unlikely(is_swap_pmd(*pmd))) { +swp_entry_t entry =pmd_to_swp_entry (*pmd); + +VM_BUG_ON (!is_migration_entry (entry)); + page =migration_entry_to_page (entry);if (is_migration_entry(entry)) page = migration_entry_to_page(entry);
Quoted 1 line
Seems safer and doesn't add much code.
With this, we lose an opportunity to capture some bugs during debugging. Right?
Best Regards,
Huang, Ying
Quoted 16 lines
Quoted 16 lines
fs/proc/task_mmu.c +4
-2+ }else { +return ; + }if (IS_ERR_OR_NULL (page))return ;if (PageAnon (page))@@ -578,8 +587,7 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, ptl =pmd_trans_huge_lock (pmd, vma);if (ptl) { -if (pmd_present (*pmd)) -smaps_pmd_entry (pmd, addr, walk); +smaps_pmd_entry (pmd, addr, walk);spin_unlock (ptl); goto out; }
Quoted 49 lines · Ying
Quoted 21 lines · Konstantin Khlebnikov
Quoted 20 lines · Ying
From: Huang Ying <[email protected]>
Now, when read
/proc/PID/smaps, the PMD migration entry in page table is simply ignored. To improve the accuracy of/proc/PID/smaps, its parsing and processing is added.Signed-off-by "Huang, Ying" <[email protected]>Cc Andrea Arcangeli <[email protected]>Cc Kirill A. Shutemov <[email protected]>Cc Zi Yan <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Alexey Dobriyan <[email protected]>Cc Michal Hocko <[email protected]>Cc Konstantin Khlebnikov <[email protected]>Cc "Jérôme Glisse" <[email protected]>Cc Yang Shi <[email protected]>--- fs/proc/task_mmu.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)Quoted 9 lines
fs/proc/task_mmu.c static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr, · line 549
Quoted 7 lines
fs/proc/task_mmu.c +0
-0@@ -548,8 +548,17 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr,bool locked = !!(vma->vm_flags &VM_LOCKED );struct page *page;struct page *page = NULL;Looks good. Will do this in the next version.
Quoted 14 lines
fs/proc/task_mmu.c static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr, · line 558
Quoted 10 lines
fs/proc/task_mmu.c +8
-1-/* FOLL_DUMP will return -EFAULT on huge zero page */ - page =follow_trans_huge_pmd (vma, addr, pmd,FOLL_DUMP ); + if (pmd_present(*pmd)) { +/* FOLL_DUMP will return -EFAULT on huge zero page */ + page =follow_trans_huge_pmd (vma, addr, pmd,FOLL_DUMP ); + } else if (unlikely(is_swap_pmd(*pmd))) { +swp_entry_t entry =pmd_to_swp_entry (*pmd); + +VM_BUG_ON (!is_migration_entry (entry)); + page =migration_entry_to_page (entry);if (is_migration_entry(entry)) page = migration_entry_to_page(entry);
Quoted 4 lines
Quoted 1 line
Seems safer and doesn't add much code.
With this, we lose an opportunity to capture some bugs during debugging. Right?
You can keep VM_BUG_ON or VM_WARN_ON_ONCE
Off-by-page in statistics isn't a big deal and not a good reason to crash (even debug) kernel. But for normal build should use safe behaviour if this isn't hard.
Quoted 20 lines
Best Regards,
Huang, YingQuoted 16 lines
Quoted 16 lines
fs/proc/task_mmu.c +4
-2+ }else { +return ; + }if (IS_ERR_OR_NULL (page))return ;if (PageAnon (page))@@ -578,8 +587,7 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, ptl =pmd_trans_huge_lock (pmd, vma);if (ptl) { -if (pmd_present (*pmd)) -smaps_pmd_entry (pmd, addr, walk); +smaps_pmd_entry (pmd, addr, walk);spin_unlock (ptl); goto out; }
Quoted 52 lines · Konstantin Khlebnikov
Quoted 51 lines · Ying
Quoted 21 lines · Konstantin Khlebnikov
Quoted 20 lines · Ying
From: Huang Ying <[email protected]>
Now, when read
/proc/PID/smaps, the PMD migration entry in page table is simply ignored. To improve the accuracy of/proc/PID/smaps, its parsing and processing is added.Signed-off-by "Huang, Ying" <[email protected]>Cc Andrea Arcangeli <[email protected]>Cc Kirill A. Shutemov <[email protected]>Cc Zi Yan <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Alexey Dobriyan <[email protected]>Cc Michal Hocko <[email protected]>Cc Konstantin Khlebnikov <[email protected]>Cc "Jérôme Glisse" <[email protected]>Cc Yang Shi <[email protected]>--- fs/proc/task_mmu.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)Quoted 9 lines
fs/proc/task_mmu.c static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr, · line 549
Quoted 7 lines
fs/proc/task_mmu.c +0
-0@@ -548,8 +548,17 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr,bool locked = !!(vma->vm_flags &VM_LOCKED );struct page *page;struct page *page = NULL;Looks good. Will do this in the next version.
Quoted 15 lines
fs/proc/task_mmu.c static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr, · line 558
Quoted 10 lines
fs/proc/task_mmu.c +8
-1-/* FOLL_DUMP will return -EFAULT on huge zero page */ - page =follow_trans_huge_pmd (vma, addr, pmd,FOLL_DUMP ); + if (pmd_present(*pmd)) { +/* FOLL_DUMP will return -EFAULT on huge zero page */ + page =follow_trans_huge_pmd (vma, addr, pmd,FOLL_DUMP ); + } else if (unlikely(is_swap_pmd(*pmd))) { +swp_entry_t entry =pmd_to_swp_entry (*pmd); + +VM_BUG_ON (!is_migration_entry (entry)); + page =migration_entry_to_page (entry);if (is_migration_entry(entry)) page = migration_entry_to_page(entry);Seems safer and doesn't add much code.
Quoted 7 lines
Quoted 2 lines
With this, we lose an opportunity to capture some bugs during debugging. Right?
You can keep
VM_BUG_ONorVM_WARN_ON_ONCEOff-by-page in statistics isn't a big deal and not a good reason to crash (even debug) kernel. But for normal build should use safe behaviour if this isn't hard.
Sounds reasonable! Will revise the code. Thanks!
Best Regards,
Huang, Ying
Quoted 20 lines
Quoted 20 lines
Best Regards,
Huang, YingQuoted 16 lines
Quoted 16 lines
fs/proc/task_mmu.c +4
-2+ }else { +return ; + }if (IS_ERR_OR_NULL (page))return ;if (PageAnon (page))@@ -578,8 +587,7 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, ptl =pmd_trans_huge_lock (pmd, vma);if (ptl) { -if (pmd_present (*pmd)) -smaps_pmd_entry (pmd, addr, walk); +smaps_pmd_entry (pmd, addr, walk);spin_unlock (ptl); goto out; }
Quoted 26 lines · Ying
From: Huang Ying <[email protected]>
Now, when read
/proc/PID/smaps, the PMD migration entry in page table is simply ignored. To improve the accuracy of/proc/PID/smaps, its parsing and processing is added.Signed-off-by "Huang, Ying" <[email protected]>Cc Andrea Arcangeli <[email protected]>Cc Kirill A. Shutemov <[email protected]>Cc Zi Yan <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Alexey Dobriyan <[email protected]>Cc Michal Hocko <[email protected]>Cc Konstantin Khlebnikov <[email protected]>Cc "Jérôme Glisse" <[email protected]>Cc Yang Shi <[email protected]>--- fs/proc/task_mmu.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)fs/proc/task_mmu.c +0
-0
fs/proc/task_mmu.c static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr, · line 549
Quoted 2 lines
fs/proc/task_mmu.c +0
-0@@ -548,8 +548,17 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr,bool locked = !!(vma->vm_flags &VM_LOCKED );struct page *page;
Like Konstantin pointed out in another email, you could initialize page to NULL here. Plus you do not need the “else-return” below, if you do that.
fs/proc/task_mmu.c static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr, · line 554
Quoted 7 lines
fs/proc/task_mmu.c +4
-2-/* FOLL_DUMP will return -EFAULT on huge zero page */ - page =follow_trans_huge_pmd (vma, addr, pmd,FOLL_DUMP ); +if (pmd_present (*pmd)) { +/* FOLL_DUMP will return -EFAULT on huge zero page */ + page =follow_trans_huge_pmd (vma, addr, pmd,FOLL_DUMP ); + }else if (unlikely (is_swap_pmd (*pmd))) {
Should be:
} else if (unlikely(thp_migration_support() && is_swap_pmd(*pmd))) {Otherwise, when THP migration is disabled and the PMD is under splitting, VM_BUG_ON will be triggered.
Quoted 21 lines
fs/proc/task_mmu.c +8
-3+swp_entry_t entry =pmd_to_swp_entry (*pmd); + +VM_BUG_ON (!is_migration_entry (entry)); + page =migration_entry_to_page (entry); + }else { +return ; + }if (IS_ERR_OR_NULL (page))return ;if (PageAnon (page))@@ -578,8 +587,7 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, ptl =pmd_trans_huge_lock (pmd, vma);if (ptl) { -if (pmd_present (*pmd)) -smaps_pmd_entry (pmd, addr, walk); +smaps_pmd_entry (pmd, addr, walk);spin_unlock (ptl); goto out; } --
Quoted 1 line
2.25.0
Everything else looks good to me. Thanks.
With the fixes mentioned above, you can add
—
Best Regards,
Yan Zi
Quoted 22 lines · Zi Yan
Quoted 21 lines · Ying
From: Huang Ying <[email protected]>
Now, when read
/proc/PID/smaps, the PMD migration entry in page table is simply ignored. To improve the accuracy of/proc/PID/smaps, its parsing and processing is added.Signed-off-by "Huang, Ying" <[email protected]>Cc Andrea Arcangeli <[email protected]>Cc Kirill A. Shutemov <[email protected]>Cc Zi Yan <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Alexey Dobriyan <[email protected]>Cc Michal Hocko <[email protected]>Cc Konstantin Khlebnikov <[email protected]>Cc "Jérôme Glisse" <[email protected]>Cc Yang Shi <[email protected]>--- fs/proc/task_mmu.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
Quoted 10 lines
fs/proc/task_mmu.c static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr, · line 549
Quoted 7 lines
fs/proc/task_mmu.c +0
-0@@ -548,8 +548,17 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr,bool locked = !!(vma->vm_flags &VM_LOCKED );struct page *page;Like Konstantin pointed out in another email, you could initialize page to NULL here. Plus you do not need the “else-return” below, if you do that.
Yes. That looks better. Will change this in the next version.
Quoted 8 lines
fs/proc/task_mmu.c static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr, · line 554
Quoted 7 lines
fs/proc/task_mmu.c +4
-2-/* FOLL_DUMP will return -EFAULT on huge zero page */ - page =follow_trans_huge_pmd (vma, addr, pmd,FOLL_DUMP ); +if (pmd_present (*pmd)) { +/* FOLL_DUMP will return -EFAULT on huge zero page */ + page =follow_trans_huge_pmd (vma, addr, pmd,FOLL_DUMP ); + }else if (unlikely (is_swap_pmd (*pmd))) {
Quoted 5 lines
Should be:
} else if (unlikely(thp_migration_support() && is_swap_pmd(*pmd))) {Otherwise, when THP migration is disabled and the PMD is under splitting,
VM_BUG_ONwill be triggered.
We hold the PMD page table lock when call smaps_pmd_entry(). How does PMD splitting trigger VM_BUG_ON()?
Quoted 25 lines
Quoted 21 lines
fs/proc/task_mmu.c +8
-3+swp_entry_t entry =pmd_to_swp_entry (*pmd); + +VM_BUG_ON (!is_migration_entry (entry)); + page =migration_entry_to_page (entry); + }else { +return ; + }if (IS_ERR_OR_NULL (page))return ;if (PageAnon (page))@@ -578,8 +587,7 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, ptl =pmd_trans_huge_lock (pmd, vma);if (ptl) { -if (pmd_present (*pmd)) -smaps_pmd_entry (pmd, addr, walk); +smaps_pmd_entry (pmd, addr, walk);spin_unlock (ptl); goto out; } --Quoted 1 line
2.25.0
Everything else looks good to me. Thanks.
Quoted 2 lines
With the fixes mentioned above, you can add
Reviewed-by Zi Yan <[email protected]>
Thanks!
Best Regards,
Huang, Ying
Quoted 38 lines · Ying
External email: Use caution opening links or attachments
Quoted 22 lines · Zi Yan
Quoted 21 lines · Ying
From: Huang Ying <[email protected]>
Now, when read
/proc/PID/smaps, the PMD migration entry in page table is simply ignored. To improve the accuracy of/proc/PID/smaps, its parsing and processing is added.Signed-off-by "Huang, Ying" <[email protected]>Cc Andrea Arcangeli <[email protected]>Cc Kirill A. Shutemov <[email protected]>Cc Zi Yan <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Alexey Dobriyan <[email protected]>Cc Michal Hocko <[email protected]>Cc Konstantin Khlebnikov <[email protected]>Cc "Jérôme Glisse" <[email protected]>Cc Yang Shi <[email protected]>--- fs/proc/task_mmu.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)Quoted 10 lines
fs/proc/task_mmu.c static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr, · line 549
Quoted 7 lines
fs/proc/task_mmu.c +0
-0@@ -548,8 +548,17 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr,bool locked = !!(vma->vm_flags &VM_LOCKED );struct page *page;Like Konstantin pointed out in another email, you could initialize page to NULL here. Plus you do not need the “else-return” below, if you do that.
Quoted 1 line
Yes. That looks better. Will change this in the next version.
Thanks.
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
fs/proc/task_mmu.c +4
-2-/* FOLL_DUMP will return -EFAULT on huge zero page */ - page =follow_trans_huge_pmd (vma, addr, pmd,FOLL_DUMP ); +if (pmd_present (*pmd)) { +/* FOLL_DUMP will return -EFAULT on huge zero page */ + page =follow_trans_huge_pmd (vma, addr, pmd,FOLL_DUMP ); + }else if (unlikely (is_swap_pmd (*pmd))) {
Quoted 8 lines
Quoted 5 lines
Should be:
} else if (unlikely(thp_migration_support() && is_swap_pmd(*pmd))) {Otherwise, when THP migration is disabled and the PMD is under splitting,
VM_BUG_ONwill be triggered.We hold the PMD page table lock when call
smaps_pmd_entry(). How does PMD splitting triggerVM_BUG_ON()?
Oh, I missed that. Your original code is right. Thank you for the explanation.
—
Best Regards,
Yan Zi
Quoted 10 lines · Zi Yan
fs/proc/task_mmu.c static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr, · line 554
Quoted 8 lines · Ying
From: Huang Ying <[email protected]>
fs/proc/task_mmu.c +4
-2-/* FOLL_DUMP will return -EFAULT on huge zero page */ - page =follow_trans_huge_pmd (vma, addr, pmd,FOLL_DUMP ); +if (pmd_present (*pmd)) { +/* FOLL_DUMP will return -EFAULT on huge zero page */ + page =follow_trans_huge_pmd (vma, addr, pmd,FOLL_DUMP ); + }else if (unlikely (is_swap_pmd (*pmd))) {
Quoted 2 lines
Should be:
} else if (unlikely(thp_migration_support() && is_swap_pmd(*pmd))) {
Thought this again. This can reduce the code size if thp_migration_support() isn't enabled. I will do this in the next version.
Best Regards,
Huang, Ying
Andrew Morton
maintainerQuoted 5 lines · Ying
From: Huang Ying <[email protected]>
Now, when read
/proc/PID/smaps, the PMD migration entry in page table is simply ignored. To improve the accuracy of/proc/PID/smaps, its parsing and processing is added.
It would be helpful to show the before-and-after output in the changelog.
Quoted 5 lines
fs/proc/task_mmu.c +0
-0@@ -548,8 +548,17 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr,bool locked = !!(vma->vm_flags &VM_LOCKED );struct page *page;
fs/proc/task_mmu.c static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr, · line 557
Quoted 10 lines
fs/proc/task_mmu.c +7
-2-/* FOLL_DUMP will return -EFAULT on huge zero page */ - page =follow_trans_huge_pmd (vma, addr, pmd,FOLL_DUMP ); +if (pmd_present (*pmd)) { +/* FOLL_DUMP will return -EFAULT on huge zero page */ + page =follow_trans_huge_pmd (vma, addr, pmd,FOLL_DUMP ); + }else if (unlikely (is_swap_pmd (*pmd))) { +swp_entry_t entry =pmd_to_swp_entry (*pmd); + +VM_BUG_ON (!is_migration_entry (entry));
I don't think this justifies nuking the kernel. A WARN()-and-recover would be better.
Quoted 17 lines
fs/proc/task_mmu.c +5
-2+ page =migration_entry_to_page (entry); + }else { +return ; + }if (IS_ERR_OR_NULL (page))return ;if (PageAnon (page))@@ -578,8 +587,7 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, ptl =pmd_trans_huge_lock (pmd, vma);if (ptl) { -if (pmd_present (*pmd)) -smaps_pmd_entry (pmd, addr, walk); +smaps_pmd_entry (pmd, addr, walk);spin_unlock (ptl); goto out; }
Quoted 9 lines · Andrew Morton
Quoted 5 lines · Ying
From: Huang Ying <[email protected]>
Now, when read
/proc/PID/smaps, the PMD migration entry in page table is simply ignored. To improve the accuracy of/proc/PID/smaps, its parsing and processing is added.It would be helpful to show the before-and-after output in the changelog.
OK.
Quoted 6 lines
Quoted 6 lines
fs/proc/task_mmu.c +0
-0@@ -548,8 +548,17 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr,bool locked = !!(vma->vm_flags &VM_LOCKED );struct page *page;
Quoted 12 lines
fs/proc/task_mmu.c static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr, · line 557
Quoted 9 lines
fs/proc/task_mmu.c +7
-2-/* FOLL_DUMP will return -EFAULT on huge zero page */ - page =follow_trans_huge_pmd (vma, addr, pmd,FOLL_DUMP ); +if (pmd_present (*pmd)) { +/* FOLL_DUMP will return -EFAULT on huge zero page */ + page =follow_trans_huge_pmd (vma, addr, pmd,FOLL_DUMP ); + }else if (unlikely (is_swap_pmd (*pmd))) { +swp_entry_t entry =pmd_to_swp_entry (*pmd); + +VM_BUG_ON (!is_migration_entry (entry));I don't think this justifies nuking the kernel. A WARN()-and-recover would be better.
Yes. Will change this in the next version.
Best Regards,
Huang, Ying
Quoted 17 lines
Quoted 17 lines
fs/proc/task_mmu.c +5
-2+ page =migration_entry_to_page (entry); + }else { +return ; + }if (IS_ERR_OR_NULL (page))return ;if (PageAnon (page))@@ -578,8 +587,7 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, ptl =pmd_trans_huge_lock (pmd, vma);if (ptl) { -if (pmd_present (*pmd)) -smaps_pmd_entry (pmd, addr, walk); +smaps_pmd_entry (pmd, addr, walk);spin_unlock (ptl); goto out; }
Quoted 9 lines · Andrew Morton
Quoted 5 lines · Ying
From: Huang Ying <[email protected]>
Now, when read
/proc/PID/smaps, the PMD migration entry in page table is simply ignored. To improve the accuracy of/proc/PID/smaps, its parsing and processing is added.It would be helpful to show the before-and-after output in the changelog.
Migration entries are ephemeral. Is this observable in practice? I suspect this is just primarily motivated by reading the code more than hitting the actual problem.
Signature · 2 lines
Michal Hocko SUSE Labs