On Tue, Jul 29, 2003 at 06:43:57PM +0200, Christophe Saout wrote: > Yes, you got me... I saw that you are using page pools in the current dm > 2.4 implementation. That's why I wanted to wait and possibly use that > implementation instead. Or should I implement my own little pool? The only place I'm using pages is in kcopyd, I needed different semantics to a mempool, so I did it a different way. You should be able to use mempools. > Yes, I could do this. Does this mean that I have to wait for a split > write to return first before I can continue to write the next part of > the bio? When the pool runs empty? You can write the rest as soon as you can allocate some memory for this. > I could do something like this: > > 1. try to allocate pages with the nowait option (so it fails if the > system needs to swap out or something) > 2. if that fails try to use some pages from the pool, so it's only used > in emergency mode > 3. if that fails and you've already got some pages, submit a partial bio > and > 4. try to wait for the pool to refill (if it's empty that means that > other write request are currently using them and they will definitely > return some day so you won't deadlock here). > > When writes terminate you can put every page back on the pool even those > that originally didn't come from the pool until the pool reaches its > maximum number of pages. > > Would that be a strategy? Or is it too complicated? You have nicely described the mempool code ;) This is already done for you, see mm/mempool.c it's not long, but it's essential that you understand how it will behave. > > on a low memory config with the dm device mounted on /mnt. I suggest > > you try the same, I really don't trust any code that has come from > > loop.c. > > Yes, I don't think that code's too clever either. If you are out of > memory, your swap is full and the kernel wants to write out dirty pages > to reclaim memory but the writes are stuck waiting for buffers to do the > encryption, you run into a deadlock. yep, this is the big deadlock that mempools were invented to fix. - Joe