From owner-freebsd-current@FreeBSD.ORG Wed Oct 10 10:13:11 2007 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 890F916A41B for ; Wed, 10 Oct 2007 10:13:11 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from gnome.kiev.sovam.com (gnome.kiev.sovam.com [212.109.32.24]) by mx1.freebsd.org (Postfix) with ESMTP id 1598C13C469 for ; Wed, 10 Oct 2007 10:13:10 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from relay02.kiev.sovam.com ([62.64.120.197]) by gnome.kiev.sovam.com with esmtp (Exim 4.67 (FreeBSD)) (envelope-from ) id 1IfYYw-000Ach-1b for freebsd-current@freebsd.org; Wed, 10 Oct 2007 13:13:10 +0300 Received: from [212.82.216.226] (helo=deviant.kiev.zoral.com.ua) by relay02.kiev.sovam.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.67) (envelope-from ) id 1IfYYu-0009U0-1W for freebsd-current@freebsd.org; Wed, 10 Oct 2007 13:13:09 +0300 Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.1/8.14.1) with ESMTP id l9AAD4BJ043678; Wed, 10 Oct 2007 13:13:04 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.1/8.14.1/Submit) id l9AAD4cj043660; Wed, 10 Oct 2007 13:13:04 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 10 Oct 2007 13:13:04 +0300 From: Kostik Belousov To: Cc: Igor Sysoev Message-ID: <20071010101304.GC2180@deviant.kiev.zoral.com.ua> 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> <20071010093436.GB2180@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="/aHqdxxe3Vo3WJ36" Content-Disposition: inline In-Reply-To: <20071010093436.GB2180@deviant.kiev.zoral.com.ua> User-Agent: Mutt/1.4.2.3i X-Scanner-Signature: ca614d1e091d53a46adb2ef7a730c6a6 X-DrWeb-checked: yes X-SpamTest-Envelope-From: kostikbel@gmail.com X-SpamTest-Group-ID: 00000000 X-SpamTest-Info: Profiles 1580 [Oct 10 2007] X-SpamTest-Info: helo_type=3 X-SpamTest-Info: {received from trusted relay: not dialup} X-SpamTest-Method: none X-SpamTest-Method: Local Lists X-SpamTest-Rate: 0 X-SpamTest-Status: Not detected X-SpamTest-Status-Extended: not_detected X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0255], KAS30/Release Cc: freebsd-current@freebsd.org, Antony Mawer Subject: Re: sendfile and page usage statistics X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Oct 2007 10:13:11 -0000 --/aHqdxxe3Vo3WJ36 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Oct 10, 2007 at 12:34:36PM +0300, Kostik Belousov wrote: > 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 us= ed, > > > >>>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 f= iles > > > >>>that accessed by sendfile() only have small chances to be cached b= y 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 th= is=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(). >=20 > Also, as a minimum you need to brace the vm_page_flag_set() with > vm_page_lock_queues()/vm_page_unlock_queues(). >=20 > 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. To clarify my point that is badly worded above: PG_REFERENCED shall be translated from PG_A (for i386/amd64) in pte when the sf buffer is dissolved. This way, PG_REFERENCED will be set only when the page was actually used, preventing page cache pollution. The busdma, most likely, shall notify pmap on hw access to the page. --/aHqdxxe3Vo3WJ36 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4 (FreeBSD) iD8DBQFHDKWvC3+MBN1Mb4gRAvoeAKC8Y1JIVrnE8wxmbyZWQjLPf/nj1wCg4AeK 5R9SJcY79tSSXAgwhoFlCAY= =Xh13 -----END PGP SIGNATURE----- --/aHqdxxe3Vo3WJ36--