Commit Graph

14 Commits

Author SHA1 Message Date
Kazuhito Hagio
b8f2ae6b49 sbitmapq: Limit kernels without sbitmap again
commit 364b2e413c ("sbitmapq: remove struct and member validation
in sbitmapq_init()") allowed the use of the "sbitmapq" command
unconditionally.  Without the patch, the command fails with the
following error on kernels without sbitmap:

  crash> sbitmapq ffff88015796e550

  sbitmapq: invalid structure member offset: sbitmap_queue_sb
            FILE: sbitmap.c  LINE: 385  FUNCTION: sbitmap_queue_context_load()

Now the command supports Linux 4.9 and later kernels since it was
abstracted out, so it can be limited by the non-existence of the
sbitmap structure.

Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
2022-06-14 17:29:52 +09:00
Kazuhito Hagio
6bc3b74c6e sbitmapq: Fix for kernels without struct wait_queue_head
The current struct wait_queue_head was renamed by kernel commit
9d9d676f595b ("sched/wait: Standardize internal naming of wait-queue heads")
at Linux 4.13.  Without the patch, on earlier kernels the "sbitmapq"
command fails with the following error:

  crash> sbitmapq ffff8801790b3b50
  depth = 128
  busy = 0
  bits_per_word = 32
  ...
  sbitmapq: invalid structure member offset: wait_queue_head_head
            FILE: sbitmap.c  LINE: 344  FUNCTION: sbitmap_queue_show()

Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
2022-06-14 17:29:52 +09:00
Kazuhito Hagio
12fe6c7cdd sbitmapq: Fix for sbitmap_queue without min_shallow_depth member
The sbitmap_queue.min_shallow_depth member was added by kernel commit
a327553965de ("sbitmap: fix missed wakeups caused by sbitmap_queue_get_shallow()")
at Linux 4.18.  Without the patch, on earlier kernels the "sbitmapq"
command fails with the following error:

  crash> sbitmapq ffff89bb7638ee50

  sbitmapq: invalid structure member offset: sbitmap_queue_min_shallow_depth
            FILE: sbitmap.c  LINE: 398  FUNCTION: sbitmap_queue_context_load()

Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
2022-06-10 14:15:32 +09:00
Kazuhito Hagio
0d3e86fee5 sbitmapq: Fix for sbitmap_word without cleared member
The sbitmap_word.cleared member was added by kernel commit ea86ea2cdced
("sbitmap: ammortize cost of clearing bits") at Linux 5.0.  Without the
patch, on earlier kernels the "sbitmapq" command fails with the
following error:

  crash> sbitmapq ffff8f1a3611cf10

  sbitmapq: invalid structure member offset: sbitmap_word_cleared
            FILE: sbitmap.c  LINE: 92  FUNCTION: __sbitmap_weight()

Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
2022-06-10 14:15:32 +09:00
Kazuhito Hagio
9ce31a14d1 sbitmapq: Fix for sbitmap_queue without ws_active member
The sbitmap_queue.ws_active member was added by kernel commit 5d2ee7122c73
("sbitmap: optimize wakeup check") at Linux 5.0.  Without the patch, on
earlier kernels the "sbitmapq" command fails with the following error:

  crash> sbitmapq ffff8f1a3611cf10

  sbitmapq: invalid structure member offset: sbitmap_queue_ws_active
            FILE: sbitmap.c  LINE: 393  FUNCTION: sbitmap_queue_context_load()

Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
2022-06-10 14:15:32 +09:00
Lianbo Jiang
3750803f6a sbitmapq: fix invalid offset for "sbitmap_word_depth" on Linux v5.18-rc1
Kernel commit 3301bc53358a ("lib/sbitmap: kill 'depth' from sbitmap_word")
removed the depth member from struct sbitmap_word.  Without the patch, the
sbitmapq will fail:

  crash> sbitmapq 0xffff8e99d0dc8010

  sbitmapq: invalid structure member offset: sbitmap_word_depth
          FILE: sbitmap.c  LINE: 84  FUNCTION: __sbitmap_weight()

Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
2022-05-24 17:21:47 +09:00
Lianbo Jiang
530fe6ad7e sbitmapq: fix invalid offset for "sbitmap_queue_round_robin" on Linux v5.13-rc1
Kernel commit efe1f3a1d583 ("scsi: sbitmap: Maintain allocation
round_robin in sbitmap") moved the round_robin member from struct
sbitmap_queue to struct sbitmap.  Without the patch, the sbitmapq
will fail:

  crash> sbitmapq 0xffff8e99d0dc8010

  sbitmapq: invalid structure member offset: sbitmap_queue_round_robin
          FILE: sbitmap.c  LINE: 378  FUNCTION: sbitmap_queue_context_load()

Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
2022-05-24 17:21:47 +09:00
Lianbo Jiang
a295cb40cd sbitmapq: fix invalid offset for "sbitmap_queue_alloc_hint" on Linux v5.13-rc1
Kernel commit c548e62bcf6a ("scsi: sbitmap: Move allocation hint
into sbitmap") moved the alloc_hint member from struct sbitmap_queue
to struct sbitmap.  Without the patch, the sbitmapq will fail:

  crash> sbitmapq 0xffff8e99d0dc8010

  sbitmapq: invalid structure member offset: sbitmap_queue_alloc_hint
          FILE: sbitmap.c  LINE: 365  FUNCTION: sbitmap_queue_context_load()

Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
2022-05-24 17:21:47 +09:00
Lianbo Jiang
364b2e413c sbitmapq: remove struct and member validation in sbitmapq_init()
Let's remove the struct and member validation from sbitmapq_init(), which
will help the crash to display the actual error when the sbitmapq fails.

Without the patch:
  crash> sbitmapq ffff8e99d0dc8010
  sbitmapq: command not supported or applicable on this architecture or kernel

With the patch:
  crash> sbitmapq ffff8e99d0dc8010

  sbitmapq: invalid structure member offset: sbitmap_queue_alloc_hint
          FILE: sbitmap.c  LINE: 365  FUNCTION: sbitmap_queue_context_load()

Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
2022-05-24 17:21:47 +09:00
Huang Shijie
b811a045ec diskdump: Optimize the boot time
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@os.amperecomputing.com>
2022-04-11 15:29:39 +08:00
Sergey Samoylenko
4cf262e237 sbitmap.c: use readmem more carefully
Signed-off-by: Sergey Samoylenko <s.samoylenko@yadro.com>
2022-03-12 14:03:01 +08:00
Sergey Samoylenko
7c7a4eddb4 Fix memory leak in __sbitmap_for_each_set function
Signed-off-by: Sergey Samoylenko <s.samoylenko@yadro.com>
2022-03-12 14:02:58 +08:00
Sergey Samoylenko
fb64fdd11d sbitmapq: add '-p' option
The -p option says, an associated with sbitmap_queue array contains
the pointers on a structure. This allows the sbitmapq command works
correctly with the array of pointers attached to the sbitmap_queue.

Signed-off-by: Sergey Samoylenko <s.samoylenko@yadro.com>
2022-02-22 09:53:30 +08:00
Sergey Samoylenko
ac86cc3558 Introduce sbitmapq command
Patch adds new 'sbitmapq' command. This command dumps
the contents of the sbitmap_queue structure and the used
bits in the bitmap. Also, it shows the dump of a structure
array associated with the sbitmap_queue.

Signed-off-by: Sergey Samoylenko <s.samoylenko@yadro.com>
2022-02-22 09:53:27 +08:00