Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Oct 2007 12:34:36 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Igor Sysoev <is@rambler-co.ru>
Cc:        freebsd-current@freebsd.org, Antony Mawer <fbsd-current@mawer.org>
Subject:   Re: sendfile and page usage statistics
Message-ID:  <20071010093436.GB2180@deviant.kiev.zoral.com.ua>
In-Reply-To: <20071010062541.GA23840@rambler-co.ru>
References:  <20071009125001.GC5758@rambler-co.ru> <20071010055748.GA18931@rambler-co.ru> <20071010060605.GB18931@rambler-co.ru> <470C6DD4.1060509@mawer.org> <20071010062541.GA23840@rambler-co.ru>

next in thread | previous in thread | raw e-mail | index | archive | help

--Iy2CUD6FdotTkhwY
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Oct 10, 2007 at 10:25:41AM +0400, Igor Sysoev wrote:
> On Wed, Oct 10, 2007 at 04:14:44PM +1000, Antony Mawer wrote:
>=20
> > On 10/10/2007 4:06 PM, Igor Sysoev wrote:
> > >On Wed, Oct 10, 2007 at 09:57:48AM +0400, Igor Sysoev wrote:
> > >
> > >>On Tue, Oct 09, 2007 at 04:50:01PM +0400, Igor Sysoev wrote:
> > >>
> > >>>As I understand if sendfile() with hardware TX chsum or TSO are used,
> > >>>then CPU does not touch file pages at all. So pagedaemon never set
> > >>>PG_REFERENCED to vnode object pages while scanning them.
> > >>>Does VM set PG_REFERENCED by another way ? Otherwise, often used fil=
es
> > >>>that accessed by sendfile() only have small chances to be cached by =
VM.
> > >>I have looked kern_sendfile() in CURRENT and it seems to me that
> > >>PG_REFERENCED is never set when sendfile() gets cached vm_page.
> > >>I have looked the code path:
> > >>
> > >>vm_page_grab()
> > >>    vm_page_lookup()
> > >>    vm_page_wire()
> > >>sf_buf_alloc() on i386 and amd64
> > >>
> > >>and have not seen PG_REFERENCED.
> > >
> > >As I understand the following patch against uipc_syscalls.c
> > >should fix the bug to some extent:
> > >
> > >                         if (pg->valid && vm_page_is_valid(pg, pgoff,=
=20
> > >                         xfsize))
> > >+                                vm_page_flag_set(pg, PG_REFERENCED);
> > >                                 VM_OBJECT_UNLOCK(obj);
> > >                         else if (m !=3D NULL)
> >=20
> > You are missing opening/closing braces on your if() statement with this=
=20
> > change...
>=20
> Oh, thank you! You have saved me from coredump.
> This is why in my coding style I always use braces for single statement=
=20
> inside if().

Also, as a minimum you need to brace the vm_page_flag_set() with
vm_page_lock_queues()/vm_page_unlock_queues().

But I think that the actual patch is wrong. The PG_REFERENCED bit shall
be set when hardware access bit is set on pte. You patch would set it in
advance.


--Iy2CUD6FdotTkhwY
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4 (FreeBSD)

iD8DBQFHDJysC3+MBN1Mb4gRAj+WAKCQNdZT728t4t7msPeDwic0+0NSaQCeIlGk
TfSYvOp0XNmAtrxVuZMgjNM=
=yxUs
-----END PGP SIGNATURE-----

--Iy2CUD6FdotTkhwY--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071010093436.GB2180>