[PATCH] Fix errors when rebuild with updated gdb-10.2.patch
by HAGIO KAZUHITO(萩尾 一仁)
The gdb-10.2.patch forgot the role that acts as a shell script that
restores gdb files to its original state and exits. Without the patch,
the following errors are emitted when rebuiding crash with an updated
gdb-10.2.patch.
$ make warn
TARGET: X86_64
CRASH: 8.0.0++
GDB: 10.2
+ --- gdb-10.2/Makefile.in.orig
gdb-10.2.patch: line 11: ---: command not found
+ +++ gdb-10.2/Makefile.in
gdb-10.2.patch: line 12: +++: command not found
+ @@ -340,6 +340,9 @@ AR_FOR_BUILD = @AR_FOR_BUILD@
gdb-10.2.patch: line 13: @@: command not found
+ AS_FOR_BUILD = @AS_FOR_BUILD@
gdb-10.2.patch: line 14: AS_FOR_BUILD: command not found
+ CC_FOR_BUILD = @CC_FOR_BUILD@
gdb-10.2.patch: line 15: CC_FOR_BUILD: command not found
+ CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
gdb-10.2.patch: line 16: CFLAGS_FOR_BUILD: command not found
gdb-10.2.patch: line 17: syntax error near unexpected token
`${CRASH_TARGET},'
gdb-10.2.patch: line 17: `+ifeq (${CRASH_TARGET}, PPC64)'
Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
---
gdb-10.2.patch | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/gdb-10.2.patch b/gdb-10.2.patch
index f5e4c06e6f97..c5aa0bf79691 100644
--- a/gdb-10.2.patch
+++ b/gdb-10.2.patch
@@ -8,6 +8,11 @@
# shell script that can restore any gdb file to its original state prior
# to all subsequent patch applications.
+#tar xvzmf gdb-10.2.tar.gz \
+# gdb-10.2/gdb/symtab.c
+
+exit 0
+
--- gdb-10.2/Makefile.in.orig
+++ gdb-10.2/Makefile.in
@@ -340,6 +340,9 @@ AR_FOR_BUILD = @AR_FOR_BUILD@
--
2.27.0
2 years, 9 months
[PATCH] Fix for "bpf -m|-M" options to appropriately display MEMLOCK and UID
by Lianbo Jiang
Kernel commit <80ee81e0403c> ("bpf: Eliminate rlimit-based memory
accounting infra for bpf maps") removed the struct bpf_map_memory
member from struct bpf_map. Without the patch, "bpf -m|-M" options
will print the following errors:
crash> bpf -m 1
ID BPF_MAP BPF_MAP_TYPE MAP_FLAGS
1 ffff96ba41804400 ARRAY 00000000
KEY_SIZE: 4 VALUE_SIZE: 8 MAX_ENTRIES: 64 MEMLOCK: (unknown)
^^^^^^^
NAME: "dist" UID: (unknown)
^^^^^^^
Signed-off-by: Lianbo Jiang <lijiang(a)redhat.com>
---
bpf.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 64 insertions(+), 3 deletions(-)
diff --git a/bpf.c b/bpf.c
index cb6b0ed385f9..d45e9ab9311b 100644
--- a/bpf.c
+++ b/bpf.c
@@ -15,6 +15,7 @@
*/
#include "defs.h"
+#include <stdbool.h>
struct bpf_info {
ulong status;
@@ -63,6 +64,66 @@ static int do_old_idr(int, ulong, struct list_pair *);
#define PROG_VERBOSE (0x40)
#define MAP_VERBOSE (0x80)
+static bool map_is_per_cpu(ulong type)
+{
+ /*
+ * See the definition of bpf_map_type:
+ * include/uapi/linux/bpf.h
+ */
+ #define BPF_MAP_TYPE_PERCPU_HASH (5UL)
+ #define BPF_MAP_TYPE_PERCPU_ARRAY (6UL)
+ #define BPF_MAP_TYPE_LRU_PERCPU_HASH (10UL)
+ #define BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE (21UL)
+
+ return type == BPF_MAP_TYPE_PERCPU_HASH ||
+ type == BPF_MAP_TYPE_PERCPU_ARRAY ||
+ type == BPF_MAP_TYPE_LRU_PERCPU_HASH ||
+ type == BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE;
+}
+
+static bool map_is_fd_map(ulong type)
+{
+ /*
+ * See the definition of bpf_map_type:
+ * include/uapi/linux/bpf.h
+ */
+ #define BPF_MAP_TYPE_PROG_ARRAY (3UL)
+ #define BPF_MAP_TYPE_PERF_EVENT_ARRAY (4UL)
+ #define BPF_MAP_TYPE_CGROUP_ARRAY (8UL)
+ #define BPF_MAP_TYPE_ARRAY_OF_MAPS (12UL)
+ #define BPF_MAP_TYPE_HASH_OF_MAPS (13UL)
+
+ return type == BPF_MAP_TYPE_PROG_ARRAY ||
+ type == BPF_MAP_TYPE_PERF_EVENT_ARRAY ||
+ type == BPF_MAP_TYPE_CGROUP_ARRAY ||
+ type == BPF_MAP_TYPE_ARRAY_OF_MAPS ||
+ type == BPF_MAP_TYPE_HASH_OF_MAPS;
+
+}
+
+static ulong bpf_map_memory_size(ulong map_type, ulong vsize, ulong ksize, ulong esize)
+{
+ ulong memsize,valsize;
+ int cpus = 0;
+
+ valsize = vsize;
+
+ if (map_is_fd_map(map_type))
+ valsize = sizeof(ulong);
+
+ if (map_is_per_cpu(map_type)) {
+ cpus = get_cpus_possible();
+ if (!cpus)
+ error(WARNING, "cpu_possible_map does not exist, pissible cpus: %d\n", cpus);
+
+ valsize = roundup(vsize, 8) * cpus;
+ }
+
+ memsize = roundup((ksize + valsize), 8);
+
+ return roundup((esize * memsize), PAGESIZE());
+}
+
void
cmd_bpf(void)
{
@@ -332,7 +393,7 @@ do_bpf(ulong flags, ulong prog_id, ulong map_id, int radix)
{
struct bpf_info *bpf;
int i, c, found, entries, type;
- uint uid, map_pages, key_size, value_size, max_entries;
+ uint uid, map_pages, key_size = 0, value_size = 0, max_entries = 0;
ulong bpf_prog_aux, bpf_func, end_func, addr, insnsi, user;
ulong do_progs, do_maps;
ulonglong load_time;
@@ -603,7 +664,7 @@ do_map_only:
map_pages = UINT(bpf->bpf_map_buf + OFFSET(bpf_map_pages));
fprintf(fp, "%d\n", map_pages * PAGESIZE());
} else
- fprintf(fp, "(unknown)\n");
+ fprintf(fp, "%ld\n", bpf_map_memory_size(type, value_size, key_size, max_entries));
fprintf(fp, " NAME: ");
if (VALID_MEMBER(bpf_map_name)) {
@@ -632,7 +693,7 @@ do_map_only:
else
fprintf(fp, "(unknown)\n");
} else
- fprintf(fp, "(unknown)\n");
+ fprintf(fp, "(unused)\n");
}
if (flags & DUMP_STRUCT) {
--
2.20.1
2 years, 9 months
[PATCH v3 0/7] log: output logs of printk safe buffers
by shogo.matsumoto@fujitsu.com
This patch set introduces -s option for log builtin command to display
printk safe buffers (safe_print_seq/nmi_print_seq) as follows:
===
crash> log -s
PRINTK_SAFE_SEQ_BUF: nmi_print_seq
CPU: 0 ADDR: ffff969d7bc19ce0 LEN: 150 MESSAGE_LOST: 0
Uhhuh. NMI received for unknown reason 20 on CPU 0.
Do you have a strange power saving mode enabled?
Dazed and confused, but trying to continue
...
===
The printk safe buffers are also displayed at the bottom of
'log' output so as not to overlook them.
===
crash> log
...
[nmi_print_seq] Uhhuh. NMI received for unknown reason 20 on CPU 0.
[nmi_print_seq] Do you have a strange power saving mode enabled?
[nmi_print_seq] Dazed and confused, but trying to continue
===
-m and -t options are also supported.
Note that the safe buffer (struct printk_safe_seq_buf) was introduced
in kernel-4.11 (Merge commit 7d91de74436a69c2b78a7a72f1e7f97f8b4396fa)
and removed in kernel-5.15 (93d102f094be9beab28e5afb656c188b16a3793b).
Changes since v2:
- Add support new options -s, -t, -m (Kazu)
- Add help text (Kazu)
[v1]: https://listman.redhat.com/archives/crash-utility/2021-December/msg00031....
[v2]: https://listman.redhat.com/archives/crash-utility/2022-January/msg00004.html
Test program is attached in the above v2 patch e-mail.
Shogo Matsumoto (7):
log: introduce -s option
log: adjust indent and line breaks for log -s
log: append printk safe buffer output to 'log'
log: add support -t option for output of printk safe buffers
log: add support -m for output of printk safe buffers
symbols: add support 'help -o' for printk safe buffers
log: add help text for printk safe buffers
defs.h | 5 ++
help.c | 25 ++++++++-
kernel.c | 159 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
symbols.c | 5 ++
4 files changed, 192 insertions(+), 2 deletions(-)
--
2.29.2
2 years, 9 months
[PATCH] arm64: Fix segfault by "bt" command with offline cpus
by HAGIO KAZUHITO(萩尾 一仁)
Currently on arm64, NT_PRSTATUS notes in dumpfile are not mapped to
online cpus and machine_specific->panic_task_regs correctly. As a
result, the "bt" command can cause a segmentation fault.
crash> bt -c 0
PID: 0 TASK: ffff8000117fa240 CPU: 0 COMMAND: "swapper/0"
Segmentation fault (core dumped)
To fix this,
1) make map_cpus_to_prstatus_kdump_cmprs() map the notes to
dd->nt_prstatus_percpu also on arm64, and
2) move arm64_get_crash_notes() to machdep_init(POST_INIT) in order
to apply the mapping to machine_specific->panic_task_regs.
Resolves: https://github.com/crash-utility/crash/issues/105
Reported-by: xuchunmei000 <xuchunmei(a)linux.alibaba.com>
Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
---
Note: I suspect that the machine_type("ARM64") in commit 9b41d403b16c might
be placed for debugging and contained in the commit by accident. Because
that segfault could be caused by the uninitialized machdep->process_elf_notes.
arm64.c | 2 +-
diskdump.c | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/arm64.c b/arm64.c
index 23c3d75d85aa..4f2c2b5104a1 100644
--- a/arm64.c
+++ b/arm64.c
@@ -472,7 +472,7 @@ arm64_init(int when)
arm64_stackframe_init();
break;
- case POST_VM:
+ case POST_INIT:
/*
* crash_notes contains machine specific information about the
* crash. In particular, it contains CPU registers at the time
diff --git a/diskdump.c b/diskdump.c
index 3e1cfd548c96..d5674276e1fd 100644
--- a/diskdump.c
+++ b/diskdump.c
@@ -111,8 +111,7 @@ map_cpus_to_prstatus_kdump_cmprs(void)
if (pc->flags2 & QEMU_MEM_DUMP_COMPRESSED) /* notes exist for all cpus */
goto resize_note_pointers;
- if (!(online = get_cpus_online()) || (online == kt->cpus) ||
- machine_type("ARM64"))
+ if (!(online = get_cpus_online()) || (online == kt->cpus))
goto resize_note_pointers;
if (CRASHDEBUG(1))
--
2.27.0
2 years, 10 months
Re: [Crash-utility] [PATCH] Improve the ps performance for vmcores with large number of threads
by lijiang
Thank you for the improvement, Tao.
This change looks good to me. Applied(but modified code comments).
Thanks.
Lianbo
On Fri, Jan 21, 2022 at 3:40 PM <crash-utility-request(a)redhat.com> wrote:
>
> Date: Fri, 21 Jan 2022 13:43:09 +0800
> From: Tao Liu <ltao(a)redhat.com>
> To: crash-utility(a)redhat.com
> Subject: [Crash-utility] [PATCH] Improve the ps performance for
> vmcores with large number of threads
> Message-ID: <20220121054309.9782-1-ltao(a)redhat.com>
> Content-Type: text/plain; charset="US-ASCII"
>
> Previously, the ps command will iterate over all threads which
> have the same tgid, to accumulate their rss value, in order to
> get a thread/process's final rss value as part of the final output.
>
> For non-live systems, the rss accumulation values are identical for
> threads which have the same tgid, so there is no need to do the
> iteration and accumulation repeatly, thus a lot of readmem calls are
> skipped. Otherwise it will be the performance bottleneck if the
> vmcores have a large number of threads.
>
> In this patch, the rss accumulation value will be stored in a cache,
> next time a thread with the same tgid will take it directly without
> the iteration.
>
> For example, we can monitor the performance issue when a vmcore has
> ~65k processes, most of which are threads for several specific
> processes. Without the patch, it will take ~7h for ps command
> to finish. With the patch, ps command will finish in 1min.
>
> Signed-off-by: Tao Liu <ltao(a)redhat.com>
> ---
> defs.h | 1 +
> memory.c | 67 ++++++++++++++++++++++++++++++--------------------------
> task.c | 1 +
> 3 files changed, 38 insertions(+), 31 deletions(-)
>
> diff --git a/defs.h b/defs.h
> index b63741c..55600d5 100644
> --- a/defs.h
> +++ b/defs.h
> @@ -829,6 +829,7 @@ struct task_context { /* context
> stored for each task */
> struct tgid_context { /* tgid and task stored for each task
> */
> ulong tgid;
> ulong task;
> + long rss_cache;
> };
>
> struct task_table { /* kernel/local task table data
> */
> diff --git a/memory.c b/memory.c
> index 5af45fd..b930933 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -4665,7 +4665,7 @@ void
> get_task_mem_usage(ulong task, struct task_mem_usage *tm)
> {
> struct task_context *tc;
> - long rss = 0;
> + long rss = 0, rss_cache = 0;
>
> BZERO(tm, sizeof(struct task_mem_usage));
>
> @@ -4730,38 +4730,43 @@ get_task_mem_usage(ulong task, struct
> task_mem_usage *tm)
> (last->tgid == (last + 1)->tgid))
> last++;
>
> - while (first <= last)
> - {
> - /* count 0 -> filepages */
> - if (!readmem(first->task +
> -
> OFFSET(task_struct_rss_stat) +
> -
> OFFSET(task_rss_stat_count), KVADDR,
> - &sync_rss,
> - sizeof(int),
> - "task_struct rss_stat
> MM_FILEPAGES",
> - RETURN_ON_ERROR))
> - continue;
> -
> - rss += sync_rss;
> -
> - /* count 1 -> anonpages */
> - if (!readmem(first->task +
> -
> OFFSET(task_struct_rss_stat) +
> -
> OFFSET(task_rss_stat_count) +
> - sizeof(int),
> - KVADDR, &sync_rss,
> - sizeof(int),
> - "task_struct rss_stat
> MM_ANONPAGES",
> - RETURN_ON_ERROR))
> - continue;
> -
> - rss += sync_rss;
> -
> - if (first == last)
> - break;
> - first++;
> + /* We will use rss_cache only for dumpfile
> */
> + if (ACTIVE() || last->rss_cache ==
> UNINITIALIZED) {
> + while (first <= last)
> + {
> + /* count 0 -> filepages */
> + if (!readmem(first->task +
> +
> OFFSET(task_struct_rss_stat) +
> +
> OFFSET(task_rss_stat_count), KVADDR,
> + &sync_rss,
> + sizeof(int),
> + "task_struct
> rss_stat MM_FILEPAGES",
> + RETURN_ON_ERROR))
> + continue;
> +
> + rss_cache += sync_rss;
> +
> + /* count 1 -> anonpages */
> + if (!readmem(first->task +
> +
> OFFSET(task_struct_rss_stat) +
> +
> OFFSET(task_rss_stat_count) +
> + sizeof(int),
> + KVADDR, &sync_rss,
> + sizeof(int),
> + "task_struct
> rss_stat MM_ANONPAGES",
> + RETURN_ON_ERROR))
> + continue;
> +
> + rss_cache += sync_rss;
> +
> + if (first == last)
> + break;
> + first++;
> + }
> + last->rss_cache = rss_cache;
> }
>
> + rss += last->rss_cache;
> tt->last_tgid = last;
> }
> }
> diff --git a/task.c b/task.c
> index 263a834..9868a6e 100644
> --- a/task.c
> +++ b/task.c
> @@ -2947,6 +2947,7 @@ add_context(ulong task, char *tp)
> tg = tt->tgid_array + tt->running_tasks;
> tg->tgid = *tgid_addr;
> tg->task = task;
> + tg->rss_cache = UNINITIALIZED;
>
> if (do_verify && !verify_task(tc, do_verify)) {
> error(INFO, "invalid task address: %lx\n", tc->task);
> --
> 2.33.1
>
>
>
> ------------------------------
>
> Message: 3
> Date: Fri, 21 Jan 2022 07:35:22 +0000
> From: HAGIO KAZUHITO(?????) <k-hagio-ab(a)nec.com>
> To: lijiang <lijiang(a)redhat.com>
> Cc: "crash-utility(a)redhat.com" <crash-utility(a)redhat.com>
> Subject: Re: [Crash-utility] [PATCH] Remove ptype command from "ps -t"
> option to reduce memory and time
> Message-ID:
> <
> TYYPR01MB6777EC6D0A3A1847AA853965DD5B9(a)TYYPR01MB6777.jpnprd01.prod.outlook.com
> >
>
> Content-Type: text/plain; charset="utf-8"
>
> -----Original Message-----
> > On Wed, Jan 19, 2022 at 4:27 PM HAGIO KAZUHITO(?????) <
> k-hagio-ab(a)nec.com <mailto:k-hagio-ab@nec.com>
> > > wrote:
> >
> >
> > With some vmlinux e.g. RHEL9 ones, the first execution of the gdb
> ptype
> > command heavily consumes memory and time. The "ps -t" option uses
> it
> > in start_time_timespec() and it can be replaced with crash macros.
> > This can reduce about 1.4 GB memory and 6 seconds time comsumption
> in
> > the following test:
> >
> > $ echo "ps -t" | time crash vmlinux vmcore
> >
> > Without the patch:
> > 11.60user 0.43system 0:11.94elapsed 100%CPU (0avgtext+0avgdata
> 1837964maxresident)k
> > 0inputs+400outputs (0major+413636minor)pagefaults 0swaps
> >
> > With the patch:
> > 5.40user 0.16system 0:05.46elapsed 101%CPU (0avgtext+0avgdata
> 417896maxresident)k
> > 0inputs+384outputs (0major+41528minor)pagefaults 0swaps
> >
> > Although the ptype command and similar ones cannot be fully
> removed,
> > but removing some of them will make the use of crash safer,
> especially
> > for an automatic crash analyzer.
> >
> > Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com <mailto:
> k-hagio-ab(a)nec.com> >
> > ---
> > task.c | 25 +++++--------------------
> > 1 file changed, 5 insertions(+), 20 deletions(-)
> >
> > diff --git a/task.c b/task.c
> > index 263a8344dd94..a79ed0d96fb5 100644
> > --- a/task.c
> > +++ b/task.c
> > @@ -4662,8 +4662,6 @@ show_task_times(struct task_context *tcp,
> ulong flags)
> > static int
> > start_time_timespec(void)
> > {
> > - char buf[BUFSIZE];
> > -
> > switch(tt->flags & (TIMESPEC | NO_TIMESPEC |
> START_TIME_NSECS))
> > {
> > case TIMESPEC:
> > @@ -4677,24 +4675,11 @@ start_time_timespec(void)
> >
> > tt->flags |= NO_TIMESPEC;
> >
> > - open_tmpfile();
> > - sprintf(buf, "ptype struct task_struct");
> > - if (!gdb_pass_through(buf, NULL, GNU_RETURN_ON_ERROR)) {
> > - close_tmpfile();
> > - return FALSE;
> > - }
> > -
> > - rewind(pc->tmpfile);
> > - while (fgets(buf, BUFSIZE, pc->tmpfile)) {
> > - if (strstr(buf, "start_time;")) {
> > - if (strstr(buf, "struct timespec")) {
> > - tt->flags &= ~NO_TIMESPEC;
> > - tt->flags |= TIMESPEC;
> > - }
> > - }
> > - }
> > -
> > - close_tmpfile();
> > + if (VALID_MEMBER(task_struct_start_time) &&
> > + STREQ(MEMBER_TYPE_NAME("task_struct", "start_time"),
> "timespec")) {
> > + tt->flags &= ~NO_TIMESPEC;
> > + tt->flags |= TIMESPEC;
> > + }
> >
> > if ((tt->flags & NO_TIMESPEC) &&
> (SIZE(task_struct_start_time) == 8)) {
> > tt->flags &= ~NO_TIMESPEC;
> > --
> > 2.27.0
> >
> >
> >
> > For this one:
> > Acked-by: Lianbo Jiang <lijiang(a)redhat.com <mailto:lijiang@redhat.com> >
> >
>
> Thank you for reviewing, applied.
>
> Kazu
>
>
>
>
> ------------------------------
>
> --
> Crash-utility mailing list
> Crash-utility(a)redhat.com
> https://listman.redhat.com/mailman/listinfo/crash-utility
>
> End of Crash-utility Digest, Vol 196, Issue 15
> **********************************************
>
>
2 years, 10 months
[PATCH v3 7/7] log: add help text for printk safe buffers
by shogo.matsumoto@fujitsu.com
Signed-off-by: Shogo Matsumoto <shogo.matsumoto(a)fujitsu.com>
---
help.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/help.c b/help.c
index 04a7eff..d8d2eab 100644
--- a/help.c
+++ b/help.c
@@ -3886,7 +3886,7 @@ NULL
char *help_log[] = {
"log",
"dump system message buffer",
-"[-Ttdma]",
+"[-Ttdmas]",
" This command dumps the kernel log_buf contents in chronological order. The",
" command supports the older log_buf formats, which may or may not contain a",
" timestamp inserted prior to each message, as well as the newer variable-length",
@@ -3907,6 +3907,8 @@ char *help_log[] = {
" shown with 'set debug 1'.",
" -a Dump the audit logs remaining in kernel audit buffers that have not",
" been copied out to the user-space audit daemon.",
+" -s Dump the printk logs remaining in kernel safe per-CPU buffers that",
+" have not been flushed out to log_buf.",
" ",
"\nEXAMPLES",
" Dump the kernel message buffer:\n",
@@ -4054,6 +4056,27 @@ char *help_log[] = {
" [Sat Apr 4 07:41:09 2020] MTRR default type: uncachable",
" [Sat Apr 4 07:41:09 2020] MTRR variable ranges disabled:",
" ...",
+" ",
+" On a system which has printk_safe_seq_buf buffer,",
+" display its unflushed log with buffer name:\n",
+" %s> log",
+" [nmi_print_seq] Uhhuh. NMI received for unknown reason 30 on CPU 0.",
+" [nmi_print_seq] Do you have a strange power saving mode enabled?",
+" [nmi_print_seq] Dazed and confused, but trying to continue",
+" ...",
+" ",
+" Dump the printk safe buffers:\n",
+" %s> log -s",
+" PRINTK_SAFE_SEQ_BUF: nmi_print_seq",
+" CPU: 0 ADDR: ffff8ca4fbc19ce0 LEN: 150 MESSAGE_LOST: 0",
+" Uhhuh. NMI received for unknown reason 20 on CPU 0.",
+" Do you have a strange power saving mode enabled?",
+" Dazed and confused, but trying to continue",
+" ...",
+" PRINTK_SAFE_SEQ_BUF: safe_print_seq",
+" CPU: 0 ADDR: ffff8ca4fbc1ad00 LEN: 0 MESSAGE_LOST: 0",
+" (empty)",
+" ...",
NULL
};
--
2.29.2
2 years, 10 months
[PATCH v3 6/7] symbols: add support 'help -o' for printk safe buffers
by shogo.matsumoto@fujitsu.com
Signed-off-by: Shogo Matsumoto <shogo.matsumoto(a)fujitsu.com>
---
symbols.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/symbols.c b/symbols.c
index 73baa95..97fb778 100644
--- a/symbols.c
+++ b/symbols.c
@@ -10523,6 +10523,10 @@ dump_offset_table(char *spec, ulong makestruct)
fprintf(fp, " prb_data_ring_size_bits: %ld\n", OFFSET(prb_data_ring_size_bits));
fprintf(fp, " prb_data_ring_data: %ld\n", OFFSET(prb_data_ring_data));
fprintf(fp, " atomit_long_t_counter: %ld\n", OFFSET(atomic_long_t_counter));
+ fprintf(fp, " printk_safe_seq_buf_len: %ld\n", OFFSET(printk_safe_seq_buf_len));
+ fprintf(fp, "printk_safe_seq_buf_message_lost: %ld\n",
+ OFFSET(printk_safe_seq_buf_message_lost));
+ fprintf(fp, " printk_safe_seq_buf_buffer: %ld\n", OFFSET(printk_safe_seq_buf_buffer));
fprintf(fp, " sched_rt_entity_my_q: %ld\n",
OFFSET(sched_rt_entity_my_q));
@@ -10954,6 +10958,7 @@ dump_offset_table(char *spec, ulong makestruct)
fprintf(fp, " printk_info: %ld\n", SIZE(printk_info));
fprintf(fp, " printk_ringbuffer: %ld\n", SIZE(printk_ringbuffer));
fprintf(fp, " prb_desc: %ld\n", SIZE(prb_desc));
+ fprintf(fp, " printk_safe_seq_buf_buffer: %ld\n", SIZE(printk_safe_seq_buf_buffer));
fprintf(fp, "\n array_table:\n");
--
2.29.2
2 years, 10 months
[PATCH v3 5/7] log: add support -m for output of printk safe buffers
by shogo.matsumoto@fujitsu.com
Signed-off-by: Shogo Matsumoto <shogo.matsumoto(a)fujitsu.com>
---
kernel.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/kernel.c b/kernel.c
index 993913c..f9e8763 100644
--- a/kernel.c
+++ b/kernel.c
@@ -11612,6 +11612,9 @@ __dump_printk_safe_seq_buf(char *buf_name, int msg_flags)
else
ilen = strlen(buf_name) + 3; // "[%s] "
}
+ if (msg_flags & SHOW_LOG_LEVEL)
+ ilen += 3; // "<%c>"
+
readmem(buffer_addr + per_cpu_offset, KVADDR,
buffer, buffer_size,
"printk_safe_seq_buf buffer", FAULT_ON_ERROR);
@@ -11632,6 +11635,14 @@ __dump_printk_safe_seq_buf(char *buf_name, int msg_flags)
else if (!(msg_flags & SHOW_LOG_TEXT))
fprintf(fp, "[%s] ", buf_name);
+ if ((msg_flags & SHOW_LOG_LEVEL) && (i < n)) {
+ switch (*p) {
+ case '0' ... '7':
+ case 'c':
+ fprintf(fp, "<%c>", *p);
+ }
+ }
+
continue;
} else {
if (sol)
--
2.29.2
2 years, 10 months
[PATCH v3 4/7] log: add support -t option for output of printk safe buffers
by shogo.matsumoto@fujitsu.com
Suppress the output of safe buffer name if -t is specified to 'log'.
Signed-off-by: Shogo Matsumoto <shogo.matsumoto(a)fujitsu.com>
---
kernel.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/kernel.c b/kernel.c
index 138ac3c..993913c 100644
--- a/kernel.c
+++ b/kernel.c
@@ -11607,7 +11607,10 @@ __dump_printk_safe_seq_buf(char *buf_name, int msg_flags)
if (show_header) {
ilen = PRINTK_SAFE_SEQ_BUF_INDENT;
} else {
- ilen = strlen(buf_name) + 3; // "[%s] "
+ if (msg_flags & SHOW_LOG_TEXT)
+ ilen = 0;
+ else
+ ilen = strlen(buf_name) + 3; // "[%s] "
}
readmem(buffer_addr + per_cpu_offset, KVADDR,
buffer, buffer_size,
@@ -11626,7 +11629,7 @@ __dump_printk_safe_seq_buf(char *buf_name, int msg_flags)
if (show_header)
fprintf(fp, space(PRINTK_SAFE_SEQ_BUF_INDENT));
- else
+ else if (!(msg_flags & SHOW_LOG_TEXT))
fprintf(fp, "[%s] ", buf_name);
continue;
--
2.29.2
2 years, 10 months
[PATCH v3 3/7] log: append printk safe buffer output to 'log'
by shogo.matsumoto@fujitsu.com
Output of 'log' compared to 'log -s':
- Suppress struct header (len, addr, message_lost...)
- Display only non-empty buffers
- Display buffer name at the beginning of line
Signed-off-by: Shogo Matsumoto <shogo.matsumoto(a)fujitsu.com>
---
kernel.c | 43 +++++++++++++++++++++++++++++++------------
1 file changed, 31 insertions(+), 12 deletions(-)
diff --git a/kernel.c b/kernel.c
index 57fe355..138ac3c 100644
--- a/kernel.c
+++ b/kernel.c
@@ -5057,6 +5057,7 @@ cmd_log(void)
}
dump_log(msg_flags);
+ dump_printk_safe_seq_buf(msg_flags);
}
@@ -11561,6 +11562,9 @@ __dump_printk_safe_seq_buf(char *buf_name, int msg_flags)
int cpu, buffer_size;
char *buffer;
ulong base_addr, len_addr, message_lost_addr, buffer_addr;
+ bool show_header;
+
+ show_header = msg_flags & SHOW_LOG_SAFE;
if (!symbol_exists(buf_name)) {
return;
@@ -11576,7 +11580,8 @@ __dump_printk_safe_seq_buf(char *buf_name, int msg_flags)
buffer_size = SIZE(printk_safe_seq_buf_buffer);
buffer = GETBUF(buffer_size);
- fprintf(fp, "PRINTK_SAFE_SEQ_BUF: %s\n", buf_name);
+ if (show_header)
+ fprintf(fp, "PRINTK_SAFE_SEQ_BUF: %s\n", buf_name);
for (cpu = 0; cpu < kt->cpus; cpu++) {
int len, message_lost;
ulong per_cpu_offset;
@@ -11584,17 +11589,26 @@ __dump_printk_safe_seq_buf(char *buf_name, int msg_flags)
readmem(len_addr + per_cpu_offset, KVADDR, &len, sizeof(int),
"printk_safe_seq_buf len", FAULT_ON_ERROR);
- readmem(message_lost_addr + per_cpu_offset, KVADDR,
- &message_lost, sizeof(int),
- "printk_safe_seq_buf message_lost", FAULT_ON_ERROR);
- fprintf(fp, "CPU: %d ADDR: %lx LEN: %d MESSAGE_LOST: %d\n",
- cpu, base_addr + per_cpu_offset, len, message_lost);
+
+ if (show_header) {
+ readmem(message_lost_addr + per_cpu_offset, KVADDR,
+ &message_lost, sizeof(int),
+ "printk_safe_seq_buf message_lost", FAULT_ON_ERROR);
+ fprintf(fp, "CPU: %d ADDR: %lx LEN: %d MESSAGE_LOST: %d\n",
+ cpu, base_addr + per_cpu_offset, len, message_lost);
+ }
if (len > 0) {
- int i, n;
+ int i, n, ilen;
char *p;
bool start_of_line;
+ ilen = 0;
+ if (show_header) {
+ ilen = PRINTK_SAFE_SEQ_BUF_INDENT;
+ } else {
+ ilen = strlen(buf_name) + 3; // "[%s] "
+ }
readmem(buffer_addr + per_cpu_offset, KVADDR,
buffer, buffer_size,
"printk_safe_seq_buf buffer", FAULT_ON_ERROR);
@@ -11610,12 +11624,15 @@ __dump_printk_safe_seq_buf(char *buf_name, int msg_flags)
if (!sol)
fprintf(fp, "\n");
- fprintf(fp, space(PRINTK_SAFE_SEQ_BUF_INDENT));
+ if (show_header)
+ fprintf(fp, space(PRINTK_SAFE_SEQ_BUF_INDENT));
+ else
+ fprintf(fp, "[%s] ", buf_name);
continue;
} else {
if (sol)
- fprintf(fp, "%s", space(PRINTK_SAFE_SEQ_BUF_INDENT));
+ fprintf(fp, "%s", space(ilen));
if (isprint(*p) || isspace(*p)) {
fputc(*p, fp);
@@ -11628,8 +11645,9 @@ __dump_printk_safe_seq_buf(char *buf_name, int msg_flags)
}
if (!start_of_line)
fputc('\n', fp);
- fputc('\n', fp);
- } else {
+ if (show_header)
+ fputc('\n', fp);
+ } else if (show_header) {
fprintf(fp, "%s(empty)\n\n", space(PRINTK_SAFE_SEQ_BUF_INDENT));
}
}
@@ -11660,7 +11678,8 @@ dump_printk_safe_seq_buf(int msg_flags)
INVALID_MEMBER(printk_safe_seq_buf_message_lost) ||
INVALID_MEMBER(printk_safe_seq_buf_buffer) ||
INVALID_SIZE(printk_safe_seq_buf_buffer)) {
- error(INFO, "-s not supported with this kernel version\n");
+ if (msg_flags & SHOW_LOG_SAFE)
+ error(INFO, "-s not supported with this kernel version\n");
return;
}
--
2.29.2
2 years, 10 months