Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/amd64/minidump_machdep.c
Context not available. | |||||
CTASSERT(sizeof(struct kerneldumpheader) == 512); | CTASSERT(sizeof(struct kerneldumpheader) == 512); | ||||
uint64_t *vm_page_dump; | |||||
int vm_page_dump_size; | |||||
static struct kerneldumpheader kdh; | static struct kerneldumpheader kdh; | ||||
/* Handle chunked writes. */ | /* Handle chunked writes. */ | ||||
Context not available. | |||||
static void *dump_va; | static void *dump_va; | ||||
static size_t counter, progress, dumpsize, wdog_next; | static size_t counter, progress, dumpsize, wdog_next; | ||||
CTASSERT(sizeof(*vm_page_dump) == 8); | |||||
static int dump_retry_count = 5; | static int dump_retry_count = 5; | ||||
SYSCTL_INT(_machdep, OID_AUTO, dump_retry_count, CTLFLAG_RWTUN, | SYSCTL_INT(_machdep, OID_AUTO, dump_retry_count, CTLFLAG_RWTUN, | ||||
&dump_retry_count, 0, "Number of times dump has to retry before bailing out"); | &dump_retry_count, 0, "Number of times dump has to retry before bailing out"); | ||||
Context not available. | |||||
uint32_t pmapsize; | uint32_t pmapsize; | ||||
vm_offset_t va; | vm_offset_t va; | ||||
int error; | int error; | ||||
uint64_t bits; | |||||
uint64_t *pml4, *pdp, *pd, *pt, pa; | uint64_t *pml4, *pdp, *pd, *pt, pa; | ||||
int i, ii, j, k, n, bit; | int i, ii, j, k, n; | ||||
kib: Might be it is time to change bit type to long ? | |||||
Done Inline ActionsINT_MAX bits for pages can cover almost 8 TiB of memory, so I think int is still working with existing hardware. I could do it now if you'd like or we can wait a year or two probably. scottph: INT_MAX bits for pages can cover almost 8 TiB of memory, so I think int is still working with… | |||||
Done Inline ActionsIndeed INT_MAX covers 8T, and this is the current limit for DMAP on amd64. I see a value in fixing places as we see them. kib: Indeed INT_MAX covers 8T, and this is the current limit for DMAP on amd64.
I see a value in… | |||||
Done Inline ActionsSounds good, I've updated the FOREACH macro to use vm_pindex_t for the bit type. scottph: Sounds good, I've updated the FOREACH macro to use vm_pindex_t for the bit type. | |||||
int retry_count; | int retry_count; | ||||
struct minidumphdr mdhdr; | struct minidumphdr mdhdr; | ||||
Context not available. | |||||
/* Calculate dump size. */ | /* Calculate dump size. */ | ||||
dumpsize = pmapsize; | dumpsize = pmapsize; | ||||
dumpsize += round_page(msgbufp->msg_size); | dumpsize += round_page(msgbufp->msg_size); | ||||
dumpsize += round_page(vm_page_dump_size); | dumpsize += round_page(BITSET_SIZE(vm_page_dump_pages)); | ||||
for (i = 0; i < vm_page_dump_size / sizeof(*vm_page_dump); i++) { | VM_PAGE_DUMP_FOREACH(pa) { | ||||
bits = vm_page_dump[i]; | /* Clear out undumpable pages now if needed */ | ||||
while (bits) { | if (is_dumpable(pa)) { | ||||
bit = bsfq(bits); | dumpsize += PAGE_SIZE; | ||||
pa = (((uint64_t)i * sizeof(*vm_page_dump) * NBBY) + bit) * PAGE_SIZE; | } else { | ||||
/* Clear out undumpable pages now if needed */ | dump_drop_page(pa); | ||||
if (is_dumpable(pa)) { | |||||
dumpsize += PAGE_SIZE; | |||||
} else { | |||||
dump_drop_page(pa); | |||||
} | |||||
bits &= ~(1ul << bit); | |||||
} | } | ||||
} | } | ||||
dumpsize += PAGE_SIZE; | dumpsize += PAGE_SIZE; | ||||
Context not available. | |||||
strcpy(mdhdr.magic, MINIDUMP_MAGIC); | strcpy(mdhdr.magic, MINIDUMP_MAGIC); | ||||
mdhdr.version = MINIDUMP_VERSION; | mdhdr.version = MINIDUMP_VERSION; | ||||
mdhdr.msgbufsize = msgbufp->msg_size; | mdhdr.msgbufsize = msgbufp->msg_size; | ||||
mdhdr.bitmapsize = vm_page_dump_size; | mdhdr.bitmapsize = round_page(BITSET_SIZE(vm_page_dump_pages)); | ||||
mdhdr.pmapsize = pmapsize; | mdhdr.pmapsize = pmapsize; | ||||
mdhdr.kernbase = VM_MIN_KERNEL_ADDRESS; | mdhdr.kernbase = VM_MIN_KERNEL_ADDRESS; | ||||
mdhdr.dmapbase = DMAP_MIN_ADDRESS; | mdhdr.dmapbase = DMAP_MIN_ADDRESS; | ||||
Context not available. | |||||
goto fail; | goto fail; | ||||
/* Dump bitmap */ | /* Dump bitmap */ | ||||
error = blk_write(di, (char *)vm_page_dump, 0, round_page(vm_page_dump_size)); | error = blk_write(di, (char *)vm_page_dump, 0, | ||||
round_page(BITSET_SIZE(vm_page_dump_pages))); | |||||
if (error) | if (error) | ||||
goto fail; | goto fail; | ||||
Context not available. | |||||
} | } | ||||
/* Dump memory chunks */ | /* Dump memory chunks */ | ||||
for (i = 0; i < vm_page_dump_size / sizeof(*vm_page_dump); i++) { | VM_PAGE_DUMP_FOREACH(pa) { | ||||
bits = vm_page_dump[i]; | error = blk_write(di, 0, pa, PAGE_SIZE); | ||||
while (bits) { | if (error) | ||||
bit = bsfq(bits); | goto fail; | ||||
pa = (((uint64_t)i * sizeof(*vm_page_dump) * NBBY) + bit) * PAGE_SIZE; | |||||
error = blk_write(di, 0, pa, PAGE_SIZE); | |||||
if (error) | |||||
goto fail; | |||||
bits &= ~(1ul << bit); | |||||
} | |||||
} | } | ||||
error = blk_flush(di); | error = blk_flush(di); | ||||
Context not available. | |||||
printf("** DUMP FAILED (ERROR %d) **\n", error); | printf("** DUMP FAILED (ERROR %d) **\n", error); | ||||
return (error); | return (error); | ||||
} | } | ||||
void | |||||
dump_add_page(vm_paddr_t pa) | |||||
{ | |||||
int idx, bit; | |||||
pa >>= PAGE_SHIFT; | |||||
idx = pa >> 6; /* 2^6 = 64 */ | |||||
bit = pa & 63; | |||||
atomic_set_long(&vm_page_dump[idx], 1ul << bit); | |||||
} | |||||
void | |||||
dump_drop_page(vm_paddr_t pa) | |||||
{ | |||||
int idx, bit; | |||||
pa >>= PAGE_SHIFT; | |||||
idx = pa >> 6; /* 2^6 = 64 */ | |||||
bit = pa & 63; | |||||
atomic_clear_long(&vm_page_dump[idx], 1ul << bit); | |||||
} | |||||
Context not available. |
Might be it is time to change bit type to long ?