From nobody Tue Jul 13 21:19:56 2021 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D4E7A12A4B92 for ; Tue, 13 Jul 2021 21:20:01 +0000 (UTC) (envelope-from gusev.vitaliy@gmail.com) Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GPYSK559Tz3hpb; Tue, 13 Jul 2021 21:20:01 +0000 (UTC) (envelope-from gusev.vitaliy@gmail.com) Received: by mail-qk1-x72b.google.com with SMTP id s6so20314850qkc.8; Tue, 13 Jul 2021 14:20:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=jDcAnjnO8S8spNXqhwSc2AY3MJ6kWiOFVM5KMnaajx8=; b=ib7ywm9oD1bMcMK72RCVxPEsmZCP09K1ddofzhLa4P30prq+wqo2WdsqpIjX1L988+ j6m2A2CH9R8MokNXQl1gqCbSSASqyQW79SAwX1b+qZn97X5UlGQlSSBvD4YBbg3+2pr6 TKt5HuVPwBCy0rT4HzF82I6tg1lGo9vmXcY522tkh0Hp80wTV7oVyLBIAScM9ACI7kjK Aq6kj6tUIZ0AFo+V1HkKKoQswn3rGQ+AdsDofhqMAMyS6ZN0dJlSBwYTHm1+4MdmJg/o HRdI+rPbnbG9TnnJP81zSeBIDsc0bccZG0YFRRJGSUNn4IMyOS07x0F/Cvu5X639Xtc4 /bsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=jDcAnjnO8S8spNXqhwSc2AY3MJ6kWiOFVM5KMnaajx8=; b=UpUR7jjRVe04udciaTN+l4NHErQQ41hsiezFSmf5JTuxopjkUH3kKzhdX2zoDo+Acb Db4SObQUV9LE3LDbpK757JYTXVbxE/NmV1lhM41TmRFeEP8VpE9lc+/2Vw2PkobRPRH5 /cJKM42qT4t4Izn8elgNdpM9B3IDXKlHbySsQM/wjQo7hlbeXh7LAAGo//x88OfvqOlN Q1KqmIrghOSkwypO2k2d3Sb4rinqQ6+9J9lMA3+mE9xGeVf5SXDlntOs2Ah6mXXiZ+Ow PeSHdwZg+8uX8+hV5+HambEO/thC14bmYMloLKkd95+yL5GDGIQiv8OZMhyqybVFmZAU w/kQ== X-Gm-Message-State: AOAM5322SEVg/L7elSxBBp5ZTUmYqfV5uwt8zKGHGlhxPdRV5oO8E+Xn mcGhPVkYBWleHO5DBDjtqPo= X-Google-Smtp-Source: ABdhPJycllDIfQ9UJ5HI2dh3BuF97BsZ0ERf75RIN0a2kLts8Zt5RrnsvO1Y6LFWtowuaSOtzaci9Q== X-Received: by 2002:ae9:e315:: with SMTP id v21mr6200109qkf.81.1626211200972; Tue, 13 Jul 2021 14:20:00 -0700 (PDT) Received: from [10.42.0.5] ([188.187.60.230]) by smtp.gmail.com with ESMTPSA id r4sm3237241qtc.66.2021.07.13.14.19.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jul 2021 14:20:00 -0700 (PDT) From: Vitaliy Gusev Message-Id: <23BF78E0-CEF9-4B4F-B7C4-6F81DD6DABEE@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_0039FE7C-4B01-4DAC-817E-424EB4742BA2" List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: madvise(MADV_FREE) doesn't work in some cases? Date: Wed, 14 Jul 2021 00:19:56 +0300 In-Reply-To: <4cab2b26-e9cb-6ca7-fbd1-90160f07bf61@gmail.com> Cc: freebsd-hackers@freebsd.org, gljennjohn@gmail.com, Mark Johnston , Peter Grehan , Konstantin Belousov To: Ka Ho Ng References: <20210703065420.6dbafb5f@ernst.home> <2390FA9B-319E-45D4-BEA7-10878E43AD4B@gmail.com> <2A7A1E60-766D-427B-8288-E92B4090022E@gmail.com> <4cab2b26-e9cb-6ca7-fbd1-90160f07bf61@gmail.com> X-Mailer: Apple Mail (2.3608.120.23.2.7) X-Rspamd-Queue-Id: 4GPYSK559Tz3hpb X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[] X-Spam: Yes X-ThisMailContainsUnwantedMimeParts: Y --Apple-Mail=_0039FE7C-4B01-4DAC-817E-424EB4742BA2 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 13 Jul 2021, at 14:03, Ka Ho Ng wrote: >=20 > On 2021/7/6 3:47 AM, Vitaliy Gusev wrote: >>> On 5 Jul 2021, at 21:54, Konstantin Belousov = wrote: >>>=20 >>> On Mon, Jul 05, 2021 at 07:32:00PM +0300, Vitaliy Gusev wrote: >>>=20 >>> DONTNEED does not allow system to free pages at all. It means that = pages >>> are less useful and can be paged out with higher priority. >>>=20 >>=20 >> That caused behaviour that memory is not freed!=20 >>=20 >> Is there a reason why FreeBSD behaviour for MADV_DONTNEED is = different than in Linux and illumos ? Why it needs swap and cannot be = easily dropped ? >>=20 > Illumos has a similar behavior as FreeBSD in the way that it does not > destroy content of the underlying object. The operation you described = in > Illumos is MAP_PURGE which is intended to be a bug-to-bug compatible > interface. See: > = https://github.com/illumos/illumos-gate/commit/8905f42caceb9f470ffaa19e5f6= c9fb6184d12c0 > for full context. >=20 Right, I was confused by RSS value of test processes in illumos, it was = shrunk to hundreds of KB: 2337 vvv 1 59 0 1002M 980K sleep 0:01 0.00% = mmapforkdontnee 2338 vvv 1 59 0 1002M 720K sleep 0:01 0.00% = mmapforkdontnee whereas free memory didn=E2=80=99t increased, so system kept memory = reserved. MADV_FREE increases "free mem" after madvise(), i.e. frees used memory, = that is expected. Thanks, Vitaliy Gusev --Apple-Mail=_0039FE7C-4B01-4DAC-817E-424EB4742BA2--