Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp294942lql; Mon, 11 Mar 2024 03:01:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV4yI4O9YHLbUZaxuoLGxTX5mMulss02lAfYPhIjrK/4ivFYMRpUp3WtT4dvRCFDQKHIW/seG169niyOfHVyseF3IAybEvUsdBgC3zANA== X-Google-Smtp-Source: AGHT+IEirtTF7LTBmCTLeKtSHS6rNdqFa11DLSOd1FWXdJYikfRcdEpOyFDBiPotl4kVHanZMn3L X-Received: by 2002:a05:620a:4056:b0:788:5aaa:4278 with SMTP id i22-20020a05620a405600b007885aaa4278mr11569110qko.24.1710151297046; Mon, 11 Mar 2024 03:01:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710151297; cv=pass; d=google.com; s=arc-20160816; b=MuSEo3zC3drNeStdIcrXc0t/c0FTEMkL7fe2IOzguFvERgKh780fbbZOSX5gyFYWCp 75If6plqJyEUDeyqDlRaMcP/U/LHOYsXPqRT7INX6FVrNRGjOCML/MzqPfkz6uYMad9i vuEMgW4/09Op816aLuq7Vhj9J3FQy2bLO6BIRIZKBBkSncRgiITGfO2vo70MGkulk7S+ Gqk2WPmcc8IwMBlRqbVjX6HTFH2scOLkhxOiPf+kJIDjgw4ySKNgSMxw8Z469R1FWCfN KgK2+pIGZPw2xv4mrRv3sFcdVf7LHC+XxSeBkLjJ2rWNqv74sbk5kUes92Dpf4mMnIYX fisA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=zjVrxa7jT6Alb18qUv/5fbPGQg11qSCep3Z1UEbuvQw=; fh=hRkKPgwajCi6P/W9Rf6vZdLTUGUN77rOpbPNdd8TWpo=; b=XHEo8nTbrGCUXO6JL8D6xZC9RHVN2m8zdda4ak+XMdMudFNDnPqMfQoSo0JL5G86cf PcrDsdlN/fEq3zd+XiaIkV1wW1zIImTx4AtMEUJ5Nt/rXMz02S4OY518HBrjWpXcmJ/3 yE7vxJG9vCkf+Ujrt3Rj94jeGdzUqx0EncpEywxiTn5+efPeQ+2tGTw3fUYSEFxkGACJ 3L43RoScG2cwvby2tp0H7oWS8ooH+ZhvNlmU/MnM8FwXE+oZHS/crOL3vuqS71/1onsN hq7E2H5tfmU2tnZHBQ372Jn6aJmsWncSnAUH5glXWBJsbTsAK3S08lJqeoSuOHb8Zp8P kvYg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Qn95L+Ym; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-98661-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98661-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id q19-20020a05622a04d300b0042eb222447dsi5037470qtx.283.2024.03.11.03.01.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 03:01:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-98661-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; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Qn95L+Ym; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-98661-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98661-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 958031C20F6C for ; Mon, 11 Mar 2024 10:01:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 269152231C; Mon, 11 Mar 2024 10:01:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Qn95L+Ym" Received: from mail-vk1-f177.google.com (mail-vk1-f177.google.com [209.85.221.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9DA614F75 for ; Mon, 11 Mar 2024 10:01:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710151290; cv=none; b=Te63ODOWPAJK08TNVYL9hllz0TPNWDflTEPJ6yYNiD31enNNaMGLhvXhaZydIl15Xbc2Gxd7a/TqZJ1/YD6klgPSusCcYDsj328uUEmh8BlISVJeOZZrOyoSlfuSH4fMJnroxlhzRmGr13Jbmfb6BmSFfIJSNdlE4b+cjaIL3bw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710151290; c=relaxed/simple; bh=zjVrxa7jT6Alb18qUv/5fbPGQg11qSCep3Z1UEbuvQw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=nocPsLXvLUQ+45OO/CPngmItsp+tvWG9ZjmfznGFK78EZjIgQ8xpNbyv8hTZCj5zfVZQg5tVddFkhz3Z7/uBYR3GyM2PCUORsTjbl694DytrPL5uNNHDWlH3EXlzO70ViJuWMNbz7/zNon35thVXP5Ck/kBc6M6XTTQ/4eoZZmI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Qn95L+Ym; arc=none smtp.client-ip=209.85.221.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-vk1-f177.google.com with SMTP id 71dfb90a1353d-4d37e76a3dfso2660434e0c.1 for ; Mon, 11 Mar 2024 03:01:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710151288; x=1710756088; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=zjVrxa7jT6Alb18qUv/5fbPGQg11qSCep3Z1UEbuvQw=; b=Qn95L+YmJWgFvbI/EOSjFPvsTDQ7Sz11cyxo9XxwXfFNNR+Qxux4z8G7GrsGXXgdQQ LO77pZjvUIfdwHzy8QKm9rwJE+GKHWcGX61y6Kb1vna12S59jrjitQ4iWT/GewD76Wk1 jIjI1X1N1wdWKNzi9jmxgiwAal+Y8MQgcX2BA89w9tGM4H5wSSpZ5u0rWo/M+5cWwwho h3iJbcOwRBmS7eZPDuwV+LqFeuomBQlw+IlPC65sFYqhQAL+3z2+5wyg4bhheUqhZWPT 2a7lycIgyWIY38TqIAVF2XuorMAhpKgv4XnR0DQ5rYgG827Hn1bBsQfP89YAvzPHZXzM FPEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710151288; x=1710756088; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zjVrxa7jT6Alb18qUv/5fbPGQg11qSCep3Z1UEbuvQw=; b=JpGfxbRYcJyt82OgdB6eXnhQ54+qUktAPszwEWc0OWWPMPbbNQxK5JyHmPdoahu9h/ LTKtWh/tb3Af6ee+kEHNCGUrkgRXw8PknowjKx83RyvNgCCvSySGZXrxMp4JqX/PdRpD FJdj3sNzChcIAV/LxF9ZRs3qAyu/VtdkpKqicpbJGPaWxJ0VXa9mL6dhdlUTAgK35w31 Ze0BT2urSguKBQ9S3XSDpGO+BBSFd8sKd0GT2dfjbQitUhF5DITODCBYSqt41yeg8AmY MWx9zuObr9WFpkBCL46/WAxbx/ruGMqveGVkG7Xxw9CW6dh8n8w/81sOLn/tdSOuDZJu XplQ== X-Forwarded-Encrypted: i=1; AJvYcCWtMKQrl39/EcbudSIkIBHtkJMouIUF62LMefNpVD1it4HYAvi4USl8kpnNS/uKgOXwHUIdJPzSjhlHeUXw7kzMVdxA1WB3x1I/GZ/e X-Gm-Message-State: AOJu0YwuhplGOUJedEnGJsmC60GdsGUn1ZB6xFGn/KkXDQNkVTZoer3z pE0Pa8pbDQt1JwyjK2SEerkIXBlAvQPBCc302M97w07hwHp1upX5kBX9xpIJC/fGmcta+MYY/zW w+e5sLbhXPUULuTfTXVB3fnhweTs= X-Received: by 2002:a05:6122:449b:b0:4b9:e8bd:3b2 with SMTP id cz27-20020a056122449b00b004b9e8bd03b2mr3514927vkb.2.1710151286195; Mon, 11 Mar 2024 03:01:26 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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> <37bc1a30-7613-4404-b123-c351e36fc800@arm.com> In-Reply-To: <37bc1a30-7613-4404-b123-c351e36fc800@arm.com> From: Barry Song <21cnbao@gmail.com> Date: Mon, 11 Mar 2024 18:01:14 +0800 Message-ID: Subject: Re: [PATCH v2 1/1] mm/madvise: enhance lazyfreeing with mTHP in madvise_free To: Ryan Roberts 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Mar 11, 2024 at 5:55=E2=80=AFPM Ryan Roberts = wrote: > > [...] > > >>>>> we don't want reclamation overhead later. and we want memories imme= diately > >>>>> available to others. > >>>> > >>>> But by that logic, you also don't want to leave the large folio part= ially mapped > >>>> all the way until the last subpage is CoWed. Surely you would want t= o reclaim it > >>>> when you reach partial map status? > >>> > >>> To some extent, I agree. But then we will have two many copies. The l= ast > >>> 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 A= BI > >> 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 abil= ity to > >> madvise/munmap/mprotect/mremap anything less than 16K alignment so tha= t acts as > >> an anti-fragmentation mechanism while allowing non-16K capable process= es 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 iss= ue 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. I fully agree with this as my Ubuntu filesystem can run on 4KiB, 16KiB and 64KiB basepage size as its elf files are 64KiB aligned. so I would expect new Android apps/middleware move to 64KiB ABI though it might want to change the base page size to 16KiB instead. I believe this is the case. Thanks Barry