Re: [Crash-utility] Kernel Crash Analysis on Android
by Shankar, AmarX
Hi Dave,
Thanks for your info regarding kexec tool.
I am unable to download kexec from below link.
http://www.kernel.org/pub/linux/kernel/people/horms/kexec-tools/kexec-too...
It says HTTP 404 Page Not Found.
Could you please guide me on this?
Thanks & Regards,
Amar Shankar
> On Wed, Mar 21, 2012 at 06:00:00PM +0000, Shankar, AmarX wrote:
>
> > I want to do kernel crash Analysis on Android Merrifield Target.
> >
> > Could someone please help me how to do it?
>
> Merrifield is pretty much similar than Medfield, e.g it has x86 core. So I
> guess you can follow the instructions how to setup kdump on x86 (see
> Documentation/kdump/kdump.txt) unless you already have that configured.
>
> crash should support this directly presuming you have vmlinux/vmcore files to
> feed it. You can configure crash to support x86 on x86_64 host by running:
>
> % make target=X86
> & make
>
> (or something along those lines).
Right -- just the first make command will suffice, i.e., when running
on an x86_64 host:
$ wget http://people.redhat.com/anderson/crash-6.0.4.tar.gz
$ tar xzf crash-6.0.4.tar.gz
...
$ cd crash-6.0.4
$ make target=X86
...
$ ./crash <path-to>/vmlinux <path-to>/vmcore
Dave
From: Shankar, AmarX
Sent: Wednesday, March 21, 2012 11:30 PM
To: 'crash-utility(a)redhat.com'
Subject: Kernel Crash Analysis on Android
Hi,
I want to do kernel crash Analysis on Android Merrifield Target.
Could someone please help me how to do it?
Thanks & Regards,
Amar Shankar
9 months, 4 weeks
[PATCH] kmem, snap: iomem/ioport display and vmcore snapshot support
by HATAYAMA Daisuke
Some days ago I was in a situation that I had to convert vmcore in
kvmdump format into ELF since some extension module we have locally
can be used only on relatively old crash utility, around version 4,
but such old crash utility cannot handle kvmdump format.
To do the conversion in handy, I used snap command with some modifications
so that it tries to use iomem information in vmcore instead of host's
/proc/iomem. This patch is its cleaned-up version.
In this development, I naturally got down to also making an interface
for an access to resource objects, and so together with the snap
command's patch, I also extended kmem command for iomem/ioport
support. Actually:
kmem -r displays /proc/iomem
crash> kmem -r
00000000-0000ffff : reserved
00010000-0009dbff : System RAM
0009dc00-0009ffff : reserved
000c0000-000c7fff : Video ROM
...
and kmem -R displays /proc/ioport
crash> kmem -R
0000-001f : dma1
0020-0021 : pic1
0040-0043 : timer0
0050-0053 : timer1
...
Looking into old version of kernel source code back, resource structure
has been unchanged since linux-2.4.0. I borrowed the way of walking on
resouce tree in this patch from the lastest v3.3-rc series, but I
guess the logic is also applicable to old kernels. I expect Dave's
regression testsuite.
Also, there would be another command more sutable for iomem/ioport.
If necessay, I'll repost the patch.
---
HATAYAMA Daisuke (4):
Add vmcore snapshot support
Add kmem -r and -R options
Add dump iomem/ioport functions; a helper for resource objects
Add a helper function for iterating resource objects
defs.h | 9 ++++
extensions/snap.c | 54 ++++++++++++++++++++++-
help.c | 2 +
memory.c | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++--
4 files changed, 180 insertions(+), 7 deletions(-)
--
Thanks.
HATAYAMA Daisuke
9 months, 4 weeks
Re: [Crash-utility] question about phys_base
by Dave Anderson
----- Original Message -----
> >
> > OK, so then I don't understand what you mean by "may be the same"?
> >
> > You didn't answer my original question, but if I understand you correctly,
> > it would be impossible for the qemu host to create a PT_LOAD segment that
> > describes an x86_64 guest's __START_KERNEL_map region, because the host
> > doesn't know that what kind of kernel the guest is running.
>
> Yes. Even if the guest is linux, it is still impossible to do it. Because
> the guest maybe in the second kernel.
>
> qemu-dump walks all guest's page table and collect virtual address and
> physical address mapping. If the page is not used by guest, the virtual is set
> to 0. I create PT_LOAD according to such mapping. So if the guest is linux,
> there may be a PT_LOAD segment that describes __START_KERNEL_map region.
> But the information stored in PT_LOAD maybe for the second kernel. If crash
> uses it, crash will see the second kernel, not the first kernel.
Just to be clear -- what do you mean by the "second" kernel? Do you
mean that a guest kernel crashed guest, and did a kdump operation,
and that second kdump kernel failed somehow, and now you're trying
to do a "virsh dump" on the kdump kernel?
Dave
9 months, 4 weeks
question about phys_base
by Wen Congyang
Hi, Dave
I am implementing a new dump command in the qemu. The vmcore's
format is elf(like kdump). And I try to provide phys_base in
the PT_LOAD. But if the os uses the first vcpu do kdump, the
value of phys_base is wrong.
I find a function x86_64_virt_phys_base() in crash's code.
Is it OK to call this function first? If the function
successes, we do not calculate phys_base according to PT_LOAD.
Thanks
Wen Congyang
9 months, 4 weeks
[PATCH] runq: search current task's runqueue explicitly
by HATAYAMA Daisuke
Currently, runq sub-command doesn't consider CFS runqueue's current
task removed from CFS runqueue. Due to this, the remaining CFS
runqueus that follow the current task's is not displayed. This patch
fixes this by making runq sub-command search current task's runqueue
explicitly.
Note that CFS runqueue exists for each task group, and so does CFS
runqueue's current task, and the above search needs to be done
recursively.
Test
====
On vmcore I made 7 task groups:
root group --- A --- AA --- AAA
+ +- AAB
|
+- AB --- ABA
+- ABB
and then I ran three CPU bound tasks, which is exactly the same as
int main(void) { for (;;) continue; return 0; }
for each task group, including root group; so total 24 tasks. For
readability, I annotated each task name with its belonging group name.
For example, loop.ABA belongs to task group ABA.
Look at CPU0 collumn below. [before] lacks 8 tasks and [after]
successfully shows all tasks on the runqueue, which is identical to
the result of [sched debug] that is expected to ouput correct result.
I'll send this vmcore later.
[before]
crash> runq | cat
CPU 0 RUNQUEUE: ffff88000a215f80
CURRENT: PID: 28263 TASK: ffff880037aaa040 COMMAND: "loop.ABA"
RT PRIO_ARRAY: ffff88000a216098
[no tasks queued]
CFS RB_ROOT: ffff88000a216010
[120] PID: 28262 TASK: ffff880037cc40c0 COMMAND: "loop.ABA"
<cut>
[after]
crash_fix> runq
CPU 0 RUNQUEUE: ffff88000a215f80
CURRENT: PID: 28263 TASK: ffff880037aaa040 COMMAND: "loop.ABA"
RT PRIO_ARRAY: ffff88000a216098
[no tasks queued]
CFS RB_ROOT: ffff88000a216010
[120] PID: 28262 TASK: ffff880037cc40c0 COMMAND: "loop.ABA"
[120] PID: 28271 TASK: ffff8800787a8b40 COMMAND: "loop.ABB"
[120] PID: 28272 TASK: ffff880037afd580 COMMAND: "loop.ABB"
[120] PID: 28245 TASK: ffff8800785e8b00 COMMAND: "loop.AB"
[120] PID: 28246 TASK: ffff880078628ac0 COMMAND: "loop.AB"
[120] PID: 28241 TASK: ffff880078616b40 COMMAND: "loop.AA"
[120] PID: 28239 TASK: ffff8800785774c0 COMMAND: "loop.AA"
[120] PID: 28240 TASK: ffff880078617580 COMMAND: "loop.AA"
[120] PID: 28232 TASK: ffff880079b5d4c0 COMMAND: "loop.A"
<cut>
[sched debug]
crash> runq -d
CPU 0
[120] PID: 28232 TASK: ffff880079b5d4c0 COMMAND: "loop.A"
[120] PID: 28239 TASK: ffff8800785774c0 COMMAND: "loop.AA"
[120] PID: 28240 TASK: ffff880078617580 COMMAND: "loop.AA"
[120] PID: 28241 TASK: ffff880078616b40 COMMAND: "loop.AA"
[120] PID: 28245 TASK: ffff8800785e8b00 COMMAND: "loop.AB"
[120] PID: 28246 TASK: ffff880078628ac0 COMMAND: "loop.AB"
[120] PID: 28262 TASK: ffff880037cc40c0 COMMAND: "loop.ABA"
[120] PID: 28263 TASK: ffff880037aaa040 COMMAND: "loop.ABA"
[120] PID: 28271 TASK: ffff8800787a8b40 COMMAND: "loop.ABB"
[120] PID: 28272 TASK: ffff880037afd580 COMMAND: "loop.ABB"
<cut>
Diff stat
=========
defs.h | 1 +
task.c | 37 +++++++++++++++++--------------------
2 files changed, 18 insertions(+), 20 deletions(-)
Thanks.
HATAYAMA, Daisuke
9 months, 4 weeks
[RFC] makedumpfile, crash: LZO compression support
by HATAYAMA Daisuke
Hello,
This is a RFC patch set that adds LZO compression support to
makedumpfile and crash utility. LZO is as good as in size but by far
better in speed than ZLIB, leading to reducing down time during
generation of crash dump and refiltering.
How to build:
1. Get LZO library, which is provided as lzo-devel package on recent
linux distributions, and is also available on author's website:
http://www.oberhumer.com/opensource/lzo/.
2. Apply the patch set to makedumpfile v1.4.0 and crash v6.0.0.
3. Build both using make. But for crash, do the following now:
$ make CFLAGS="-llzo2"
How to use:
I've newly used -l option for lzo compression in this patch. So for
example, do as follows:
$ makedumpfile -l vmcore dumpfile
$ crash vmlinux dumpfile
Request of configure-like feature for crash utility:
I would like configure-like feature on crash utility for users to
select wheather to add LZO feature actually or not in build-time,
that is: ./configure --enable-lzo or ./configure --disable-lzo.
The reason is that support staff often downloads and installs the
latest version of crash utility on machines where lzo library is not
provided.
Looking at the source code, it looks to me that crash does some kind
of configuration processing in a local manner, around configure.c,
and I guess it's difficult to use autoconf tools directly.
Or is there another better way?
Performance Comparison:
Sample Data
Ideally, I must have measured the performance for many enough
vmcores generated from machines that was actually running, but now
I don't have enough sample vmcores, I couldn't do so. So this
comparison doesn't answer question on I/O time improvement. This
is TODO for now.
Instead, I choosed worst and best cases regarding compression
ratio and speed only. Specifically, the former is /dev/urandom and
the latter is /dev/zero.
I get the sample data of 10MB, 100MB and 1GB by doing like this:
$ dd bs=4096 count=$((1024*1024*1024/4096)) if=/dev/urandom of=urandom.1GB
How to measure
Then I performed compression for each block, 4096 bytes, and
measured total compression time and output size. See attached
mycompress.c.
Result
See attached file result.txt.
Discussion
For both kinds of data, lzo's compression was considerably quicker
than zlib's. Compression ratio is about 37% for urandom data, and
about 8.5% for zero data. Actual situation of physical memory
would be in between the two cases, and so I guess average
compression time ratio is between 37% and 8.5%.
Although beyond the topic of this patch set, we can estimate worst
compression time on more data size since compression is performed
block size wise and the compression time increases
linearly. Estimated worst time on 2TB memory is about 15 hours for
lzo and about 40 hours for zlib. In this case, compressed data
size is larger than the original, so they are really not used,
compression time is fully meaningless. I think compression must be
done in parallel, and I'll post such patch later.
Diffstat
* makedumpfile
diskdump_mod.h | 3 +-
makedumpfile.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++------
makedumpfile.h | 12 +++++++
3 files changed, 101 insertions(+), 12 deletions(-)
* crash
defs.h | 1 +
diskdump.c | 20 +++++++++++++++++++-
diskdump.h | 3 ++-
3 files changed, 22 insertions(+), 2 deletions(-)
TODO
* evaluation including I/O time using actual vmcores
Thanks.
HATAYAMA, Daisuke
9 months, 4 weeks
Re: [Crash-utility] [RFI] Support Fujitsu's sadump dump format
by tachibana@mxm.nes.nec.co.jp
Hi Hatayama-san,
On 2011/06/29 12:12:18 +0900, HATAYAMA Daisuke <d.hatayama(a)jp.fujitsu.com> wrote:
> From: Dave Anderson <anderson(a)redhat.com>
> Subject: Re: [Crash-utility] [RFI] Support Fujitsu's sadump dump format
> Date: Tue, 28 Jun 2011 08:57:42 -0400 (EDT)
>
> >
> >
> > ----- Original Message -----
> >> Fujitsu has stand-alone dump mechanism based on firmware level
> >> functionality, which we call SADUMP, in short.
> >>
> >> We've maintained utility tools internally but now we're thinking that
> >> the best is crash utility and makedumpfile supports the sadump format
> >> for the viewpoint of both portability and maintainability.
> >>
> >> We'll be of course responsible for its maintainance in a continuous
> >> manner. The sadump dump format is very similar to diskdump format and
> >> so kdump (compressed) format, so we estimate patch set would be a
> >> relatively small size.
> >>
> >> Could you tell me whether crash utility and makedumpfile can support
> >> the sadump format? If OK, we'll start to make patchset.
I think it's not bad to support sadump by makedumpfile. However I have
several questions.
- Do you want to use makedumpfile to make an existing file that sadump has
dumped small?
- It isn't possible to support the same form as kdump-compressed format
now, is it?
- When the information that makedumpfile reads from a note of /proc/vmcore
(or a header of kdump-compressed format) is added by an extension of
makedumpfile, do you need to modify sadump?
Thanks
tachibana
> >
> > Sure, yes, the crash utility can always support another dumpfile format.
> >
>
> Thanks. It helps a lot.
>
> > It's unclear to me how similar SADUMP is to diskdump/compressed-kdump.
> > Does your internal version patch diskdump.c, or do you maintain your
> > own "sadump.c"? I ask because if your patchset is at all intrusive,
> > I'd prefer it be kept in its own file, primarily for maintainability,
> > but also because SADUMP is essentially a black-box to anybody outside
> > Fujitsu.
>
> What I meant when I used ``similar'' is both literally and
> logically. The format consists of diskdump header-like header, two
> kinds of bitmaps used for the same purpose as those in diskump format,
> and memory data. They can be handled in common with the existing data
> structure, diskdump_data, non-intrusively, so I hope they are placed
> in diskdump.c.
>
> On the other hand, there's a code to be placed at such specific
> area. sadump is triggered depending on kdump's progress and so
> register values to be contained in vmcore varies according to the
> progress: If crash_notes has been initialized when sadump is
> triggered, sadump packs the register values in crash_notes; if not
> yet, packs registers gathered by firmware. This is sadump specific
> processing, so I think putting it in specific sadump.c file is a
> natural and reasonable choise.
>
> Anyway, I have not made any patch set for this. I'll post a patch set
> when I complete.
>
> Again, thanks a lot for the positive answer.
>
> Thanks.
> HATAYAMA, Daisuke
>
>
> _______________________________________________
> kexec mailing list
> kexec(a)lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
9 months, 4 weeks
Re: [Crash-utility] [PATCH v3 5/6] Update the maple tree help info for tree cmd
by lijiang
On Tue, Dec 6, 2022 at 4:40 PM <crash-utility-request(a)redhat.com> wrote:
> Date: Tue, 6 Dec 2022 16:40:21 +0800
> From: Tao Liu <ltao(a)redhat.com>
> To: crash-utility(a)redhat.com
> Subject: [Crash-utility] [PATCH v3 5/6] Update the maple tree help
> info for tree cmd
> Message-ID: <20221206084022.58693-6-ltao(a)redhat.com>
> Content-Type: text/plain; charset="US-ASCII"; x-default=true
>
> Signed-off-by: Tao Liu <ltao(a)redhat.com>
> ---
> help.c | 46 ++++++++++++++++++++++++----------------------
> 1 file changed, 24 insertions(+), 22 deletions(-)
>
> diff --git a/help.c b/help.c
> index 99214c1..f764d08 100644
> --- a/help.c
> +++ b/help.c
> @@ -6306,19 +6306,20 @@ NULL
>
> char *help_tree[] = {
> "tree",
> -"display radix tree, XArray or red-black tree",
> -"[-t [radix|xarray|rbtree]] [-r offset] [-[s|S] struct[.member[,member]]]\n -[x|d] [-o offset] [-l] [-p] [-N] start",
> -" This command dumps the contents of a radix tree, an XAarray, or a red-black",
> -" tree. The arguments are as follows:\n",
> +"display radix tree, XArray, red-black tree or maple tree",
> +"[-t [radix|xarray|rbtree|maple]] [-r offset] [-[s|S] struct[.member[,member]]]\n"
> +" -[x|d] [-o offset] [-l] [-p] [-v] [-N] start",
> +" This command dumps the contents of a radix tree, an XAarray, a red-black",
> +" tree, or a maple tree. The arguments are as follows:\n",
> " -t type The type of tree to dump; the type string can be one of ",
> -" \"radix\", \"rbtree\", or \"xarray\", or alternatively, \"ra\",",
> -" \"rb\" or \"x\" are acceptable. If not specified, rbtree is the",
> -" default type.",
> +" \"radix\", \"rbtree\", \"xarray\", or \"maple\", or alternatively,",
> +" \"ra\", \"rb\", \"x\" or \"m\" are acceptable. If not specified,",
> +" rbtree is the default type.",
> " -r offset If the \"start\" argument is the address of a data structure that",
> -" contains an radix_tree_root, xarray or rb_root structure, then this",
> -" is the offset to that structure member. If the offset is non-zero,",
> -" then this option is required. The offset may be entered in either",
> -" of two manners:",
> +" contains an radix_tree_root, maple_tree, xarray or rb_root",
> +" structure, then this is the offset to that structure member. If",
> +" the offset is non-zero, then this option is required. The offset",
> +" may be entered in either of two manners:",
> " 1. In \"structure.member\" format.",
> " 2. A number of bytes.",
> " -o offset For red-black trees only, the offset of the rb_node within its ",
> @@ -6347,25 +6348,26 @@ char *help_tree[] = {
> " -p Display the node's position information, showing the relationship",
> " between it and the root. For red-black trees, a position that",
> " indicates \"root/l/r\" means that the node is the right child",
> -" of the left child of the root node. For radix trees and xarrays,",
> -" the index, the height, and the slot index values are shown with",
> -" respect to the root.",
> +" of the left child of the root node. For radix trees, xarrays and",
> +" maple trees, the index, the height, and the slot index values are",
> +" shown with respect to the root.",
> " -x Override default output format with hexadecimal format.",
> " -d Override default output format with decimal format.",
> +" -v For maple trees only, showing the contents of each maple tree node.",
> " ",
> " The meaning of the \"start\" argument, which can be expressed either in",
> " hexadecimal format or symbolically, depends upon whether the -N option",
> " is prepended:",
> " ",
> -" start The address of a radix_tree_root, xarray or rb_root structure, or",
> -" the address of a structure containing the radix_tree_root, xarray",
> -" or rb_root structure; if the latter, then the \"-r offset\" option",
> -" must be used if the member offset of the root structure is ",
> -" non-zero.",
> +" start The address of a radix_tree_root, maple_tree, xarray or rb_root",
> +" structure, or the address of a structure containing the",
> +" radix_tree_root, maple_tree, xarray or rb_root structure; if the",
> +" latter, then the \"-r offset\" option must be used if the member",
> +" offset of the root structure is non-zero.",
> " ",
> -" -N start The address of a radix_tree_node, xa_node or rb_node structure,",
> -" bypassing the radix_tree_root, xarray, or rb_root that points",
> -" to it.",
> +" -N start The address of a radix_tree_node, maple_node, xa_node or rb_node",
> +" structure, bypassing the radix_tree_root, maple_tree, xarray, or",
> +" rb_root that points to it.",
> "",
> "\nEXAMPLES",
> " The vmap_area_root is a standalone rb_root structure. Display the ",
Could you please also add a simple example for the maple tree option
to the above EXAMPLES section? That looks more helpful.
BTW: I noticed that you had put several examples to patch[2] log.
Thanks.
Lianbo
> --
> 2.33.1
1 year, 8 months
Re: [Crash-utility] [PATCH v3 2/6] Add tree cmd support for maple tree
by lijiang
On Tue, Dec 6, 2022 at 4:40 PM <crash-utility-request(a)redhat.com> wrote:
> Date: Tue, 6 Dec 2022 16:40:18 +0800
> From: Tao Liu <ltao(a)redhat.com>
> To: crash-utility(a)redhat.com
> Subject: [Crash-utility] [PATCH v3 2/6] Add tree cmd support for maple
> tree
> Message-ID: <20221206084022.58693-3-ltao(a)redhat.com>
> Content-Type: text/plain; charset="US-ASCII"; x-default=true
>
> Maple tree is a new data structure for crash, so cmd_tree support is
> needed for users to dump and view the content of maple tree. This patch
> achieves this by porting mt_dump() and its related functions from kernel,
> and adapting them with tree cmd.
>
> We introduced a new -v arg specifically for dumping the complete
> content of maple tree:
>
> crash> tree -t maple 0xffff9034c006aec0 -v
>
> maple_tree(ffff9034c006aec0) flags 309, height 2 root 0xffff9034de70041e
>
> 0-18446744073709551615: node 0xffff9034de700400 depth 0 type 3 parent 0xffff9034c006aec1 contents:...
> 0-140112331583487: node 0xffff9034c01e8800 depth 1 type 1 parent 0xffff9034de700406 contents:...
> 0-94643156942847: (nil)
> 94643156942848-94643158024191: 0xffff9035131754c0
> 94643158024192-94643160117247: (nil)
> ...
>
> The old tree args can work as well:
>
> crash> tree -t maple -r mm_struct.mm_mt 0xffff9034c006aec0 -p
> ffff9035131754c0
> index: 0 position: root/0/1
> ffff9035131751c8
> index: 1 position: root/0/3
> ffff9035131757b8
> index: 2 position: root/0/4
> ...
>
> crash> tree -t maple 0xffff9034c006aec0 -p -x -s vm_area_struct.vm_start,vm_end
> ffff9035131754c0
> index: 0 position: root/0/1
> vm_start = 0x5613d3c00000,
> vm_end = 0x5613d3d08000,
> ffff9035131751c8
> index: 1 position: root/0/3
> vm_start = 0x5613d3f07000,
> vm_end = 0x5613d3f0b000,
> ffff9035131757b8
> index: 2 position: root/0/4
> vm_start = 0x5613d3f0b000,
> vm_end = 0x5613d3f14000,
> ....
>
> Signed-off-by: Tao Liu <ltao(a)redhat.com>
> ---
> defs.h | 1 +
> maple_tree.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++
> tools.c | 64 ++++++++++++++++++++++++++++++++++++++--------------
> 3 files changed, 110 insertions(+), 17 deletions(-)
>
> diff --git a/defs.h b/defs.h
> index 792b007..cc40cba 100644
> --- a/defs.h
> +++ b/defs.h
> @@ -2704,6 +2704,7 @@ struct tree_data {
> #define TREE_PARSE_MEMBER (VERBOSE << 7)
> #define TREE_READ_MEMBER (VERBOSE << 8)
> #define TREE_LINEAR_ORDER (VERBOSE << 9)
> +#define TREE_STRUCT_VERBOSE (VERBOSE << 10)
>
> #define ALIAS_RUNTIME (1)
> #define ALIAS_RCLOCAL (2)
> diff --git a/maple_tree.c b/maple_tree.c
> index e27369b..756dc0a 100644
> --- a/maple_tree.c
> +++ b/maple_tree.c
> @@ -186,6 +186,10 @@ static void do_mt_range64(void *maple_tree_mt, void *entry,
>
> maple_range_64_node = tmp_node + OFFSET(maple_node_mr64);
>
> + if (td && td->flags & TREE_STRUCT_VERBOSE) {
> + dump_mt_range64(maple_range_64_node);
> + }
> +
> for (i = 0; i < mt_slots[maple_range_64]; i++) {
> last = max;
>
> @@ -246,6 +250,10 @@ static void do_mt_arange64(void *maple_tree_mt, void *entry,
>
> maple_arange_64_node = tmp_node + OFFSET(maple_node_ma64);
>
> + if (td && td->flags & TREE_STRUCT_VERBOSE) {
> + dump_mt_arange64(maple_arange_64_node);
> + }
> +
> for (i = 0; i < mt_slots[maple_arange_64]; i++) {
> last = max;
>
> @@ -294,6 +302,50 @@ static void do_mt_entry(void *entry, unsigned long min, unsigned long max,
>
> if (!td)
> return;
> +
> + if (!td->count && td->structname_args) {
> + /*
> + * Retrieve all members' info only once (count == 0)
> + * After last iteration all memory will be freed up
> + */
> + e = (struct req_entry **)GETBUF(sizeof(*e) * td->structname_args);
> + for (i = 0; i < td->structname_args; i++)
> + e[i] = fill_member_offsets(td->structname[i]);
> + }
> +
> + td->count++;
> +
> + if (td->flags & TREE_STRUCT_VERBOSE) {
> + dump_mt_entry(entry, min, max, depth);
> + } else if (td->flags & VERBOSE && entry)
> + fprintf(fp, "%lx\n", (ulong)entry);
> + if (td->flags & TREE_POSITION_DISPLAY && entry)
> + fprintf(fp, " index: %ld position: %s/%u\n",
> + (*global_index)++, path, index);
> +
> + if (td->structname) {
> + if (td->flags & TREE_STRUCT_RADIX_10)
> + print_radix = 10;
> + else if (td->flags & TREE_STRUCT_RADIX_16)
> + print_radix = 16;
> + else
> + print_radix = 0;
> +
> + for (i = 0; i < td->structname_args; i++) {
> + switch (count_chars(td->structname[i], '.')) {
> + case 0:
> + dump_struct(td->structname[i],
> + (ulong)entry, print_radix);
> + break;
> + default:
> + if (td->flags & TREE_PARSE_MEMBER)
> + dump_struct_members_for_tree(td, i, (ulong)entry);
> + else if (td->flags & TREE_READ_MEMBER)
> + dump_struct_members_fast(e[i], print_radix, (ulong)entry);
> + break;
Seems the above "break" is redundant. The default is at the end of the
switch, it can be dropped.
Thanks.
Lianbo
> + }
> + }
> + }
> }
>
> static void do_mt_node(void *maple_tree_mt, void *entry,
> @@ -313,6 +365,10 @@ static void do_mt_node(void *maple_tree_mt, void *entry,
> readmem((ulong)maple_node, KVADDR, tmp_node, SIZE(maple_node_struct),
> "mt_dump_node read maple_node", FAULT_ON_ERROR);
>
> + if (td && td->flags & TREE_STRUCT_VERBOSE) {
> + dump_mt_node(maple_node, tmp_node, type, min, max, depth);
> + }
> +
> switch (type) {
> case maple_dense:
> for (i = 0; i < mt_slots[maple_dense]; i++) {
> @@ -359,6 +415,12 @@ static int do_maple_tree_traverse(ulong ptr, int is_root,
> "mt_dump read maple_tree", FAULT_ON_ERROR);
> entry = *(void **)(tmp_tree + OFFSET(maple_tree_ma_root));
>
> + if (td && td->flags & TREE_STRUCT_VERBOSE) {
> + fprintf(fp, "maple_tree(%lx) flags %X, height %u root %p\n\n",
> + ptr, *(unsigned int *)(tmp_tree + OFFSET(maple_tree_ma_flags)),
> + mt_height(tmp_tree), entry);
> + }
> +
> if (!xa_is_node(entry))
> do_mt_entry(entry, 0, 0, 0, 0, path, &global_index, ops);
> else if (entry) {
> diff --git a/tools.c b/tools.c
> index 39306c1..4e72c60 100644
> --- a/tools.c
> +++ b/tools.c
> @@ -30,7 +30,7 @@ static void dealloc_hq_entry(struct hq_entry *);
> static void show_options(void);
> static void dump_struct_members(struct list_data *, int, ulong);
> static void rbtree_iteration(ulong, struct tree_data *, char *);
> -static void dump_struct_members_for_tree(struct tree_data *, int, ulong);
> +void dump_struct_members_for_tree(struct tree_data *, int, ulong);
>
> struct req_entry {
> char *arg, *name, **member;
> @@ -40,8 +40,8 @@ struct req_entry {
> };
>
> static void print_value(struct req_entry *, unsigned int, ulong, unsigned int);
> -static struct req_entry *fill_member_offsets(char *);
> -static void dump_struct_members_fast(struct req_entry *, int, ulong);
> +struct req_entry *fill_member_offsets(char *);
> +void dump_struct_members_fast(struct req_entry *, int, ulong);
>
> FILE *
> set_error(char *target)
> @@ -3666,7 +3666,7 @@ dump_struct_members_fast(struct req_entry *e, int radix, ulong p)
> }
> }
>
> -static struct req_entry *
> +struct req_entry *
> fill_member_offsets(char *arg)
> {
> int j;
> @@ -4307,6 +4307,7 @@ dump_struct_members(struct list_data *ld, int idx, ulong next)
> #define RADIXTREE_REQUEST (0x1)
> #define RBTREE_REQUEST (0x2)
> #define XARRAY_REQUEST (0x4)
> +#define MAPLE_REQUEST (0x8)
>
> void
> cmd_tree()
> @@ -4317,6 +4318,7 @@ cmd_tree()
> struct datatype_member struct_member, *sm;
> struct syment *sp;
> ulong value;
> + char *type_name = NULL;
>
> type_flag = 0;
> root_offset = 0;
> @@ -4324,25 +4326,33 @@ cmd_tree()
> td = &tree_data;
> BZERO(td, sizeof(struct tree_data));
>
> - while ((c = getopt(argcnt, args, "xdt:r:o:s:S:plN")) != EOF) {
> + while ((c = getopt(argcnt, args, "xdt:r:o:s:S:plNv")) != EOF) {
> switch (c)
> {
> case 't':
> - if (type_flag & (RADIXTREE_REQUEST|RBTREE_REQUEST|XARRAY_REQUEST)) {
> + if (type_flag & (RADIXTREE_REQUEST|RBTREE_REQUEST|XARRAY_REQUEST|MAPLE_REQUEST)) {
> error(INFO, "multiple tree types may not be entered\n");
> cmd_usage(pc->curcmd, SYNOPSIS);
> }
>
> if (STRNEQ(optarg, "ra"))
> - if (MEMBER_EXISTS("radix_tree_root", "xa_head"))
> + if (MEMBER_EXISTS("radix_tree_root", "xa_head")) {
> type_flag = XARRAY_REQUEST;
> - else
> + type_name = "Xarrays";
> + } else {
> type_flag = RADIXTREE_REQUEST;
> - else if (STRNEQ(optarg, "rb"))
> + type_name = "radix trees";
> + }
> + else if (STRNEQ(optarg, "rb")) {
> type_flag = RBTREE_REQUEST;
> - else if (STRNEQ(optarg, "x"))
> + type_name = "rbtrees";
> + } else if (STRNEQ(optarg, "x")) {
> type_flag = XARRAY_REQUEST;
> - else {
> + type_name = "Xarrays";
> + } else if (STRNEQ(optarg, "m")) {
> + type_flag = MAPLE_REQUEST;
> + type_name = "maple trees";
> + } else {
> error(INFO, "invalid tree type: %s\n", optarg);
> cmd_usage(pc->curcmd, SYNOPSIS);
> }
> @@ -4417,6 +4427,9 @@ cmd_tree()
> "-d and -x are mutually exclusive\n");
> td->flags |= TREE_STRUCT_RADIX_10;
> break;
> + case 'v':
> + td->flags |= TREE_STRUCT_VERBOSE;
> + break;
> default:
> argerrs++;
> break;
> @@ -4426,13 +4439,14 @@ cmd_tree()
> if (argerrs)
> cmd_usage(pc->curcmd, SYNOPSIS);
>
> - if ((type_flag & (XARRAY_REQUEST|RADIXTREE_REQUEST)) && (td->flags & TREE_LINEAR_ORDER))
> - error(FATAL, "-l option is not applicable to %s\n",
> - type_flag & RADIXTREE_REQUEST ? "radix trees" : "Xarrays");
> + if ((type_flag & (XARRAY_REQUEST|RADIXTREE_REQUEST|MAPLE_REQUEST)) && (td->flags & TREE_LINEAR_ORDER))
> + error(FATAL, "-l option is not applicable to %s\n", type_name);
>
> - if ((type_flag & (XARRAY_REQUEST|RADIXTREE_REQUEST)) && (td->flags & TREE_NODE_OFFSET_ENTERED))
> - error(FATAL, "-o option is not applicable to %s\n",
> - type_flag & RADIXTREE_REQUEST ? "radix trees" : "Xarrays");
> + if ((type_flag & (XARRAY_REQUEST|RADIXTREE_REQUEST|MAPLE_REQUEST)) && (td->flags & TREE_NODE_OFFSET_ENTERED))
> + error(FATAL, "-o option is not applicable to %s\n", type_name);
> +
> + if ((type_flag & (RBTREE_REQUEST|XARRAY_REQUEST|RADIXTREE_REQUEST)) && (td->flags & TREE_STRUCT_VERBOSE))
> + error(FATAL, "-v option is not applicable to %s\n", type_name);
>
> if ((td->flags & TREE_ROOT_OFFSET_ENTERED) &&
> (td->flags & TREE_NODE_POINTER))
> @@ -4506,12 +4520,26 @@ next_arg:
> if (td->flags & TREE_STRUCT_RADIX_16)
> fprintf(fp, "%sTREE_STRUCT_RADIX_16",
> others++ ? "|" : "");
> + if (td->flags & TREE_PARSE_MEMBER)
> + fprintf(fp, "%sTREE_PARSE_MEMBER",
> + others++ ? "|" : "");
> + if (td->flags & TREE_READ_MEMBER)
> + fprintf(fp, "%sTREE_READ_MEMBER",
> + others++ ? "|" : "");
> + if (td->flags & TREE_LINEAR_ORDER)
> + fprintf(fp, "%sTREE_LINEAR_ORDER",
> + others++ ? "|" : "");
> + if (td->flags & TREE_STRUCT_VERBOSE)
> + fprintf(fp, "%sTREE_STRUCT_VERBOSE",
> + others++ ? "|" : "");
> fprintf(fp, ")\n");
> fprintf(fp, " type: ");
> if (type_flag & RADIXTREE_REQUEST)
> fprintf(fp, "radix\n");
> else if (type_flag & XARRAY_REQUEST)
> fprintf(fp, "xarray\n");
> + else if (type_flag & MAPLE_REQUEST)
> + fprintf(fp, "maple\n");
> else
> fprintf(fp, "red-black%s",
> type_flag & RBTREE_REQUEST ?
> @@ -4532,6 +4560,8 @@ next_arg:
> do_rdtree(td);
> else if (type_flag & XARRAY_REQUEST)
> do_xatree(td);
> + else if (type_flag & MAPLE_REQUEST)
> + do_mptree(td);
> else
> do_rbtree(td);
> hq_close();
> --
> 2.33.1
1 year, 8 months