Commit Graph

435 Commits

Author SHA1 Message Date
John Dyson
0bc3a91127 Remove an unnecessary tsleep in the swapin code. This tsleep
can defer swapping in processes and is just not the right thing to do.
1995-10-16 05:45:49 +00:00
David Greenman
cd41fc123e Fix argument passing to the "freeer" routine. Added some prototypes. (bde)
Moved extern declaration of swap_pager_full into swap_pager.h and out of
the various files that reference it. (davidg)

Submitted by:	bde & davidg
1995-10-07 19:02:56 +00:00
Poul-Henning Kamp
a5eb0e27e4 Avoid a 64bit divide. 1995-10-06 09:42:11 +00:00
Bruce Evans
f2caf6f548 Fix pollution of application namespace by declarations of kernel
functions.  The application header <sys/user.h> includes <vm/vm.h>
which includes <vm/lock.h>...

vm.h:
Don't include <machine/cpufunc.h>.  It is already included by
<sys/systm.h> in the kernel and isn't designed to be included by
applications (the 2.1 version causes a syntax error in C++ and the
current version has initializers that are invalid in strict C++).

lock.h:
Only declare kernel functions if KERNEL is defined.
1995-10-05 01:11:48 +00:00
John Dyson
0e27a03ffb Perform more checking for proper loading of the UPAGES when a process
is swapped in.  Also, remove unnecessary map locking/unlocking during
selection of processes to be swapped out.

This code might afford proper panics as opposed to spontaneous reboots
on certain systems.  This should allow us to debug these problems better.
1995-09-24 19:51:50 +00:00
John Dyson
22ba64e870 Significantly simplify the fault clustering code. After some analysis by
David Greenman, it has been determined that the more sophisticated code
only made a very minor difference in fault performance.  Therefore, this
code eliminates some of the complication of the fault code, decreasing
the amount of CPU used to scan shadow chains.
1995-09-24 19:47:58 +00:00
David Greenman
2f82e60467 Check that the swap block is valid before including it in a cluster.
Submitted by:	John Dyson
1995-09-24 04:40:19 +00:00
David Greenman
c87ad37e61 Check the return value from vm_map_pageable() when mapping the process's
UPAGES and associated page table page. Panic on error. This is less than
optimial and will be fixed in the future, but is better than the old
behavior of panicing with a "kernel page directory invalid" in pmap_enter.
1995-09-17 01:46:03 +00:00
John Dyson
21bf390418 Fixed a typo in vm_fault_additional_pages. 1995-09-14 13:42:52 +00:00
John Dyson
6eab77f210 Fix really bogus casting of a block number to a long. Also change the
comparison from a "< 0" to "== -1" like it should be.
1995-09-12 14:42:43 +00:00
John Dyson
894048d71c Make sure that the prezero flag is cleared when needed. 1995-09-11 00:47:17 +00:00
John Dyson
b1fc01b7da Fix an error that can cause attempted reading beyond the end of file. 1995-09-11 00:46:19 +00:00
John Dyson
ccbb2f7226 Code cleanup and minor performance improvement in the faultin cluster
code.
1995-09-11 00:45:15 +00:00
David Greenman
4590fd3a2a Fixed init functions argument type - caddr_t -> void *. Fixed a couple of
compiler warnings.
1995-09-09 18:10:37 +00:00
John Dyson
ca56715fd8 Fixed a sign reversal problem -- might have cause some Sig-11s that
people have been seeing.
1995-09-06 07:08:45 +00:00
John Dyson
ced399ee65 Minor performance improvements, additional prototype for additional
exported symbol.
1995-09-06 05:37:43 +00:00
John Dyson
170db9c63a Allow the fault code to use additional clustering info from both
bmap and the swap pager.  Improved fault clustering performance.
1995-09-04 04:44:26 +00:00
John Dyson
c83ebe7781 Added VOP_GETPAGES/VOP_PUTPAGES and also the "backwards" block count
for VOP_BMAP.  Updated affected filesystems...
1995-09-04 00:21:16 +00:00
John Dyson
f70f05f238 Machine independent changes to support pre-zeroed free pages. This
significantly improves demand-zero performance.
1995-09-03 20:40:43 +00:00
John Dyson
10ad4d483c Added prototype for new routine "vm_page_set_validclean" and initial
declarations for the prezeroed pages mechanism.
1995-09-03 20:11:26 +00:00
John Dyson
4589a4b5dc New subroutine "vm_page_set_validclean" for a vfs_bio improvement. 1995-09-03 19:57:25 +00:00
Julian Elischer
2b14f991e6 Reviewed by: julian with quick glances by bruce and others
Submitted by:	terry (terry lambert)
This is  a composite of 3 patch sets submitted by terry.
they are:
New low-level init code that supports loadbal modules better
some cleanups in the namei code to help terry in 16-bit character support
some changes to the mount-root code to make it a little more
modular..

NOTE: mounting root off cdrom or NFS MIGHT be broken as I haven't been able
to test those cases..

certainly mounting root of disk still works just fine..
mfs should work but is untested. (tomorrows task)

The low level init stuff includes a total rewrite of init_main.c
to make it possible for new modules to have an init phase by simply
adding an entry to a TEXT_SET (or is it DATA_SET) list. thus a new module can
be added to the kernel without editing any other files other than the
'files' file.
1995-08-28 09:19:25 +00:00
Bruce Evans
187f023877 Change vm_object_print() to have the correct number and type of args
for a ddb command.
1995-08-26 23:19:49 +00:00
Bruce Evans
914181e7de Change vm_map_print() to have the correct number and type of args for
a ddb command.
1995-08-26 23:18:38 +00:00
Bruce Evans
bf25be48a5 Make everything except the unsupported network sources compile cleanly
with -Wnested-externs.
1995-08-16 16:14:28 +00:00
Bruce Evans
28f8db1403 Eliminate sloppy common-style declarations. There should be none left for
the LINT configuation.
1995-07-29 11:44:31 +00:00
David Greenman
b367ddb191 #if 0'd one of the DIAGNOSTIC checks in vm_page_alloc(). It was too
expensive for "normal" use.
1995-07-20 05:28:07 +00:00
David Greenman
2a4895f4bb 1) Merged swpager structure into vm_object.
2) Changed swap_pager internal interfaces to cope w/#1.
3) Eliminated object->copy as we no longer have copy objects.
4) Minor stylistic changes.
1995-07-16 13:28:37 +00:00
David Greenman
588d138f56 Added a copyright to this file. 1995-07-13 10:29:34 +00:00
David Greenman
2541af0bba Oops, forgot to add the "default" pager files...
NOTE: libkvm, w, ps, 'top', and any other utility which depends on struct
      proc or any VM system structure will have to be rebuilt!!!

Much needed overhaul of the VM system. Included in this first round of
changes:

1) Improved pager interfaces: init, alloc, dealloc, getpages, putpages,
   haspage, and sync operations are supported. The haspage interface now
   provides information about clusterability. All pager routines now take
   struct vm_object's instead of "pagers".

2) Improved data structures. In the previous paradigm, there is constant
   confusion caused by pagers being both a data structure ("allocate a
   pager") and a collection of routines. The idea of a pager structure has
   escentially been eliminated. Objects now have types, and this type is
   used to index the appropriate pager. In most cases, items in the pager
   structure were duplicated in the object data structure and thus were
   unnecessary. In the few cases that remained, a un_pager structure union
   was created in the object to contain these items.

3) Because of the cleanup of #1 & #2, a lot of unnecessary layering can now
   be removed. For instance, vm_object_enter(), vm_object_lookup(),
   vm_object_remove(), and the associated object hash list were some of the
   things that were removed.

4) simple_lock's removed. Discussion with several people reveals that the
   SMP locking primitives used in the VM system aren't likely the mechanism
   that we'll be adopting. Even if it were, the locking that was in the code
   was very inadequate and would have to be mostly re-done anyway. The
   locking in a uni-processor kernel was a no-op but went a long way toward
   making the code difficult to read and debug.

5) Places that attempted to kludge-up the fact that we don't have kernel
   thread support have been fixed to reflect the reality that we are really
   dealing with processes, not threads. The VM system didn't have complete
   thread support, so the comments and mis-named routines were just wrong.
   We now use tsleep and wakeup directly in the lock routines, for instance.

6) Where appropriate, the pagers have been improved, especially in the
   pager_alloc routines. Most of the pager_allocs have been rewritten and
   are now faster and easier to maintain.

7) The pagedaemon pageout clustering algorithm has been rewritten and
   now tries harder to output an even number of pages before and after
   the requested page. This is sort of the reverse of the ideal pagein
   algorithm and should provide better overall performance.

8) Unnecessary (incorrect) casts to caddr_t in calls to tsleep & wakeup
   have been removed. Some other unnecessary casts have also been removed.

9) Some almost useless debugging code removed.

10) Terminology of shadow objects vs. backing objects straightened out.
    The fact that the vm_object data structure escentially had this
    backwards really confused things. The use of "shadow" and "backing
    object" throughout the code is now internally consistent and correct
    in the Mach terminology.

11) Several minor bug fixes, including one in the vm daemon that caused
    0 RSS objects to not get purged as intended.

12) A "default pager" has now been created which cleans up the transition
    of objects to the "swap" type. The previous checks throughout the code
    for swp->pg_data != NULL were really ugly. This change also provides
    the rudiments for future backing of "anonymous" memory by something
    other than the swap pager (via the vnode pager, for example), and it
    allows the decision about which of these pagers to use to be made
    dynamically (although will need some additional decision code to do
    this, of course).

13) (dyson) MAP_COPY has been deprecated and the corresponding "copy
    object" code has been removed. MAP_COPY was undocumented and non-
    standard. It was furthermore broken in several ways which caused its
    behavior to degrade to MAP_PRIVATE. Binaries that use MAP_COPY will
    continue to work correctly, but via the slightly different semantics
    of MAP_PRIVATE.

14) (dyson) Sharing maps have been removed. It's marginal usefulness in a
    threads design can be worked around in other ways. Both #12 and #13
    were done to simplify the code and improve readability and maintain-
    ability. (As were most all of these changes)

TODO:

1) Rewrite most of the vnode pager to use VOP_GETPAGES/PUTPAGES. Doing
   this will reduce the vnode pager to a mere fraction of its current size.

2) Rewrite vm_fault and the swap/vnode pagers to use the clustering
   information provided by the new haspage pager interface. This will
   substantially reduce the overhead by eliminating a large number of
   VOP_BMAP() calls. The VOP_BMAP() filesystem interface should be
   improved to provide both a "behind" and "ahead" indication of
   contiguousness.

3) Implement the extended features of pager_haspage in swap_pager_haspage().
   It currently just says 0 pages ahead/behind.

4) Re-implement the swap device (swstrategy) in a more elegant way, perhaps
   via a much more general mechanism that could also be used for disk
   striping of regular filesystems.

5) Do something to improve the architecture of vm_object_collapse(). The
   fact that it makes calls into the swap pager and knows too much about
   how the swap pager operates really bothers me. It also doesn't allow
   for collapsing of non-swap pager objects ("unnamed" objects backed by
   other pagers).
1995-07-13 10:15:03 +00:00
David Greenman
24a1cce34f NOTE: libkvm, w, ps, 'top', and any other utility which depends on struct
proc or any VM system structure will have to be rebuilt!!!

Much needed overhaul of the VM system. Included in this first round of
changes:

1) Improved pager interfaces: init, alloc, dealloc, getpages, putpages,
   haspage, and sync operations are supported. The haspage interface now
   provides information about clusterability. All pager routines now take
   struct vm_object's instead of "pagers".

2) Improved data structures. In the previous paradigm, there is constant
   confusion caused by pagers being both a data structure ("allocate a
   pager") and a collection of routines. The idea of a pager structure has
   escentially been eliminated. Objects now have types, and this type is
   used to index the appropriate pager. In most cases, items in the pager
   structure were duplicated in the object data structure and thus were
   unnecessary. In the few cases that remained, a un_pager structure union
   was created in the object to contain these items.

3) Because of the cleanup of #1 & #2, a lot of unnecessary layering can now
   be removed. For instance, vm_object_enter(), vm_object_lookup(),
   vm_object_remove(), and the associated object hash list were some of the
   things that were removed.

4) simple_lock's removed. Discussion with several people reveals that the
   SMP locking primitives used in the VM system aren't likely the mechanism
   that we'll be adopting. Even if it were, the locking that was in the code
   was very inadequate and would have to be mostly re-done anyway. The
   locking in a uni-processor kernel was a no-op but went a long way toward
   making the code difficult to read and debug.

5) Places that attempted to kludge-up the fact that we don't have kernel
   thread support have been fixed to reflect the reality that we are really
   dealing with processes, not threads. The VM system didn't have complete
   thread support, so the comments and mis-named routines were just wrong.
   We now use tsleep and wakeup directly in the lock routines, for instance.

6) Where appropriate, the pagers have been improved, especially in the
   pager_alloc routines. Most of the pager_allocs have been rewritten and
   are now faster and easier to maintain.

7) The pagedaemon pageout clustering algorithm has been rewritten and
   now tries harder to output an even number of pages before and after
   the requested page. This is sort of the reverse of the ideal pagein
   algorithm and should provide better overall performance.

8) Unnecessary (incorrect) casts to caddr_t in calls to tsleep & wakeup
   have been removed. Some other unnecessary casts have also been removed.

9) Some almost useless debugging code removed.

10) Terminology of shadow objects vs. backing objects straightened out.
    The fact that the vm_object data structure escentially had this
    backwards really confused things. The use of "shadow" and "backing
    object" throughout the code is now internally consistent and correct
    in the Mach terminology.

11) Several minor bug fixes, including one in the vm daemon that caused
    0 RSS objects to not get purged as intended.

12) A "default pager" has now been created which cleans up the transition
    of objects to the "swap" type. The previous checks throughout the code
    for swp->pg_data != NULL were really ugly. This change also provides
    the rudiments for future backing of "anonymous" memory by something
    other than the swap pager (via the vnode pager, for example), and it
    allows the decision about which of these pagers to use to be made
    dynamically (although will need some additional decision code to do
    this, of course).

13) (dyson) MAP_COPY has been deprecated and the corresponding "copy
    object" code has been removed. MAP_COPY was undocumented and non-
    standard. It was furthermore broken in several ways which caused its
    behavior to degrade to MAP_PRIVATE. Binaries that use MAP_COPY will
    continue to work correctly, but via the slightly different semantics
    of MAP_PRIVATE.

14) (dyson) Sharing maps have been removed. It's marginal usefulness in a
    threads design can be worked around in other ways. Both #12 and #13
    were done to simplify the code and improve readability and maintain-
    ability. (As were most all of these changes)

TODO:

1) Rewrite most of the vnode pager to use VOP_GETPAGES/PUTPAGES. Doing
   this will reduce the vnode pager to a mere fraction of its current size.

2) Rewrite vm_fault and the swap/vnode pagers to use the clustering
   information provided by the new haspage pager interface. This will
   substantially reduce the overhead by eliminating a large number of
   VOP_BMAP() calls. The VOP_BMAP() filesystem interface should be
   improved to provide both a "behind" and "ahead" indication of
   contiguousness.

3) Implement the extended features of pager_haspage in swap_pager_haspage().
   It currently just says 0 pages ahead/behind.

4) Re-implement the swap device (swstrategy) in a more elegant way, perhaps
   via a much more general mechanism that could also be used for disk
   striping of regular filesystems.

5) Do something to improve the architecture of vm_object_collapse(). The
   fact that it makes calls into the swap pager and knows too much about
   how the swap pager operates really bothers me. It also doesn't allow
   for collapsing of non-swap pager objects ("unnamed" objects backed by
   other pagers).
1995-07-13 08:48:48 +00:00
David Greenman
6306c897b5 swapout_threads() -> swapout_procs(). 1995-07-10 08:53:22 +00:00
David Greenman
f2daac0c69 Increased global RSS limit to total RAM. 1995-07-10 08:48:58 +00:00
David Greenman
06cb725951 Moved call to VOP_GETATTR() out of vnode_pager_alloc() and into the places
that call vnode_pager_alloc() so that a failure return can be dealt with.
This fixes a panic seen on NFS clients when a file being opened is deleted
on the server before the open completes.
1995-07-09 06:58:03 +00:00
David Greenman
39d38f93e2 Fixed an object allocation race condition that was causing a "object
deallocated too many times" panic when using NFS.

Reviewed by:	John Dyson
1995-07-06 11:48:48 +00:00
David Greenman
aa2cabb958 1) Converted v_vmdata to v_object.
2) Removed unnecessary vm_object_lookup()/pager_cache(object, TRUE) pairs
   after vnode_pager_alloc() calls - the object is already guaranteed to be
   persistent.
3) Removed some gratuitous casts.
1995-06-28 12:01:13 +00:00
Rodney W. Grimes
d3628763db Merge RELENG_2_0_5 into HEAD 1995-06-11 19:33:05 +00:00
Rodney W. Grimes
9b2e535452 Remove trailing whitespace. 1995-05-30 08:16:23 +00:00
David Greenman
956e9ca5a0 Removed check for sw_dev == NODEV; this is a normal condition for swap
over NFS and was gratuitously panicing when it happens.

Reviewed by:	John Dyson
Submitted by:	Pierre Beyssac via Poul-Henning Kamp
1995-05-25 03:38:11 +00:00
David Greenman
61f5d51062 Changes to fix the following bugs:
1) Files weren't properly synced on filesystems other than UFS. In some
   cases, this lead to lost data. Most likely would be noticed on NFS.
   The fix is to make the VM page sync/object_clean general rather than
   in each filesystem.
2) Mixing regular and mmaped file I/O on NFS was very broken. It caused
   chunks of files to end up as zeroes rather than the intended contents.
   The fix was to fix several race conditions and to kludge up the
   "b_dirtyoff" and "b_dirtyend" that NFS relies upon - paying attention
   to page modifications that occurred via the mmapping.

Reviewed by:	David Greenman
Submitted by:	John Dyson
1995-05-21 21:39:31 +00:00
David Greenman
2976b7f19f NFS diskless operation was broken because swapdev_vp wasn't initialized.
These changes solve the problem in a general way by moving the
initialization out of the individual fs_mountroot's and into swaponvp().

Submitted by:	Poul-Henning Kamp
1995-05-19 03:27:08 +00:00
David Greenman
0e5b52868f Fixed a bug that managed to slip in during Poul's dynamic swap partition
changes. The check for nswap was bogus, but the code was so convoluted
that it was difficult to tell. It's better now. :-)

Reviewed by:	David Greenman (extensively), and John Dyson
Submitted by:	Poul-Henning Kamp, w/tweaks by me.
1995-05-18 05:09:54 +00:00
David Greenman
5f55e84104 Accessing pages beyond the end of a mapped file results in internal
inconsistencies in the VM system that eventually lead to a panic. These
changes fix the behavior to conform to the behavior in SunOS, which is
to deny faults to pages beyond the EOF (returning SIGBUS). Internally,
this is implemented by requiring faults to be within the object size
boundaries. These changes exposed another bug, namely that passing in
an offset to mmap when trying to map an unnamed anonymous region also
results in internal inconsistencies. In this case, the offset is forced
to zero.

Reviewed by:	John Dyson and others
1995-05-18 02:59:26 +00:00
David Greenman
a401ebbe32 Changed swap partition handling/allocation so that it doesn't
require specific partitions be mentioned in the kernel config
file ("swap on foo" is now obsolete).

From Poul-Henning:

The visible effect is this:

As default, unless
        options "NSWAPDEV=23"
is in your config, you will have four swap-devices.
You can swapon(2) any block device you feel like, it doesn't have
to be in the kernel config.

There is a performance/resource win available by getting the NSWAPDEV right
(but only if you have just one swap-device ??), but using that as default
would be too restrictive.

The invisible effect is that:

Swap-handling disappears from the $arch part of the kernel.
It gets a lot simpler (-145 lines) and cleaner.

Reviewed by:	John Dyson, David Greenman
Submitted by:	Poul-Henning Kamp, with minor changes by me.
1995-05-14 03:00:10 +00:00
Poul-Henning Kamp
8af2296bcb I'm about to jump on the swap-initialization, and having talked
with davidg about it, I hereby kill two undocumented misfeatures:
The code to skip a miniroot in the swapdev is not particular useful, and
if we need it we need it to be done properly, ie size the fs and skip all
of it not some hardcoded size, and subtract what we skip from the length
in the first place.
The SEQSWAP dies too.  It's not the way to do it, it doesn't work, and
nobody have expressed any great desire for it to work.  The way to
implement it correctly would be a second argument to swapon(2) to give
a priority/policy information.  Low priority swapdevs can be made so
by adding them at a far offset (0x80000000 kind of thing), with almost no
modification to the strategy routine (in particular a offset per swapdev).
But until the need is obvious, it will not be done.
1995-05-12 03:54:59 +00:00
David Greenman
ee3a64c992 Changed "handle" from type caddr_t to void *; "handle" is several different
types of pointers, and "char *" is a bad choice for the type.
1995-05-10 18:56:09 +00:00
John Dyson
11fda60b40 Another error in the correction for trimming swap allocation for
small objects.  (This code needs to be revisited.)
1995-05-07 06:36:59 +00:00
John Dyson
85b67b98fd Fixed a calculation that would once-in-a-while cause the swap_pager
to emit spurious page outside of object type messages.  It is not
a fatal condition anyway, so the message will be omitted for
release.  Also, the code that "clips" the allocation size, associated
with the above problem, was fixed.
1995-05-07 03:48:54 +00:00
David Greenman
f325917a65 Changed object hash list to be a list rather than a tailq. This saves
space for the hash list buckets and is a little faster. The features
of tailq aren't needed. Increased the size of the object hash table
to improve performance. In the future, this will be changed so that
the table is sized dynamically.
1995-05-02 05:57:11 +00:00
David Greenman
3fc3004e03 Fixed a "bswbuf" hang caused by the wakeup in relpbuf() waking up the
wrong thing.
1995-04-25 06:22:47 +00:00
Bruce Evans
7666fb4753 inline -> __inline.
Headers should always use `__inline' for inline functions to avoid
syntax errors when modules that don't even use the offending functions
are compiled with `gcc -ansi'.
1995-04-23 08:05:49 +00:00
John Dyson
7e15fd2757 Fixed a problem in _vm_object_page_clean that could cause an
infinite loop.
1995-04-21 02:48:40 +00:00
David Greenman
aba8f38eb9 New flag: B_PAGING. Added as part of the vn driver hack. 1995-04-19 10:32:11 +00:00
David Greenman
4c1f8ee9b8 Fixed a logic bug that caused the vmdaemon to not wake up when intended.
Submitted by:	John Dyson
1995-04-17 10:00:55 +00:00
David Greenman
7c0414d074 Removed obsolete/unused variable declarations. Killed externs and included
appropriate include files.
1995-04-16 14:12:15 +00:00
David Greenman
64abb5a522 Removed obsolete/unused variable declarations.
Removed some extern declarations and included the correct include files.
1995-04-16 13:58:42 +00:00
David Greenman
c3cb3e12f5 Moved some zero-initialized variables into .bss. Made code intended to be
called only from DDB #ifdef DDB. Removed some completely unused globals.
1995-04-16 12:56:22 +00:00
David Greenman
8c3d9c403c Removed gratuitous m->blah=0 assignments when initializing the vm_page
structs in vm_page_startup(). The vm_page structs are already completely
zeroed.
1995-04-16 11:50:45 +00:00
David Greenman
2fdccd5e8c Make "print_page_info" #ifdef DDB. 1995-04-16 09:59:16 +00:00
David Greenman
ec4f9fb0ee Fixed a few bugs in vm_object_page_clean, mostly related to not syncing
pages that are in FS buffers. This fixes the (believed to already have been
fixed) problem with msync() not doing it's job...in other words, the
stuff that Andrew has continuously been complaining about.

Submitted by:	John Dyson, w/minor changes by me.
1995-04-16 03:11:28 +00:00
David Greenman
f6b04d2bfb Changes from John Dyson and myself:
Fixed remaining known bugs in the buffer IO and VM system.

vfs_bio.c:
Fixed some race conditions and locking bugs. Improved performance
by removing some (now) unnecessary code and fixing some broken
logic.
Fixed process accounting of # of FS outputs.
Properly handle NFS interrupts (B_EINTR).

(various)
Replaced calls to clrbuf() with calls to an optimized routine
called vfs_bio_clrbuf().

(various FS sync)
Sync out modified vnode_pager backed pages.

ffs_vnops.c:
Do two passes: Sync out file data first, then indirect blocks.

vm_fault.c:
Fixed deadly embrace caused by acquiring locks in the wrong order.

vnode_pager.c:
Changed to use buffer I/O system for writing out modified pages. This
should fix the problem with the modification date previous not getting
updated. Also dramatically simplifies the code. Note that this is
going to change in the future and be implemented via VOP_PUTPAGES().

vm_object.c:
Fixed a pile of bugs related to cleaning (vnode) objects. The performance
of vm_object_page_clean() is terrible when dealing with huge objects,
but this will change when we implement a binary tree to keep the object
pages sorted.

vm_pageout.c:
Fixed broken clustering of pageouts. Fixed race conditions and other
lockup style bugs in the scanning of pages. Improved performance.
1995-04-09 06:03:56 +00:00
Bruce Evans
3aa12267a5 Add and move declarations to fix all of the warnings from `gcc -Wimplicit'
(except in netccitt, netiso and netns) that I didn't notice when I fixed
"all" such warnings before.
1995-03-28 07:58:53 +00:00
David Greenman
17c4c40800 Fixed typo...using wrong variable in page_shortage calculation. 1995-03-28 05:58:35 +00:00
David Greenman
0bb3a0d2f4 Fixed "pages freed by daemon" statistic (again). 1995-03-28 05:35:29 +00:00
David Greenman
2ddba2158c Explicitly set page dirty if this is a write fault - reduces calls to
pmap_is_modified() later.
1995-03-27 02:41:00 +00:00
David Greenman
8953151fc8 Removed some obsolete flags.
Submitted by:   John Dyson
1995-03-26 23:33:14 +00:00
David Greenman
6c534ad868 Fix logic bug I just introduced with the flags to msync(). 1995-03-25 17:44:03 +00:00
David Greenman
492d73bd99 Pass syncio flag to vm_object_clean(). It remains unimplemented, however. 1995-03-25 17:36:57 +00:00
David Greenman
1e62bc6357 Disallow both MS_ASYNC and MS_INVALIDATE flags being set at the same time
in msync().
1995-03-25 17:36:00 +00:00
David Greenman
e6c6af1149 Added "flags" argument to msync, and implemented MS_ASYNC and MS_INVALIDATE.
The MS_ASYNC flag doesn't current work, and MS_INVALIDATE will only toss out
the pages in the address space (not all pages in the shadow chain).
1995-03-25 16:55:46 +00:00
David Greenman
7fd9a8b12f Implemented cnt.v_reactivated and moved vm_page_activate() routine to
before vm_page_deactivate().
1995-03-25 08:47:35 +00:00
David Greenman
260295f979 Removed (almost) meaningless "object cache lookups/hits" statistic. In
our framework, these numbers will usually be nearly the same, and not
because of any sort of high 'hit rate'.
1995-03-25 08:42:14 +00:00
David Greenman
a34297995a Removed cnt.v_nzfod: In our current scheme of things it is not possible
to accurately track this. It isn't an indicator of resource consumption
anyway.
Removed cnt.v_kernel_pages: We don't implement this and doing so accurately
would be very difficult (and ambiguous - since process pages are often
double mapped in the kernel and the process address spaces).
1995-03-25 06:09:33 +00:00
David Greenman
d7a0fc9360 Fixed warning caused by returning a value in a void function (introduced
in a recent commit by me). Relaxed checks before calling vm_object_remove;
a non-internal object always has a pager.
1995-03-23 05:19:44 +00:00
David Greenman
f5cf85d40a Removed unused fifth argument to vm_object_page_clean(). Fixed bug with
VTEXT not always getting cleared when it is supposed to. Added check to
make sure that vm_object_remove() isn't called with a NULL pager or for
a pager for an OBJ_INTERNAL object (neither of which will be on the hash
list). Clear OBJ_CANPERSIST if we decide to terminate it because of no
resident pages.
1995-03-22 12:24:11 +00:00
David Greenman
563128e49e Fixed potential sleep/wakeup race conditional with splhigh().
Submitted by:	John Dyson
1995-03-22 08:08:44 +00:00
David Greenman
c419d77e29 Added a check for wrong object size; print a warning, but deal with it
correctly. The warning will tell us that there is a bug somewhere else
in sizing the object correctly.

Submitted by:	John Dyson
1995-03-22 05:12:18 +00:00
David Greenman
8f4e17d4b2 Fixed bug in vm_mmap() where the object that is created in some cases
was the wrong size. This is the likely cause of panics reported by
Lars Fredriksen and Paul Richards related to a -1 blkno when paging
via the swap_pager.

Submitted by:	John Dyson
1995-03-22 05:08:41 +00:00
David Greenman
1b369d9858 Removed unused variable declaration missed in previous commit. 1995-03-21 23:09:53 +00:00
David Greenman
71263bf8db Removed do-nothing VOP_UPDATE() call. 1995-03-21 23:07:19 +00:00
David Greenman
bc9ad24756 Disallow non page-aligned file offsets in vm_mmap(). We don't support this
in either the high or low level parts of the VM system. Just return EINVAL
in this case, just like SunOS does.
1995-03-21 10:15:52 +00:00
David Greenman
fbcfcdf7db Fixed bug in the size == 0 case of msync() caused by a bogus return value
check..
1995-03-21 02:54:04 +00:00
David Greenman
7c1f6cedec Added a new boolean argument to vm_object_page_clean that causes it to
only toss out clean pages if TRUE.
1995-03-21 01:11:44 +00:00
David Greenman
0426122fa0 Don't gain/lose an object reference in vnode_pager_setsize(). It will
cause vnode locking problems in vm_object_terminate().
Implement proper vnode locking in vm_object_terminate().
1995-03-20 10:20:42 +00:00
David Greenman
9ba0a56334 Fixed "objde1" hang. It was caused by a "&" where an "&&" belonged in the
expression that decides if a wakeup should occur.
1995-03-20 10:14:55 +00:00
David Greenman
83edfd47d8 Removed an unnecessary call to vinvalbuf after the page clean. 1995-03-20 02:06:09 +00:00
David Greenman
0bdb7528db Do proper vnode locking when doing paging I/O. Removed the asynchronous
paging capability to facilitate this (we saw little or no measureable
improvement with this anyway).

Submitted by:	John Dyson
1995-03-19 23:46:25 +00:00
David Greenman
edf8a81561 Removed redundant newlines that were in some panic strings. 1995-03-19 14:29:26 +00:00
David Greenman
c01a9b8ca0 Incorporated 4.4-lite vnode_pager_uncache() and vnode_pager_umount()
routines (and merged local changes). The changed vnode_pager_uncache
gets rids of the bogosity that you can call the routine without
having the vnode locked. The changed vnode_pager_umount properly locks
the vnode before calling vnode_pager_uncache.
1995-03-19 12:36:10 +00:00
David Greenman
806e386083 In vm_page_alloc_contig: Removed a redundant semicolon and used 'm' instead
of &pga[i] in one place.
1995-03-18 01:04:36 +00:00
Bruce Evans
b5e8ce9f12 Add and move declarations to fix all of the warnings from `gcc -Wimplicit'
(except in netccitt, netiso and netns) and most of the warnings from
`gcc -Wnested-externs'.  Fix all the bugs found.  There were no serious
ones.
1995-03-16 18:17:34 +00:00
David Greenman
5eb7d0cd2e Special cased the handling of mb_map in the M_WAITOK case. kmem_malloc()
now returns NULL and sets a global 'mb_map_full' when the map is full.
m_clalloc() has further been taught to expect this and do the right thing.
This should fix the "mb_map full" panics that several people have reported.
1995-03-15 07:52:06 +00:00
Bruce Evans
1475d9283e Move a kernel inline function inside `#ifdef KERNEL' so that including
<vm/vm.h> doesn't cause warnings about nonexistent functions called
by the inline function.  Clean up the formatting of the function.
1995-03-12 12:42:00 +00:00
David Greenman
c4ed5a07a5 Fixed obsolete comment. 1995-03-12 08:11:34 +00:00
David Greenman
6879ca0fcd Deleted vm_object_setpager(). 1995-03-12 08:05:46 +00:00
David Greenman
61ca29b0e5 Deleted vm_object_setpager(). 1995-03-12 07:58:29 +00:00
David Greenman
4bb624613f Explicitly set object->flags = OBJ_CANPERSIST. 1995-03-12 07:56:06 +00:00
David Greenman
a14e8fd032 Fix completely bogus comment. 1995-03-11 22:25:20 +00:00
David Greenman
63635f5ae2 Clear OBJ_INTERNAL flag for device pager objects and named anonymous
objects.
1995-03-11 22:25:02 +00:00
David Greenman
0007244260 Set VAGE flag when pager is destroyed. This usually happens when an
object has fallen off the end of the cached list - this is likely the
last reference to the vnode and it should be reused before non file
vnodes that are already on the free list (VDIR mostly).
1995-03-07 19:04:10 +00:00
David Greenman
f2da180f8e Fixed object reference count problem that occurred in the MAP_PRIVATE
case after we rewrote vm_mmap(). Added some comments to make it easier
to follow the reference counts.
1995-03-07 17:27:49 +00:00
David Greenman
be6d5bfac7 Don't attempt to reverse collapse non OBJ_INTERNAL objects. 1995-03-07 17:25:46 +00:00
Jordan K. Hubbard
7b936a1e66 Remove a gratutious cast. 1995-03-04 21:14:19 +00:00
David Greenman
f919ebde54 Various changes from John and myself that do the following:
New functions create - vm_object_pip_wakeup and pagedaemon_wakeup that
are used to reduce the actual number of wakeups.
New function vm_page_protect which is used in conjuction with some new
page flags to reduce the number of calls to pmap_page_protect.
Minor changes to reduce unnecessary spl nesting.
Rewrote vm_page_alloc() to improve readability.
Various other mostly cosmetic changes.
1995-03-01 23:30:04 +00:00
David Greenman
54ab07303b Slight change to include file order to accommodate upcoming changes. 1995-03-01 21:37:44 +00:00
Bruce Evans
4f9fb771a5 Don't use __P(()) in a function definition. 1995-02-25 18:39:04 +00:00
David Greenman
c3a1e4250f Fixed severely broken printf (arguments out of order, no newline). 1995-02-25 17:02:48 +00:00
David Greenman
b106f3b255 Removed redundant HOLDRELE()'s. 1995-02-23 22:32:38 +00:00
David Greenman
187f007190 Changed return value from vnode_pager_addr to be in DEV_BSIZE units so
that 9 bits aren't lost in the conversion. Changed all callers to expect
this. This allows paging on large (>2GB) filesystems.

Submitted by:	John Dyson
1995-02-22 10:34:34 +00:00
David Greenman
6f2b142ed8 vm_page.c:
Use request==VM_ALLOC_NORMAL rather than object!=kmem_object in deciding
if the caller is "important" in vm_page_alloc(). Also established a new
low threshold for non-interrupt allocations via cnt.v_interrupt_free_min.

vm_pageout.c:
Various algorithmic cleanup. Some calculations simplified. Initialize
cnt.v_interrupt_free_min to 2 pages.

Submitted by:	John Dyson
1995-02-22 10:27:24 +00:00
David Greenman
5e716206c0 Just return in the case of a page not on any queue in vm_page_unqueue().
Return VM_PAGE_BITS_ALL even if size > PAGE_SIZE in vm_page_bits().

Submitted by:	John Dyson
1995-02-22 10:16:21 +00:00
David Greenman
26f5e3ab12 Removed object locking code (it was a left over from an abortion that
was done a month or so ago).

Submitted by:	John Dyson
1995-02-22 10:06:43 +00:00
David Greenman
a7ac758ec7 Removed bogus copy object collapse check (the idea is right, but the
spcific check was bogus).
Removed old copy of vm_object_page_clean and took out the #if 1 around
the remaining one.

Submitted by:	John Dyson
1995-02-22 10:00:16 +00:00
David Greenman
c0503609a0 Only do object paging_in_progress wakeups if someone is waiting on this
condition.

Submitted by:	John Dyson
1995-02-22 09:15:35 +00:00
David Greenman
50ce2102e1 Rewrote MAP_PRIVATE case of vm_mmap() - all of the COW portion of this
routine was highly convoluted.

Submitted by:	John Dyson
1995-02-22 08:40:54 +00:00
David Greenman
2c0bc39683 Panic if u_map allocation fails. 1995-02-21 12:06:06 +00:00
David Greenman
2df771e5c0 vm_extern.h: removed vm_allocate_with_pager.
Removed vm_user.c...it's now completely deprecated.
1995-02-21 01:32:47 +00:00
David Greenman
7fb0c17ed2 Deprecated remaining use of vm_deallocate. Deprecated vm_allocate_with_
pager(). Almost completely rewrote vm_mmap(); when John gets done with
the bottom half, it will be a complete rewrite. Deprecated most use of
vm_object_setpager(). Removed side effect of setting object persist
in vm_object_enter and moved this into the pager(s). A few other
cosmetic changes.
1995-02-21 01:22:48 +00:00
David Greenman
d9459480fb Set page alloced for map entries as valid. 1995-02-21 01:13:05 +00:00
David Greenman
ffeec4aefe Removed vm_allocate(), vm_deallocate(), and vm_protect() functions. The
only function remaining in this file is vm_allocate_with_pager(), and this
will be going RSN. The file will be removed when this happens.
1995-02-20 23:58:10 +00:00
David Greenman
0c1dacbc5c Moved ACT_MAX, ACT_ADVANCE, and ACT_DECLINE to vm_page.h. 1995-02-20 23:35:45 +00:00
David Greenman
a6e1b30301 vm_inherit function has been deprecated. 1995-02-20 18:08:18 +00:00
David Greenman
a1e5cf9de7 Stop using vm_allocate and vm_deallocate. 1995-02-20 17:36:36 +00:00
David Greenman
ff16eeefb0 VM for the kernel stack and page tables doesn't need to be explicitly
deallocated as it isn't inherited across the fork.
Use vm_map_find not vm_allocate.

Submitted by:	John Dyson
1995-02-20 17:26:21 +00:00
David Greenman
ba8da83911 Panic if object is deallocated too many times.
Slight change to reverse collapsing so that vm_object_deallocate doesn't
have to be called recursively.
Removed half of a previous fix - the renamed page during a collapse doesn't
need to be marked dirty because the pager backing store pointers are copied
- thus preserving the page's data. This assumes that pages without backing
store are always dirty (except perhaps for when they are first zeroed, but
this doesn't matter).
Switch order of two lines of code so that the correct pager is removed
from the hash list. The previous code bogusly passed a NULL pointer to
vm_object_remove(). The call to vm_object_remove() should be unnecessary
if named anonymous objects were being dealt with correctly. They are
currently marked as OBJ_INTERNAL, which really screws up things (such as
this).
1995-02-20 14:21:58 +00:00
David Greenman
d0686727c0 Don't allow act_count to exceed ACT_MAX when bumping it up.
Small optimization to vm_page_bits().

Submitted by:	John Dyson
1995-02-20 14:00:50 +00:00
David Greenman
d89ced81b2 Fully initialize pages returned via vm_page_alloc_contig() so that the
memory can be later freed.
1995-02-20 13:58:14 +00:00
David Greenman
9b4814bba2 1) Added protection against collapsing OBJ_DEAD objects.
2) bump reference counts by 2 instead of 1 so that an object deallocate
   doesn't try to recursively collapse the object.
3) mark pages renamed during the collapse as dirty so that their contents
   are preserved.

Submitted by:	John and me.
1995-02-18 06:48:33 +00:00
David Greenman
ca40da7417 Don't bother calling pmap_create() when creating the temporary map.
The whole COW section of vm_mmap() should be rewritten; the current
implementation is highly convoluted.
1995-02-15 09:22:17 +00:00
Poul-Henning Kamp
d2fc53150b YF fix. 1995-02-14 06:14:28 +00:00
Poul-Henning Kamp
7aa3a026ad YF Fix. 1995-02-14 06:11:21 +00:00
David Greenman
bf4bd9bd9b Fixed problem with msync causing a panic.
Submitted by:	John Dyson
1995-02-14 04:00:17 +00:00
David Greenman
0217125f2b Carefully choose the value for vm_object_cache_max. The previous calculation
was rather bogus in most cases; the new value works very well for both
large and small memory machines.
1995-02-12 09:19:44 +00:00
David Greenman
a7fa409d30 Killed MACHVMCOMPAT function prototypes as the functions don't exist. 1995-02-09 14:16:07 +00:00
David Greenman
94aade54ff Killed MACHVMCOMPAT code. It doesn't compile, and in its present state
would require some work to make it not a serious security problem. It's
non-standard and not very useful anyway.
1995-02-09 14:14:13 +00:00
David Greenman
1ed81ef2fa Minor algorithmic adjustments that reduce the CPU consumption of the
pagedaemon in half while not reducing its effectiveness.

Submitted by:	me & John
1995-02-09 07:41:42 +00:00
David Greenman
efc68ce10f Fixed bmap run-length brokeness.
Use bmap run-length extension when doing clustered paging.

Submitted by:	John Dyson
1995-02-03 06:46:28 +00:00
David Greenman
a1f6d91cc2 swap_pager.c:
Fixed long standing bug in freeing swap space during object collapses.
Fixed 'out of space' messages from printing out too often.
Modified to use new kmem_malloc() calling convention.
Implemented an additional stat in the swap pager struct to count the
amount of space allocated to that pager. This may be removed at some
point in the future.
Minimized unnecessary wakeups.

vm_fault.c:
Don't try to collect fault stats on 'swapped' processes - there aren't
any upages to store the stats in.
Changed read-ahead policy (again!).

vm_glue.c:
Be sure to gain a reference to the process's map before swapping.
Be sure to lose it when done.

kern_malloc.c:
Added the ability to specify if allocations are at interrupt time or
are 'safe'; this affects what types of pages can be allocated.

vm_map.c:
Fixed a variety of map lock problems; there's still a lurking bug that
will eventually bite.

vm_object.c:
Explicitly initialize the object fields rather than bzeroing the struct.
Eliminated the 'rcollapse' code and folded it's functionality into the
"real" collapse routine.
Moved an object_unlock() so that the backing_object is protected in
the qcollapse routine.
Make sure nobody fools with the backing_object when we're destroying it.
Added some diagnostic code which can be called from the debugger that
looks through all the internal objects and makes certain that they
all belong to someone.

vm_page.c:
Fixed a rather serious logic bug that would result in random system
crashes. Changed pagedaemon wakeup policy (again!).

vm_pageout.c:
Removed unnecessary page rotations on the inactive queue.
Changed the number of pages to explicitly free to just free_reserved
level.

Submitted by:	John Dyson
1995-02-02 09:09:15 +00:00
David Greenman
8f895206ff Completed the fix for attempting to page out pages via the device_pager.
Submitted by:	John Dyson
1995-01-28 02:02:25 +00:00
David Greenman
1e9122e529 Use the VM_PAGE_BITS_ALL in a place it can be used.
Comment out call to pmap_prefault() until stability problems can be
thoroghly analyzed.
1995-01-26 01:40:04 +00:00
David Greenman
a465acdaf8 Don't attempt to clean device_pager backed objects at terminate time.
There is similar bogusness in the pageout daemon that will be fixed soon.
This fixes a panic pointed out to me by Bruce Evans that occurs when
/dev/mem is used to map managed memory.
1995-01-25 20:36:29 +00:00
David Greenman
6d40c3d394 Added ability to detect sequential faults and DTRT. (swap_pager.c)
Added hook for pmap_prefault() and use symbolic constant for new third
argument to vm_page_alloc() (vm_fault.c, various)
Changed the way that upages and page tables are held. (vm_glue.c)
Fixed architectural flaw in allocating pages at interrupt time that was
introduced with the merged cache changes. (vm_page.c, various)
Adjusted some algorithms to acheive better paging performance and to
accomodate the fix for the architectural flaw mentioned above. (vm_pageout.c)
Fixed pbuf handling problem, changed policy on handling read-behind page.
(vnode_pager.c)

Submitted by:	John Dyson
1995-01-24 10:14:09 +00:00
David Greenman
edfab85b1a Moved some splx's down a few lines in vm_page_insert and vm_page_remove
to make the locking a bit more clear - this change is currently a NOP
as the calls to those routines are already at splhigh().
1995-01-15 07:31:34 +00:00
David Greenman
b9921222a2 Protect a qcollapse call with an object lock before calling. The locks
need to be moved into the qcollapse and rcollapse routines, but I don't
have time at the moment to make all the required changes...this will do
for now.
1995-01-13 13:30:24 +00:00
David Greenman
8b4dd3c473 Improve my previous change to use the same tests as are used in qcollapse. 1995-01-11 20:19:20 +00:00
David Greenman
a748978457 Fixed a panic that Garrett reported to me...the OBJ_INTERNAL flag wasn't
being cleared in some cases for vnode backed objects; we now do this in
vnode_pager_alloc proper to guarantee it. Also be more careful in the
rcollapse code about messing with busy/bmapped pages.
1995-01-11 20:00:10 +00:00
David Greenman
a776a317e9 Kill VM_PAGE_INIT macro as it is only used once and makes the code more
difficult to understand. Got rid of unused vm_page flags.
1995-01-10 09:19:52 +00:00
David Greenman
480dff540b Fixed some formatting weirdness that I overlooked in the previous commit. 1995-01-10 07:32:52 +00:00
David Greenman
0d94caffca These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.

The majority of the merged VM/cache work is by John Dyson.

The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.

vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme.  The scheme is almost fully compatible with the old filesystem
interface.  Significant improvement in the number of opportunities for write
clustering.

vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache.  Fixup of vfs_cluster to eliminate the bogus pagemove stuff.

vm_object.c:
Yet more improvements in the collapse code.  Elimination of some windows that
can cause list corruption.

vm_pageout.c:
Fixed it, it really works better now.  Somehow in 2.0, some "enhancements"
broke the code.  This code has been reworked from the ground-up.

vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.

pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.

vm_glue.c
Much simpler and more effective swapping code.  No more gratuitous swapping.

proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.

swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency.  Now the
code doesn't need it anymore.

machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.

machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.

ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache.  Add "bypass" support for sneaking in on
busy buffers.

Submitted by:	John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
David Greenman
010cf3b9e3 Make sure that the object being collapsed doesn't go away on us...by
gaining extra references to it.

Submitted by:	John Dyson
Obtained from:
1995-01-05 04:30:40 +00:00
Andreas Schulz
832f3afd12 Submitted by: Ben Jackson
just a missing newline in a kernel printf added.
1995-01-02 22:56:00 +00:00
Bruce Evans
1365ed99fb Clean up previous commits (format for 80 columns...). 1994-12-30 08:02:16 +00:00
David Greenman
45cbbb298d Do vm_page_rename more conservatively in rcollapse and qcollapse, and
change list walk so that it doesn't get stuck in an infinite loop.

Submitted by:	 John Dyson
1994-12-23 05:00:19 +00:00
David Greenman
7609ab12e4 Initialize b_vnbuf.le_next before returning a new buffer in getpbuf and
trypbuf. Move a couple of splbio's to be slightly less conservative.
1994-12-23 04:56:51 +00:00
David Greenman
6f7bc393bb Fixed a benign off by one error. 1994-12-22 05:18:12 +00:00
David Greenman
6185408336 Don't ever clear B_BUSY on a pbuf (or any other flag for that matter).
This appears to be the cause of some buffer confusion that leads to
a panic during heavy paging.

Submitted by:	 John Dyson
1994-12-19 00:02:56 +00:00
David Greenman
66ecebed58 Fixed multiple bogons with the map entry handling. 1994-12-18 13:58:41 +00:00
David Greenman
053bbc788c Fixed bug where statically allocated map entries might be freed to the
malloc pool...causing a panic.

Submitted by:	John Dyson
1994-12-18 10:28:40 +00:00
David Greenman
dd0bd066e0 Change swapping policy to be a bit more aggressive about finding a
candidate for swapout. Increased default RSS limit to a minimum of 2MB.
1994-12-18 06:31:31 +00:00
David Greenman
8d6e8ede62 Protect kmem_map modifications with splhigh() to work around a problem with
the map being locked at interrupt time.
1994-12-15 22:47:11 +00:00
David Greenman
7b18a71899 Don't put objects that have no parent on the reverse_shadow_list. Problem
identified and explained by Gene Stark (thanks Gene!).

Submitted by:	John Dyson
1994-12-11 01:36:53 +00:00
David Greenman
eadf9e27cd These changes fix a couple of lingering VM problems:
1.	The pageout daemon used to block under certain
	circumstances, and we needed to add new functionality
	that would cause the pageout daemon to block more often.
	Now, the pageout daemon mostly just gets rid of pages
	and kills processes when the system is out of swap.
	The swapping, rss limiting and object cache trimming
	have been folded into a new daemon called "vmdaemon".
	This new daemon does things that need to be done for
	the VM system, but can block.  For example, if the
	vmdaemon blocks for memory, the pageout daemon
	can take care of it.  If the pageout daemon had
	blocked for memory, it was difficult to handle
	the situation correctly (and in some cases, was
	impossible).

2.	The collapse problem has now been entirely fixed.
	It now appears to be impossible to accumulate unnecessary
	vm objects.  The object collapsing now occurs when ref counts
	drop to one (where it is more likely to be more simple anyway
	because less pages would be out on disk.)  The original
	fixes were incomplete in that pathological circumstances
	could still be contrived to cause uncontrolled growth
	of swap.  Also, the old code still, under steady state
	conditions, used more swap space than necessary.  When
	using the new code, users will generally notice a
	significant decrease in swap space usage, and theoretically,
	the system should be leaving fewer unused pages around
	competing for memory.

Submitted by:	John Dyson
1994-11-25 07:58:29 +00:00
David Greenman
4abc71c008 Don't try to page to a vnode that had it's filesystem unmounted. 1994-11-24 14:43:22 +00:00
David Greenman
d49456add7 Preallocate the first swap block to work around a failure with swap starting
at physical block 0. Note that this will show up in pstat -s and swapinfo
as space "in use". In reality, the space is simply never made available.
1994-11-22 08:47:20 +00:00
David Greenman
792216316f Don't ever try to kill off process 1 - even if we are out of swap space
and it's the candidate pig.
1994-11-17 06:24:25 +00:00
Justin T. Gibbs
bf556a1617 Remove a peice of commented out code that was left over from the early
stages of debugging LFS:

         * if we can't bmap, use old VOP code
         */
!       if (/* (vp->v_mount && vp->v_mount->mnt_stat.f_type == MOUNT_LFS) || */
!               VOP_BMAP(vp, foff, &dp, 0, 0)) {
                for (i = 0; i < count; i++) {
                        if (i != reqpage) {
                                vnode_pager_freepage(m[i]);
--- 804,810 ----
        /*
         * if we can't bmap, use old VOP code
         */
!       if (VOP_BMAP(vp, foff, &dp, 0, 0)) {

Reviewed by: gibbs
Submitted by: John Dyson
1994-11-17 01:22:45 +00:00
Bruce Evans
4f21005bdd pmap.h:
Disable the bogus declaration of pmap_bootstrap().  Since its arg list
is machine-dependent, it must be declared in a machine-dependent header.

vm_page.h:
Change `inline' to `__inline' and old-style function parameter lists for
inlined functions to new-style.

`inline' and old-style function parameter lists should never be used in
system headers, even in very machine-dependent ones, because they cause
warnings from gcc -Wreally-all.
1994-11-14 08:19:08 +00:00
David Greenman
b0150bfc4b Set laundry flag when transitioning an inactive page from clean to dirty.
This fixes a performance bug where pages would sometimes not be paged
out when they could be.

Submitted by:	John Dyson
1994-11-14 02:57:40 +00:00
David Greenman
317205ca28 Fixed bug where a read-behind to a negative offset would occur if the
fault was at offset 0 in the object. This resulted in more overhead but
was othewise benign. Added incore() check in vnode_pager_has_page()
to work around a problem with LFS...other than slightly higher overhead,
this change has no affect on UFS.
1994-11-13 22:48:55 +00:00
David Greenman
24ea4a9671 Fixed bugs in accounting of swap space that resulted in the pager thinking
it was out of space when it really wasn't.

Submitted by:	John Dyson
1994-11-13 15:36:48 +00:00
David Greenman
bfbfac11c9 Implemented swap locking via P_SWAPPING flag. It was possible for a process
to be chosen for swap-in while it was being swapped-out. This was BAD.

Submitted by:	John Dyson
1994-11-13 12:47:07 +00:00
David Greenman
a83c285c7e Fixed return status from pagers. Ahem...the previous method would manufacture
data when it couldn't get it legitimately. :-(

Submitted by:	John Dyson
1994-11-06 09:55:31 +00:00
David Greenman
2fe6e4d71e Added support for starting the experimental "vmdaemon" system process.
Enabled via REL2_1.

Added support for doing object collapses "on the fly". Enabled via REL2_1a.

Improved object collapses so that they can happen in more cases. Improved
sensing of modified pages to fix an apparant race condition and improve
clustered pageout opportunities. Fixed an "oops" with not restarting page
scan after a potential block in vm_pageout_clean() (not doing this can result
in strange behavior in some cases).

Submitted by:	John Dyson & David Greenman
1994-11-06 05:07:53 +00:00
David Greenman
1b119d9d17 Improved I/O error reporting. 1994-10-25 07:06:20 +00:00
David Greenman
191ee5b300 #if 0'd out the object cache trimming code - there are multiple ways
that the pageout daemon can deadlock otherwise.

Submitted by:	John Dyson
1994-10-25 05:35:44 +00:00
David Greenman
e8fbe458e4 Fixed object cache trimming policy so it actually works.
Submitted by:	John Dyson
1994-10-23 21:03:09 +00:00
David Greenman
389918ee95 Adjusted reserved levels to fix a deadlock condition.
Submitted by:	John Dyson
1994-10-23 20:53:33 +00:00
David Greenman
47c9acfdeb Changed a thread_sleep into an spl protected tsleep. A deadlock can occur
otherwise. Minor efficiency improvement in vm_page_free().

Submitted by:	John Dyson
1994-10-23 06:15:04 +00:00
Poul-Henning Kamp
2fc59d0032 Contrary to my last commit here: NFS-swap is enabled automatically. 1994-10-22 17:53:35 +00:00
David Greenman
36df951444 Fixed a comment from the previous commit. 1994-10-22 02:41:19 +00:00
David Greenman
5663e6de1c Various changes to allow operation without any swapspace configured. Note
that this is intended for use only in floppy situations and is done at
the sacrifice of performance in that case (in ther words, this is not the
best solution, but works okay for this exceptional situation).

Submitted by:	John Dyson
1994-10-22 02:18:03 +00:00
Poul-Henning Kamp
2a054bc060 ATTENTION!
From now on, >all< swapdevices must be activated with "swapon".

If you havn't got it, add this line to /etc/fstab:
	/dev/wd0b	none	swap	sw	0 0
ne sec

Reason:
We want our GENERIC* kernels to have a large selection of swap-devices, but
on the other hand, we don't want to use a wd0b as swap when we boot of a
floppy.  This way, we will never use a unexpected swapdevice.  Nothing else
has changed.
1994-10-21 03:17:11 +00:00
Garrett Wollman
091b0456f4 Make my ALLDEVS kernel compile (basically, LINT minus a lot of options).
This involves fixing a few things I broke last time.
1994-10-21 01:19:28 +00:00
David Greenman
a58d1fa15d Fix the remaining vmmeter counters. They all now work correctly. 1994-10-18 14:59:20 +00:00
David Greenman
27de4e40b8 Put sanity check for negative hold count into #ifdef DIAGNOSTIC so that
it doesn't consume an extra 3k of kernel text because of gcc's bogus
inlining code.
1994-10-17 10:43:56 +00:00
David Greenman
976e77fc9c 1) Some of the counters in the vmmeter struct don't fit well into the Mach VM
scheme of things, so I've changed them to be more appropriate. page in/ous
   are now associated with the pager that did them. Nuked v_fault as the
   only fault of interest that wouldn't be already counted in v_trap is a VM
   fault, and this is counted seperately.
2) Implemented most of the remaining counters and corrected the counting of
   some that were done wrong. They are all almost correct now...just a few
   minor ones left to fix.
1994-10-15 13:33:09 +00:00
David Greenman
b8d95f1624 Count vm faults as v_vm_fault, not v_fault. 1994-10-15 10:33:47 +00:00
David Greenman
a08a17a3ce Properly count object lookups and hits. 1994-10-15 10:28:47 +00:00
David Greenman
b73f3b1da2 Got rid of redundant declaration warnings. 1994-10-14 12:26:18 +00:00
Jordan K. Hubbard
0a99546c0a Add missing )'s to previous midnight changes. :-) 1994-10-14 08:57:25 +00:00
David Greenman
2e1e24dd28 Fixed bug where page modifications would be lost when swap space was
almost depleted.

Reviewed by:	John Dyson
1994-10-14 01:58:52 +00:00
David Greenman
defb6744ba Changed I/O error messages to be somewhat less cryptic. Removed a piece
of unused code.
1994-10-14 00:57:19 +00:00
David Greenman
28e12d63f3 Fixed an object reference count problem that was caused by a call to
vm_object_lookup() being outside of some parens. The bug was introduced
via some recently added code.

Reviewed by:	John Dyson
1994-10-13 21:01:39 +00:00
David Greenman
35c10d2239 Got rid of map.h. It's a leftover from the rmap code, and we use rlists.
Changed swapmap into swaplist.
1994-10-09 07:35:18 +00:00
Poul-Henning Kamp
05f0fdd26a Cosmetics: unused vars, ()'s, #include's &c &c to silence gcc.
Reviewed by:	davidg
1994-10-09 01:52:19 +00:00
David Greenman
da8b3304fb Call resetpriority, not setpriority() ...oops.
Submitted by:	John Dyson
1994-10-09 00:18:22 +00:00
Poul-Henning Kamp
4e39a515d4 Cosmetics. Unused vars and other warnings. 1994-10-07 07:23:04 +00:00
David Greenman
8e58bf6875 Stuff object into v_vmdata rather than pager. Not important which at
the moment, but will be in the future. Other changes mostly cosmetic,
but are made for future VMIO considerations.

Submitted by:	John Dyson
1994-10-05 09:48:45 +00:00
David Greenman
5cedf6806b Fixed minor bug caused by some missing parens that can result in slightly
reduced paging performance by missing a clustering opportunity. Found
by Poul-Henning Kamp with gcc -Wall.
1994-10-05 09:02:53 +00:00
David Greenman
8baf4dac64 John Dyson's work in progress. Not currently used. 1994-10-04 07:32:08 +00:00
David Greenman
edaaafdb0f Fixed bug related to proper sensing of page modification that we
inadvertantly introduced in pre-1.1.5. This could cause page modifications
to go unnoticed during certain extreme low memory/high paging rate conditions.

Submitted by:	John Dyson and David Greenman
1994-10-04 03:05:09 +00:00
Poul-Henning Kamp
623ae52e4e GCC cleanup.
Reviewed by:
Submitted by:
Obtained from:
1994-10-02 17:48:58 +00:00
David Greenman
1ffd2a2cbd Previous commit should have read ...in vm_page_alloc_contig().
...(this commit): moved initialization of 'start' to make it more clear
that it is initialized properly (also in vm_page_alloc_contig).
Reviewed by:
Submitted by:
Obtained from:
1994-09-27 20:49:02 +00:00
David Greenman
5992708aea Fixed another bug, and cleaned up the code. 1994-09-27 20:45:24 +00:00
David Greenman
0d040c7eae Fixed multiple bugs in previous version of vm_page_alloc_contig. 1994-09-27 19:34:16 +00:00
David Greenman
d3c2cf7a80 1) New "vm_page_alloc_contig" routine by me.
2) Created a new vm_page flag "PG_FREE" to help track free pages.
3) Use PG_FREE flag to detect inconsistencies in a few places.
1994-09-27 18:00:29 +00:00
David Greenman
c770b47d56 Removed unimplemented subr_rmap.c and unused references to it. 1994-09-25 22:31:11 +00:00
David Greenman
426de76026 Disabled swap anti-fragmentation code. It reduces swap paging performance
by 20% in my tests, and it appears to be the cause of a swap leak.

Submitted by:	John Dyson
1994-09-25 04:02:10 +00:00
David Greenman
11b224dca2 Fixed a bug I introduced when fixing the rss limit code. Changed swapout
policy to be a bit more selective about what processes get swapped out.

Reviewed by:	John Dyson
1994-09-12 15:06:14 +00:00
David Greenman
cde7257454 Eliminated a whole pile of ancient (we're taking 4.3BSD) VM system
related #define constants. Corrected incorrect VM_MAX_KERNEL_ADDRESS.

Reviewed by:	John Dyson
1994-09-12 11:38:31 +00:00
David Greenman
ed74321b1a Don't deactivate pages in 0-refcount objects. Added a couple of missing
paging stats. Fixed problem with free_reserved becoming depleted during
certain swap_pager operations.

Submitted by:	John Dyson, with a little help from me
1994-09-12 11:31:36 +00:00
David Greenman
55e8e4749f Fixed problem with no swap on boot device, but there is some on an
alternate device (as specified via kernel config file)...that casues
the machine to panic.
1994-09-11 03:55:39 +00:00
David Greenman
db141545dc Disabled a debugging printf. 1994-09-06 17:53:24 +00:00
David Greenman
a647a30954 Simple changes to paging algorithms...but boy do they make a difference.
FreeBSD's paging performance has never been better. Wow.

Submitted by:	John Dyson
1994-09-06 11:28:46 +00:00
David Greenman
90324b078e Whoops, accidently left out some pieces of the munmapfd patch. 1994-09-02 15:06:51 +00:00
David Greenman
2c7a40c7ca Removed all vestiges of tlbflush(). Replaced them with calls to pmap_update().
Made pmap_update an inline assembly function.
1994-09-02 04:12:26 +00:00
David Greenman
a6ca859eb1 Fixed bug caused by change of rlimit variables to quad_t's. The bug was in
using min() to calculate the minimum of rss_cur,rss_max - since these
are now quad_t's and min() takes u_ints...the comparison later for exceeding
the rss limit was always true - resulting in rather serious page thrashing.
Now using new qmin() function for this purpose.

Fixed another bug where PG_BUSY pages would sometimes be paged out (bad!).
This was caused by the PG_BUSY flag not being included in a comparison.
1994-08-30 18:27:44 +00:00
David Greenman
fff93ab600 Patches from John Dyson to improve swap code efficiency.
Religiously add back pmap_clear_modify() in vnode_pager_input until we figure
out why system performance isn't what we expect.

Submitted by:	John Dyson (swap_pager) & David Greenman (vnode_pager)
1994-08-29 06:23:19 +00:00
David Greenman
8a129caed5 1) Changed ddb into a option rather than a pseudo-device (use options DDB
in your kernel config now).
2) Added ps ddb function from 1.1.5. Cleaned it up a bit and moved into its
   own file.
3) Added \r handing in db_printf.
4) Added missing memory usage stats to statclock().
5) Added dummy function to pseudo_set so it will be emitted if there
   are no other pseudo declarations.
1994-08-27 16:14:39 +00:00
Paul Richards
3301cc3c0a Made idempotent
Reviewed by:
Submitted by:
1994-08-21 07:19:45 +00:00
Garrett Wollman
f23b4c91c4 Fix up some sloppy coding practices:
- Delete redundant declarations.
- Add -Wredundant-declarations to Makefile.i386 so they don't come back.
- Delete sloppy COMMON-style declarations of uninitialized data in
  header files.
- Add a few prototypes.
- Clean up warnings resulting from the above.

NB: ioconf.c will still generate a redundant-declaration warning, which
is unavoidable unless somebody volunteers to make `config' smarter.
1994-08-18 22:36:09 +00:00
David Greenman
28b5c68f2f Fixed vm_page_deactivate to deal with getting called with a page that's
not on any queue. This is an old patchkit days fix.

Reviewed by:	John Dyson and David Greenman
Submitted by:	originally by Paul Mackerras
1994-08-10 03:09:37 +00:00
David Greenman
92a34c0c6d Removed an old, obsolete call to vmmeter(). This is called now in the
schedcpu() routine in kern/kern_synch.c. This extra call to vmmeter() in
vm_glue.c was what was totally messing up the load average calculations.
1994-08-09 10:42:41 +00:00
David Greenman
8339815ff9 Made pmap_kenter "TLB safe". ...and then removed all the pmap_updates that
are no longer needed because of this.
1994-08-07 14:53:27 +00:00
David Greenman
a481f20029 Provide support for upcoming merged VM/buffer cache, and fixed a few bugs
that haven't appeared to manifest themselves (yet).

Submitted by:	John Dyson
1994-08-07 13:10:43 +00:00
David Greenman
c87801fe54 Fixed various prototype problems with the pmap functions and the subsequent
problems that fixing them caused.
1994-08-06 10:25:50 +00:00
David Greenman
16f62314cd Incorporated post 1.1.5 work from John Dyson. This includes performance
improvements via the new routines pmap_qenter/pmap_qremove and pmap_kenter/
pmap_kremove. These routine allow fast mapping of pages for those
architectures that have "normal" MMUs. Also included is a fix to the
pageout daemon to properly check a queue end condition.

Submitted by:	John Dyson
1994-08-06 09:15:42 +00:00
David Greenman
f720dc2ceb Enabled page table preloading of cached objects.
Submitted by:	John Dyson
1994-08-06 09:00:50 +00:00
David Greenman
d6a6c0f60c Added some code that was accidently left out early in the 1.x -> 2.0 VM
system conversion.
Submitted by:	John Dyson
1994-08-04 19:40:47 +00:00
David Greenman
bbc0ec5284 Integrated VM system improvements/fixes from FreeBSD-1.1.5. 1994-08-04 03:06:48 +00:00
David Greenman
3c4dd3568f Added $Id$ 1994-08-02 07:55:43 +00:00
David Greenman
03e6c2532f Removed all code related to the pagescan daemon, and changed 'act_count'
adjustments to compensate for a world without the pagescan daemon.
1994-08-01 11:25:45 +00:00
David Greenman
0a620217f0 Don't move the page's position in the active queue if it is busy or
held. John has noticed some stability problems when doing this.
1994-06-06 11:56:27 +00:00
Rodney W. Grimes
26f9a76710 The big 4.4BSD Lite to FreeBSD 2.0.0 (Development) patch.
Reviewed by:	Rodney W. Grimes
Submitted by:	John Dyson and David Greenman
1994-05-25 09:21:21 +00:00
Rodney W. Grimes
df8bae1de4 BSD 4.4 Lite Kernel Sources 1994-05-24 10:09:53 +00:00