svn commit: r366837 - head/sys/kern
Mark Johnston
markj at FreeBSD.org
Mon Oct 19 16:52:27 UTC 2020
Author: markj
Date: Mon Oct 19 16:52:27 2020
New Revision: 366837
URL: https://svnweb.freebsd.org/changeset/base/366837
Log:
vmem: Simplify bt_fill() callers a bit
No functional change intended.
Reviewed by: alc, kib, rlibby
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D26769
Modified:
head/sys/kern/subr_vmem.c
Modified: head/sys/kern/subr_vmem.c
==============================================================================
--- head/sys/kern/subr_vmem.c Mon Oct 19 15:52:42 2020 (r366836)
+++ head/sys/kern/subr_vmem.c Mon Oct 19 16:52:27 2020 (r366837)
@@ -266,8 +266,8 @@ bt_isfree(bt_t *bt)
* allocation will not fail once bt_fill() passes. To do so we cache
* at least the maximum possible tag allocations in the arena.
*/
-static int
-bt_fill(vmem_t *vm, int flags)
+static __noinline int
+_bt_fill(vmem_t *vm, int flags)
{
bt_t *bt;
@@ -307,6 +307,14 @@ bt_fill(vmem_t *vm, int flags)
return 0;
}
+static inline int
+bt_fill(vmem_t *vm, int flags)
+{
+ if (vm->vm_nfreetags >= BT_MAXALLOC)
+ return (0);
+ return (_bt_fill(vm, flags));
+}
+
/*
* Pop a tag off of the freetag stack.
*/
@@ -1104,7 +1112,7 @@ retry:
/*
* Make sure we have enough tags to complete the operation.
*/
- if (vm->vm_nfreetags < BT_MAXALLOC && bt_fill(vm, flags) != 0)
+ if (bt_fill(vm, flags) != 0)
goto out;
/*
@@ -1387,11 +1395,9 @@ vmem_xalloc(vmem_t *vm, const vmem_size_t size0, vmem_
* Make sure we have enough tags to complete the
* operation.
*/
- if (vm->vm_nfreetags < BT_MAXALLOC &&
- bt_fill(vm, flags) != 0) {
- error = ENOMEM;
+ error = bt_fill(vm, flags);
+ if (error != 0)
break;
- }
/*
* Scan freelists looking for a tag that satisfies the
@@ -1510,13 +1516,12 @@ vmem_add(vmem_t *vm, vmem_addr_t addr, vmem_size_t siz
{
int error;
- error = 0;
flags &= VMEM_FLAGS;
+
VMEM_LOCK(vm);
- if (vm->vm_nfreetags >= BT_MAXALLOC || bt_fill(vm, flags) == 0)
+ error = bt_fill(vm, flags);
+ if (error == 0)
vmem_add1(vm, addr, size, BT_TYPE_SPAN_STATIC);
- else
- error = ENOMEM;
VMEM_UNLOCK(vm);
return (error);
More information about the svn-src-all
mailing list