summaryrefslogtreecommitdiffstats
path: root/sys/vm/uma_core.c
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2002-04-29 23:45:41 +0000
committerjeff <jeff@FreeBSD.org>2002-04-29 23:45:41 +0000
commitc52db1bfdfb3a9e4065f735384e8e23dd29a14c0 (patch)
tree6dec1f923097576eb3f5e981d5d602bbff1c0b68 /sys/vm/uma_core.c
parent1b161ee22037718913e8fcbbd1e19c367713e1b7 (diff)
downloadFreeBSD-src-c52db1bfdfb3a9e4065f735384e8e23dd29a14c0.zip
FreeBSD-src-c52db1bfdfb3a9e4065f735384e8e23dd29a14c0.tar.gz
Add a new zone flag UMA_ZONE_MTXCLASS. This puts the zone in it's own
mutex class. Currently this is only used for kmapentzone because kmapents are are potentially allocated when freeing memory. This is not dangerous though because no other allocations will be done while holding the kmapentzone lock.
Diffstat (limited to 'sys/vm/uma_core.c')
-rw-r--r--sys/vm/uma_core.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c
index 8418fed..2bb8f15 100644
--- a/sys/vm/uma_core.c
+++ b/sys/vm/uma_core.c
@@ -959,6 +959,7 @@ zone_ctor(void *mem, int size, void *udata)
{
struct uma_zctor_args *arg = udata;
uma_zone_t zone = mem;
+ int privlc;
int cplen;
int cpu;
@@ -992,6 +993,11 @@ zone_ctor(void *mem, int size, void *udata)
else
zone_small_init(zone);
+ if (arg->flags & UMA_ZONE_MTXCLASS)
+ privlc = 1;
+ else
+ privlc = 0;
+
/* We do this so that the per cpu lock name is unique for each zone */
memcpy(zone->uz_lname, "PCPU ", 5);
cplen = min(strlen(zone->uz_name) + 1, LOCKNAME_LEN - 6);
@@ -1053,7 +1059,7 @@ zone_ctor(void *mem, int size, void *udata)
zone->uz_size, zone->uz_ipers,
zone->uz_ppera, zone->uz_pgoff);
#endif
- ZONE_LOCK_INIT(zone);
+ ZONE_LOCK_INIT(zone, privlc);
mtx_lock(&uma_mtx);
LIST_INSERT_HEAD(&uma_zones, zone, uz_link);
@@ -1073,7 +1079,7 @@ zone_ctor(void *mem, int size, void *udata)
zone->uz_count = UMA_BUCKET_SIZE - 1;
for (cpu = 0; cpu < maxcpu; cpu++)
- CPU_LOCK_INIT(zone, cpu);
+ CPU_LOCK_INIT(zone, cpu, privlc);
}
/*
@@ -1799,10 +1805,12 @@ uma_zone_set_max(uma_zone_t zone, int nitems)
ZONE_LOCK(zone);
if (zone->uz_ppera > 1)
zone->uz_maxpages = nitems * zone->uz_ppera;
- else
+ else
zone->uz_maxpages = nitems / zone->uz_ipers;
+
if (zone->uz_maxpages * zone->uz_ipers < nitems)
zone->uz_maxpages++;
+
ZONE_UNLOCK(zone);
}
OpenPOWER on IntegriCloud