Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Jul 2021 08:54:20 +0200
From:      Gary Jennejohn <gljennjohn@gmail.com>
To:        Vitaliy Gusev <gusev.vitaliy@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: madvise(MADV_FREE) doesn't work in some cases?
Message-ID:  <20210703065420.6dbafb5f@ernst.home>
In-Reply-To: <D5749BDF-36B5-4AE9-A75F-2A702DF71F8C@gmail.com>
References:  <D5749BDF-36B5-4AE9-A75F-2A702DF71F8C@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 3 Jul 2021 02:56:40 +0300
Vitaliy Gusev <gusev.vitaliy@gmail.com> wrote:

> Hi, 
> 
> I came across not expected behaviour with madvise() in FreeBSD.
> 
> Attached test program mmapfork does: mmap, fork, touch memory and then madvise(MADV_FREE).
> 
> Expected behaviour - one process can allocate memory (lazy allocation) while system is freeing previously allocated memory for a second process.
> 
> Current behaviour -  system kills one process with message in dmesg:
> 
> pid 31314 (mmapfork), jid 0, uid 1001, was killed: out of swap space
> 
> Running this test in Linux or illumos shows expected behaviour with a little difference in illumos - it frees memory almost immediately, w/o needs lack of memory in a system.
> 
> If use MADV_NOTNEED - no changes.
> 
> If modify program and do not do fork(), but run two instances  - that shows expected behaviour.
> 
> To reproduce just disable swap, and run program with argument as 1/2 RAM on a system. For instance, command below will try run and use ~ 2GB area twice.
> 
> [vetal@bsdev ~]$ ./mmapfork 2000
> 
> Testing program is attached.
> 
> Note, during testing I disabled swap on all systems: Linux, illumos and FreeBSD.
> 
> Does it mean madvise() doesn't work well in FreeBSD or test does something wrong?
> 

The FreeBSD mail server apparently removed the attachment.

So either provide it in-line or put it on some pubic file server and
add a link to it.

-- 
Gary Jennejohn



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20210703065420.6dbafb5f>