vm_object.c (4a62209c07d53045be79be59cb3b33bbe1dbc082) | vm_object.c (0a47b48b9f61ddbac24f3f22e1f266acdd493080) |
---|---|
1/* 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * The Mach Operating System project at Carnegie-Mellon University. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 47 unchanged lines hidden (view full) --- 56 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 57 * School of Computer Science 58 * Carnegie Mellon University 59 * Pittsburgh PA 15213-3890 60 * 61 * any improvements or extensions that they make and grant Carnegie the 62 * rights to redistribute these changes. 63 * | 1/* 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * The Mach Operating System project at Carnegie-Mellon University. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 47 unchanged lines hidden (view full) --- 56 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 57 * School of Computer Science 58 * Carnegie Mellon University 59 * Pittsburgh PA 15213-3890 60 * 61 * any improvements or extensions that they make and grant Carnegie the 62 * rights to redistribute these changes. 63 * |
64 * $Id: vm_object.c,v 1.71 1996/05/21 05:26:27 dyson Exp $ | 64 * $Id: vm_object.c,v 1.72 1996/05/21 17:13:31 dyson Exp $ |
65 */ 66 67/* 68 * Virtual memory object module. 69 */ 70#include "opt_ddb.h" 71 72#include <sys/param.h> --- 631 unchanged lines hidden (view full) --- 704 if (m == NULL || m->busy || (m->flags & PG_BUSY) || 705 m->hold_count || m->wire_count || 706 m->valid != VM_PAGE_BITS_ALL) 707 continue; 708 709 if (advise == MADV_WILLNEED) { 710 if (m->queue != PQ_ACTIVE) 711 vm_page_activate(m); | 65 */ 66 67/* 68 * Virtual memory object module. 69 */ 70#include "opt_ddb.h" 71 72#include <sys/param.h> --- 631 unchanged lines hidden (view full) --- 704 if (m == NULL || m->busy || (m->flags & PG_BUSY) || 705 m->hold_count || m->wire_count || 706 m->valid != VM_PAGE_BITS_ALL) 707 continue; 708 709 if (advise == MADV_WILLNEED) { 710 if (m->queue != PQ_ACTIVE) 711 vm_page_activate(m); |
712 } else if (advise == MADV_DONTNEED) { | 712 } else if ((advise == MADV_DONTNEED) || 713 ((advise == MADV_FREE) && 714 ((object->type != OBJT_DEFAULT) && (object->type != OBJT_SWAP)))) { |
713 /* 714 * If the upper level VM system doesn't think that 715 * the page is dirty, check the pmap layer. 716 */ 717 if (m->dirty == 0) { 718 vm_page_test_dirty(m); 719 } 720 /* --- 6 unchanged lines hidden (view full) --- 727 } else { 728 /* 729 * If the page IS dirty, then we remove it from all 730 * pmaps and deactivate it. 731 */ 732 vm_page_protect(m, VM_PROT_NONE); 733 vm_page_deactivate(m); 734 } | 715 /* 716 * If the upper level VM system doesn't think that 717 * the page is dirty, check the pmap layer. 718 */ 719 if (m->dirty == 0) { 720 vm_page_test_dirty(m); 721 } 722 /* --- 6 unchanged lines hidden (view full) --- 729 } else { 730 /* 731 * If the page IS dirty, then we remove it from all 732 * pmaps and deactivate it. 733 */ 734 vm_page_protect(m, VM_PROT_NONE); 735 vm_page_deactivate(m); 736 } |
737 } else if (advise == MADV_FREE) { 738 /* 739 * Force a demand-zero on next ref 740 */ 741 if (object->type == OBJT_SWAP) 742 swap_pager_dmzspace(object, m->pindex, 1); 743 vm_page_protect(m, VM_PROT_NONE); 744 vm_page_free(m); |
|
735 } 736 } 737} 738 739/* | 745 } 746 } 747} 748 749/* |
740 * vm_object_copy: 741 * 742 * Create a new object which is a copy of an existing 743 * object, and mark all of the pages in the existing 744 * object 'copy-on-write'. The new object has one reference. 745 * Returns the new object. 746 * 747 * May defer the copy until later if the object is not backed 748 * up by a non-default pager. 749 * 750 */ 751void 752vm_object_copy(src_object, src_offset, 753 dst_object, dst_offset, src_needs_copy) 754 register vm_object_t src_object; 755 vm_pindex_t src_offset; 756 vm_object_t *dst_object;/* OUT */ 757 vm_pindex_t *dst_offset;/* OUT */ 758 boolean_t *src_needs_copy; /* OUT */ 759{ 760 if (src_object == NULL) { 761 /* 762 * Nothing to copy 763 */ 764 *dst_object = NULL; 765 *dst_offset = 0; 766 *src_needs_copy = FALSE; 767 return; 768 } 769 770 /* 771 * Try to collapse the object before copying it. 772 */ 773 if (src_object->handle == NULL && 774 (src_object->type == OBJT_DEFAULT || 775 src_object->type == OBJT_SWAP)) 776 vm_object_collapse(src_object); 777 778 779 /* 780 * Make another reference to the object 781 */ 782 src_object->ref_count++; 783 *dst_object = src_object; 784 *dst_offset = src_offset; 785 786 /* 787 * Must make a shadow when write is desired 788 */ 789 *src_needs_copy = TRUE; 790 return; 791} 792 793/* | |
794 * vm_object_shadow: 795 * 796 * Create a new object which is backed by the 797 * specified existing object range. The source 798 * object reference is deallocated. 799 * 800 * The new object and offset into that object 801 * are returned in the source parameters. --- 740 unchanged lines hidden --- | 750 * vm_object_shadow: 751 * 752 * Create a new object which is backed by the 753 * specified existing object range. The source 754 * object reference is deallocated. 755 * 756 * The new object and offset into that object 757 * are returned in the source parameters. --- 740 unchanged lines hidden --- |