Date: Mon, 24 Mar 2014 14:11:56 +0200 From: Konstantin Belousov <kostikbel@gmail.com> To: Dmitry Sivachenko <trtrmitya@gmail.com> Cc: hackers@freebsd.org, Trond Endrest??l <Trond.Endrestol@fagskolen.gjovik.no> Subject: Re: madvise() vs posix_fadvise() Message-ID: <20140324121156.GX21331@kib.kiev.ua> In-Reply-To: <C5489EF2-34D8-412C-88AC-476120D3F1F4@gmail.com> References: <D6BD48AF-9522-495D-8D54-37854E53C272@gmail.com> <alpine.BSF.2.00.1403211725140.56113@mail.fig.ol.no> <C5489EF2-34D8-412C-88AC-476120D3F1F4@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--D+UG5SQJKkIYNVx0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Mar 24, 2014 at 04:03:04PM +0400, Dmitry Sivachenko wrote: >=20 > On 21 =CD=C1=D2=D4=C1 2014 =C7., at 20:27, Trond Endrest??l <Trond.Endres= tol@fagskolen.gjovik.no> wrote: >=20 > > On Fri, 21 Mar 2014 18:56+0400, Dmitry Sivachenko wrote: > >=20 > >> Hello! > >>=20 > >> I have a program which uses large data files (read-only, via mmap()). > >>=20 > >> These machines have a bit more RAM that these files occupy, so it is= =20 > >> possible to have all these data in memory. > >>=20 > >> What techniques should I use to promote this data not to be purged=20 > >> from RAM: > >>=20 > >> -- madvise(MADV_WILLNEED) > >> -- posix_fadvise(POSIX_FADV_WILLNEED) > >> -- both? > >=20 > > Although a bit dangerous, mlock(2) might be your ticket. That system=20 > > call prevents your memory region from being swapped/paged away from=20 > > physical memory. > >=20 >=20 >=20 > I know about mlock(2), it is a bit overkill. > Can someone please explain the difference between madvise(MADV_WILLNEED) = and posix_fadvise(POSIX_FADV_WILLNEED)? >=20 The difference is only in the way the errors are reported; madvise(2) is the 'classic' syscall which sets errno, while posix_madvise(3) is a trivial wrapper which returns error. You would get the answer yourself in approx. 1 minute if you looked at the man page or code. --D+UG5SQJKkIYNVx0 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (FreeBSD) iQIcBAEBAgAGBQJTMCELAAoJEJDCuSvBvK1Bh4gP/iGagR41B/Wj+VbwYf/AnSJN arteO7s8odPafp83+bBKl6iT9DgE/SAFMENGmaqpOeehR1VEu7vkwSPBjadSsd9s rKYvOSC6eKGBU2jJNptGYgmR4MqAZzesZjLzkIqEyNfOz/LKFa8uWeTA+/kmdtDt JPb57dY6aYN+BatEzl2aRmsngc/ZQF3SXyqrTIP2Heu+K0P2du8P9R4fw6VYY7jU XOqnShZP7Fb5HSpKcFh+h4Y6WVoS4Yp2ADYqdCF0bytOnT0S3DFnWGkZmTrY95E4 jVQFidpYr9MfoKkDqfiaFzhHZhkSOP5gqM2Y9M9GK2wkLEYKxuREiZFNXjt/BwSn atYtkUmNBzc9+QdfE0wT+0x9V3LLx3QxQX98O5hVYQNYD5q3YvfvOdRx700oCyr2 G3CNwEvXMhOTc2oVh9byaYcqLfxjAWhV6Vku8//pNEYTG4/To41csX8srwpVbMf0 IQ8DUH+dNOfVwV82HBOpanGl/gE1T4Ng4I5b1XescvUbOs+EP0DXFbTZH45A3uGt vxInpRd/83yZNILKznFzX9y5YTSoQnsrUhP/Qe1TslIjUtmUau/wCQyUB+R+GiVJ EwHzs+hpXi7vgX+EpJdI5Xh21qPC1TS8NG+EtNkCpM2DDZ/rloGi4K1XgDEdwkST gA+zNV3Aacc2tI5WGX4T =1gTN -----END PGP SIGNATURE----- --D+UG5SQJKkIYNVx0--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140324121156.GX21331>