cregit-Linux how code gets into the kernel

Release 4.15 fs/xfs/kmem.c

Directory: fs/xfs
/*
 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
 * All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it would be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write the Free Software Foundation,
 * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
#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

PersonTokensPropCommitsCommitProp
Nathan Scott8478.50%220.00%
Tetsuo Handa87.48%110.00%
Eric Sandeen76.54%110.00%
Dave Chinner32.80%110.00%
Al Viro21.87%220.00%
Harvey Harrison10.93%110.00%
Andrew Morton10.93%110.00%
Jens Axboe10.93%110.00%
Total107100.00%10100.00%


void * kmem_zalloc_large(size_t size, xfs_km_flags_t flags) { unsigned nofs_flag = 0; void *ptr; gfp_t lflags; ptr = kmem_zalloc(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 | __GFP_ZERO, PAGE_KERNEL); if (flags & KM_NOFS) memalloc_nofs_restore(nofs_flag); return ptr; }

Contributors

PersonTokensPropCommitsCommitProp
Dave Chinner8090.91%250.00%
Michal Hocko66.82%125.00%
Nathan Scott22.27%125.00%
Total88100.00%4100.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

PersonTokensPropCommitsCommitProp
Christoph Hellwig6861.82%120.00%
Nathan Scott3935.45%120.00%
Barry Naujok10.91%120.00%
Dave Chinner10.91%120.00%
Al Viro10.91%120.00%
Total110100.00%5100.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

PersonTokensPropCommitsCommitProp
Nathan Scott8583.33%222.22%
Tetsuo Handa98.82%111.11%
Dave Chinner32.94%111.11%
Al Viro21.96%222.22%
Andrew Morton10.98%111.11%
Jens Axboe10.98%111.11%
Harvey Harrison10.98%111.11%
Total102100.00%9100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Nathan Scott22651.95%421.05%
Dave Chinner9020.69%315.79%
Christoph Hellwig6815.63%15.26%
Tetsuo Handa173.91%15.26%
Eric Sandeen71.61%15.26%
Michal Hocko61.38%15.26%
Andrew Morton51.15%15.26%
Al Viro51.15%210.53%
Tejun Heo30.69%15.26%
Ingo Molnar30.69%15.26%
Harvey Harrison20.46%15.26%
Jens Axboe20.46%15.26%
Barry Naujok10.23%15.26%
Total435100.00%19100.00%
Directory: fs/xfs
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.