15MALLOC_DEFINE(M_VM_ANON,
"vm-anon",
"anonymous virtual memory object");
26 size_t *b = (
size_t *) _b;
149 if (!src || !dst || !src->
arefs || !dst->
arefs)
156 if (hashmap_insert(dst->
arefs, node->
hash, aref))
#define hashmap_for(n, h)
void mm_page_dealloc(paddr_t paddr)
Frees a page of physical memory, back to the zone it came from.
#define MALLOC_DEFINE(type, _name, _desc)
void * kmalloc(size_t size, struct malloc_type *type, int flags)
Allocates memory for one of the kernel's structures.
void kfree(void *)
Frees an object that kmalloc() gave.
A hash table's node: an entry, with its key's hash.
A queue's node, holding one entry.
An anon: a mapping's private pages, those the process wrote to.
struct hashmap * arefs
its arefs, by the offset of their page in the mapping
int flags
its flags (VM_COPY: to be copied before it's written to)
size_t ref
how many mappings share the anon
An anon's reference to a page (an aref).
size_t ref
how many anons have the aref
struct vm_page * vm_page
the page
size_t off
its offset in its object or anon
paddr_t paddr
its physical address
#define VM_COPY
to be copied before it's written to
void vm_anon_destroy(struct vm_anon *vm_anon)
Releases an anon's arefs, and the pages of those that no other anon shares.
void vm_anon_incref(struct vm_anon *vm_anon)
Adds a reference to an anon: another mapping shares it (a fork).
struct vm_anon * vm_anon_new(void)
Makes a new, empty anon.
struct vm_anon * vm_anon_copy(struct vm_anon *vm_anon)
Makes a copy of an anon that shares its arefs, and so its pages, when a mapping's shared anon is writ...
void vm_anon_decref(struct vm_anon *vm_anon)
Drops a reference to an anon, and frees it with the last one.
void vm_aref_decref(struct vm_aref *vm_aref)
Drops a reference to an aref.
static int vm_anon_copy_arefs(struct vm_anon *src, struct vm_anon *dst)
Puts all of src's arefs in dst as well, shared: each gets one more reference.
static int vm_aref_eq(void *_a, void *_b)
Says whether an aref is the one for an offset (_b, a size_t *), for the anon's hashmap.
void vm_aref_destroy(struct vm_aref *vm_aref)
Releases what an aref holds.