From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id AD9CF158094 for ; Sun, 28 Aug 2022 15:32:08 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4CCBBE0921; Sun, 28 Aug 2022 15:32:03 +0000 (UTC) Received: from smtp.hosts.co.uk (smtp.hosts.co.uk [85.233.160.19]) (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) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 181D7E090F for ; Sun, 28 Aug 2022 15:32:02 +0000 (UTC) Received: from host86-128-157-135.range86-128.btcentralplus.com ([86.128.157.135] helo=[192.168.1.218]) by smtp.hosts.co.uk with esmtpa (Exim) (envelope-from ) id 1oSKGX-000CBD-ET for gentoo-user@lists.gentoo.org; Sun, 28 Aug 2022 16:32:01 +0100 Message-ID: <2895bfbc-5795-5729-69c5-1fd15874d35d@youngman.org.uk> Date: Sun, 28 Aug 2022 16:32:00 +0100 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [gentoo-user] Limiting amount of memory a program can use. Content-Language: en-GB To: gentoo-user@lists.gentoo.org References: <464b2b22-6c7c-6dd1-c0b0-b4905222943f@gmail.com> From: Wols Lists In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Archives-Salt: 7fd295df-2261-4b26-8715-85c24a5432ec X-Archives-Hash: 03c777ee065b02894e68f1a056f6c8c7 On 28/08/2022 15:21, Rich Freeman wrote: > Something I wish linux supported was discardable memory, for > caches/etc. A program should be able to allocate memory while passing > a hint to the kernel saying that the memory is discardable. Linux DOES have that ... I'm not sure how to use it, but you can pass a flag to open(), which says "do not cache this file". The obvious use case is something like cp, but there's plenty of others. Or there are applications which cache stuff in the app, so don't want to waste OS cache as well - databases are a prime example. Apparently not only does memory use crash when this is actively used, but because the OS does not have to manage cache, speed is actually noticeably impacted. Given the obsession kernel devs have with not wasting memory and time, this is likely to be actively maintained and supported. We just need to find out how to access this from user space. Cheers, Wol