Does writing to NFS put processes into un-interruptible sleep?
Or: NFS, I hate you.
tl;dr: yes.
Following on from my discovery in my previous article, that when attempting to write pages back to the NFS server linux will place the process into TASK_INTERRUPTIBLE state (D state in ps):
/**
* nfs_wait_on_request — Wait for a request to complete.
* @req: request to wait upon.
*
* Interruptible by fatal signals only.
* The user is responsible for holding a count on the request.
*/
int
nfs_wait_on_request(struct nfs_page *req)
{
return wait_on_bit(&req->wb_flags, PG_BUSY,
nfs_wait_bit_uninterruptible,
TASK_UNINTERRUPTIBLE);
}I devised a simple experiment to test my theory. In one terminal I would execute dd with a blocksize of my NFS pagesize simply writing a stream from /dev/zero to some file and in another terminal I would run my procmon.pl (found here) script to check for processes jumping into D state:
$ dd if=/dev/zero of=zeros bs=32768 count=10000
10000+0 records in
10000+0 records out
327680000 bytes (328 MB) copied, 1.89115 seconds, 173 MB/sGet Jon Philpott’s stories in your inbox
Join Medium for free to get updates from this writer.
And the output from procmon.pl:
$ ./procmon.pl -t -i .01
1395160192,16355,dd,D,63180 kB,63180 kB,1,nfs_wait_bit_uninterruptible
1395160192,16355,dd,D,63180 kB,63180 kB,1,nfs_wait_bit_uninterruptible
1395160192,16355,dd,D,63180 kB,63180 kB,1,nfs_wait_bit_uninterruptible
1395160192,16355,dd,D,63180 kB,63180 kB,1,nfs_wait_bit_uninterruptible
1395160193,16355,dd,D,63180 kB,63180 kB,1,
1395160193,16355,dd,D,63180 kB,63180 kB,1,nfs_wait_bit_uninterruptible
1395160193,16355,dd,D,63180 kB,63180 kB,1,nfs_wait_bit_uninterruptible
1395160193,16355,dd,D,63180 kB,63180 kB,1,
1395160193,16355,dd,D,63180 kB,63180 kB,1,
1395160193,16355,dd,D,63180 kB,63180 kB,1,nfs_wait_bit_uninterruptible
1395160193,16355,dd,D,63180 kB,63180 kB,1,
1395160193,16355,dd,D,63180 kB,63180 kB,1,nfs_wait_bit_uninterruptibleInterestingly also, the wait channel or the function the kernel is executing on behalf of this process while it sleeps is nfs_wait_bit_uninterruptible, the same function that is called by nfs_wait_on_request to sleep.
So what?
Is it a big deal that these processes trying to write to NFS get put into uninterruptible sleep? Well, yes and no. There are at least two things to be aware of here. Firstly, processes in uninterruptible sleep are err, uninterruptable, they will not receive signals and they are by definition blocked. Secondly, Linux includes the count of processes into uninterruptable sleep into it’s calculation of load averages:
/*
* Either called from update_cpu_load() or from a cpu going idle
*/
static void calc_load_account_active(struct rq *this_rq)
{
long nr_active, delta; nr_active = this_rq->nr_running;
nr_active += (long) this_rq->nr_uninterruptible; if (nr_active != this_rq->calc_load_active) {
delta = nr_active — this_rq->calc_load_active;
this_rq->calc_load_active = nr_active;
atomic_long_add(delta, &calc_load_tasks);
}
}
So when you’re looking at your load average graphs be aware that you’re not just seeing processes that couldn’t run because available CPU time was low, you’re also seeing processes that couldn’t run because blocked on uninterruptible I/O, or in this case writing to NFS.







