How do I stop Ubuntu from hanging due to processes going into 'disk sleep'?

8,296

A process in disk sleep or uninterruptible sleep is typically waiting on some I/O operation to complete. In this state, it cannot be woken up by signals, hence the process cannot be terminated using the SIGKILL signal.

My limited understanding of what happens is this: The CPU scheduler in the kernel maintains a run queue which is the list of processes that are ready to run. When a process gets the CPU, it either

  1. Utilizes it's time slice fully and gets scheduled out, or
  2. It needs to wait for the response of an operation, typically I/O, and requests to be transferred to the sleep queue, waiting on the event.

Processes that schedule out due to #2 also indicate to the scheduler if they should be interrupted or not while they are waiting on the event. When they cannot continue proper operation if interrupted by a signal (typically device drivers), they'll indicate that they should be woken up only by the event. These are in uninterruptible sleep state, and will get moved to the sleep queue.

If you are experiencing regular freezing of the system due to disk sleep, it could be one of

  • Buggy device driver
  • Faults on your hardware (Disk drive?)
  • Mounted filesystems that are slow to respond.

I've seen this time and again with NFS file systems. If for some reason the device response is lost the process will remain in sleep state, making it almost impossible to use the mount/device till a reboot.

If you think it's your hard disk access causing the I/O freezes, it might be prudent to check if there are bad blocks or sectors on the drive.

Share:
8,296

Related videos on Youtube

joeforker
Author by

joeforker

How much rep do I need to get an epic mount?

Updated on September 17, 2022

Comments

  • joeforker
    joeforker over 1 year

    I'm using Ubuntu 9.04 64 bit on an AMD. It regularly hangs for a few minutes at a time when some of the processes's CPU usage % goes into 'disk sleep'. During that time I can't start new programs and most of the programs on the desktop become unresponsive.

    I would rather it didn't hang and my applications remained reliably responsive. Why does this happen and how can I stop it?

    • Admin
      Admin over 14 years
      I've seen this behaviour with processes accessing mounted filesystems, mainly NFS. Do you have any NFS, Samba, USB mounts on the system?
    • joeforker
      joeforker over 14 years
      I have a couple of CIFS mounts and a webdav partition. Might be the problem. Can I make these go away when unavailable instead of hanging the system?
    • Admin
      Admin over 14 years
      The problem is that they are intermittently unavailable, either due to network latency or driver issues. In my experience CIFS, NFS are prone to such behaviour. Would a solution be acceptable where these are unmounted by default, and you mount them when needed?