Release 4.18 fs/xfs/kmem.c
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
*/
#include <linux/mm.h>
#include <linux/sched/mm.h>
#include <linux/highmem.h>
#include <linux/slab.h>
#include <linux/swap.h>
#include <linux/blkdev.h>
#include <linux/backing-dev.h>
#include "kmem.h"
#include "xfs_message.h"
void *
kmem_alloc(size_t size, xfs_km_flags_t flags)
{
int retries = 0;
gfp_t lflags = kmem_flags_convert(flags);
void *ptr;
do {
ptr = kmalloc(size, lflags);
if (ptr || (flags & (KM_MAYFAIL|KM_NOSLEEP)))
return ptr;
if (!(++retries % 100))
xfs_err(NULL,
"%s(%u) possible memory allocation deadlock size %u in %s (mode:0x%x)",
current->comm, current->pid,
(unsigned int)size, __func__, lflags);
congestion_wait(BLK_RW_ASYNC, HZ/50);
} while (1);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| Nathan Scott | 84 | 78.50% | 2 | 20.00% |
| Tetsuo Handa | 8 | 7.48% | 1 | 10.00% |
| Eric Sandeen | 7 | 6.54% | 1 | 10.00% |
| Dave Chinner | 3 | 2.80% | 1 | 10.00% |
| Al Viro | 2 | 1.87% | 2 | 20.00% |
| Jens Axboe | 1 | 0.93% | 1 | 10.00% |
| Andrew Morton | 1 | 0.93% | 1 | 10.00% |
| Harvey Harrison | 1 | 0.93% | 1 | 10.00% |
| Total | 107 | 100.00% | 10 | 100.00% |
void *
kmem_alloc_large(size_t size, xfs_km_flags_t flags)
{
unsigned nofs_flag = 0;
void *ptr;
gfp_t lflags;
ptr = kmem_alloc(size, flags | KM_MAYFAIL);
if (ptr)
return ptr;
/*
* __vmalloc() will allocate data pages and auxillary structures (e.g.
* pagetables) with GFP_KERNEL, yet we may be under GFP_NOFS context
* here. Hence we need to tell memory reclaim that we are in such a
* context via PF_MEMALLOC_NOFS to prevent memory reclaim re-entering
* the filesystem here and potentially deadlocking.
*/
if (flags & KM_NOFS)
nofs_flag = memalloc_nofs_save();
lflags = kmem_flags_convert(flags);
ptr = __vmalloc(size, lflags, PAGE_KERNEL);
if (flags & KM_NOFS)
memalloc_nofs_restore(nofs_flag);
return ptr;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| Dave Chinner | 78 | 90.70% | 3 | 60.00% |
| Michal Hocko | 6 | 6.98% | 1 | 20.00% |
| Nathan Scott | 2 | 2.33% | 1 | 20.00% |
| Total | 86 | 100.00% | 5 | 100.00% |
void *
kmem_realloc(const void *old, size_t newsize, xfs_km_flags_t flags)
{
int retries = 0;
gfp_t lflags = kmem_flags_convert(flags);
void *ptr;
do {
ptr = krealloc(old, newsize, lflags);
if (ptr || (flags & (KM_MAYFAIL|KM_NOSLEEP)))
return ptr;
if (!(++retries % 100))
xfs_err(NULL,
"%s(%u) possible memory allocation deadlock size %zu in %s (mode:0x%x)",
current->comm, current->pid,
newsize, __func__, lflags);
congestion_wait(BLK_RW_ASYNC, HZ/50);
} while (1);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| Christoph Hellwig | 68 | 61.82% | 1 | 20.00% |
| Nathan Scott | 39 | 35.45% | 1 | 20.00% |
| Dave Chinner | 1 | 0.91% | 1 | 20.00% |
| Al Viro | 1 | 0.91% | 1 | 20.00% |
| Barry Naujok | 1 | 0.91% | 1 | 20.00% |
| Total | 110 | 100.00% | 5 | 100.00% |
void *
kmem_zone_alloc(kmem_zone_t *zone, xfs_km_flags_t flags)
{
int retries = 0;
gfp_t lflags = kmem_flags_convert(flags);
void *ptr;
do {
ptr = kmem_cache_alloc(zone, lflags);
if (ptr || (flags & (KM_MAYFAIL|KM_NOSLEEP)))
return ptr;
if (!(++retries % 100))
xfs_err(NULL,
"%s(%u) possible memory allocation deadlock in %s (mode:0x%x)",
current->comm, current->pid,
__func__, lflags);
congestion_wait(BLK_RW_ASYNC, HZ/50);
} while (1);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| Nathan Scott | 85 | 83.33% | 2 | 22.22% |
| Tetsuo Handa | 9 | 8.82% | 1 | 11.11% |
| Dave Chinner | 3 | 2.94% | 1 | 11.11% |
| Al Viro | 2 | 1.96% | 2 | 22.22% |
| Jens Axboe | 1 | 0.98% | 1 | 11.11% |
| Andrew Morton | 1 | 0.98% | 1 | 11.11% |
| Harvey Harrison | 1 | 0.98% | 1 | 11.11% |
| Total | 102 | 100.00% | 9 | 100.00% |
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| Nathan Scott | 225 | 51.84% | 3 | 15.00% |
| Dave Chinner | 90 | 20.74% | 5 | 25.00% |
| Christoph Hellwig | 68 | 15.67% | 1 | 5.00% |
| Tetsuo Handa | 17 | 3.92% | 1 | 5.00% |
| Eric Sandeen | 7 | 1.61% | 1 | 5.00% |
| Michal Hocko | 6 | 1.38% | 1 | 5.00% |
| Andrew Morton | 5 | 1.15% | 1 | 5.00% |
| Al Viro | 5 | 1.15% | 2 | 10.00% |
| Ingo Molnar | 3 | 0.69% | 1 | 5.00% |
| Tejun Heo | 3 | 0.69% | 1 | 5.00% |
| Jens Axboe | 2 | 0.46% | 1 | 5.00% |
| Harvey Harrison | 2 | 0.46% | 1 | 5.00% |
| Barry Naujok | 1 | 0.23% | 1 | 5.00% |
| Total | 434 | 100.00% | 20 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.