From 2519863249fb1e3a358633cc8bec26c3ce5fcf00 Mon Sep 17 00:00:00 2001 From: chenqiwu Date: Tue, 10 Dec 2019 14:11:02 +0800 Subject: [PATCH v3] Optimization for ARM64 getting crash notes arm64_get_crash_notes() check the sanity of NT_PRSTATUS notes only for online cpus. If one cpu contains invalid note, it's better to continue finding the crash notes for other online cpus. So we can extract the backtraces for the online cpus which contain valid note by using command "bt -a". Signed-off-by: chenqiwu --- arm64.c | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/arm64.c b/arm64.c index 233029d..bee4c18 100644 --- a/arm64.c +++ b/arm64.c @@ -3587,7 +3587,7 @@ arm64_get_crash_notes(void) ulong offset; char *buf, *p; ulong *notes_ptrs; - ulong i; + ulong i, j; if (!symbol_exists("crash_notes")) return FALSE; @@ -3620,12 +3620,12 @@ arm64_get_crash_notes(void) if (!(ms->panic_task_regs = calloc((size_t)kt->cpus, sizeof(struct arm64_pt_regs)))) error(FATAL, "cannot calloc panic_task_regs space\n"); - for (i = 0; i < kt->cpus; i++) { - + for (i = 0, j = 0; i < kt->cpus; i++) { if (!readmem(notes_ptrs[i], KVADDR, buf, SIZE(note_buf), "note_buf_t", RETURN_ON_ERROR)) { - error(WARNING, "failed to read note_buf_t\n"); - goto fail; + error(WARNING, "cpu#%d: failed to read note_buf_t\n", i); + ++j; + continue; } /* @@ -3655,19 +3655,29 @@ arm64_get_crash_notes(void) note->n_descsz == notesz) BCOPY((char *)note, buf, notesz); } else { - error(WARNING, - "cannot find NT_PRSTATUS note for cpu: %d\n", i); + if (CRASHDEBUG(1)) + error(WARNING, + "cpu#%d: cannot find NT_PRSTATUS note\n", i); + ++j; continue; } } + /* + * Check the sanity of NT_PRSTATUS note only for each online cpu. + * If this cpu has invalid note, continue to find the crash notes + * for other online cpus. + */ if (note->n_type != NT_PRSTATUS) { - error(WARNING, "invalid note (n_type != NT_PRSTATUS)\n"); - goto fail; + error(WARNING, "cpu#%d: invalid note (n_type != NT_PRSTATUS)\n", i); + ++j; + continue; } - if (p[0] != 'C' || p[1] != 'O' || p[2] != 'R' || p[3] != 'E') { - error(WARNING, "invalid note (name != \"CORE\"\n"); - goto fail; + + if (!STRNEQ(p, "CORE")) { + error(WARNING, "cpu#%d: invalid note (name != \"CORE\")\n", i); + ++j; + continue; } /* @@ -3684,14 +3694,13 @@ arm64_get_crash_notes(void) FREEBUF(buf); FREEBUF(notes_ptrs); - return TRUE; -fail: - FREEBUF(buf); - FREEBUF(notes_ptrs); - free(ms->panic_task_regs); - ms->panic_task_regs = NULL; - return FALSE; + if (j == kt->cpus) { + free(ms->panic_task_regs); + ms->panic_task_regs = NULL; + return FALSE; + } + return TRUE; } static void -- 1.9.1