2022-03-24 20:48:10

by Naresh Kamboju

[permalink] [raw]
Subject: next: BUG: sleeping function called from invalid context at block/blk-sysfs.c:766

While running kselftest zram test cases on Linux next-20220324 the kernel BUG
reported on arm64 Qcom db845 development board.

metadata:
git_ref: master
git_repo: https://gitlab.com/Linaro/lkft/mirrors/next/linux-next
git_sha: b61581ae229d8eb9f21f8753be3f4011f7692384
git_describe: next-20220323
kernel_version: 5.17.0
kernel-config: https://builds.tuxbuild.com/26mKdspULB326eo6s22cXZzYhmt/config

Log:
[ 0.000000] Linux version 5.17.0-next-20220323 (tuxmake@tuxmake)
(aarch64-linux-gnu-gcc (Debian 11.2.0-18) 11.2.0, GNU ld (GNU Binutils
for Debian) 2.38) #1 SMP PREEMPT @1648023452
[ 0.000000] Machine model: Thundercomm Dragonboard 845c

# running zram tests
# --------------------
# create '1' zram device(s)
# zram load module successful
# set max_comp_streams to zram device(s)
# FAIL can't set max_streams '2', get
# /sys/block/zram0/max_comp_streams = '8' (1/1)
# z[ 626.759707] zram0: detected capacity change from 0 to 4096
ram max streams: OK
# test that we can set compression algorithm
# supported algs: lzo [lzo-rle] lz4 lz4hc 842
# /sys/block/zram0/comp_algorithm = 'lzo' (1/1)
# zram set compression algorithm: OK
# set disk size to zram device(s)
# /sys/block/zram0/disksize = '2097152' (1/1)
# zram set disksizes: OK
# set memory limit to zram device(s)
# /sys/block/zram0/mem_limit = '2M' (1/1)
# zram set memory limit: OK
# make ext4 filesystem on /dev/zram0
# zram mkfs.ext4: OK
# mount /dev/zram0
[ 626.812708] EXT4-fs (zram0): mounted filesystem without journal.
Quota mode: none.
[ 626.820412] ext4 filesystem being mounted at
/opt/kselftests/default-in-kernel/zram/zram0 supports timestamps until
2038 (0x7fffffff)
# zram mount of zram device(s): OK
# fill zram0...
# zram0 can be filled with '1932' KB
# zram used 12M, zram disk sizes 2097152M
# zram compression ratio: 174762.66:1: OK
# zram cleanup
[ 636.589363] zram0: detected capacity change from 4096 to 0
# zram rmmod zram
[ 636.607315] zram: Removed device: zram0
[ 636.682510] BUG: sleeping function called from invalid context at
block/blk-sysfs.c:766
[ 636.690716] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid:
0, name: swapper/0
[ 636.698836] preempt_count: 101, expected: 0
[ 636.703169] RCU nest depth: 0, expected: 0
[ 636.707410] INFO: lockdep is turned off.
[ 636.711471] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.17.0-next-20220323 #1
[ 636.718729] Hardware name: Thundercomm Dragonboard 845c (DT)
[ 636.724485] Call trace:
[ 636.726988] dump_backtrace+0xc0/0x134
[ 636.730823] show_stack+0x24/0x7c
[ 636.734210] dump_stack_lvl+0x8c/0xb8
[ 636.737949] dump_stack+0x18/0x34
[ 636.741333] __might_resched+0x1c8/0x240
[ 636.745334] __might_sleep+0x5c/0x94
[ 636.748981] blk_release_queue+0x38/0x100
[ 636.753070] kobject_put+0xa4/0x210
[ 636.756631] blk_put_queue+0x20/0x30
[ 636.760278] blkg_free.part.0+0x68/0xa0
[ 636.764191] __blkg_release+0x50/0x74
[ 636.767926] rcu_core+0x410/0xb90
[ 636.771316] rcu_core_si+0x1c/0x2c
[ 636.774789] __do_softirq+0x14c/0x654
[ 636.778522] __irq_exit_rcu+0x17c/0x1b0
[ 636.782436] irq_exit_rcu+0x1c/0x44
[ 636.785998] el1_interrupt+0x38/0x64
[ 636.789645] el1h_64_irq_handler+0x18/0x24
[ 636.793813] el1h_64_irq+0x64/0x68
[ 636.797284] cpuidle_enter_state+0xe4/0x380
[ 636.801544] cpuidle_enter+0x44/0x5c
[ 636.805191] do_idle+0x240/0x2d0
[ 636.808484] cpu_startup_entry+0x34/0x3c
[ 636.812479] rest_init+0x1c8/0x2d0
[ 636.815951] arch_call_rest_init+0x1c/0x28
[ 636.820126] start_kernel+0x73c/0x77c
[ 636.823861] __primary_switched+0xc0/0xc8
# zram01 : [PASS]
#
# create '1' zram device(s)
[ 636.859790] zram: Added device: zram0
# zram load module successful
# set max_comp_streams to zram device(s)
# FAIL can't set max_streams '2', get
# /sys/block/zram0/max_comp_streams = '[ 637.901396] zram0: detected
capacity change from 0 to 2048
8' (1/1)
# zram max streams: OK
# set disk size to zram device(s)
# /sys/block/zram0/disksize = '1048576' (1/1)
# zram set disksizes: OK
# set memory limit to zram device(s)
# /sys/block/zram0/mem_limit = '1M' (1/1)
# zram set memory limit: OK
# make swap with zram device(s)
[ 637.935258] Adding 1020k swap on /dev/zram0. Priority:-2 extents:1
across:1020k SS
# done with /dev/zram0
# zram making zram mkswap and swapon: OK
# zram swapoff: OK
# zram cleanup
[ 637.995603] zram0: detected capacity change from 2048 to 0
# zram rmmod zram
[ 638.012764] zram: Removed device: zram0
[ 638.110836] BUG: sleeping function called from invalid context at
block/blk-sysfs.c:766
[ 638.118965] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid:
0, name: swapper/7
[ 638.126928] preempt_count: 101, expected: 0
[ 638.131179] RCU nest depth: 0, expected: 0
[ 638.135349] INFO: lockdep is turned off.
[ 638.139350] CPU: 7 PID: 0 Comm: swapper/7 Tainted: G W
5.17.0-next-20220323 #1
[ 638.147964] Hardware name: Thundercomm Dragonboard 845c (DT)
[ 638.153687] Call trace:
[ 638.156170] dump_backtrace+0xc0/0x134
[ 638.159977] show_stack+0x24/0x7c
[ 638.163332] dump_stack_lvl+0x8c/0xb8
[ 638.167049] dump_stack+0x18/0x34
[ 638.170408] __might_resched+0x1c8/0x240
[ 638.174387] __might_sleep+0x5c/0x94
[ 638.178004] blk_release_queue+0x38/0x100
[ 638.182071] kobject_put+0xa4/0x210
[ 638.185599] blk_put_queue+0x20/0x30
[ 638.189216] blkg_free.part.0+0x68/0xa0
[ 638.193106] __blkg_release+0x50/0x74
[ 638.196811] rcu_core+0x410/0xb90
[ 638.200168] rcu_core_si+0x1c/0x2c
[ 638.203612] __do_softirq+0x14c/0x654
[ 638.207314] __irq_exit_rcu+0x17c/0x1b0
[ 638.211196] irq_exit_rcu+0x1c/0x44
[ 638.214727] el1_interrupt+0x38/0x64
[ 638.218346] el1h_64_irq_handler+0x18/0x24
[ 638.222493] el1h_64_irq+0x64/0x68
[ 638.225934] cpuidle_enter_state+0xe4/0x380
[ 638.230170] cpuidle_enter+0x44/0x5c
[ 638.233787] do_idle+0x240/0x2d0
[ 638.237060] cpu_startup_entry+0x34/0x3c
[ 638.241034] secondary_start_kernel+0x148/0x170
[ 638.245616] __secondary_switched+0xa0/0xa4
# zram02 : [PASS]

steps to produce:
# cd /opt/kselftests/default-in-kernel/zram/
# ./zram.sh

Reported-by: Linux Kernel Functional Testing <[email protected]>


--
Linaro LKFT
https://lkft.linaro.org

[1] https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20220323/testrun/8654494/suite/linux-log-parser/test/check-kernel-bug-4772266/log
[2] https://lkft.validation.linaro.org/scheduler/job/4772266#L5186


2022-03-25 20:52:19

by Eric Biggers

[permalink] [raw]
Subject: Re: next: BUG: sleeping function called from invalid context at block/blk-sysfs.c:766

On Thu, Mar 24, 2022 at 02:04:23PM +0530, Naresh Kamboju wrote:
> While running kselftest zram test cases on Linux next-20220324 the kernel BUG
> reported on arm64 Qcom db845 development board.
>
> metadata:
> git_ref: master
> git_repo: https://gitlab.com/Linaro/lkft/mirrors/next/linux-next
> git_sha: b61581ae229d8eb9f21f8753be3f4011f7692384
> git_describe: next-20220323
> kernel_version: 5.17.0
> kernel-config: https://builds.tuxbuild.com/26mKdspULB326eo6s22cXZzYhmt/config

next-20220323 or next-20220324? Your report is inconsistent. If it's the
former, I'd guess this was already fixed by:

commit d578c770c85233af592e54537f93f3831bde7e9a (linux-block/for-5.18/block)
Author: Ming Lei <[email protected]>
Date: Wed Mar 23 09:13:08 2022 +0800

block: avoid calling blkg_free() in atomic context