19 size_t *b = (
size_t *) _b;
76 if (!buf)
return NULL;
85 hash_t hash = hashmap_digest(&off,
sizeof(off));
141 hash_t hash = hashmap_digest(&off,
sizeof(off));
150 printk(
"vm: no memory to update a file's cached pages\n");
static int vm_page_eq(void *a, void *b)
Tells whether a page is at the offset that b points to (for the object's hashmap of pages).
void vnode_pages_update(struct vnode *vnode, off_t start, off_t end)
Reads a file's cached pages again after a write or a truncation changed a range of it.
void vnode_pages_free(struct vnode *vnode)
Frees a vnode's vm object and its cached pages, when the vnode itself is freed.
struct vm_object * vm_object_vnode(struct vnode *vnode)
Gets a vnode's vm object, making it the first time.
struct vm_page * vnode_page_in(struct vm_object *vm_object, size_t off)
Reads a page of a file into its vm object: the vnode pager's page in.
static struct vm_pager vnode_pager
#define hashmap_for(n, h)
struct vm_page * mm_page_alloc(void)
Allocates a free page of physical memory.
void mm_page_dealloc(paddr_t paddr)
Frees a page of physical memory, back to the zone it came from.
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.
void * memset(void *dst, int c, size_t n)
Sets n bytes to c.
int pmap_page_write(paddr_t paddr, off_t off, size_t size, void *buf)
Writes to a page of physical memory, through the kernel's mapping.
int printk(const char *fmt,...)
Writes a kernel message, to the message buffer and the consoles.
ssize_t vfs_read(struct vnode *vnode, off_t off, size_t size, void *buf)
Reads from a vnode into a kernel buffer.
A hash table's node: an entry, with its key's hash.
A queue's node, holding one entry.
A vm object: what a mapping's pages come from (a file), and its pages that have been read in.
void * p
the pager's own data (a file's vnode)
int type
its kind (VMOBJ_*)
struct vm_pager * pager
its pager
struct hashmap * pages
its pages that have been read in, by their offset
A page of physical memory (pages[] has one for every page of RAM).
size_t off
its offset in its object or anon
size_t ref
how many references it has
struct vm_object * vm_object
the object it belongs to, or NULL
paddr_t paddr
its physical address
A file in memory (a vnode): what its inode says, and the kernel's own state.
struct vm_object * vm_object
its vm object: its pages, read in (the page cache)
#define VMOBJ_FILE
a file's pages
int vm_object_page_insert(struct vm_object *vm_object, struct vm_page *vm_page)
Adds a page to a vm object, at the page's offset (vm_page->off).