From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC334EB64D9 for ; Mon, 10 Jul 2023 10:36:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 466706B0072; Mon, 10 Jul 2023 06:36:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4166E6B0074; Mon, 10 Jul 2023 06:36:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 304B96B0075; Mon, 10 Jul 2023 06:36:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 20E9D6B0072 for ; Mon, 10 Jul 2023 06:36:52 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id DF2C6A033A for ; Mon, 10 Jul 2023 10:36:51 +0000 (UTC) X-FDA: 80995349022.10.C9716C4 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf27.hostedemail.com (Postfix) with ESMTP id E06F240004 for ; Mon, 10 Jul 2023 10:36:49 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf27.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688985410; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yzw4PYVADSOGEsQLiCWVZj7OhQYT8FUxHSMJwFBjflk=; b=YyINLJi1qlM0ddcgA2ChvDIC45DIWDju1bfTzDFMnCunvDW31U7p4azaiZvBMlxWsqjw4k 7K7HdSYZpuYRDM2ChT25DhfGa/BturJewuqsquZnexsBslmH/1B9rubwBU/Cu2VhArsMkA Zn9WJZL7CC/5Vf8OsomZkuB49lVGA9E= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf27.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688985410; a=rsa-sha256; cv=none; b=SP/AXONg9eLdS1atNMpJZx3lm6lTAWUpBHhe1rx201RYC3RetiSA4/Pwlzg8/sicsNRKc+ tqeadwOMVE4/c9vQUZZIBQy6l7qflI2HM7R046PdiFga74G6zvdmFe4xu5gz7rUWlQGEIj 5+k8E/l9i3I9VZvp1Uti2AaZim5VIRU= 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 EB2AE2B; Mon, 10 Jul 2023 03:37:30 -0700 (PDT) Received: from [10.57.77.63] (unknown [10.57.77.63]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 660A03F740; Mon, 10 Jul 2023 03:36:46 -0700 (PDT) Message-ID: Date: Mon, 10 Jul 2023 11:36:44 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [RFC PATCH 0/3] support large folio for mlock To: Matthew Wilcox , David Hildenbrand Cc: Yin Fengwei , linux-mm@kvack.org, linux-kernel@vger.kernel.org, yuzhao@google.com, shy828301@gmail.com, akpm@linux-foundation.org References: <20230707165221.4076590-1-fengwei.yin@intel.com> <4bb39d6e-a324-0d85-7d44-8e8a37a1cfec@redhat.com> <5c9bf622-0866-168f-a1cd-4e4a98322127@redhat.com> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: E06F240004 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 8csr1refca7rex4837uujony7khcew7k X-HE-Tag: 1688985409-517939 X-HE-Meta: U2FsdGVkX1/9dEQPPTJLRrpbMqtc51ZTtn42LUkNlOZaiH64XhkJHJr11zi/a2b7a9TzWiIOFQ+JZ+GoH6Fx+13Ff9ZrXZf41KkAW6YFCARzLOctEsdbMpYawVfapoM7VuOjVWFqDOTXoo+GTW8ae7rjXFpwQmIkNgXPXgVxliUBYf/Fc+5A8Qd8SmtOPM3UNtbG9RaJJclZDdNx0wnIkCsrbW5h5BemoGdCW0kd5cmdlcwASSmG6i1aGM3WttjPiiC55HVPvrqOjxmw2jglC6yR0AbxwBQHi1kMvx8rGK4/v32mhojBoRSwIvCOmBTy8P/6aB3zU9ByuOMX/rRfmfben73gB6s7AYmLeBS9ffGIp1I0W7x9QzQY0hEgGsH9YSNI9rsw7Ng2woAC4lLPy0KbVHnN9pVLuTZzkpG4XEDsX6k0uc+/R7yDOrKhoB1O7sf5yrqDNA2laGMMuMMvnkronc11/xjVvTWM/ilspMadpyZ4yppH4ep5tCwaP5uvmREcb1kkeLVrlXoZPS5HaDC049LCuQSqrd1DSkv6nGs852tDrxntakAz67LlZ43HySVf0eZ124Yl5YweVN7q3WyvP2dGZ0I0Z9el1pxmwAVjHmQdPqGWSdlrCFsCCEJv0QqTpznCpCRZ+hQbQdulk3gGHWOb2y9VKGBNReEDa6kf4BUzdOYMxBT3YT9E3SQmqZnmScXv1+RcbWjCZLJQOK47jBs5EnbvEGwqU9AxaaeFjLPhyu2GhnuB5B3Ymq269livvpeURK+DxzTrIeE15xmWCOL/rfwVpfWNx97/VMwp8Et/mc/VkoVn0EZedOY1rwNnazf4t6h5DEyaaydvzxk1jdKx0Fo6iLSM0T1Lm/Aef/nhI39hDBUbJAPSzaEC0FwQPSsnBFoh6HN5x20TbfsUBwTvCY19QoRoOZlSycdmQB8uUA/7fYl24AMyLts+ArMa0C0pueoL/x3sv+O nQn552DK XkK0dcQQTl63vEARADbJ6OnsTDPRjJHvjtp4bXdCpKdhE2oiJPpS9jptt6CKc46v5GBWf828pne1vNIELk50SjcnMkOQnrh8tak5GO20DZinxsZxIKOdHkPAMse3lMelOqPWFPcOBiNuTzLK46PmYtXwyRuljJbczDSCoTJFg/8oudQXY7IOHtWFyIdFzM9qykTDnYZcjyHeatHwzRGsP97YZo9aaK2jakhWK4rcdtbD07+6xHez/d7iAUp3R2bdzAJwWLHaSEBlg0NSsz/bJixxBh+QfMvyJDFWq X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 07/07/2023 20:26, Matthew Wilcox wrote: > On Fri, Jul 07, 2023 at 09:15:02PM +0200, David Hildenbrand wrote: >>>> Sure, any time we PTE-map a THP we might just say "let's put that on the >>>> deferred split queue" and cross fingers that we can eventually split it >>>> later. (I was recently thinking about that in the context of the mapcount >>>> ...) >>>> >>>> It's all a big mess ... >>> >>> Oh, I agree, there are always going to be circumstances where we realise >>> we've made a bad decision and can't (easily) undo it. Unless we have a >>> per-page pincount, and I Would Rather Not Do That. >> >> I agree ... >> >> But we should _try_ >>> to do that because it's the right model -- that's what I meant by "Tell >> >> Try to have per-page pincounts? :/ or do you mean, try to split on VMA >> split? I hope the latter (although I'm not sure about performance) :) > > Sorry, try to split a folio on VMA split. > >>> me why I'm wrong"; what scenarios do we have where a user temporarilly >>> mlocks (or mprotects or ...) a range of memory, but wants that memory >>> to be aged in the LRU exactly the same way as the adjacent memory that >>> wasn't mprotected? >> >> Let me throw in a "fun one". >> >> Parent process has a 2 MiB range populated by a THP. fork() a child process. >> Child process mprotects half the VMA. >> >> Should we split the (COW-shared) THP? Or should we COW/unshare in the child >> process (ugh!) during the VMA split. >> >> It all makes my brain hurt. > > OK, so this goes back to what I wrote earlier about attempting to choose > what size of folio to allocate on COW: > > https://lore.kernel.org/linux-mm/Y%2FU8bQd15aUO97vS@casper.infradead.org/ > > : the parent had already established > : an appropriate size folio to use for this VMA before calling fork(). > : Whether it is the parent or the child causing the COW, it should probably > : inherit that choice and we should default to the same size folio that > : was already found. FWIW, I had patches in my original RFC that aimed to follow this policy for large anon folios [1] & [2], and intend to follow up with a modified version of these patches once we have an initial submission. [1] https://lore.kernel.org/linux-mm/20230414130303.2345383-11-ryan.roberts@arm.com/ [2] https://lore.kernel.org/linux-mm/20230414130303.2345383-15-ryan.roberts@arm.com/