Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/ptdump: Display size of BATs

Display the size of areas mapped with BATs.

For that, the size display for pages is refactorised.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/acf764eee231f0358e66ca9e819f052804055acc.1589866984.git.christophe.leroy@csgroup.eu

authored by

Christophe Leroy and committed by
Michael Ellerman
6b30830e 3af4786e

+21 -9
+4
arch/powerpc/mm/ptdump/bats.c
··· 10 10 #include <asm/pgtable.h> 11 11 #include <asm/cpu_has_feature.h> 12 12 13 + #include "ptdump.h" 14 + 13 15 static char *pp_601(int k, int pp) 14 16 { 15 17 if (pp == 0) ··· 44 42 #else 45 43 seq_printf(m, "0x%08x ", pbn); 46 44 #endif 45 + pt_dump_size(m, size); 47 46 48 47 seq_printf(m, "Kernel %s User %s", pp_601(k & 2, pp), pp_601(k & 1, pp)); 49 48 ··· 91 88 #else 92 89 seq_printf(m, "0x%08x ", brpn); 93 90 #endif 91 + pt_dump_size(m, size); 94 92 95 93 if (k == 1) 96 94 seq_puts(m, "User ");
+14 -9
arch/powerpc/mm/ptdump/ptdump.c
··· 112 112 seq_putc(m, c); \ 113 113 }) 114 114 115 + void pt_dump_size(struct seq_file *m, unsigned long size) 116 + { 117 + static const char units[] = "KMGTPE"; 118 + const char *unit = units; 119 + 120 + /* Work out what appropriate unit to use */ 121 + while (!(size & 1023) && unit[1]) { 122 + size >>= 10; 123 + unit++; 124 + } 125 + pt_dump_seq_printf(m, "%9lu%c ", size, *unit); 126 + } 127 + 115 128 static void dump_flag_info(struct pg_state *st, const struct flag_info 116 129 *flag, u64 pte, int num) 117 130 { ··· 159 146 160 147 static void dump_addr(struct pg_state *st, unsigned long addr) 161 148 { 162 - static const char units[] = "KMGTPE"; 163 - const char *unit = units; 164 149 unsigned long delta; 165 150 166 151 #ifdef CONFIG_PPC64 ··· 175 164 pt_dump_seq_printf(st->seq, " " REG " ", st->start_pa); 176 165 delta = (addr - st->start_address) >> 10; 177 166 } 178 - /* Work out what appropriate unit to use */ 179 - while (!(delta & 1023) && unit[1]) { 180 - delta >>= 10; 181 - unit++; 182 - } 183 - pt_dump_seq_printf(st->seq, "%9lu%c", delta, *unit); 184 - 167 + pt_dump_size(st->seq, delta); 185 168 } 186 169 187 170 static void note_prot_wx(struct pg_state *st, unsigned long addr)
+3
arch/powerpc/mm/ptdump/ptdump.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 2 #include <linux/types.h> 3 + #include <linux/seq_file.h> 3 4 4 5 struct flag_info { 5 6 u64 mask; ··· 18 17 }; 19 18 20 19 extern struct pgtable_level pg_level[5]; 20 + 21 + void pt_dump_size(struct seq_file *m, unsigned long delta);