--- Gnu-Mach/vm/vm_object.h 2020/09/02 04:36:57 1.1 +++ Gnu-Mach/vm/vm_object.h 2020/09/02 04:54:14 1.1.1.7 @@ -1,25 +1,25 @@ -/* +/* * Mach Operating System * Copyright (c) 1993-1987 Carnegie Mellon University * All Rights Reserved. - * + * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. - * + * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to - * + * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 - * + * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ @@ -34,9 +34,7 @@ #ifndef _VM_VM_OBJECT_H_ #define _VM_VM_OBJECT_H_ -#include -#include - +#include #include #include #include @@ -46,41 +44,35 @@ #include #include #include -#include +#include +#include #include +#include #if MACH_PAGEMAP #include #endif /* MACH_PAGEMAP */ -#if NORMA_VM -typedef struct xmm_obj * pager_request_t; -#else /* NORMA_VM */ typedef struct ipc_port * pager_request_t; -#endif /* NORMA_VM */ #define PAGER_REQUEST_NULL ((pager_request_t) 0) /* - * Types defined: - * - * vm_object_t Virtual memory object. - * * We use "struct ipc_port *" instead of "ipc_port_t" * to avoid include file circularities. */ struct vm_object { - queue_chain_t memq; /* Resident memory */ + queue_head_t memq; /* Resident memory */ decl_simple_lock_data(, Lock) /* Synchronization */ #if VM_OBJECT_DEBUG thread_t LockHolder; /* Thread holding Lock */ -#endif VM_OBJECT_DEBUG +#endif /* VM_OBJECT_DEBUG */ vm_size_t size; /* Object size (only valid * if internal) */ - short ref_count; /* Number of references */ - short resident_page_count; + int ref_count; /* Number of references */ + unsigned long resident_page_count; /* number of resident pages */ struct vm_object *copy; /* Object that should receive @@ -121,6 +113,13 @@ struct vm_object { * of these fields (i.e., don't * collapse, destroy or terminate) */ + /* boolean_t */ used_for_pageout:1,/* The object carries data sent to + * a memory manager, which signals + * it's done by releasing memory. + * This flag prevents coalescing so + * that unmapping memory immediately + * results in object termination. + */ /* boolean_t */ pager_created:1,/* Has pager ever been created? */ /* boolean_t */ pager_initialized:1,/* Are fields ready to use? */ /* boolean_t */ pager_ready:1, /* Will manager take requests? */ @@ -151,13 +150,11 @@ struct vm_object { /* Should lock request in * progress restart search? */ - /* boolean_t */ use_old_pageout : 1, - /* Use old pageout primitives? - */ /* boolean_t */ use_shared_copy : 1,/* Use shared (i.e., * delayed) copy on write */ - /* boolean_t */ shadowed: 1; /* Shadow may exist */ + /* boolean_t */ shadowed: 1, /* Shadow may exist */ + /* boolean_t */ cached: 1; /* Object is cached */ queue_chain_t cached_list; /* Attachment point for the list * of objects cached as a result * of their can_persist value @@ -168,9 +165,6 @@ struct vm_object { #endif /* MACH_PAGEMAP */ }; -typedef struct vm_object *vm_object_t; -#define VM_OBJECT_NULL ((vm_object_t) 0) - extern vm_object_t kernel_object; /* the single kernel object */ @@ -180,6 +174,7 @@ vm_object_t kernel_object; /* the singl extern void vm_object_bootstrap(void); extern void vm_object_init(void); +extern void vm_object_collect(vm_object_t); extern void vm_object_terminate(vm_object_t); extern vm_object_t vm_object_allocate(vm_size_t); extern void vm_object_reference(vm_object_t); @@ -237,17 +232,35 @@ extern void vm_object_pager_create( extern void vm_object_destroy( struct ipc_port *pager); -extern void vm_object_page_map( - vm_object_t, - vm_offset_t, - vm_size_t, +extern void vm_object_page_map( + vm_object_t, + vm_offset_t, + vm_size_t, vm_offset_t (*)(void *, vm_offset_t), void *); -extern void vm_object_print(vm_object_t); - extern vm_object_t vm_object_request_object(struct ipc_port *); +extern boolean_t vm_object_coalesce( + vm_object_t prev_object, + vm_object_t next_object, + vm_offset_t prev_offset, + vm_offset_t next_offset, + vm_size_t prev_size, + vm_size_t next_size); + +extern void vm_object_pager_wakeup(ipc_port_t pager); + +void memory_object_release( + ipc_port_t pager, + pager_request_t pager_request, + ipc_port_t pager_name); + +void vm_object_deactivate_pages(vm_object_t); + +vm_object_t vm_object_copy_delayed( + vm_object_t src_object); + /* * Event waiting handling */ @@ -283,6 +296,10 @@ extern vm_object_t vm_object_request_obj * Routines implemented as macros */ +#define vm_object_collectable(object) \ + (((object)->ref_count == 0) \ + && ((object)->resident_page_count == 0)) + #define vm_object_paging_begin(object) \ ((object)->paging_in_progress++) @@ -371,4 +388,12 @@ MACRO_END #define vm_object_lock_taken(object) simple_lock_taken(&(object)->Lock) #endif /* VM_OBJECT_DEBUG */ +/* + * Page cache accounting. + * + * The page queues must be locked when changing these counters. + */ +extern int vm_object_external_count; +extern int vm_object_external_pages; + #endif /* _VM_VM_OBJECT_H_ */