Date: Thu, 27 Mar 2014 11:41:41 -0400 From: John Baldwin <jhb@freebsd.org> To: freebsd-hackers@freebsd.org Cc: hackers@freebsd.org, Dmitry Sivachenko <trtrmitya@gmail.com>, Trond =?utf-8?q?Endrest=C3=B8l?= <Trond.Endrestol@fagskolen.gjovik.no> Subject: Re: madvise() vs posix_fadvise() Message-ID: <201403271141.41487.jhb@freebsd.org> 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
On Monday, March 24, 2014 8:03:04 am Dmitry Sivachenko wrote: >=20 > On 21 =D0=BC=D0=B0=D1=80=D1=82=D0=B0 2014 =D0=B3., at 20:27, Trond Endres= t=C3=B8l=20 <Trond.Endrestol@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=20 posix_fadvise(POSIX_FADV_WILLNEED)? Right now FADV_WILLNEED is a nop. (I have some patches to implement it for UFS.) I can't recall off the top of my head if MADV_WILLNEED is also a nop. However, if both are fully implemented they should be similar in terms of requesting async read-ahead. MADV_WILLNEED might also conceivably pre-create PTEs while FADV_WILLNEED can be used on a file that isn't mapped but is accessed via read(2). =2D-=20 John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201403271141.41487.jhb>