0001
0002
0003
0004
0005
0006 #include "xfs.h"
0007 #include "xfs_message.h"
0008 #include "xfs_trace.h"
0009
0010 void *
0011 kmem_alloc(size_t size, xfs_km_flags_t flags)
0012 {
0013 int retries = 0;
0014 gfp_t lflags = kmem_flags_convert(flags);
0015 void *ptr;
0016
0017 trace_kmem_alloc(size, flags, _RET_IP_);
0018
0019 do {
0020 ptr = kmalloc(size, lflags);
0021 if (ptr || (flags & KM_MAYFAIL))
0022 return ptr;
0023 if (!(++retries % 100))
0024 xfs_err(NULL,
0025 "%s(%u) possible memory allocation deadlock size %u in %s (mode:0x%x)",
0026 current->comm, current->pid,
0027 (unsigned int)size, __func__, lflags);
0028 memalloc_retry_wait(lflags);
0029 } while (1);
0030 }