From nobody Mon Jul 5 19:47:41 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 335097CDEBA for ; Mon, 5 Jul 2021 19:47:44 +0000 (UTC) (envelope-from gusev.vitaliy@gmail.com) Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) (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 4GJbnX0l3Yz3kRS; Mon, 5 Jul 2021 19:47:43 +0000 (UTC) (envelope-from gusev.vitaliy@gmail.com) Received: by mail-lf1-x12a.google.com with SMTP id c28so10797045lfp.11; Mon, 05 Jul 2021 12:47:43 -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=86JzPH9MLxZzDqf63gQaP0qBE2RRVkOK4wobC590+gU=; b=UExSQOaeVsT+Kc39OYLo1HVjqUf8VBZ2ukgjXH0MENMDHYyxPvrkzYiLzwv33A+HrL deaZhnLRDxDgi1XPSUBk1rVE3KCu0SxKltSGeGQ5fy+K+fJGoVCu8WpfRZK2JLqsqIIG 9aeakDUQGxiTLzXF74Dz5iEzsK1xgwPHE958nEEDRCktM/hDU8dalb0TV0KZeWv3spf2 F7E8f+/crhBXikIp44mHERJw+NNyeG/1zdZwwc0I8GCGBVR/wdVyuCm9lUsjrFUD+42+ +fvXwecNs7yJWW4CxMEdBIUYHswl952NnMsnSG9+cr49VwnTtEybDkxLVQ/KJy9s84im N8Sw== 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=86JzPH9MLxZzDqf63gQaP0qBE2RRVkOK4wobC590+gU=; b=EH3Hmsp5D0Xskk75JIuKkZNw1hHZIW5V8IrrMHhjkWU+plZoMt6FqXqsyO/bmG9Hdb vlkns5sqzHAUhZNTo0VmKfGw/F0gcKKKH6QgHyfAFj0ZK4Yyaevehy0F2yXLsZkqL6/g SKZXpd/v7blCoTIWZlpzgKnW9T5I5fSQ1+KcPhnM3H25X023MDTLZlKN4eU9EHLEskpw OIGG3GRjdDThPyewRaLZjaCheJ3+S5/XgdCABIcsH8XptmkdHs/KG/PPaZ58iG7X2+JM Fh5nsv13feCVh/lvjGch9xaTrfKrWXrYX7JXJvbO5W7XRAGEYfMYWJwIfdYXB7qyjNj3 +dPg== X-Gm-Message-State: AOAM531DzljC0ugehNEwb0SmjSpFvWm9hfoWIG79gB1vSNaXbtjZ9fW+ 9WqqsrZRw7JgLVDDL0248pM= X-Google-Smtp-Source: ABdhPJzXQ7IYg0aHlEpQPSpP8cPwKWDWTYfkN8W7O6jD4W3ABCpRmJj8/8tgvPaqzoMH8+X/GN60Zw== X-Received: by 2002:a19:6803:: with SMTP id d3mr11696968lfc.235.1625514461909; Mon, 05 Jul 2021 12:47:41 -0700 (PDT) Received: from [10.42.0.5] ([188.187.60.230]) by smtp.gmail.com with ESMTPSA id u5sm1173340lfg.268.2021.07.05.12.47.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Jul 2021 12:47:41 -0700 (PDT) From: Vitaliy Gusev Message-Id: <2A7A1E60-766D-427B-8288-E92B4090022E@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_82CC2F6D-5182-4E17-96FC-1768BCE1AE35" 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: Mon, 5 Jul 2021 22:47:41 +0300 In-Reply-To: Cc: freebsd-hackers@freebsd.org, gljennjohn@gmail.com, Mark Johnston , Peter Grehan To: Konstantin Belousov References: <20210703065420.6dbafb5f@ernst.home> <2390FA9B-319E-45D4-BEA7-10878E43AD4B@gmail.com> X-Mailer: Apple Mail (2.3608.120.23.2.7) X-Rspamd-Queue-Id: 4GJbnX0l3Yz3kRS 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-ThisMailContainsUnwantedMimeParts: Y --Apple-Mail=_82CC2F6D-5182-4E17-96FC-1768BCE1AE35 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > 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 That caused behaviour that memory is not freed!=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 ? As Mark wrote in another thread: Indeed, in FreeBSD madvise() never reclaims pages. I'm not sure which hint is being provided here, but MADV_DONTNEED and MADV_FREE both prioritize reclamation of the pages backing the specified virtual address range. The difference between the two is that MADV_FREE permits dirty pages to be freed without paging out their contents first and so is destructive. That is why I expected the same behaviour for both. >>>=20 >>> You can read more details in the referenced commit, as well as some = musings >>> about way to make it somewhat better. >>>=20 >>> I must say, that trying to allocated 1/2 + 1/2 of RAM this way, on a = system >>> without swap, is the way to ask for troubles anyway. >> I=E2=80=99ve just notify that other operation systems work well with = that, whereas FreeBSD has troubles. Probably something in madvise() is = not finished ? >=20 > Well, yes, as I said, non-trivial shadow chains for MADV_FREE are not > handled due to the 'old content revival' bug. For your specific case, = the > following patch might help (modulo bugs). Thanks, I will try and report result. =E2=80=94=E2=80=94 Vitaliy Gusev --Apple-Mail=_82CC2F6D-5182-4E17-96FC-1768BCE1AE35--