Re: GFS2 and DLM

From: Ingo Molnar
Date: Tue Jun 27 2006 - 04:26:11 EST



* Nathan Scott <nathans@xxxxxxx> wrote:

> > */
> > buf = (xfs_caddr_t) kmem_zalloc(NBPP, KM_SLEEP);
> > [...]
> >
> > where kmem_zalloc() may fail!!!
>
> Not with the flags it was given.

yeah, you are right - sorry about that.

XFS instead loops infinitely:

void *
kmem_alloc(size_t size, unsigned int __nocast flags)
{
int retries = 0;
gfp_t lflags = kmem_flags_convert(flags);
void *ptr;

do {
if (size < MAX_SLAB_SIZE || retries > MAX_VMALLOCS)
ptr = kmalloc(size, lflags);
else
ptr = __vmalloc(size, lflags, PAGE_KERNEL);
if (ptr || (flags & (KM_MAYFAIL|KM_NOSLEEP)))
return ptr;
if (!(++retries % 100))
printk(KERN_ERR "XFS: possible memory allocation "
"deadlock in %s (mode:0x%x)\n",
__FUNCTION__, lflags);
blk_congestion_wait(WRITE, HZ/50);
} while (1);
}

which is in essence an open-coded GFP_NOFAIL implementation. Here's what
__GFP_NOFAIL does:

if (gfp_mask & __GFP_NOFAIL) {
blk_congestion_wait(WRITE, HZ/50);
goto nofail_alloc;
}

and since XFS makes use of KM_SLEEP in 130+ callsites, that means it is
in essence using GFP_NOFAIL massively!

Ingo
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/