[PATCH 0/2] Get diskio statistics from the hw queues in blk-mq
by Lianbo Jiang
Currently, crash doesn't support to display disk I/O statistics
for blk-mq devices. The patchset will implement it by parsing
the bitmap, it includes two patches:
[1] [PATCH 1/2] Support for "dev -d|-D" options by parsing bitmap in
blk-mq layer
[2] [PATCH 2/2] Fix for "dev -d|-D" options to correctly display disk I/O
statistics
Related kernel commits:
[1] commit <9a14d6ce4135> ("block: remove debugfs blk_mq_ctx
dispatched/merged/completed attributes")
[2] commit <4e5cc99e1e48> ("blk-mq: manage hctx map via xarray")
[3] commit <3301bc53358a> ("lib/sbitmap: kill 'depth' from sbitmap_word")
The patchset is tested on v5.17.0-rc8 and the latest kernel 5.18.0-rc4.
Lianbo Jiang (2):
Support for "dev -d|-D" options by parsing bitmap in blk-mq layer
Fix for "dev -d|-D" options to correctly display disk I/O statistics
defs.h | 14 ++
dev.c | 373 ++++++++++++++++++++++++++++++++++++++++++++++++------
symbols.c | 28 ++++
3 files changed, 376 insertions(+), 39 deletions(-)
--
2.20.1
2 years, 6 months
[ANNOUNCE] crash-7.3.2 is available
by HAGIO KAZUHITO(萩尾 一仁)
Download from: https://crash-utility.github.io/
or
https://github.com/crash-utility/crash/releases
As announced before, this crash-7.3.2 is the last release for crash 7.x.
Changelog:
41da48e crash-7.3.1 -> crash-7.3.2
df1fd92 diskdump: Optimize the boot time
bf24b45 diskdump: use mmap/madvise to improve the start-up
bbd6f7b arm64: handle 1GB block for VM_L4_4K
b654750 Fix for "kmem -s|-S" on Linux 5.17+ with CONFIG_SLAB
ef0bf92 Fix the failure of resolving ".rodata" on s390x
7d34768 kernel: fix start-up time degradation caused by strings command
502d605 arm64: fix the seek error of "pud page" for live debugging
d497af9 arm64: fix the wrong vmemmap_end
386d4b5 arm64: use the vmcore info to get module/vmalloc/vmemmap ranges
dc42750 arm64: update the modules/vmalloc/vmemmap ranges
e42559f sbitmap.c: use readmem more carefully
48630a9 Fix memory leak in __sbitmap_for_each_set function
5daaa09 help.c: Fix a missing new line in "sbitmapq" help page
0e2841d arm64: deduce the start address of kernel code, based on kernel version
c5ea36c Makefile: Change the behavior of target "cscope"
7b4b459 Fix sys command to display its help information correctly
95f1acd Makefile: crash multi-target and multithread compile support
f00d105 x86_64_init: Refresh vmalloc region addresses in POST_RELOC instead of POST_GDB phase
949c6e1 sbitmapq: add '-p' option
33c7508 Introduce sbitmapq command
9077a35 arm64: Use CONFIG_ARM64_VA_BITS to initialize VA_BITS_ACTUAL
bc5c3b4 log: support "log -t|-m" option for output of printk safe buffers
1aec6f8 log: introduce "log -s" option to display printk safe buffers
4c9bfec Makefile: Fix build failure with "make -j jobs" option
2b3215d Support for multiple jobs to build crash
fe81838 Doc: update man page for the option "--src directory"
c235e2b Fix for "bpf -m|-M" options to appropriately display MEMLOCK and UID
86446ea Fix for "kmem -s|-S" and "bt -F[F]" on Linux 5.17-rc1
1a1fd21 arm64: Fix segfault by "bt" command with offline cpus
d52cccf Improve the ps performance for vmcores with large number of threads
bbd5a5c Remove ptype command from "ps -t" option to reduce memory and time
fa0b645 Move the initialization of "boot_date" to task_init()
a392b27 memory: Handle struct slab changes on Linux 5.17-rc1 and later
f5637f3 Fix for HZ calculation on Linux 5.14 and later
1706f8b Fix for "bt -v" option to display the stack-end address correctly
c481779 Fix for "timer -r" option to display all the per-CPU clocks
78255e3 Handle blk_mq_ctx member changes for kernels 5.16-rc1 and later
5c4f786 Fix pvops Xen detection for arm machine
a0eec39 defs.h: fix breakage of compatibility of struct symbol_table_data for extension modules
c05db8d arm64: Support overflow stack panic
967be7b Mark start of 7.3.2 development phase with version 7.3.1++
Full changelog: https://crash-utility.github.io/changelog/ChangeLog-7.3.2.txt
2 years, 7 months
[ANNOUNCE] crash-8.0.1 is available
by HAGIO KAZUHITO(萩尾 一仁)
Download from: https://crash-utility.github.io/
or
https://github.com/crash-utility/crash/releases
The GitHub master branch serves as a development branch that will contain
all patches that are queued for the next release:
$ git clone https://github.com/crash-utility/crash.git
Changelog:
2d19346 crash-8.0.0 -> crash-8.0.1
b811a04 diskdump: Optimize the boot time
a334423 diskdump: use mmap/madvise to improve the start-up
8736908 arm64: handle 1GB block for VM_L4_4K
b89f9cc Fix for "kmem -s|-S" on Linux 5.17+ with CONFIG_SLAB
8d49ad6 Fix the failure of resolving ".rodata" on s390x
cd89540 kernel: fix start-up time degradation caused by strings command
8827424 arm64: fix the seek error of "pud page" for live debugging
49df472 arm64: fix the wrong vmemmap_end
01689f3 arm64: use the vmcore info to get module/vmalloc/vmemmap ranges
e397e1b arm64: update the modules/vmalloc/vmemmap ranges
4cf262e sbitmap.c: use readmem more carefully
7c7a4ed Fix memory leak in __sbitmap_for_each_set function
a92ff26 help.c: Fix a missing new line in "sbitmapq" help page
e3bdc32 arm64: deduce the start address of kernel code, based on kernel version
8f19dde Makefile: Change the behavior of target "cscope"
c1f45f8 Fix sys command to display its help information correctly
0260367 Makefile: crash multi-target and multithread compile support
b1fb3cd x86_64_init: Refresh vmalloc region addresses in POST_RELOC instead of POST_GDB phase
fb64fdd sbitmapq: add '-p' option
ac86cc3 Introduce sbitmapq command
6ecb8a2 arm64: Use CONFIG_ARM64_VA_BITS to initialize VA_BITS_ACTUAL
3ed30b5 log: support "log -t|-m" option for output of printk safe buffers
b0d447d log: introduce "log -s" option to display printk safe buffers
def34f5 Makefile: Fix build failure with "make -j jobs" option
74ac929 Support for multiple jobs to build crash
0a4434f Doc: update man page for the option "--src directory"
1ecb351 Fix for "bpf -m|-M" options to appropriately display MEMLOCK and UID
5f390ed Fix for "kmem -s|-S" and "bt -F[F]" on Linux 5.17-rc1
dd35cf6 arm64: Fix segfault by "bt" command with offline cpus
e389667 Improve the ps performance for vmcores with large number of threads
ce92e45 GDB: fix completion related libstdc++ assert
2ebd8c5 Remove ptype command from "ps -t" option to reduce memory and time
d16dc6f Move the initialization of "boot_date" to task_init()
14f8c46 memory: Handle struct slab changes on Linux 5.17-rc1 and later
b9dc76e Fix for HZ calculation on Linux 5.14 and later
0d3d80b Fix for "bt -v" option to display the stack-end address correctly
70a27ae Fix for "timer -r" option to display all the per-CPU clocks
98b417f Handle blk_mq_ctx member changes for kernels 5.16-rc1 and later
7eba220 Fix pvops Xen detection for arm machine
6968345 defs.h: fix breakage of compatibility of struct symbol_table_data for extension modules
c477b04 defs.h: fix breakage of compatibility of struct machdep_table for extension modules
995db8a arm64: Support overflow stack panic
d9b11dd Mark start of 8.0.1 development phase with version 8.0.0++
Full changelog: https://crash-utility.github.io/changelog/ChangeLog-8.0.1.txt
2 years, 7 months
Re: [Crash-utility] [PATCH v2] diskdump: Optimize the boot time
by lijiang
Hi, Shijie
Thank you for the update.
On Wed, Mar 30, 2022 at 8:00 PM <crash-utility-request(a)redhat.com> wrote:
> Date: Wed, 30 Mar 2022 19:03:23 +0000
> From: Huang Shijie <shijie(a)os.amperecomputing.com>
> To: k-hagio-ab(a)nec.com, lijiang(a)redhat.com
> Cc: patches(a)amperecomputing.com, zwang(a)amperecomputing.com,
> darren(a)os.amperecomputing.com, crash-utility(a)redhat.com, Huang
> Shijie
> <shijie(a)os.amperecomputing.com>
> Subject: [Crash-utility] [PATCH v2] diskdump: Optimize the boot time
> Message-ID: <20220330190323.2420144-1-shijie(a)os.amperecomputing.com>
> Content-Type: text/plain
>
> 1.) The vmcore file maybe very big.
>
> For example, I have a vmcore file which is over 23G,
> and the panic kernel had 767.6G memory,
> its max_sect_len is 4468736.
>
> Current code costs too much time to do the following loop:
> ..............................................
> for (i = 1; i < max_sect_len + 1; i++) {
> dd->valid_pages[i] = dd->valid_pages[i - 1];
> for (j = 0; j < BITMAP_SECT_LEN; j++, pfn++)
> if (page_is_dumpable(pfn))
> dd->valid_pages[i]++;
> ..............................................
>
> For my case, it costs about 56 seconds to finish the
> big loop.
>
> This patch moves the hweightXX macros to defs.h,
> and uses hweight64 to optimize the loop.
>
> For my vmcore, the loop only costs about one second now.
>
> 2.) Tests result:
> # cat ./commands.txt
> quit
>
> Before:
>
> #echo 3 > /proc/sys/vm/drop_caches;
> #time ./crash -i ./commands.txt /root/t/vmlinux /root/t/vmcore >
> /dev/null 2>&1
> ............................
> real 1m54.259s
> user 1m12.494s
> sys 0m3.857s
> ............................
>
> After this patch:
>
> #echo 3 > /proc/sys/vm/drop_caches;
> #time ./crash -i ./commands.txt /root/t/vmlinux /root/t/vmcore >
> /dev/null 2>&1
> ............................
> real 0m55.217s
> user 0m15.114s
> sys 0m3.560s
> ............................
>
> Signed-off-by: Huang Shijie <shijie(a)os.amperecomputing.com>
> ---
> v1 --> v2:
> 1.) change u64 to ulonglong.
> 2.) compile this patch in x86_64.
>
> ---
> defs.h | 20 ++++++++++++++++++++
> diskdump.c | 12 +++++++++---
> sbitmap.c | 19 -------------------
> 3 files changed, 29 insertions(+), 22 deletions(-)
>
> diff --git a/defs.h b/defs.h
> index 81ac049..1e8360d 100644
> --- a/defs.h
> +++ b/defs.h
> @@ -4531,6 +4531,26 @@ struct machine_specific {
> #define NUM_IN_BITMAP(bitmap, x) (bitmap[(x)/BITS_PER_LONG] &
> NUM_TO_BIT(x))
> #define SET_BIT(bitmap, x) (bitmap[(x)/BITS_PER_LONG] |= NUM_TO_BIT(x))
>
> +static inline unsigned int __const_hweight8(unsigned long w)
> +{
> + return
> + (!!((w) & (1ULL << 0))) +
> + (!!((w) & (1ULL << 1))) +
> + (!!((w) & (1ULL << 2))) +
> + (!!((w) & (1ULL << 3))) +
> + (!!((w) & (1ULL << 4))) +
> + (!!((w) & (1ULL << 5))) +
> + (!!((w) & (1ULL << 6))) +
> + (!!((w) & (1ULL << 7)));
> +}
> +
> +#define __const_hweight16(w) (__const_hweight8(w) +
> __const_hweight8((w) >> 8))
> +#define __const_hweight32(w) (__const_hweight16(w) +
> __const_hweight16((w) >> 16))
> +#define __const_hweight64(w) (__const_hweight32(w) +
> __const_hweight32((w) >> 32))
> +
> +#define hweight32(w) __const_hweight32(w)
> +#define hweight64(w) __const_hweight64(w)
> +
>
No need to move the above code from sbitmap.c to defs.h, a simple way is to
implement a new function in sbitmap.c and add its definition in defs.h,
that will
be easy to call it in diskdump.c. For example:
diff --git a/defs.h b/defs.h
index 81ac0498dac7..0c5115e71f1c 100644
--- a/defs.h
+++ b/defs.h
@@ -5894,6 +5894,7 @@ typedef bool (*sbitmap_for_each_fn)(unsigned int idx,
void *p);
void sbitmap_for_each_set(const struct sbitmap_context *sc,
sbitmap_for_each_fn fn, void *data);
void sbitmap_context_load(ulong addr, struct sbitmap_context *sc);
+unsigned long get_hweight64(unsigned long w);
/* sbitmap_queue helpers */
typedef bool (*sbitmapq_for_each_fn)(unsigned int idx, ulong addr, void
*p);
diff --git a/sbitmap.c b/sbitmap.c
index 286259f71d64..628cc00c0b6b 100644
--- a/sbitmap.c
+++ b/sbitmap.c
@@ -71,6 +71,11 @@ static inline unsigned int __const_hweight8(unsigned
long w)
#define BIT(nr) (1UL << (nr))
+unsigned long get_hweight64(unsigned long w)
+{
+ return hweight64(w);
+}
+
static inline unsigned long min(unsigned long a, unsigned long b)
{
return (a < b) ? a : b;
//diskdump.c
...
dd->valid_pages[i] += get_hweight64(tmp);
...
How about the above suggestions? Shijie and Kazu.
Thanks.
Lianbo
/*
> * precision lengths for fprintf
> */
> diff --git a/diskdump.c b/diskdump.c
> index d567427..ff1e9a3 100644
> --- a/diskdump.c
> +++ b/diskdump.c
> @@ -547,6 +547,7 @@ read_dump_header(char *file)
> ulong pfn;
> int i, j, max_sect_len;
> int is_split = 0;
> + ulonglong tmp, *bitmap;
>
> if (block_size < 0)
> return FALSE;
> @@ -899,11 +900,16 @@ restart:
>
> dd->valid_pages = calloc(sizeof(ulong), max_sect_len + 1);
> dd->max_sect_len = max_sect_len;
> +
> + /* It is safe to convert it to (ulonglong *). */
> + bitmap = (ulonglong *)dd->dumpable_bitmap;
> for (i = 1; i < max_sect_len + 1; i++) {
> dd->valid_pages[i] = dd->valid_pages[i - 1];
> - for (j = 0; j < BITMAP_SECT_LEN; j++, pfn++)
> - if (page_is_dumpable(pfn))
> - dd->valid_pages[i]++;
> + for (j = 0; j < BITMAP_SECT_LEN; j += 64, pfn += 64) {
> + tmp = bitmap[pfn >> 6];
> + if (tmp)
> + dd->valid_pages[i] += hweight64(tmp);
> + }
> }
>
> return TRUE;
> diff --git a/sbitmap.c b/sbitmap.c
> index 286259f..96a61e6 100644
> --- a/sbitmap.c
> +++ b/sbitmap.c
> @@ -49,25 +49,6 @@ struct sbitmapq_data {
>
> static uint sb_flags = 0;
>
> -static inline unsigned int __const_hweight8(unsigned long w)
> -{
> - return
> - (!!((w) & (1ULL << 0))) +
> - (!!((w) & (1ULL << 1))) +
> - (!!((w) & (1ULL << 2))) +
> - (!!((w) & (1ULL << 3))) +
> - (!!((w) & (1ULL << 4))) +
> - (!!((w) & (1ULL << 5))) +
> - (!!((w) & (1ULL << 6))) +
> - (!!((w) & (1ULL << 7)));
> -}
> -
> -#define __const_hweight16(w) (__const_hweight8(w) +
> __const_hweight8((w) >> 8))
> -#define __const_hweight32(w) (__const_hweight16(w) +
> __const_hweight16((w) >> 16))
> -#define __const_hweight64(w) (__const_hweight32(w) +
> __const_hweight32((w) >> 32))
> -
> -#define hweight32(w) __const_hweight32(w)
> -#define hweight64(w) __const_hweight64(w)
>
> #define BIT(nr) (1UL << (nr))
>
> --
> 2.30.2
>
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> --
> Crash-utility mailing list
> Crash-utility(a)redhat.com
> https://listman.redhat.com/mailman/listinfo/crash-utility
>
>
> ------------------------------
>
> End of Crash-utility Digest, Vol 198, Issue 45
> **********************************************
>
>
2 years, 7 months
Re: [Crash-utility] invalid structure member offset: page_active #115
by lijiang
On Fri, Apr 8, 2022 at 8:00 PM <crash-utility-request(a)redhat.com> wrote:
> Date: Fri, 8 Apr 2022 05:44:33 +0000
> From: HAGIO KAZUHITO(?????) <k-hagio-ab(a)nec.com>
> To: sholck <xiaer1921(a)gmail.com>, "lijiang(a)redhat.com"
> <lijiang(a)redhat.com>
> Cc: "Discussion list for crash utility usage, maintenance and
> development" <crash-utility(a)redhat.com>
> Subject: Re: [Crash-utility] invalid structure member offset:
> page_active #115
> Message-ID:
> <
> TYYPR01MB677738025B44279C88396ACDDDE99(a)TYYPR01MB6777.jpnprd01.prod.outlook.com
> >
>
> Content-Type: text/plain; charset="utf-8"
>
> Hi,
>
> -----Original Message-----
> > Hi,
> >
> > I have update patch to v2 and test it is ok.
>
> Thank you for the v2 patch and testing, we will move on with this.
>
> Lianbo, I've updated its subject and indents etc. a little, attached.
>
The test passed. Applied(with Kazu's changes).
Thanks.
Lianbo
2 years, 7 months
Re: [Crash-utility] [PATCH v2] arm64: handle 1GB block for VM_L4_4K
by lijiang
On Wed, Apr 6, 2022 at 11:48 PM <crash-utility-request(a)redhat.com> wrote:
> Date: Wed, 6 Apr 2022 22:38:40 +0800
> From: Rongwei Wang <rongwei.wang(a)linux.alibaba.com>
> To: crash-utility(a)redhat.com, k-hagio-ab(a)nec.com,
> shijie(a)os.amperecomputing.com, piliu(a)redhat.com
> Subject: [Crash-utility] [PATCH v2] arm64: handle 1GB block for
> VM_L4_4K
> Message-ID: <20220406143840.76523-1-rongwei.wang(a)linux.alibaba.com>
> Content-Type: text/plain; charset="US-ASCII"; x-default=true
>
> When arm64 is configured with PAGE_SIZE=4k and 4 level
> translation, the pagetable of all pages may be created with
> block mapping or contiguous mapping as much as possible, likes
> disable CONFIG_RODATA_FULL_DEFAULT_ENABLED. But now, vtop
> command can not handle 1GB block (PUD mapping) well, and just
> shows a seek error:
>
> crash> vtop ffff00184a800000
> VIRTUAL PHYSICAL
> ffff00184a800000 188a800000
>
> PAGE DIRECTORY: ffff8000110aa000
> PGD: ffff8000110aa000 => 203fff9003
> PUD: ffff001fffff9308 => 68001880000705
> PMD: ffff0018400002a0 => ffff8000103b4fd0
> vtop: seek error: kernel virtual address: ffff7fffd03b4000 type: "page
> table"
>
> This patch fixes it, and shows as following:
>
> crash> vtop ffff00184a800000
> VIRTUAL PHYSICAL
> ffff00184a800000 188a800000
>
> PAGE DIRECTORY: ffff8000110aa000
> PGD: ffff8000110aa000 => 203fff9003
> PUD: ffff001fffff9308 => 68001880000705
> PAGE: 1880000000 (1GB)
>
> PTE PHYSICAL FLAGS
> 68001880000705 1880000000 (VALID|SHARED|AF|PXN|UXN)
>
> PAGE PHYSICAL MAPPING INDEX CNT FLAGS
> fffffe00610a0000 188a800000 0 0 0 77fffe0000000000
>
> Acked-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
> Signed-off-by: Rongwei Wang <rongwei.wang(a)linux.alibaba.com>
> ---
> arm64.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/arm64.c b/arm64.c
> index 2177c52..65f6cdf 100644
> --- a/arm64.c
> +++ b/arm64.c
> @@ -1999,6 +1999,16 @@ arm64_vtop_4level_4k(ulong pgd, ulong vaddr,
> physaddr_t *paddr, int verbose)
> if (!pud_val)
> goto no_page;
>
> + if ((pud_val & PUD_TYPE_MASK) == PUD_TYPE_SECT) {
> + ulong sectionbase = (pud_val & SECTION_PAGE_MASK_1GB) &
> PHYS_MASK;
> + if (verbose) {
> + fprintf(fp, " PAGE: %lx (1GB)\n\n", sectionbase);
> + arm64_translate_pte(pud_val, 0, 0);
> + }
> + *paddr = sectionbase + (vaddr & ~SECTION_PAGE_MASK_1GB);
> + return TRUE;
> + }
> +
> pmd_base = (ulong *)PTOV(pud_val & PHYS_MASK &
> (s32)machdep->pagemask);
> FILL_PMD(pmd_base, KVADDR, PTRS_PER_PMD_L4_4K * sizeof(ulong));
> pmd_ptr = pmd_base + (((vaddr) >> PMD_SHIFT_L4_4K) &
> (PTRS_PER_PMD_L4_4K - 1));
> --
Thank you for the fix.
The v2 looks good to me. Applied.
Thanks.
Lianbo
> 2.27.0
>
2 years, 7 months
Re: [Crash-utility] [PATCH v2] diskdump: use mmap/madvise to improve the start-up
by lijiang
On Wed, Apr 6, 2022 at 10:08 AM <crash-utility-request(a)redhat.com> wrote:
> Date: Wed, 6 Apr 2022 02:07:47 +0000
> From: HAGIO KAZUHITO(?????) <k-hagio-ab(a)nec.com>
> To: Huang Shijie <shijie(a)os.amperecomputing.com>, "lijiang(a)redhat.com"
> <lijiang(a)redhat.com>
> Cc: "patches(a)amperecomputing.com" <patches(a)amperecomputing.com>,
> "zwang(a)amperecomputing.com" <zwang(a)amperecomputing.com>,
> "darren(a)os.amperecomputing.com" <darren(a)os.amperecomputing.com>,
> "crash-utility(a)redhat.com" <crash-utility(a)redhat.com>
> Subject: Re: [Crash-utility] [PATCH v2] diskdump: use mmap/madvise to
> improve the start-up
> Message-ID:
> <
> TYYPR01MB67776D37C6B5F947EBAE6750DDE79(a)TYYPR01MB6777.jpnprd01.prod.outlook.com
> >
>
> Content-Type: text/plain; charset="iso-2022-jp"
>
> -----Original Message-----
> > 1.) The bitmap of vmcore file can be very big in the server kernel panic,
> > such as over 256M.
> >
> > This patch uses mmap/madvise to improve the read speed
> > of the bitmap in the non-FLAT_FORMAT code path.
> >
> > Use MADV_WILLNEED for madvise, it will trigger read ahead for
> > reading the bitmap.
>
> Thanks for the update.
>
> With removing the unused variables (will be fixed when merging),
> Acked-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
>
> $ make clean ; make warn
>
> diskdump.c: In function ?read_dump_header?:
> diskdump.c:543:10: warning: unused variable ?bytes_read?
> [-Wunused-variable]
> ssize_t bytes_read;
> ^~~~~~~~~~
> diskdump.c:542:9: warning: unused variable ?len? [-Wunused-variable]
> size_t len;
> ^~~
> diskdump.c:541:8: warning: unused variable ?bufptr? [-Wunused-variable]
> char *bufptr;
> ^~~~~~
>
This looks good.
Applied(with the above fix) and modified patch log.
Thanks.
Lianbo
> As for a second ack, please wait for a while.
> Lianbo is taking a leave and will be back soon.
>
> Thanks,
> Kazu
>
2 years, 7 months
Re: [Crash-utility] invalid structure member offset: page_active #115
by HAGIO KAZUHITO(萩尾 一仁)
Hi,
-----Original Message-----
> Hi,
>
> I have update patch to v2 and test it is ok.
Thank you for the v2 patch and testing, we will move on with this.
Lianbo, I've updated its subject and indents etc. a little, attached.
Thanks,
Kazu
>
> From 9284131e93fd2f0af20239a9f7ec1fb0eb3081e2 Mon Sep 17 00:00:00 2001
> From: xiaer1921 <xiaer1921(a)gmail.com>
> Date: Thu, 7 Apr 2022 15:05:17 +0800
> Subject: [PATCH] Fix for "kmem -s|-S" on Linux 5.17.0+
>
> Since the following kernel commits split slab info from struct page
> into struct slab, crash cannot get several slab related offsets from
> struct page.
>
> d122019bf061 ("mm: Split slab into its own type")
> 401fb12c68c2 ("mm: Differentiate struct slab fields by sl*b implementations")
> 07f910f9b729 ("mm: Remove slab from struct page")
>
> Without the patch, "kmem -s|-S" options cannot work correctly on kernels
> configured with CONFIG_SLAB with the following error:
>
> crash> kmem -s
> kmem: invalid structure member offset: page_active
> FILE: memory.c LINE: 12225 FUNCTION: verify_slab_overload_page()
>
> Signed-off-by: xiaer1921 <xiaer1921(a)gmail.com>
> ---
> memory.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/memory.c b/memory.c
> index 8448ddc..c8eed28 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -541,6 +541,15 @@ vm_init(void)
> ANON_MEMBER_OFFSET_INIT(page_s_mem, "page", "s_mem");
> ANON_MEMBER_OFFSET_INIT(page_freelist, "page", "freelist");
> ANON_MEMBER_OFFSET_INIT(page_active, "page", "active");
> + /*
> + * Moved to struct slab in Linux 5.17
> + */
> + if (INVALID_MEMBER(page_s_mem))
> + MEMBER_OFFSET_INIT(page_s_mem, "slab", "s_mem");
> + if (INVALID_MEMBER(page_freelist))
> + MEMBER_OFFSET_INIT(page_freelist, "slab", "freelist");
> + if (INVALID_MEMBER(page_active))
> + MEMBER_OFFSET_INIT(page_active, "slab", "active");
> }
>
> if (!VALID_STRUCT(kmem_slab_s) && VALID_STRUCT(slab_s)) {
> --
> 2.7.4
>
>
> 在 2022/4/4 下午1:59, HAGIO KAZUHITO(萩尾 一仁) 写道:
> > Hi,
> >
> > Thank you for the patch.
> >
> >> -----Original Message-----
> >> Hi.
> >>
> >> update patch:
> >>
> >> From 0f5d39e416b2fa12d6afdb0a0222b2734e139455 Mon Sep 17 00:00:00 2001
> >> From: xiaer1921 <xiaer1921(a)gmail.com>
> >> Date: Tue, 29 Mar 2022 20:03:03 +0800
> >> Subject: [PATCH] Fix for "kmem -s|-S" on Linux 5.17.0+
> >>
> >> Since the following kernel commits split slab info from struct page
> >> into struct slab, crash cannot get several slab related offsets from
> >> struct page.
> >>
> >> d122019bf061 ("mm: Split slab into its own type")
> >> 401fb12c68c2 ("mm: Differentiate struct slab fields by sl*b implementations")
> >> 07f910f9b729 ("mm: Remove slab from struct page")
> >>
> >> Without the patch, "kmem -s|-S" options cannot work
> >> correctly with the following errors:
> >
> > It would be preferable to mention CONFIG_SLAB:
> >
> > Without the patch, "kmem -s|-S" options cannot work correctly on kernels
> > configured with CONFIG_SLAB with the following error:
> >
> >>
> >> crash> kmem -s
> >> kmem: invalid structure member offset: page_active
> >> FILE: memory.c LINE: 12225 FUNCTION: verify_slab_overload_page()
> >>
> >
> >> [/usr/bin/crash] error trace: 532526 => 53353a => 5e0a6a => 5e09dc
> >> [Detaching after fork from child process 28299]
> >>
> >> 5e09dc: OFFSET_verify.part.36+92
> >> [Detaching after fork from child process 28301]
> >> 5e0a6a: OFFSET_verify+58
> >> [Detaching after fork from child process 28303]
> >> 53353a: verify_slab_overload_page+588
> >> [Detaching after fork from child process 28305]
> >> 532526: do_slab_chain_slab_overload_page+1171
> >>
> >> kmem: invalid structure member offset: page_active
> >> FILE: memory.c LINE: 12225 FUNCTION: verify_slab_overload_page()
> >
> > Please drop these extra errors.
> >
> >>
> >> Signed-off-by: xiaer1921 <xiaer1921(a)gmail.com>
> >> ---
> >> memory.c | 12 ++++++++++++
> >> 1 file changed, 12 insertions(+)
> >>
> >> diff --git a/memory.c b/memory.c
> >> index 8448ddc..6240d4c 100644
> >> --- a/memory.c
> >> +++ b/memory.c
> >> @@ -680,6 +680,12 @@ vm_init(void)
> >> MEMBER_OFFSET_INIT(slab_s_mem, "slab", "s_mem");
> >> MEMBER_OFFSET_INIT(slab_inuse, "slab", "inuse");
> >> MEMBER_OFFSET_INIT(slab_free, "slab", "free");
> >> + if (INVALID_MEMBER(page_s_mem))
> >> + MEMBER_OFFSET_INIT(page_s_mem, "slab", "s_mem");
> >> + if (INVALID_MEMBER(page_active))
> >> + MEMBER_OFFSET_INIT(page_active, "slab", "active");
> >> + if (INVALID_MEMBER(page_freelist))
> >> + MEMBER_OFFSET_INIT(page_freelist, "slab", "freelist");
> >> /*
> >> * slab members were moved to an anonymous union in 2.6.39.
> >> */
> >> @@ -691,6 +697,12 @@ vm_init(void)
> >> ANON_MEMBER_OFFSET_INIT(slab_inuse, "slab", "inuse");
> >> if (INVALID_MEMBER(slab_free))
> >> ANON_MEMBER_OFFSET_INIT(slab_free, "slab", "free");
> >> + if (INVALID_MEMBER(page_s_mem))
> >> + ANON_MEMBER_OFFSET_INIT(page_s_mem, "slab", "s_mem");
> >> + if (INVALID_MEMBER(page_active))
> >> + ANON_MEMBER_OFFSET_INIT(page_active, "slab", "active");
> >> + if (INVALID_MEMBER(page_freelist))
> >> + ANON_MEMBER_OFFSET_INIT(page_freelist, "slab", "freelist");
> >
> > Hmm, probably these additional ANON_MEMBER_OFFSET_INIT() were used for anonymous
> > union. Looking at the current kernel source, they will not be needed.
> >
> > And these OFFSET(page_s_mem) and etc. are set in the block for SLAB_OVERLOAD_PAGE,
> > so I think it would be more readable to do this here:
> >
> > diff --git a/memory.c b/memory.c
> > index 8448ddc3a16c..7339f0cd0224 100644
> > --- a/memory.c
> > +++ b/memory.c
> > @@ -541,6 +541,15 @@ vm_init(void)
> > ANON_MEMBER_OFFSET_INIT(page_s_mem, "page", "s_mem");
> > ANON_MEMBER_OFFSET_INIT(page_freelist, "page", "freelist");
> > ANON_MEMBER_OFFSET_INIT(page_active, "page", "active");
> > + /*
> > + * Moved to struct slab in Linux 5.17
> > + */
> > + if (INVALID_MEMBER(page_s_mem))
> > + MEMBER_OFFSET_INIT(page_s_mem, "slab", "s_mem");
> > + if (INVALID_MEMBER(page_freelist))
> > + MEMBER_OFFSET_INIT(page_freelist, "slab", "freelist");
> > + if (INVALID_MEMBER(page_active))
> > + MEMBER_OFFSET_INIT(page_active, "slab", "active");
> > }
> >
> > if (!VALID_STRUCT(kmem_slab_s) && VALID_STRUCT(slab_s)) {
> >
> > Could you try this and update your patch if it's ok?
> >
> > Thanks,
> > Kazu
> >
> >> }
> >>
> >> MEMBER_OFFSET_INIT(array_cache_avail, "array_cache", "avail");
> >> --
> >> 2.7.4
> >>
2 years, 7 months
[PATCH RFC] arm64: fix vtop command when handling PUD mapping
by Rongwei Wang
When arm64 is configed with PAGE_SIZE=4k and 4 level
translation, the pagetable of all pages may be created
with block mapping or contiguous mapping as much as
possible, likes disable CONFIG_RODATA_FULL_DEFAULT_ENABLED.
But now, vtop command can not handle pud mapping well, and
just shows a seek error:
crash> vtop ffff00184a800000
VIRTUAL PHYSICAL
ffff00184a800000 188a800000
PAGE DIRECTORY: ffff8000110aa000
PGD: ffff8000110aa000 => 203fff9003
PUD: ffff001fffff9308 => 68001880000705
PMD: ffff0018400002a0 => ffff8000103b4fd0
vtop: seek error: kernel virtual address: ffff7fffd03b4000 type: "page table"
This patch fixes it, and shows as following:
crash> vtop ffff00184a800000
VIRTUAL PHYSICAL
ffff00184a800000 188a800000
PAGE DIRECTORY: ffff8000110aa000
PGD: ffff8000110aa000 => 203fff9003
PUD: ffff001fffff9308 => 68001880000705
PAGE: 1880000000 (1GB)
PTE PHYSICAL FLAGS
68001880000705 1880000000 (VALID|SHARED|AF|PXN|UXN)
PAGE PHYSICAL MAPPING INDEX CNT FLAGS
fffffe00610a0000 188a800000 0 0 0 77fffe0000000000
Signed-off-by: Rongwei Wang <rongwei.wang(a)linux.alibaba.com>
---
arm64.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arm64.c b/arm64.c
index 2177c52..65f6cdf 100644
--- a/arm64.c
+++ b/arm64.c
@@ -1999,6 +1999,16 @@ arm64_vtop_4level_4k(ulong pgd, ulong vaddr, physaddr_t *paddr, int verbose)
if (!pud_val)
goto no_page;
+ if ((pud_val & PUD_TYPE_MASK) == PUD_TYPE_SECT) {
+ ulong sectionbase = (pud_val & SECTION_PAGE_MASK_1GB) & PHYS_MASK;
+ if (verbose) {
+ fprintf(fp, " PAGE: %lx (1GB)\n\n", sectionbase);
+ arm64_translate_pte(pud_val, 0, 0);
+ }
+ *paddr = sectionbase + (vaddr & ~SECTION_PAGE_MASK_1GB);
+ return TRUE;
+ }
+
pmd_base = (ulong *)PTOV(pud_val & PHYS_MASK & (s32)machdep->pagemask);
FILL_PMD(pmd_base, KVADDR, PTRS_PER_PMD_L4_4K * sizeof(ulong));
pmd_ptr = pmd_base + (((vaddr) >> PMD_SHIFT_L4_4K) & (PTRS_PER_PMD_L4_4K - 1));
--
2.27.0
2 years, 7 months
[PATCH v2] diskdump: use mmap/madvise to improve the start-up
by Huang Shijie
1.) The bitmap of vmcore file can be very big in the server kernel panic,
such as over 256M.
This patch uses mmap/madvise to improve the read speed
of the bitmap in the non-FLAT_FORMAT code path.
Use MADV_WILLNEED for madvise, it will trigger read ahead for
reading the bitmap.
2.) Test.
The files:
vmlinux: 272M
vmcore : 23G (bitmap_len: 4575985664)
#cat ./commands.txt
quit
Before this patch:
#echo 3 > /proc/sys/vm/drop_caches;
#time ./crash -i ./commands.txt /root/t/vmlinux /root/t/vmcore > /dev/null 2>&1
............................
real 0m55.217s
user 0m15.114s
sys 0m3.560s
............................
After this patch:
#echo 3 > /proc/sys/vm/drop_caches;
#time ./crash -i ./commands.txt /root/t/vmlinux /root/t/vmcore > /dev/null 2>&1
............................
real 0m44.097s
user 0m19.031s
sys 0m1.620s
............................
Signed-off-by: Huang Shijie <shijie(a)os.amperecomputing.com>
---
v1 --> v2:
Use MADV_WILLNEED for mmap, not MADV_SEQUENTIAL.
---
diskdump.c | 39 ++++++++++++++++-----------------------
1 file changed, 16 insertions(+), 23 deletions(-)
diff --git a/diskdump.c b/diskdump.c
index ff1e9a3..102062b 100644
--- a/diskdump.c
+++ b/diskdump.c
@@ -724,10 +724,6 @@ restart:
offset = (off_t)block_size * (1 + header->sub_hdr_size);
- if ((dd->bitmap = malloc(bitmap_len)) == NULL)
- error(FATAL, "%s: cannot malloc bitmap buffer\n",
- DISKDUMP_VALID() ? "diskdump" : "compressed kdump");
-
dd->dumpable_bitmap = calloc(bitmap_len, 1);
if (CRASHDEBUG(8))
@@ -736,30 +732,23 @@ restart:
(ulonglong)offset);
if (FLAT_FORMAT()) {
+ if ((dd->bitmap = malloc(bitmap_len)) == NULL)
+ error(FATAL, "%s: cannot malloc bitmap buffer\n",
+ DISKDUMP_VALID() ? "diskdump" : "compressed kdump");
+
if (!read_flattened_format(dd->dfd, offset, dd->bitmap, bitmap_len)) {
error(INFO, "%s: cannot read memory bitmap\n",
DISKDUMP_VALID() ? "diskdump" : "compressed kdump");
goto err;
}
} else {
- if (lseek(dd->dfd, offset, SEEK_SET) == failed) {
- error(INFO, "%s: cannot lseek memory bitmap\n",
+ dd->bitmap = mmap(NULL, bitmap_len, PROT_READ,
+ MAP_SHARED, dd->dfd, offset);
+ if (dd->bitmap == MAP_FAILED)
+ error(FATAL, "%s: cannot mmap bitmap buffer\n",
DISKDUMP_VALID() ? "diskdump" : "compressed kdump");
- goto err;
- }
- bufptr = dd->bitmap;
- len = bitmap_len;
- while (len) {
- bytes_read = read(dd->dfd, bufptr, len);
- if (bytes_read <= 0) {
- error(INFO, "%s: cannot read memory bitmap\n",
- DISKDUMP_VALID() ? "diskdump"
- : "compressed kdump");
- goto err;
- }
- len -= bytes_read;
- bufptr += bytes_read;
- }
+
+ madvise(dd->bitmap, bitmap_len, MADV_WILLNEED);
}
if (dump_is_partial(header))
@@ -920,8 +909,12 @@ err:
free(sub_header);
if (sub_header_kdump)
free(sub_header_kdump);
- if (dd->bitmap)
- free(dd->bitmap);
+ if (dd->bitmap) {
+ if (FLAT_FORMAT())
+ free(dd->bitmap);
+ else
+ munmap(dd->bitmap, dd->bitmap_len);
+ }
if (dd->dumpable_bitmap)
free(dd->dumpable_bitmap);
if (dd->notes_buf)
--
2.30.2
2 years, 7 months