]>
Commit | Line | Data |
---|---|---|
0b61f8a4 | 1 | // SPDX-License-Identifier: GPL-2.0 |
1da177e4 | 2 | /* |
7b718769 NS |
3 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
4 | * All Rights Reserved. | |
1da177e4 | 5 | */ |
0ad95687 | 6 | #include "xfs.h" |
4f10700a | 7 | #include "xfs_message.h" |
0ad95687 | 8 | #include "xfs_trace.h" |
1da177e4 | 9 | |
1da177e4 | 10 | void * |
77ba7877 | 11 | kmem_alloc(size_t size, xfs_km_flags_t flags) |
1da177e4 | 12 | { |
27496a8c AV |
13 | int retries = 0; |
14 | gfp_t lflags = kmem_flags_convert(flags); | |
15 | void *ptr; | |
1da177e4 | 16 | |
0ad95687 DC |
17 | trace_kmem_alloc(size, flags, _RET_IP_); |
18 | ||
1da177e4 | 19 | do { |
bdfb0430 | 20 | ptr = kmalloc(size, lflags); |
707e0dda | 21 | if (ptr || (flags & KM_MAYFAIL)) |
1da177e4 LT |
22 | return ptr; |
23 | if (!(++retries % 100)) | |
4f10700a | 24 | xfs_err(NULL, |
847f9f68 | 25 | "%s(%u) possible memory allocation deadlock size %u in %s (mode:0x%x)", |
5bf97b1c | 26 | current->comm, current->pid, |
847f9f68 | 27 | (unsigned int)size, __func__, lflags); |
4034247a | 28 | memalloc_retry_wait(lflags); |
1da177e4 LT |
29 | } while (1); |
30 | } |