From owner-freebsd-hackers@FreeBSD.ORG Mon Mar 24 12:03:09 2014 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 78EC15A1 for ; Mon, 24 Mar 2014 12:03:09 +0000 (UTC) Received: from mail-la0-x22d.google.com (mail-la0-x22d.google.com [IPv6:2a00:1450:4010:c03::22d]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 00651AB8 for ; Mon, 24 Mar 2014 12:03:08 +0000 (UTC) Received: by mail-la0-f45.google.com with SMTP id hr17so3516886lab.4 for ; Mon, 24 Mar 2014 05:03:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=/YlIW2HNy+XBP4ONqP3FVFD/Ec40H9bo5a7vxlgBCeY=; b=PAF7FF157fmksq9oXpSX+G2mH5DDRfUKuHzQ3rnn6ONBa6OcHmaPEXzl4LykuAmOkN L+RzNGphSGqMsZVZkBE2FFA3TZMnKGnvg/SgAU4cm24UJaoMLXLk8UBHceoDkN40w8n1 3hcMolwKwZNNBm+86msLhkLXgS8cTX1z9hijHTNIeI9raqpspiDxeAlo29jQGaEhCoS4 WsjkdDVofA/fus4ykQF9HIC9f+lx9aZR0t5ZicU9ClAqrgkdTFoa0WHnVrVZ3aHajGsI FlZmWJ9W2mzHGwuVeIt5Cu84O0vgTqtiVvBlFHm+stg9/zMmGQs3Q+9VifIFnS7HK50g lLug== X-Received: by 10.112.171.1 with SMTP id aq1mr31198lbc.67.1395662587093; Mon, 24 Mar 2014 05:03:07 -0700 (PDT) Received: from [10.0.1.20] ([176.193.80.226]) by mx.google.com with ESMTPSA id jm3sm855523lbc.29.2014.03.24.05.03.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Mar 2014 05:03:06 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) Subject: Re: madvise() vs posix_fadvise() From: Dmitry Sivachenko In-Reply-To: Date: Mon, 24 Mar 2014 16:03:04 +0400 Content-Transfer-Encoding: quoted-printable Message-Id: References: To: =?utf-8?Q?Trond_Endrest=C3=B8l?= X-Mailer: Apple Mail (2.1874) Cc: hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Mar 2014 12:03:09 -0000 On 21 =D0=BC=D0=B0=D1=80=D1=82=D0=B0 2014 =D0=B3., at 20:27, Trond = Endrest=C3=B8l wrote: > 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 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)?