vm_object.c (8e58bf687510147b5cd664eab7a2bf7ddb4025f6) vm_object.c (05f0fdd26aa1789c04ae89358880922a54d197c3)
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.6 1994/08/27 16:14:39 davidg Exp $
64 * $Id: vm_object.c,v 1.7 1994/10/05 09:48:43 davidg Exp $
65 */
66
67/*
68 * Virtual memory object module.
69 */
70
71#include <sys/param.h>
72#include <sys/systm.h>
73#include <sys/kernel.h>
74#include <sys/proc.h> /* for curproc, pageproc */
75#include <sys/malloc.h>
76
77#include <vm/vm.h>
78#include <vm/vm_page.h>
79#include <vm/vm_pageout.h>
65 */
66
67/*
68 * Virtual memory object module.
69 */
70
71#include <sys/param.h>
72#include <sys/systm.h>
73#include <sys/kernel.h>
74#include <sys/proc.h> /* for curproc, pageproc */
75#include <sys/malloc.h>
76
77#include <vm/vm.h>
78#include <vm/vm_page.h>
79#include <vm/vm_pageout.h>
80#include <vm/swap_pager.h>
80
81static void _vm_object_allocate(vm_size_t, vm_object_t);
82
83/*
84 * Virtual memory objects maintain the actual data
85 * associated with allocated virtual memory. A given
86 * page of memory exists within exactly one object.
87 *

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

183 * Returns a new object with the given size.
184 */
185
186vm_object_t
187vm_object_allocate(size)
188 vm_size_t size;
189{
190 register vm_object_t result;
81
82static void _vm_object_allocate(vm_size_t, vm_object_t);
83
84/*
85 * Virtual memory objects maintain the actual data
86 * associated with allocated virtual memory. A given
87 * page of memory exists within exactly one object.
88 *

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

184 * Returns a new object with the given size.
185 */
186
187vm_object_t
188vm_object_allocate(size)
189 vm_size_t size;
190{
191 register vm_object_t result;
191 int s;
192
193 result = (vm_object_t)
194 malloc((u_long)sizeof *result, M_VMOBJ, M_WAITOK);
195
196
197 _vm_object_allocate(size, result);
198
199 return(result);

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

432vm_object_page_clean(object, start, end, syncio, de_queue)
433 register vm_object_t object;
434 register vm_offset_t start;
435 register vm_offset_t end;
436 boolean_t syncio;
437 boolean_t de_queue;
438{
439 register vm_page_t p, nextp;
192
193 result = (vm_object_t)
194 malloc((u_long)sizeof *result, M_VMOBJ, M_WAITOK);
195
196
197 _vm_object_allocate(size, result);
198
199 return(result);

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

432vm_object_page_clean(object, start, end, syncio, de_queue)
433 register vm_object_t object;
434 register vm_offset_t start;
435 register vm_offset_t end;
436 boolean_t syncio;
437 boolean_t de_queue;
438{
439 register vm_page_t p, nextp;
440 int s;
441 int size;
442
443 if (object->pager == NULL)
444 return 1;
445
446 if (start != end) {
447 start = trunc_page(start);
448 end = round_page(end);

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

1229 * We can collapse the backing object.
1230 *
1231 * Move all in-memory pages from backing_object
1232 * to the parent. Pages that have been paged out
1233 * will be overwritten by any of the parent's
1234 * pages that shadow them.
1235 */
1236
440 int size;
441
442 if (object->pager == NULL)
443 return 1;
444
445 if (start != end) {
446 start = trunc_page(start);
447 end = round_page(end);

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

1228 * We can collapse the backing object.
1229 *
1230 * Move all in-memory pages from backing_object
1231 * to the parent. Pages that have been paged out
1232 * will be overwritten by any of the parent's
1233 * pages that shadow them.
1234 */
1235
1237 while (p = backing_object->memq.tqh_first) {
1236 while ((p = backing_object->memq.tqh_first) != 0) {
1238
1239 new_offset = (p->offset - backing_offset);
1240
1241 /*
1242 * If the parent has a page here, or if
1243 * this page falls outside the parent,
1244 * dispose of it.
1245 *

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

1439void
1440vm_object_page_remove(object, start, end)
1441 register vm_object_t object;
1442 register vm_offset_t start;
1443 register vm_offset_t end;
1444{
1445 register vm_page_t p, next;
1446 vm_offset_t size;
1237
1238 new_offset = (p->offset - backing_offset);
1239
1240 /*
1241 * If the parent has a page here, or if
1242 * this page falls outside the parent,
1243 * dispose of it.
1244 *

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

1438void
1439vm_object_page_remove(object, start, end)
1440 register vm_object_t object;
1441 register vm_offset_t start;
1442 register vm_offset_t end;
1443{
1444 register vm_page_t p, next;
1445 vm_offset_t size;
1447 int cnt;
1448 int s;
1449
1450 if (object == NULL)
1451 return;
1452
1453 start = trunc_page(start);
1454 end = round_page(end);
1455again:

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

1470 vm_page_lock_queues();
1471 vm_page_free(p);
1472 vm_page_unlock_queues();
1473 size -= PAGE_SIZE;
1474 }
1475 }
1476 } else {
1477 while (size > 0) {
1446 int s;
1447
1448 if (object == NULL)
1449 return;
1450
1451 start = trunc_page(start);
1452 end = round_page(end);
1453again:

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

1468 vm_page_lock_queues();
1469 vm_page_free(p);
1470 vm_page_unlock_queues();
1471 size -= PAGE_SIZE;
1472 }
1473 }
1474 } else {
1475 while (size > 0) {
1478 while (p = vm_page_lookup(object, start)) {
1476 while ((p = vm_page_lookup(object, start)) != 0) {
1479 s = splhigh();
1480 if (p->flags & PG_BUSY) {
1481 p->flags |= PG_WANTED;
1482 tsleep((caddr_t) p, PVM, "vmopar", 0);
1483 splx(s);
1484 goto again;
1485 }
1486 splx(s);

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

1622 return;
1623
1624 iprintf("Object 0x%x: size=0x%x, res=%d, ref=%d, ",
1625 (int) object, (int) object->size,
1626 object->resident_page_count, object->ref_count);
1627 printf("pager=0x%x+0x%x, shadow=(0x%x)+0x%x\n",
1628 (int) object->pager, (int) object->paging_offset,
1629 (int) object->shadow, (int) object->shadow_offset);
1477 s = splhigh();
1478 if (p->flags & PG_BUSY) {
1479 p->flags |= PG_WANTED;
1480 tsleep((caddr_t) p, PVM, "vmopar", 0);
1481 splx(s);
1482 goto again;
1483 }
1484 splx(s);

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

1620 return;
1621
1622 iprintf("Object 0x%x: size=0x%x, res=%d, ref=%d, ",
1623 (int) object, (int) object->size,
1624 object->resident_page_count, object->ref_count);
1625 printf("pager=0x%x+0x%x, shadow=(0x%x)+0x%x\n",
1626 (int) object->pager, (int) object->paging_offset,
1627 (int) object->shadow, (int) object->shadow_offset);
1630 printf("cache: next=0x%x, prev=0x%x\n",
1628 printf("cache: next=%p, prev=%p\n",
1631 object->cached_list.tqe_next, object->cached_list.tqe_prev);
1632
1633 if (!full)
1634 return;
1635
1636 indent += 2;
1637 count = 0;
1638 for (p = object->memq.tqh_first; p != NULL; p = p->listq.tqe_next) {
1639 if (count == 0)
1640 iprintf("memory:=");
1641 else if (count == 6) {
1642 printf("\n");
1643 iprintf(" ...");
1644 count = 0;
1645 } else
1646 printf(",");
1647 count++;
1648
1629 object->cached_list.tqe_next, object->cached_list.tqe_prev);
1630
1631 if (!full)
1632 return;
1633
1634 indent += 2;
1635 count = 0;
1636 for (p = object->memq.tqh_first; p != NULL; p = p->listq.tqe_next) {
1637 if (count == 0)
1638 iprintf("memory:=");
1639 else if (count == 6) {
1640 printf("\n");
1641 iprintf(" ...");
1642 count = 0;
1643 } else
1644 printf(",");
1645 count++;
1646
1649 printf("(off=0x%x,page=0x%x)", p->offset, VM_PAGE_TO_PHYS(p));
1647 printf("(off=0x%lx,page=0x%lx)",
1648 (u_long)p->offset, (u_long)VM_PAGE_TO_PHYS(p));
1650 }
1651 if (count != 0)
1652 printf("\n");
1653 indent -= 2;
1654}
1655#endif /* defined(DEBUG) || defined(DDB) */
1649 }
1650 if (count != 0)
1651 printf("\n");
1652 indent -= 2;
1653}
1654#endif /* defined(DEBUG) || defined(DDB) */