Deleted Added
full compact
vm_page.h (70374) vm_page.h (76827)
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 * $FreeBSD: head/sys/vm/vm_page.h 70374 2000-12-26 19:41:38Z dillon $
64 * $FreeBSD: head/sys/vm/vm_page.h 76827 2001-05-19 01:28:09Z alfred $
65 */
66
67/*
68 * Resident memory system definitions.
69 */
70
71#ifndef _VM_PAGE_
72#define _VM_PAGE_

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

300extern long first_page; /* first physical page number */
301
302#define VM_PAGE_TO_PHYS(entry) ((entry)->phys_addr)
303
304#define PHYS_TO_VM_PAGE(pa) \
305 (&vm_page_array[atop(pa) - first_page ])
306
307/*
65 */
66
67/*
68 * Resident memory system definitions.
69 */
70
71#ifndef _VM_PAGE_
72#define _VM_PAGE_

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

300extern long first_page; /* first physical page number */
301
302#define VM_PAGE_TO_PHYS(entry) ((entry)->phys_addr)
303
304#define PHYS_TO_VM_PAGE(pa) \
305 (&vm_page_array[atop(pa) - first_page ])
306
307/*
308 * For now, a global vm lock
309 */
310#define VM_PAGE_MTX(m) (&vm_mtx)
311
312/*
308 * Functions implemented as macros
309 */
310
311static __inline void
312vm_page_flag_set(vm_page_t m, unsigned short bits)
313{
313 * Functions implemented as macros
314 */
315
316static __inline void
317vm_page_flag_set(vm_page_t m, unsigned short bits)
318{
314 atomic_set_short(&(m)->flags, bits);
319
320 mtx_assert(VM_PAGE_MTX(m), MA_OWNED);
321 m->flags |= bits;
315}
316
317static __inline void
318vm_page_flag_clear(vm_page_t m, unsigned short bits)
319{
322}
323
324static __inline void
325vm_page_flag_clear(vm_page_t m, unsigned short bits)
326{
320 atomic_clear_short(&(m)->flags, bits);
327
328 mtx_assert(VM_PAGE_MTX(m), MA_OWNED);
329 m->flags &= ~bits;
321}
322
323#if 0
324static __inline void
325vm_page_assert_wait(vm_page_t m, int interruptible)
326{
327 vm_page_flag_set(m, PG_WANTED);
328 assert_wait((int) m, interruptible);
329}
330#endif
331
332static __inline void
333vm_page_busy(vm_page_t m)
334{
330}
331
332#if 0
333static __inline void
334vm_page_assert_wait(vm_page_t m, int interruptible)
335{
336 vm_page_flag_set(m, PG_WANTED);
337 assert_wait((int) m, interruptible);
338}
339#endif
340
341static __inline void
342vm_page_busy(vm_page_t m)
343{
335 KASSERT((m->flags & PG_BUSY) == 0, ("vm_page_busy: page already busy!!!"));
344
345 KASSERT((m->flags & PG_BUSY) == 0,
346 ("vm_page_busy: page already busy!!!"));
336 vm_page_flag_set(m, PG_BUSY);
337}
338
339/*
340 * vm_page_flash:
341 *
342 * wakeup anyone waiting for the page.
343 */

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

370/*
371 *
372 *
373 */
374
375static __inline void
376vm_page_io_start(vm_page_t m)
377{
347 vm_page_flag_set(m, PG_BUSY);
348}
349
350/*
351 * vm_page_flash:
352 *
353 * wakeup anyone waiting for the page.
354 */

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

381/*
382 *
383 *
384 */
385
386static __inline void
387vm_page_io_start(vm_page_t m)
388{
378 atomic_add_char(&(m)->busy, 1);
389
390 mtx_assert(VM_PAGE_MTX(m), MA_OWNED);
391 m->busy++;
379}
380
381static __inline void
382vm_page_io_finish(vm_page_t m)
383{
392}
393
394static __inline void
395vm_page_io_finish(vm_page_t m)
396{
384 atomic_subtract_char(&m->busy, 1);
397
398 mtx_assert(VM_PAGE_MTX(m), MA_OWNED);
399 m->busy--;
385 if (m->busy == 0)
386 vm_page_flash(m);
387}
388
389
390#if PAGE_SIZE == 4096
391#define VM_PAGE_BITS_ALL 0xff
392#endif

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

442 * Keep page from being freed by the page daemon
443 * much of the same effect as wiring, except much lower
444 * overhead and should be used only for *very* temporary
445 * holding ("wiring").
446 */
447static __inline void
448vm_page_hold(vm_page_t mem)
449{
400 if (m->busy == 0)
401 vm_page_flash(m);
402}
403
404
405#if PAGE_SIZE == 4096
406#define VM_PAGE_BITS_ALL 0xff
407#endif

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

457 * Keep page from being freed by the page daemon
458 * much of the same effect as wiring, except much lower
459 * overhead and should be used only for *very* temporary
460 * holding ("wiring").
461 */
462static __inline void
463vm_page_hold(vm_page_t mem)
464{
465
466 mtx_assert(VM_PAGE_MTX(m), MA_OWNED);
450 mem->hold_count++;
451}
452
453static __inline void
454vm_page_unhold(vm_page_t mem)
455{
467 mem->hold_count++;
468}
469
470static __inline void
471vm_page_unhold(vm_page_t mem)
472{
473
474 mtx_assert(VM_PAGE_MTX(m), MA_OWNED);
456 --mem->hold_count;
457 KASSERT(mem->hold_count >= 0, ("vm_page_unhold: hold count < 0!!!"));
458}
459
460/*
461 * vm_page_protect:
462 *
463 * Reduce the protection of a page. This routine never raises the

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

560{
561 if ((m->flags & PG_BUSY) || (also_m_busy && m->busy)) {
562 int s = splvm();
563 if ((m->flags & PG_BUSY) || (also_m_busy && m->busy)) {
564 /*
565 * Page is busy. Wait and retry.
566 */
567 vm_page_flag_set(m, PG_WANTED | PG_REFERENCED);
475 --mem->hold_count;
476 KASSERT(mem->hold_count >= 0, ("vm_page_unhold: hold count < 0!!!"));
477}
478
479/*
480 * vm_page_protect:
481 *
482 * Reduce the protection of a page. This routine never raises the

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

579{
580 if ((m->flags & PG_BUSY) || (also_m_busy && m->busy)) {
581 int s = splvm();
582 if ((m->flags & PG_BUSY) || (also_m_busy && m->busy)) {
583 /*
584 * Page is busy. Wait and retry.
585 */
586 vm_page_flag_set(m, PG_WANTED | PG_REFERENCED);
568 tsleep(m, PVM, msg, 0);
587 msleep(m, VM_PAGE_MTX(m), PVM, msg, 0);
569 }
570 splx(s);
571 return(TRUE);
572 /* not reached */
573 }
574 return(FALSE);
575}
576

--- 56 unchanged lines hidden ---
588 }
589 splx(s);
590 return(TRUE);
591 /* not reached */
592 }
593 return(FALSE);
594}
595

--- 56 unchanged lines hidden ---