diff options
author | alc <alc@FreeBSD.org> | 2010-05-02 17:33:46 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 2010-05-02 17:33:46 +0000 |
commit | f35e97166b133de28351ffee3f6de3407d0272b7 (patch) | |
tree | 800dba3ed92fa905f4e1acbc91746a06e2e47bc9 /sys/fs | |
parent | 1b4eb78965d8d551d4997edd6125fd401a212f5b (diff) | |
download | FreeBSD-src-f35e97166b133de28351ffee3f6de3407d0272b7.zip FreeBSD-src-f35e97166b133de28351ffee3f6de3407d0272b7.tar.gz |
It makes no sense for vm_page_sleep_if_busy()'s helper, vm_page_sleep(),
to unconditionally set PG_REFERENCED on a page before sleeping. In many
cases, it's perfectly ok for the page to disappear, i.e., be reclaimed by
the page daemon, before the caller to vm_page_sleep() is reawakened.
Instead, we now explicitly set PG_REFERENCED in those cases where having
the page persist until the caller is awakened is clearly desirable. Note,
however, that setting PG_REFERENCED on the page is still only a hint,
and not a guarantee that the page should persist.
Diffstat (limited to 'sys/fs')
-rw-r--r-- | sys/fs/tmpfs/tmpfs_vnops.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index c17efff..3d3755d 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -516,8 +516,16 @@ tmpfs_mappedread(vm_object_t vobj, vm_object_t tobj, size_t len, struct uio *uio lookupvpg: if (((m = vm_page_lookup(vobj, idx)) != NULL) && vm_page_is_valid(m, offset, tlen)) { - if (vm_page_sleep_if_busy(m, FALSE, "tmfsmr")) + if ((m->oflags & VPO_BUSY) != 0) { + /* + * Reference the page before unlocking and sleeping so + * that the page daemon is less likely to reclaim it. + */ + vm_page_lock_queues(); + vm_page_flag_set(m, PG_REFERENCED); + vm_page_sleep(m, "tmfsmr"); goto lookupvpg; + } vm_page_busy(m); VM_OBJECT_UNLOCK(vobj); error = uiomove_fromphys(&m, offset, tlen, uio); @@ -526,8 +534,16 @@ lookupvpg: VM_OBJECT_UNLOCK(vobj); return (error); } else if (m != NULL && uio->uio_segflg == UIO_NOCOPY) { - if (vm_page_sleep_if_busy(m, FALSE, "tmfsmr")) + if ((m->oflags & VPO_BUSY) != 0) { + /* + * Reference the page before unlocking and sleeping so + * that the page daemon is less likely to reclaim it. + */ + vm_page_lock_queues(); + vm_page_flag_set(m, PG_REFERENCED); + vm_page_sleep(m, "tmfsmr"); goto lookupvpg; + } vm_page_busy(m); VM_OBJECT_UNLOCK(vobj); sched_pin(); @@ -627,8 +643,16 @@ tmpfs_mappedwrite(vm_object_t vobj, vm_object_t tobj, size_t len, struct uio *ui lookupvpg: if (((vpg = vm_page_lookup(vobj, idx)) != NULL) && vm_page_is_valid(vpg, offset, tlen)) { - if (vm_page_sleep_if_busy(vpg, FALSE, "tmfsmw")) + if ((vpg->oflags & VPO_BUSY) != 0) { + /* + * Reference the page before unlocking and sleeping so + * that the page daemon is less likely to reclaim it. + */ + vm_page_lock_queues(); + vm_page_flag_set(vpg, PG_REFERENCED); + vm_page_sleep(vpg, "tmfsmw"); goto lookupvpg; + } vm_page_busy(vpg); vm_page_lock_queues(); vm_page_undirty(vpg); |