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>
index | next in thread | previous in thread | raw e-mail
On Monday, March 24, 2014 8:03:04 am Dmitry Sivachenko wrote: > > On 21 марта 2014 г., at 20:27, Trond Endrestøl <Trond.Endrestol@fagskolen.gjovik.no> wrote: > > > On Fri, 21 Mar 2014 18:56+0400, Dmitry Sivachenko wrote: > > > >> Hello! > >> > >> I have a program which uses large data files (read-only, via mmap()). > >> > >> These machines have a bit more RAM that these files occupy, so it is > >> possible to have all these data in memory. > >> > >> What techniques should I use to promote this data not to be purged > >> from RAM: > >> > >> -- madvise(MADV_WILLNEED) > >> -- posix_fadvise(POSIX_FADV_WILLNEED) > >> -- both? > > > > Although a bit dangerous, mlock(2) might be your ticket. That system > > call prevents your memory region from being swapped/paged away from > > physical memory. > > > > > 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)? 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). -- John Baldwinhelp
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201403271141.41487.jhb>
