Skip to content

Workqueue: events_freezable mmc_rescan crash with Raspbian kernel 4.14.79-v7+ #2810

Open

Description

@op-ecoprintq

I have a few Raspberry Pi 3 B+ exhibiting the same problem. They crash after 2-3 days of uptime with the following error:

[169451.220021] INFO: task kworker/0:3:10949 blocked for more than 120 seconds.
[169451.220036] Tainted: G C 4.14.79-v7+ #1159
[169451.220041] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[169451.220048] kworker/0:3 D 0 10949 2 0x00000000
[169451.220077] Workqueue: events_freezable mmc_rescan
[169451.220110] [<8079ef70>] (__schedule) from [<8079f5d8>] (schedule+0x50/0xa8)
[169451.220130] [<8079f5d8>] (schedule) from [<8061a2d0>] (__mmc_claim_host+0xb8/0x1cc)
[169451.220147] [<8061a2d0>] (__mmc_claim_host) from [<8061a414>] (mmc_get_card+0x30/0x34)
[169451.220163] [<8061a414>] (mmc_get_card) from [<80623010>] (mmc_sd_detect+0x20/0x74)
[169451.220179] [<80623010>] (mmc_sd_detect) from [<8061ccdc>] (mmc_rescan+0x1c8/0x394)
[169451.220197] [<8061ccdc>] (mmc_rescan) from [<801379b4>] (process_one_work+0x158/0x454)
[169451.220212] [<801379b4>] (process_one_work) from [<80137d14>] (worker_thread+0x64/0x5b8)
[169451.220227] [<80137d14>] (worker_thread) from [<8013dd98>] (kthread+0x13c/0x16c)
[169451.220246] [<8013dd98>] (kthread) from [<801080ac>] (ret_from_fork+0x14/0x28)

The machines are running Rasbian Stretch

Activity

  1. ldrolez commented on Jan 18, 2019

    @ldrolez

    Same problem on a 3B after upgrading to 4.14.79-v7+
    Crash every 1-3 days. Now downgrading to 4.14.52-v7+

  2. JamesH65 commented on Jan 18, 2019

    @JamesH65
    Contributor

    Hmm, what are the Pi's doing during that time? We haven't seen anything like this in the office, so would be interested to know what they are doing that might cause this.

  3. JamesH65 commented on Jan 18, 2019

    @JamesH65
    Contributor

    Actually, this is a duplicate of an issue on our Linux tracker which is the correct place for it to be. Please continue conversation there...#2810

  4. JamesH65 commented on Jan 18, 2019

    @JamesH65
    Contributor

    Bum, closed wrong one. Reopened. Will now attempt to close the one in firmware...

  5. op-ecoprintq commented on Jan 18, 2019

    @op-ecoprintq
    Author

    So the machines in question are running LXDE, a Java application, and the onboard keyboard.

  6. pelwell commented on Jan 18, 2019

    @pelwell
    Contributor

    That doesn't tell me anything about their level of activity - CPU, file system, network etc.

  7. Alexurb commented on Jan 19, 2019

    @Alexurb

    Same issue here. Attached is my kernel log.
    kern.log
    The issue occurs around Jan 18 19:57:02
    This is on a headless install. The green light is constant, the PI responds to pings but is unable to open up an ssh session.
    This actually occurs for me during a movie being streamed by plex , around an hour and a half in.
    I left the pi to see if it would recover overnight, sadly it didn't.

  8. Alexurb commented on Jan 21, 2019

    @Alexurb

    Happened again mid movie. Attached is another kernel log
    kern.log

  9. Alexurb commented on Jan 23, 2019

    @Alexurb

    I've so far found some advice from https://www.blackmoreops.com/2014/09/22/linux-kernel-panic-issue-fix-hung_task_timeout_secs-blocked-120-seconds-problem/
    summary:
    sudo sysctl -w vm.dirty_ratio=10
    sudo sysctl -w vm.dirty_background_ratio=5
    sudo sysctl -p
    seems to do the trick so far, still testing (3 movies down)
    I'll comment if it occurs again.
    To make it permanent(after reboot) read the link

  10. Alexurb commented on Jan 23, 2019

    @Alexurb

    I've so far found some advice from https://www.blackmoreops.com/2014/09/22/linux-kernel-panic-issue-fix-hung_task_timeout_secs-blocked-120-seconds-problem/
    summary:
    sudo sysctl -w vm.dirty_ratio=10
    sudo sysctl -w vm.dirty_background_ratio=5
    sudo sysctl -p
    seems to do the trick so far, still testing (3 movies down)
    I'll comment if it occurs again.
    To make it permanent(after reboot) read the link

    So far so good.

  11. peabody commented on Aug 29, 2019

    @peabody

    Just going say this thread saved my pi 3b+. Was hanging terrible on any intense IO. The solution by Alexurb fixed the problem for me.

  12. jdrch commented on Apr 4, 2020

    @jdrch

    Same problem here on my Pi 3B+ running Raspbian Buster. Gonna try that edit and then reboot. Fingers crossed!

  13. paralin commented on Sep 22, 2020

    @paralin

    Just ran into this with kernel 5.4.51-v8 aarch64 on Pi 4.

    Ill try the fix recommended above in this thread:

    vm.dirty_background_ratio = 5
    vm.dirty_ratio = 10
    

    Here's the dmesg errors:

    [11722.001585] INFO: task kworker/1:0:1663 blocked for more than 120 seconds.
    [11722.005139]       Tainted: G         C        5.4.51-v8 #1
    [11722.008672] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
    [11722.012222] kworker/1:0     D    0  1663      2 0x00000028
    [11722.015773] Workqueue: events_freezable mmc_rescan
    [11722.019269] Call trace:
    [11722.022724]  __switch_to+0x110/0x180
    [11722.026149]  __schedule+0x2f4/0x750
    [11722.029523]  schedule+0x44/0xe0
    [11722.032807]  __mmc_claim_host+0xb8/0x210
    [11722.036111]  mmc_get_card+0x38/0x50
    [11722.039407]  mmc_sd_detect+0x24/0x90
    [11722.042671]  mmc_rescan+0xc8/0x390
    [11722.045892]  process_one_work+0x1c0/0x470
    [11722.049078]  worker_thread+0x50/0x430
    [11722.052405]  kthread+0x100/0x130
    [11722.055223]  ret_from_fork+0x10/0x18
    
  14. 47 remaining items

  15. JamesH65 commented on May 24, 2022

    @JamesH65
    Contributor

    I did change the sysctl setting as described here: https://www.blackmoreops.com/2014/09/22/linux-kernel-panic-issue-fix-hung_task_timeout_secs-blocked-120-seconds-problem/ but the freeze still happens. It happens ALWAYS in this situation:

    I noticed this when I used VS Code's SSH Remote Extension which install a bunch of stuff in the remote server. This cause a HUGE use of CPU by "node" program, and then everything freezes, I couldn't even connect via SSH because the server is freezed. My remote server is a simple Raspberry Pi 3 B+, so not very powerful.

    Something curious: when all this happens, I noticed in both my host machine and remote server a process "kswapd0" that consumes much CPU too, can this be related?

    Also, if the scheduler sends interrupts constantly to context switch and to pass to another process, so why a certain process that consumes too much CPU can freeze the pi? Shouldn't scheduler go on with other processes equally? Why can it monopolize the CPU and freeze the pi?

    I believe you are running out of memory, which is why kswapd is going mad, rather than running out of CPU power.

  16. paralin commented on May 24, 2022

    @paralin

    @JamesH65 is probably right, you're out of memory.

    My bad, I assumed that the comment was related to this issue and not some other unrelated thing :)

  17. jdrch commented on May 24, 2022

    @jdrch

    If this happens your SD card is probably bad. Best replace it.

    Even relatively new SD cards can go bad, because they are not designed for repeated continuous writes to the same location over & over, nor continuous 24/7 operation.

    I have had the best luck with SanDisk Ultra microSDHC UHS-I Memory Card DSQUA4-032G-GN6MT which rarely fail. Regardless I would recommend swapping out SD cards once every year to be safe.

    The kernel should be updated nevertheless with better error handling, in my opinion.

    All storage devices fail eventually ;) But yes, I have had the best luck with SanDisk, and their warranty (both length and replacement policy) is the best in the business.

    Last Friday I retired the 32 GB card I'd been using since I got the Pi in 2018 and replaced it with a 200 GB card. We'll see what happens from there.

    For those wondering about the process for doing so:

    1. Use SD Card Copier (Raspberry Pi OS GUI app) to copy existing card to new card
    2. Physically swap in new card
    3. (If desired) Use GParted to:
      • resize the shared data partition to its minimum size at the end of the partition table
      • extend the root partition into the unallocated space resulting from the above
  18. All3xJ commented on May 24, 2022

    @All3xJ

    I believe you are running out of memory, which is why kswapd is going mad, rather than running out of CPU power.

    @JamesH65 @paralin
    Is there a way to fix this? Or to workaround this?

  19. JamesH65 commented on May 25, 2022

    @JamesH65
    Contributor

    Use less memory? Use Pi4 with more memory? Use a USB SSD and put a swap file on it, that might be faster than swap on the SD card?

    What is the Pi doing that is using all the RAM?

  20. All3xJ commented on May 25, 2022

    @All3xJ

    What is the Pi doing that is using all the RAM?

    I noticed this when I used VS Code's SSH Remote Extension which install and runs a bunch of stuff in the remote server. This cause a HUGE use of memory, and then everything freezes, I couldn't even connect via SSH because the server is freezed.

    EDIT: I fixed by increasing the swap partition size!

  21. shakin89 commented on Oct 21, 2022

    @shakin89

    I would like to thanks everyone for all the comments i've found on this page.
    I've an rpi4 4G memory, and from this summer i've began to have this issue too frequently.

    My system is a plain debian 11, with /boot/firmware and / mounted on sdcard; /home, /var and /tmp are mounted on ssd.
    I think i'll move my / to ssd to and activate the swap, and first of all i'll replace my sdcard!!! 😄

  22. jdrch commented on Oct 26, 2022

    @jdrch

    If this happens your SD card is probably bad. Best replace it.
    Even relatively new SD cards can go bad, because they are not designed for repeated continuous writes to the same location over & over, nor continuous 24/7 operation.
    I have had the best luck with SanDisk Ultra microSDHC UHS-I Memory Card DSQUA4-032G-GN6MT which rarely fail. Regardless I would recommend swapping out SD cards once every year to be safe.
    The kernel should be updated nevertheless with better error handling, in my opinion.

    All storage devices fail eventually ;) But yes, I have had the best luck with SanDisk, and their warranty (both length and replacement policy) is the best in the business.

    Last Friday I retired the 32 GB card I'd been using since I got the Pi in 2018 and replaced it with a 200 GB card. We'll see what happens from there.

    For those wondering about the process for doing so:

    1. Use SD Card Copier (Raspberry Pi OS GUI app) to copy existing card to new card
    
    2. Physically swap in new card
    
    3. (If desired) Use GParted to:
       
       * resize the shared data partition to its minimum size at the end of the partition table
       * extend the root partition into the unallocated space resulting from the above
    

    FWIW replacing the microSD card has fixed the problem. I think I've experienced only 1 crash since.

  23. sirjeannot commented on May 23, 2023

    @sirjeannot

    Hello, just joining the thread on this issue, which also happens to my raspberry pi 3b+ rev1.2.

    It had been running fine since ~2018 on raspbian armv7, however this issue has started ever since I migrated to aarch64 raspiOS in march. I'm currently running kernel 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux. It is running docker with HomeAssistant, Nodered, Signal-CLI and mqtt. The raspi locks up every 6 to 8 days.
    Also:

    cat /etc/debian_version
    11.7
    

    I've had to replace the SD card before this migration several times, but the symptoms of a dying SD were different, being random crashes of containers, not a full system lockup.
    In this case replacing the SD doesn't change anything. (suing Sandisk 16/32GiB A1 class 10)
    I'm currently trying the proposed fix (applied it 3 days ago, currently monitoring):

    sudo sysctl -w vm.dirty_ratio=10
    sudo sysctl -w vm.dirty_background_ratio=5
    sudo sysctl -p
    

    If it doesn't work, I'll move the swap file to a USB stick and likely the whole system to a USB SSD afterwards.

    edit:
    the system partly locked up with the fix. the system still runs (replies to pings) but any write will not complete.
    now moving swap to a usb key (not ssd, no power budget left)

    edit2 (+1month):
    it appears the system running low on memory on many occasions mainly due to 2 docker containers requiring more and more ressources (homeassistant and signal-cli in json-rpc mode). Some are now set to restart daily to contain the increasing memory consumption.
    the swap on a usb key did work out quite well. However the USB key died in a few weeks : the system crashed within minutes of booting, corrupting docker log files ('\x00' error).
    I've "moved" the swap to zram with aggressive values.

    vm.vfs_cache_pressure = 500
    vm.swappiness = 100
    vm.dirty_background_ratio = 1
    vm.dirty_ratio = 50
    

    It's been a few days, some more time is needed to see if it helps mitigating the issue.
    SSD migration still needs to be done, but zram swap doesn't interfere with this upgrade.

    edit3 (+1.5months):
    so far there are no more hangs with the zram swap. I've graphed the ram and swap usage to get a view of what is happening. it shows there is a major memory consumption after a few days with my workload, with only a few MiB of memory left even in the swap. so the swap increasing slowness on the sd-card was the culprit. no more hangs but I'll have to migrate to a sbc with more memory.
    image

    edit4 (+3 months)
    still using the raspi3b+ 1GiB of RAM and no hang ups. The memory is heavily occupied but no more crashes.
    over the last 1.5months (no reboot)
    image
    image

    edit5 (+10 months)
    still using raspi3b+ but encountering memory depletion and usb ssd disconnects (other kernel module issue, not power replated).
    moved back to armv7l and emmc disk, not a single issue since : 300MiB+ free and no hangups or disconnects.

  24. djr-spectrummfg commented on Jun 28, 2023

    @djr-spectrummfg

    I am able to reproduce this on a CM4 (lite, 1GB ram, no wifi, no heatsink) using the official CM4 IO board and a Sandisk EVO Select 128GB microSD card (which has not seen much abuse). I am using a 64bit kernel, v5.15.34-v8, built using Yocto and meta-raspberrypi.

    I can trigger it by compiling a large C++ project (https://github.com/OpenLightingProject/ola using make -j4) on the RPi. After some time the build will often hang and eventually produce the hung task kernel message. As well as stressing the CPU, this build does seem to consume most of the available RAM as at times I have seen oom-killer messages.

    Sample of kernel message:

    [ 7250.956746] INFO: task kworker/2:1:312 blocked for more than 120 seconds.
    [ 7250.963695]       Tainted: G         C O      5.15.34-v8 #1
    [ 7250.969448] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
    [ 7250.977466] task:kworker/2:1     state:D stack:    0 pid:  312 ppid:     2 flags:0x00000208
    [ 7250.986034] Workqueue: events_freezable mmc_rescan
    [ 7250.990939] Call trace:
    [ 7250.993481]  __switch_to+0x110/0x164
    [ 7250.997144]  __schedule+0x314/0x8a0
    [ 7251.000768]  schedule+0x50/0x10c
    [ 7251.004065]  __mmc_claim_host+0xc0/0x1f0
    [ 7251.008084]  mmc_get_card+0x40/0x50
    [ 7251.011652]  mmc_sd_detect+0x2c/0xa0
    [ 7251.015305]  mmc_rescan+0x98/0x2f0
    [ 7251.018776]  process_one_work+0x1e0/0x48c
    [ 7251.022871]  worker_thread+0x144/0x470
    [ 7251.027399]  kthread+0x144/0x160
    [ 7251.030716]  ret_from_fork+0x10/0x20
    
  25. gec75 commented on Feb 16, 2024

    @gec75
  26. sresam89 commented on Mar 3, 2024

    @sresam89

    I finding the same issue on newer kernel
    Trying not to cross-post
    Issue linked here

  27. djr-spectrummfg commented on Apr 15, 2024

    @djr-spectrummfg

    Observed this again after updating my kernel to 5.15.92 (still on a CM4 with the same uSD card, this time without running anything stressing the CPU/RAM/SD card IO):

    [236227.555571] INFO: task kworker/1:0:1010415 blocked for more than 120 seconds.
    [236227.562933]       Tainted: G         C O      5.15.92-v8 #1
    [236227.569081] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
    [236227.577030] task:kworker/1:0     state:D stack:    0 pid:1010415 ppid:     2 flags:0x00000208
    [236227.585685] Workqueue: events_freezable mmc_rescan
    [236227.590613] Call trace:
    [236227.593207]  __switch_to+0x110/0x164
    [236227.597452]  __schedule+0x32c/0x8f4
    [236227.601081]  schedule+0x70/0x12c
    [236227.604426]  __mmc_claim_host+0xc0/0x1f0
    [236227.608463]  mmc_get_card+0x3c/0x50
    [236227.612079]  mmc_sd_detect+0x28/0xa0
    [236227.616265]  mmc_rescan+0x94/0x2f0
    [236227.619794]  process_one_work+0x1dc/0x4a4
    [236227.623935]  worker_thread+0x144/0x490
    [236227.627810]  kthread+0x140/0x154
    [236227.631256]  ret_from_fork+0x10/0x20
    
  28. jdrch commented on Apr 15, 2024

    @jdrch

    updating my kernel to 5.15.92

    Isn't Raspberry Pi OS on v6+ for all devices? I'd think that's where any fixes are most likely to be.

  29. djr-spectrummfg commented on Apr 15, 2024

    @djr-spectrummfg

    I'm not using Raspberry Pi OS, I'm using an image built with Yocto kirkstone and meta-raspberrypi. This kernel update was a result of the update in meta-raspberrypi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions