This is potentially useful debugging information and matches the existing
page offset provided.

Use the raw __linear_virt_page_index() function so as to always output this
value regardless of whether the mapping is file-backed or not.

Signed-off-by: Lorenzo Stoakes (ARM) <[email protected]>
---
 mm/memory.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index d5e87624f692..56b244552f13 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -631,13 +631,14 @@ static void print_bad_page_map(struct vm_area_struct *vma,
 {
        struct address_space *mapping;
        char entry_str[PTVAL_STR_MAX];
-       pgoff_t index;
+       pgoff_t index, virt_index;
 
        if (is_bad_page_map_ratelimited())
                return;
 
        mapping = vma->vm_file ? vma->vm_file->f_mapping : NULL;
        index = linear_page_index(vma, addr);
+       virt_index = __linear_virt_page_index(vma, addr);
 
        ptval_bytes_to_hex_str(entry_str, sizeof(entry_str), entry, entry_size);
        pr_alert("BUG: Bad page map in process %s  %s:%s", current->comm,
@@ -645,8 +646,9 @@ static void print_bad_page_map(struct vm_area_struct *vma,
        __print_bad_page_map_pgtable(vma->vm_mm, addr);
        if (page)
                dump_page(page, "bad page map");
-       pr_alert("addr:%px vm_flags:%08lx anon_vma:%px mapping:%px index:%lx\n",
-                (void *)addr, vma->vm_flags, vma->anon_vma, mapping, index);
+       pr_alert("addr:%px vm_flags:%08lx anon_vma:%px mapping:%px index:%lx 
virt_index:%lx\n",
+                (void *)addr, vma->vm_flags, vma->anon_vma, mapping, index,
+                virt_index);
        pr_alert("file:%pD fault:%ps mmap:%ps mmap_prepare: %ps 
read_folio:%ps\n",
                 vma->vm_file,
                 vma->vm_ops ? vma->vm_ops->fault : NULL,

-- 
2.55.0


Reply via email to