Re: [patch 1/5] mm: add nofail variants of kmalloc kcalloc and kzalloc

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Dave Chinner
Date: Thursday, August 26, 2010 - 12:06 am

On Wed, Aug 25, 2010 at 08:09:21PM -0700, David Rientjes wrote:

It would take a handful of concurrent transactions in XFS with
worst case memory allocation requirements to exhaust that pool, and
then we really would be in trouble.  Alternatively, it would take a
few allocations from each of a couple of thousand concurrent
transactions to get to the same point.

Bound memory pools only work when serialised access to the pool can
be enforced and there are no dependencies on other operations in
progress for completion of the work and freeing of the memory.
This is where it becomes exceedingly difficult to guarantee
progress.

One of the ideas that has floated around (I think Mel Gorman came up
with it first) was that if hardening the filesystem is so difficult,
why not just harden a single path via a single thread? e.g. we allow
the bdi flusher thread to have a separate reserve pool of free
pages, and when memory allocations start to fail, then that thread
can dip into it's pool to complete the writeback of the dirty pages
being flushed.  When a fileystem attaches to a bdi, it can specify
the size of the reserve pool it needs. 

This can be easily tested for during allocation (say a PF_ flag) and
switched to the reserve pool as necessary. because it is per-thread,
access to the pool is guaranteed to serialised. Memory reclaim can
then refill these pools before putting pages on freelists. This
could give us a mechanism for ensuring that allocations succeed in
the ->writepage path without needing to care about filesystem
implementation details.

And in the case of ext3/4, a pool could be attached to the jbd
thread as well so that it never starves of memory when commits are
required...

So, rather than turning filesystems upside down, maybe we should
revisit per-thread reserve pools for threads that are tasked with
cleaning pages for the VM?

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch 2/5] mm: add nofail variant of kmem_cache_zalloc, David Rientjes, (Tue Aug 24, 3:50 am)
[patch 3/5] fs: add nofail variant of alloc_buffer_head, David Rientjes, (Tue Aug 24, 3:50 am)
[patch 4/5] btrfs: add nofail variant of set_extent_dirty, David Rientjes, (Tue Aug 24, 3:50 am)
[patch 5/5] ntfs: remove dependency on __GFP_NOFAIL, David Rientjes, (Tue Aug 24, 3:50 am)
Re: [patch 1/5] mm: add nofail variants of kmalloc kcalloc ..., Christoph Lameter, (Wed Aug 25, 2:11 pm)
Re: [patch 1/5] mm: add nofail variants of kmalloc kcalloc ..., Christoph Lameter, (Wed Aug 25, 2:35 pm)
Re: [patch 1/5] mm: add nofail variants of kmalloc kcalloc ..., Christoph Lameter, (Wed Aug 25, 6:30 pm)
Re: [patch 1/5] mm: add nofail variants of kmalloc kcalloc ..., Dave Chinner, (Thu Aug 26, 12:06 am)
Re: [patch 1/5] mm: add nofail variants of kmalloc kcalloc ..., Christoph Lameter, (Thu Aug 26, 7:16 am)
[patch v2 5/5] ntfs: remove dependency on __GFP_NOFAIL, David Rientjes, (Wed Sep 1, 6:03 pm)
Re: [patch v2 5/5] ntfs: remove dependency on __GFP_NOFAIL, Anton Altaparmakov, (Thu Sep 2, 2:08 am)