Deleted Added
sdiff udiff text old ( 222184 ) new ( 226313 )
full compact
1/*-
2 * Copyright (c) 2002-2005, 2009 Jeffrey Roberson <jeff@FreeBSD.org>
3 * Copyright (c) 2004, 2005 Bosko Milekic <bmilekic@FreeBSD.org>
4 * Copyright (c) 2004-2006 Robert N. M. Watson
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 34 unchanged lines hidden (view full) ---

43
44/*
45 * TODO:
46 * - Improve memory usage for large allocations
47 * - Investigate cache size adjustments
48 */
49
50#include <sys/cdefs.h>
51__FBSDID("$FreeBSD: head/sys/vm/uma_core.c 222184 2011-05-22 17:46:16Z alc $");
52
53/* I should really use ktr.. */
54/*
55#define UMA_DEBUG 1
56#define UMA_DEBUG_ALLOC 1
57#define UMA_DEBUG_ALLOC_1 1
58*/
59
60#include "opt_ddb.h"
61#include "opt_param.h"
62
63#include <sys/param.h>
64#include <sys/systm.h>
65#include <sys/kernel.h>
66#include <sys/types.h>
67#include <sys/queue.h>
68#include <sys/malloc.h>
69#include <sys/ktr.h>

--- 13 unchanged lines hidden (view full) ---

83#include <vm/vm_kern.h>
84#include <vm/vm_extern.h>
85#include <vm/uma.h>
86#include <vm/uma_int.h>
87#include <vm/uma_dbg.h>
88
89#include <ddb/ddb.h>
90
91/*
92 * This is the zone and keg from which all zones are spawned. The idea is that
93 * even the zone & keg heads are allocated from the allocator, so we use the
94 * bss section to bootstrap us.
95 */
96static struct uma_keg masterkeg;
97static struct uma_zone masterzone_k;
98static struct uma_zone masterzone_z;

--- 1874 unchanged lines hidden (view full) ---

1973#endif
1974 CTR3(KTR_UMA, "uma_zalloc_arg thread %x zone %s flags %d", curthread,
1975 zone->uz_name, flags);
1976
1977 if (flags & M_WAITOK) {
1978 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
1979 "uma_zalloc_arg: zone \"%s\"", zone->uz_name);
1980 }
1981
1982 /*
1983 * If possible, allocate from the per-CPU cache. There are two
1984 * requirements for safe access to the per-CPU cache: (1) the thread
1985 * accessing the cache must not be preempted or yield during access,
1986 * and (2) the thread must not migrate CPUs without switching which
1987 * cache it accesses. We rely on a critical section to prevent
1988 * preemption and migration. We release the critical section in
1989 * order to acquire the zone mutex if we are unable to allocate from

--- 549 unchanged lines hidden (view full) ---

2539 printf("Freeing item %p to %s(%p)\n", item, zone->uz_name, zone);
2540#endif
2541 CTR2(KTR_UMA, "uma_zfree_arg thread %x zone %s", curthread,
2542 zone->uz_name);
2543
2544 /* uma_zfree(..., NULL) does nothing, to match free(9). */
2545 if (item == NULL)
2546 return;
2547
2548 if (zone->uz_dtor)
2549 zone->uz_dtor(item, zone->uz_size, udata);
2550
2551#ifdef INVARIANTS
2552 ZONE_LOCK(zone);
2553 if (zone->uz_flags & UMA_ZONE_MALLOC)
2554 uma_dbg_free(zone, udata, item);
2555 else

--- 796 unchanged lines hidden ---