Subject: Re: vm.bufmem_hiwater not honored (Re: failing to keep a process from swapping)
To: Daniel Carosone <dan@geek.com.au>
From: Daniel Carosone <dan@geek.com.au>
List: tech-kern
Date: 11/17/2004 11:04:58
--RUqJLqMNe5u4kDWT
Content-Type: multipart/mixed; boundary="3eH4Qcq5fItR5cpy"
Content-Disposition: inline
--3eH4Qcq5fItR5cpy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Wed, Nov 17, 2004 at 10:38:32AM +1100, Daniel Carosone wrote:
> Please try the attached diff, which I have been using since we last
With attachment this time. D'oh.
--
Dan.
--3eH4Qcq5fItR5cpy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="vfs_bio.c.diff"
Content-Transfer-Encoding: quoted-printable
Index: vfs_bio.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/src/sys/kern/vfs_bio.c,v
retrieving revision 1.137
diff -u -r1.137 vfs_bio.c
--- vfs_bio.c 13 Nov 2004 19:16:18 -0000 1.137
+++ vfs_bio.c 16 Nov 2004 23:29:59 -0000
@@ -480,20 +480,28 @@
static int
buf_canrelease(void)
{
- int pagedemand, ninvalid =3D 0;
+ int pagedemand, ninvalid =3D 0, gotnow, giveback;
=20
LOCK_ASSERT(simple_lock_held(&bqueue_slock));
=20
- if (bufmem < bufmem_lowater)
+ gotnow =3D bufmem - bufmem_lowater;=20
+
+ if (gotnow < 0)
return 0;
=20
ninvalid +=3D bufqueues[BQ_AGE].bq_bytes;
=20
pagedemand =3D uvmexp.freetarg - uvmexp.free;
- if (pagedemand < 0)
- return ninvalid;
- return MAX(ninvalid, MIN(2 * MAXBSIZE,
- MIN((bufmem - bufmem_lowater) / 16, pagedemand * PAGE_SIZE)));
+
+ giveback =3D MAX(ninvalid,=20
+ MAX(2 * MAXBSIZE,
+ MAX(gotnow / 16, pagedemand * PAGE_SIZE)));
+
+ if (giveback > gotnow) {
+ giveback =3D gotnow;
+ }
+
+ return giveback;
}
=20
/*
--3eH4Qcq5fItR5cpy--
--RUqJLqMNe5u4kDWT
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (NetBSD)
iD8DBQFBmpWqEAVxvV4N66cRAk2GAJ9wSHK3vr6wQmayHni/J7lWE4p1CwCgw21d
zp5dn5xVjo9tMh4NmSmCDak=
=RGh6
-----END PGP SIGNATURE-----
--RUqJLqMNe5u4kDWT--