Skip to content

Commit

Permalink
use MAX_MCACHE_ORDER instead of hard-coded
Browse files Browse the repository at this point in the history
  • Loading branch information
0x5459 committed Nov 13, 2024
1 parent 7632b7c commit 8660efa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 0 additions & 1 deletion kernel-open/nvidia-uvm/uvm_kvmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ static void *alloc_internal(size_t size, bool zero_memory)
// Make sure that (sizeof(hdr) + size) is what it should be
BUILD_BUG_ON(sizeof(uvm_vmalloc_hdr_t) != offsetof(uvm_vmalloc_hdr_t *, ptr));

assert(size <= (1 << 32));
if (size <= UVM_KMALLOC_THRESHOLD) {
if (zero_memory)
return kzalloc(size, NV_UVM_GFP_FLAGS);
Expand Down
8 changes: 5 additions & 3 deletions kernel-open/nvidia-uvm/uvm_kvmalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include "uvm_nanos.h"
#include "uvm_test_ioctl.h"

#ifndef _CONFIG_H_
#include <config.h>
#define _CONFIG_H_

// kmalloc is faster than vmalloc because it doesn't have to remap kernel
// virtual memory, but for that same reason it requires physically-contiguous
// memory. It also supports a native krealloc function which is missing in
Expand All @@ -41,9 +45,7 @@
//
// This is in the header so callers can use it to inform their allocation sizes
// if they wish.
//
// Default value is 16. See: https://github.com/nanovms/nanos/blob/103518003874e7c8c3cb6e5a93d81fd0f197fde6/src/config.h#L84-L85
#define UVM_KMALLOC_THRESHOLD 16
#define UVM_KMALLOC_THRESHOLD (1 << MAX_MCACHE_ORDER)

NV_STATUS uvm_kvmalloc_init(void);
void uvm_kvmalloc_exit(void);
Expand Down

0 comments on commit 8660efa

Please sign in to comment.