Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp292791lql; Mon, 11 Mar 2024 02:56:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUFZ9Brn90ul7AH9s0EUzjdU1SVJE5Ctip1ZOUaozGynC40pXxSH8OAElEQnToF2zS/06zxLbSLPZiCd5fsxP6IKYR0HZmWTJTGxxDOmg== X-Google-Smtp-Source: AGHT+IFhSgKH7UnUmiO+1tpnb2urKpc8miaJnFWRIKzyjbV75Wi0+5KUCbMSJ/qaQ9ydepsnlo5Z X-Received: by 2002:a05:622a:120a:b0:42e:f55f:3922 with SMTP id y10-20020a05622a120a00b0042ef55f3922mr10513878qtx.26.1710150987977; Mon, 11 Mar 2024 02:56:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710150987; cv=pass; d=google.com; s=arc-20160816; b=N6QmVGxLDUAIjIXc3hO5MikGxD6rrwR/EcT0UnZrm8H+M0WqIHyGXDgWygucAKONDg BuJ+zNu5Ld5bFDMLtY8WBUfRnZqKK4dB2VT/xwFZftWhTSiDA7bSBLpy6Lg5Y3Yn/vSw 2mGHoHaXF+QE7ZfjoYQZZWMt+FoyxjyaTBtPxNbMYy+zne8dC+V+4Rn9rQ3zyPNuudB/ XAgUMh12wtu1bOaBtzt+jO2iHZcOqzz920V9sZZmvygPviactYLKvjc/0h38l2Ubswjs Aq/9SMlFFWJqcKecUXZOqZY+TF9Nglw0Ij/vbnkQ7MpS5b8CrATCpy9jtvfgPoRWeKnT LQBg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=X1c+hEMR80Q/kJZqWLzkQ1O04geoMGmmd85KrH1eFqI=; fh=bMtvsyevLsXMidwFw3eYTSCWT7tHsdwU1xKY5RElBaM=; b=bRS7N/oqSOxF21739mxkSy0PHJMER4PkMofVjR1vlYxmqrXgCW/02x0ZxB/cDnYUPu W9Bqws2T4ceDE6msVrkVC6VuTqNZ/+SnoC0AISmPyNBSc931IU1lCsBhY7sV1zJPW0u+ kO5z8v40iq4ZfsqV7pZSSnLUYsoTWmeXSzJzIlrKCxODbYLyQGiz+xcZi+PWLuu+SGbQ WasR4TueLUVUq7n02vSwSkE+gKx0JgEGTG3GfmNOwb1Arv51fUL88up2XBjVilPToU75 Sac4ZO5O2X68jM4hQ6b0eHjAhTM8DrzkoZSMbHxLqkcYOXH44/vWxrZhvy5sznzz8VMq gxXA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-98654-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98654-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id e6-20020ac84e46000000b0042ee30f7ac1si5077497qtw.507.2024.03.11.02.56.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 02:56:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-98654-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-98654-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98654-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B164D1C210F1 for ; Mon, 11 Mar 2024 09:56:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 922662BB0A; Mon, 11 Mar 2024 09:55:52 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C08B14298 for ; Mon, 11 Mar 2024 09:55:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710150952; cv=none; b=tc3dYq+eN0hX9KmL2tkf/aNjbQ5SDPLItBbkdZDoA4HGNyIBZvvWGPZQNW20/mrU9NfbmN2D72hYNBbR5sHz5J4P0boWLFg8Hyddt1eObG8YP5FHEWJIpgigb0ELWlQKhgpH4qHm5qOFddMMYnEXk4ua24qVxUdMHwvznZ236Eo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710150952; c=relaxed/simple; bh=PVQ0nLXJeQRQT9nyBVKRT/9QcfjaLIzaAdJ3AvAhDxQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=T8yC7SIHMcJ79uI34g34pRY+DMBRMks+BmKSwBEKLcjUhTA5yFiBO+aUfzPDeVlX4hnKqX8/Q/zMvMTYNrXtmlBxEPwVE4Fl1k2ZG3AKkqCMVK/DiRfzpChH7F8OOlCl/bJKUNejjmHAMSQHCcCrBi/TXj8zoTG+Zje3KdVYv14= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0E748FEC; Mon, 11 Mar 2024 02:56:26 -0700 (PDT) Received: from [10.57.68.246] (unknown [10.57.68.246]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5E8603F762; Mon, 11 Mar 2024 02:55:46 -0700 (PDT) Message-ID: <37bc1a30-7613-4404-b123-c351e36fc800@arm.com> Date: Mon, 11 Mar 2024 09:55:44 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/1] mm/madvise: enhance lazyfreeing with mTHP in madvise_free Content-Language: en-GB To: Barry Song <21cnbao@gmail.com> Cc: David Hildenbrand , Lance Yang , Vishal Moola , akpm@linux-foundation.org, zokeefe@google.com, shy828301@gmail.com, mhocko@suse.com, fengwei.yin@intel.com, xiehuan09@gmail.com, wangkefeng.wang@huawei.com, songmuchun@bytedance.com, peterx@redhat.com, minchan@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20240307061425.21013-1-ioworker0@gmail.com> <03458c20-5544-411b-9b8d-b4600a9b802f@arm.com> <501c9f77-1459-467a-8619-78e86b46d300@arm.com> <8f84c7d6-982a-4933-a7a7-3f640df64991@redhat.com> <60dc7309-cb38-45e3-b2c0-ff0119202a12@arm.com> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit [...] >>>>> we don't want reclamation overhead later. and we want memories immediately >>>>> available to others. >>>> >>>> But by that logic, you also don't want to leave the large folio partially mapped >>>> all the way until the last subpage is CoWed. Surely you would want to reclaim it >>>> when you reach partial map status? >>> >>> To some extent, I agree. But then we will have two many copies. The last >>> subpage is small, and a safe place to copy instead. >>> >>> We actually had to tune userspace to decrease partial map as too much >>> partial map both unfolded CONT-PTE and wasted too much memory. if a >>> vma had too much partial map, we disabled mTHP on this VMA. >> >> I actually had a whacky idea around introducing selectable page size ABI >> per-process that might help here. I know Android is doing work to make the >> system 16K page compatible. You could run most of the system processes with 16K >> ABI on top of 4K kernel. Then those processes don't even have the ability to >> madvise/munmap/mprotect/mremap anything less than 16K alignment so that acts as >> an anti-fragmentation mechanism while allowing non-16K capable processes to run >> side-by-side. Just a passing thought... > > Right, this project faces a challenge in supporting legacy > 4KiB-aligned applications. > but I don't find it will be an issue to run 16KiB-aligned applications > on a kernel whose > page size is 4KiB. Yes, agreed that a 16K-aligned (or 64K-aligned) app will work without issue on 4K kernel, but it will also use getpagesize() and know what the page size is. I'm suggesting you could actually run these apps on a 4K kernel but with a 16K ABI and potentially get close to the native 16K performance out of them. It's just a thought though - I don't have any data that actually shows this is better than just running on a 4K kernel with a 4K ABI, and using 16K or 64K mTHP opportunistically.