minidump: De-duplicate the progress bar

The implementation of the progress bar is simple, but duplicated for
most minidump implementations. Extract the common bits to kern_dump.c.
Ensure that the bar is reset with each subsequent dump; this was only
done on some platforms previously.

Reviewed by:	markj
MFC after:	2 weeks
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D31885
This commit is contained in:
Mitchell Horne
2021-09-29 14:44:27 -03:00
parent 31991a5a45
commit ab4ed843a3
15 changed files with 113 additions and 248 deletions
+2 -11
View File
@@ -63,9 +63,6 @@ static struct kerneldumpheader kdh;
/* Handle chunked writes. */
static size_t fragsz;
static void *dump_va;
static uint64_t counter, progress;
#define PG2MB(pgs) (((pgs) + (1 << 8) - 1) >> 8)
static int
blk_flush(struct dumperinfo *di)
@@ -115,13 +112,8 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz)
len = maxdumpsz - fragsz;
if (len > sz)
len = sz;
counter += len;
progress -= len;
if (counter >> 22) {
printf(" %lld", PG2MB(progress >> PAGE_SHIFT));
counter &= (1<<22) - 1;
}
dumpsys_pb_progress(len);
#ifdef SW_WATCHDOG
wdog_kern_pat(WD_LASTVAL);
#endif
@@ -182,7 +174,6 @@ minidumpsys(struct dumperinfo *di)
*/
dcache_wbinv_poc_all();
counter = 0;
/* Walk page table pages, set bits in vm_page_dump */
ptesize = 0;
for (va = KERNBASE; va < kernel_vm_end; va += PAGE_SIZE) {
@@ -206,7 +197,7 @@ minidumpsys(struct dumperinfo *di)
}
dumpsize += PAGE_SIZE;
progress = dumpsize;
dumpsys_pb_init(dumpsize);
/* Initialize mdhdr */
bzero(&mdhdr, sizeof(mdhdr));
+3
View File
@@ -36,6 +36,9 @@
#define DUMPSYS_MD_PA_NPAIRS 20
#define DUMPSYS_NUM_AUX_HDRS 1
/* How often to check the dump progress bar? */
#define DUMPSYS_PB_CHECK_BITS 22 /* Every 4MB */
void dumpsys_wbinv_all(void);
int dumpsys_write_aux_headers(struct dumperinfo *di);