Re: [RFC][PATCH 2/9] deadlock prevention core

From: Peter Zijlstra
Date: Mon Aug 14 2006 - 00:39:38 EST

On Sun, 2006-08-13 at 18:53 -0700, Andrew Morton wrote:
> On Sun, 13 Aug 2006 18:31:14 -0700
> Daniel Phillips <phillips@xxxxxxxxxx> wrote:
> > But to solve the whole problem
> What problem? Has anyone come up with a testcase which others can
> reproduce?


Networked Block devices (NBD, iSCSI, AoE) can deadlock in the following
deplete normal memory because of memory pressure; deplete reserves by
writeout over network (pageout happens under PF_MEMALLOC), little to no
memory left for receiving those now crucial ACK packets.
A few packets could still fit in memory, but are quickly gobbled up by
non-crucial sockets and are left waiting on blocked user-space
processes. All memory is depleted and progress stalled forever.

(This affects swap and shared mmap)

Our Solution:

Mark some sockets with SOCK_MEMALLOC; which is essentially a promise to
never block. When under memory pressure only deliver packets to these
sockets, memory will still be used but never lost waiting on a blocked
user space process.

Also make sure the reserve is large enough so that writeout will never
be able to completely deplete it.

(It is here I still do not see Evgeniy's Network Tree Allocator work;
where is the guarantee that you do not end up with all memory lost
waiting on blocked sockets?)


Mount an NBD device as sole swap device and mmap > physical RAM, then
loop through touching pages only once.

My normal test setup is a p3-550 with 192M of ram with a 100Mbit card
and remote machine with a regular 7200 RPM pata drive.

I'm sure there is an iSCSI equivalent scenario, playing with iSCSI is
next on my list of things.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at