From nobody Mon Jul 12 19:52:31 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 4A4CA127D485 for ; Mon, 12 Jul 2021 19:52:39 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4GNvYy70pXz3jyT; Mon, 12 Jul 2021 19:52:38 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 16CJqVmD069932 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 12 Jul 2021 22:52:34 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 16CJqVmD069932 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 16CJqVp6069931; Mon, 12 Jul 2021 22:52:31 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 12 Jul 2021 22:52:31 +0300 From: Konstantin Belousov To: Vitaliy Gusev Cc: freebsd-hackers@freebsd.org, gljennjohn@gmail.com, Mark Johnston , Peter Grehan Subject: Re: madvise(MADV_FREE) doesn't work in some cases? Message-ID: References: <20210703065420.6dbafb5f@ernst.home> <2390FA9B-319E-45D4-BEA7-10878E43AD4B@gmail.com> <2A7A1E60-766D-427B-8288-E92B4090022E@gmail.com> <4C23FE3C-4FC3-41B2-9A6A-5C267CC0A0E0@gmail.com> 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 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4C23FE3C-4FC3-41B2-9A6A-5C267CC0A0E0@gmail.com> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.5 X-Spam-Checker-Version: SpamAssassin 3.4.5 (2021-03-20) on tom.home X-Rspamd-Queue-Id: 4GNvYy70pXz3jyT X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; TAGGED_RCPT(0.00)[]; REPLY(-4.00)[] X-Spam: Yes X-ThisMailContainsUnwantedMimeParts: N On Mon, Jul 12, 2021 at 02:55:37PM +0300, Vitaliy Gusev wrote: > Thanks for response, > > > On 10 Jul 2021, at 16:54, Konstantin Belousov wrote: > > > >> > >> After testing it looks that backing_object is not null here, memory is not freed and mmapfork test program is still killed. Any ideas? > >> > > I finally looked at this thing again. You do madvise(PAGE_SIZE). With > > my patch (updated version below) issue madvise() for the whole region > > once. > > I guess madvise() should work well even with PAGE_SIZE granularity. Usually a caller doesn’t need to free the whole region. As I reported earlier madvise(PAGE_SIZE) works well in Linux and illumos. > > Current behaviour in FreeBSD can confuse programmers and brings impossibility to effectively give back unused memory. Also I have another case with madvise() but with shared memory that also doesn’t work (but works in Linux and illumos), will report it in new thread. > I want the confirmation or report that it still did not worked, for the case when my latest patch was applied and the test program switched to the single call to madvise(2) for the whole region. After that, I can claim that the problem is understood and might consider some solutions.