• Christophe Leroy's avatar
    powerpc/mm: Properly coalesce pages in ptdump · 6ca6512c
    Christophe Leroy authored
    Commit aaa22952 ("powerpc/mm: Add physical address to Linux page
    table dump") changed range coalescing to only combine ranges that are
    both virtually and physically contiguous, in order to avoid erroneous
    combination of unrelated mappings in IOREMAP space.
    
    But in the VMALLOC space, mappings almost never have contiguous
    physical pages, so the commit mentionned above leads to dumping one
    line per page for vmalloc mappings.
    
    Taking into account the vmalloc always leave a gap between two areas,
    we never have two mappings dumped as a single combination even if they
    have the exact same flags. The only space that may have encountered
    such an issue was the early IOREMAP which is not using vmalloc engine.
    But previous commits added gaps between early IO mappings, so it is
    not an issue anymore.
    
    That commit created some difficulties with KASAN mappings, see
    commit cabe8138 ("powerpc: dump as a single line areas mapping a
    single physical page.") and with huge page, see
    commit b00ff6d8 ("powerpc/ptdump: Properly handle non standard
    page size").
    
    So, almost revert commit aaa22952 to properly coalesce pages
    mapped with the same flags as before, only keep the display of the
    first physical address of the range, as it can be usefull especially
    for IO mappings.
    
    It brings back powerpc at the same level as other architectures and
    simplifies the conversion to GENERIC PTDUMP.
    
    With the patch:
    
    ---[ kasan shadow mem start ]---
    0xf8000000-0xf8ffffff  0x07000000        16M   huge        rw       present           dirty  accessed
    0xf9000000-0xf91fffff  0x01434000         2M               r        present                  accessed
    0xf9200000-0xf95affff  0x02104000      3776K               rw       present           dirty  accessed
    0xfef5c000-0xfeffffff  0x01434000       656K               r        present                  accessed
    ---[ kasan shadow mem end ]---
    
    Before:
    
    ---[ kasan shadow mem start ]---
    0xf8000000-0xf8ffffff  0x07000000        16M   huge        rw       present           dirty  accessed
    0xf9000000-0xf91fffff  0x01434000        16K               r        present                  accessed
    0xf9200000-0xf9203fff  0x02104000        16K               rw       present           dirty  accessed
    0xf9204000-0xf9207fff  0x0213c000        16K               rw       present           dirty  accessed
    0xf9208000-0xf920bfff  0x02174000        16K               rw       present           dirty  accessed
    0xf920c000-0xf920ffff  0x02188000        16K               rw       present           dirty  accessed
    0xf9210000-0xf9213fff  0x021dc000        16K               rw       present           dirty  accessed
    0xf9214000-0xf9217fff  0x02220000        16K               rw       present           dirty  accessed
    0xf9218000-0xf921bfff  0x023c0000        16K               rw       present           dirty  accessed
    0xf921c000-0xf921ffff  0x023d4000        16K               rw       present           dirty  accessed
    0xf9220000-0xf9227fff  0x023ec000        32K               rw       present           dirty  accessed
    ...
    0xf93b8000-0xf93e3fff  0x02614000       176K               rw       present           dirty  accessed
    0xf93e4000-0xf94c3fff  0x027c0000       896K               rw       present           dirty  accessed
    0xf94c4000-0xf94c7fff  0x0236c000        16K               rw       present           dirty  accessed
    0xf94c8000-0xf94cbfff  0x041f0000        16K               rw       present           dirty  accessed
    0xf94cc000-0xf94cffff  0x029c0000        16K               rw       present           dirty  accessed
    0xf94d0000-0xf94d3fff  0x041ec000        16K               rw       present           dirty  accessed
    0xf94d4000-0xf94d7fff  0x0407c000        16K               rw       present           dirty  accessed
    0xf94d8000-0xf94f7fff  0x041c0000       128K               rw       present           dirty  accessed
    ...
    0xf95ac000-0xf95affff  0x042b0000        16K               rw       present           dirty  accessed
    0xfef5c000-0xfeffffff  0x01434000        16K               r        present                  accessed
    ---[ kasan shadow mem end ]---
    Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/c56ce1f5c3c75adc9811b1a5f9c410fa74183a8d.1618828806.git.christophe.leroy@csgroup.eu
    6ca6512c
ptdump.c 11.5 KB