From nobody Sat Jul 03 06:54:20 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 287CC11E26C9 for ; Sat, 3 Jul 2021 06:54:23 +0000 (UTC) (envelope-from gljennjohn@gmail.com) Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) (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 4GH2k70R0cz3rMr for ; Sat, 3 Jul 2021 06:54:22 +0000 (UTC) (envelope-from gljennjohn@gmail.com) Received: by mail-ed1-x534.google.com with SMTP id w13so16377180edc.0 for ; Fri, 02 Jul 2021 23:54:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=XkLeE2flVx2KlGvoF8AbPUezqxedTIXSaxtRt2B7Plo=; b=PJ3GQW5M5DqS8ZCrrfnLv7b6UDsv8gohups0YJ6XxhdtVWdRtAVfQUYFQMmqR6BZCj rcWSJoUkCmN8/7mQ387DZcI27Qd7aKg6qm2RJ4kaW6YNG4UyHwq4B+GJRQ0MfwM3ud1d C0fYKe8SILu4oB7v08Eh3s0hIRNhA6h7fo/YAJ0ei1r4J0S5RSpae4gHsCGEJ0SJVJAp ebLT/rw6r9iV06gluY2C+pEbYfJQT2/e2x4iiWU9gnL6O4xelJH796w9EcDT8AFqRrT9 956PXrTxMkP4eeK9S8oAsRJCfPNJcTKUMXIz5amhv2mUqyoOBsvi4KEiTf6FEe0kcFtb MfoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=XkLeE2flVx2KlGvoF8AbPUezqxedTIXSaxtRt2B7Plo=; b=lvYGuEWNZ2ufSb3CEQkOLcfTlmMV/d/c7UE76kiJX/dh1C/v8PK6uBphKRDn2Y/FXu ZNDGMuTKib7r6qhkIyYW6N8pVKLegTL/pJBmOFvqS8sJl8Q/UoPkvt1Vbt0TasG9QIOK HdYOMI+4sfxYLvjwp224h4aeSsTEzt/7lVH+kUONRPIm1MQDTmsn3Fo7GjBQOj8BL8eE 4a9xpvTL+fHti1KvY2KABc0zY6CFPXRE1iyjljGMgxEXehkN0ayDhJSq98gF8OimIY2K 8cqTEpBHHSlCaPZ7UE8HFkRy37fByiH/uH41Evm+IG91s//i34N5ZLX5PM+KHT2mTLpI vakw== X-Gm-Message-State: AOAM533l5J0xMIRh1LDPxI1QW3CwiWk88SFnrm97OChe/goSVPy63WGZ GrxtxRNusiccbe0qBdz1GTI= X-Google-Smtp-Source: ABdhPJzG+o+MLcdx+LHWzR0A5yTGIRl1P+7p7uLK8KrEXbz1ROCdXErmSl5iSaYJu17EMhs/wMHz+A== X-Received: by 2002:a05:6402:27c7:: with SMTP id c7mr3840483ede.272.1625295261507; Fri, 02 Jul 2021 23:54:21 -0700 (PDT) Received: from ernst.home (pd9e2360f.dip0.t-ipconnect.de. [217.226.54.15]) by smtp.gmail.com with ESMTPSA id i18sm2275635edc.7.2021.07.02.23.54.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 23:54:20 -0700 (PDT) Date: Sat, 3 Jul 2021 08:54:20 +0200 From: Gary Jennejohn To: Vitaliy Gusev 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: References: Reply-To: gljennjohn@gmail.com X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; amd64-portbld-freebsd14.0) 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=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4GH2k70R0cz3rMr 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-ThisMailContainsUnwantedMimeParts: N On Sat, 3 Jul 2021 02:56:40 +0300 Vitaliy Gusev 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