mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 00:32:25 -04:00
LinuxKPI: make __kmalloc() play by the rules
According to Documentation/core-api/dma-api.rst kmalloc() is supposd
to provide physically contiguous memory. [1]
In order to guarantee that allocations are contiguous even if using
PAGE_SIZE or larger check the size and use contigmalloc if needed.
This makes use of 9e6544dd6e (and following) allowing free(9) to
also work for contigmalloced memory.
Sponsored by: The FreeBSD Foundation
Pointed out by: jhb [1]
Reviewed by: jhb, emaste
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D46656
This commit is contained in:
parent
a5c7b44d6a
commit
19df0c5abc
1 changed files with 5 additions and 1 deletions
|
|
@ -215,7 +215,11 @@ lkpi___kmalloc(size_t size, gfp_t flags)
|
||||||
/* sizeof(struct llist_node) is used for kfree_async(). */
|
/* sizeof(struct llist_node) is used for kfree_async(). */
|
||||||
_s = MAX(size, sizeof(struct llist_node));
|
_s = MAX(size, sizeof(struct llist_node));
|
||||||
|
|
||||||
return (malloc(_s, M_KMALLOC, linux_check_m_flags(flags)));
|
if (_s < PAGE_SIZE)
|
||||||
|
return (malloc(_s, M_KMALLOC, linux_check_m_flags(flags)));
|
||||||
|
else
|
||||||
|
return (contigmalloc(_s, M_KMALLOC, linux_check_m_flags(flags),
|
||||||
|
0, -1UL, PAGE_SIZE, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct lkpi_kmalloc_ctx {
|
struct lkpi_kmalloc_ctx {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue