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 35F50C3271F for ; Fri, 5 Jul 2024 08:42:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ADC066B0098; Fri, 5 Jul 2024 04:42:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A8D0B6B0099; Fri, 5 Jul 2024 04:42:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 979E16B009A; Fri, 5 Jul 2024 04:42:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 796D76B0098 for ; Fri, 5 Jul 2024 04:42:55 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0014F81779 for ; Fri, 5 Jul 2024 08:42:54 +0000 (UTC) X-FDA: 82305058710.21.090A15F Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf13.hostedemail.com (Postfix) with ESMTP id F256020011 for ; Fri, 5 Jul 2024 08:42:52 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720168959; 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=G2z3a6CL0wKmkpwT+vkfgBFzNbxivV7sh12DNtXEm1k=; b=yItJnB+6K1NS0v3OGU+BfxQPMgSMoiWN6aQx25DOZtnMr/VqXWDfuhzgvBHvvvm0E1vmRi 5VAOwu92eNZlYWCKSYvnNJa87bOXS57gGgGktu2wtBeg5cMTTZ6TUQCX80aI/YmSZm98CJ pPtTEh4PAh+aNd8QRcdQhit8hsa4Yns= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720168959; a=rsa-sha256; cv=none; b=WLz+Md5JMLeQYPKiez2yloAbsAORxBjuPBuM20LndjneEaQvLCcprTnt0zcrGb/pNj2Ur1 cunt0eahMc12EenkogcMEjPLBBuCChFDeA6xJREqcWWkSLRipRtUKDaPgIUgh8EKJYVY1+ fpOT6GELL/80XfwaYi4HmTkPixPgSq0= 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 BFE8B367; Fri, 5 Jul 2024 01:43:16 -0700 (PDT) Received: from [10.57.74.223] (unknown [10.57.74.223]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 24AE93F762; Fri, 5 Jul 2024 01:42:49 -0700 (PDT) Message-ID: <96625631-ef7d-44a2-ad5f-f7beb64f0ed0@arm.com> Date: Fri, 5 Jul 2024 09:42:47 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 4/6] mm: shmem: add mTHP support for anonymous shmem Content-Language: en-GB To: Baolin Wang , Bang Li , akpm@linux-foundation.org, hughd@google.com Cc: willy@infradead.org, david@redhat.com, wangkefeng.wang@huawei.com, ying.huang@intel.com, 21cnbao@gmail.com, shy828301@gmail.com, ziy@nvidia.com, ioworker0@gmail.com, da.gomez@samsung.com, p.raghav@samsung.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <65796c1e72e51e15f3410195b5c2d5b6c160d411.1718090413.git.baolin.wang@linux.alibaba.com> <65c37315-2741-481f-b433-cec35ef1af35@arm.com> <475332ea-a80b-421c-855e-a663d1d5bfc7@linux.alibaba.com> <076550c4-0e8a-4344-9f8a-31ae9e1051b5@linux.alibaba.com> From: Ryan Roberts In-Reply-To: <076550c4-0e8a-4344-9f8a-31ae9e1051b5@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: F256020011 X-Stat-Signature: arnemsxeaq44rm8sq8yaj6nnkz47cpqg X-Rspam-User: X-HE-Tag: 1720168972-350920 X-HE-Meta: U2FsdGVkX18WU5z2+Wi0DDuudtug5dn7zlzovc3HTHRzDpF1qYzszcOHqJbxsdaUsyKg5k1PZnpRO+KNS8XQhM+tzXITBii4MmS7c7PJXNVNVtICUqZ67IlIwXHAzAfKRH0hq/ClifdHJ7cLdQ16nVrIZsIBLGzACCFzSHRx2/+z9GEQ2OYdZ2hlZZGtL0Kqxrp8cp91heGoKDisE6a9bTJ4g1Zq9+NxEhGNAeM2J096EmSaXGiTj065JTvxZobd1Y5lw6dbysPY25228K0bBjHOzh/xhDFKHMfv5Byhka8EiMH9sHkllx5/ZHSF2KN5EhV1vDGgQmh6cdvZPQ6fOhwuVfwJQb8IWCmUzt7UA/MUg465TvQ5F/WfaPspHcL5eGkIYQaa/1OwMMfdftmbQDEz4IuXygdTk+eCOfQ3WGhd4gFw5lqHGTFbP8AOkBfk5M21lQQrfcFV2nogAWhcu1/YURjvqygFjiDuScqJ3XflPbKTX7MQWwQObr1oISxpS/jbbrYI12zPo6HQ110J4hncEEQVVfFf/PaOXboBP4VM9/LcIJYHd3RzhZ5umRe80vHyInGIaoGU1g8Q9m6gRbZDP5siMRpF7UKVrqzH+KB/1k+rFAtocrtEanXGRSKSaNyBMfuiWQu5FJWlefBN3qOefcajNQ0/m+oJglBpy/DQfsPvA8yN6FjvRB0IxH9WhOs3RX7hmiGN/8GRlZcp4qHlcDwblFTZ8obzymx6zYk6osRG2qoop4L41f0BL4N/rp8c8kbz+/g8kcv6MXj3BKDJ80dRC2+nftX7iAH0z1/FjZsGpxotvi1sSew98zW6OZWZWw7kPaAwyiLYvOTZFCU3ICdNtmsQMvHX38m+Sy8boCK+JXHQ76DCoofNsVc/awafUgiiopZjLoyD9QCGrcRcVfAkhDQ2x/DSjLXQCpPNgZJ3rihV08OQk2fE8ud1PIHhDkSACKC2U/8AXuq K9csOEnW 5Xph2IiX1LqNTdLiiIHezOyzLdvAX1TOCZEiK8B+8F29Lcgy+4MdDNOsojp0xNsi/a+MzBnz9va8O2nKZn82jh/aFUHbRP/vGaVggdR5ybt5IaN6FFTRuk+IMI34qZ1rPT+rfcVkFrMpjtI1Wh4jNAJaFaWNiL1c93ju1b5CAeh+ZELzu/tOcWJMSgccVgbYSOcgZf8dVE4/s9++U/5Hg6WL5lsmBFukdzVlldGFrEl/zPSzIZy1Ec/RM4t/e6VeV4nEBweGKUmENJx+6JjHKdyrMRFO4EltRKawTfXHgerTKnwa3a3YRpvtzezDCXKXhn2N2JshuWR6+bHY= 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: List-Subscribe: List-Unsubscribe: On 05/07/2024 04:01, Baolin Wang wrote: > > > On 2024/7/4 22:46, Bang Li wrote: >> Hi Bao lin, >> >> On 2024/7/4 19:15, Baolin Wang wrote: >>> >>>>> + >>>>> +    /* >>>>> +     * Only allow inherit orders if the top-level value is 'force', which >>>>> +     * means non-PMD sized THP can not override 'huge' mount option now. >>>>> +     */ >>>>> +    if (shmem_huge == SHMEM_HUGE_FORCE) >>>>> +        return READ_ONCE(huge_shmem_orders_inherit); >>>> >>>> I vaguely recall that we originally discussed that trying to set 'force' on the >>>> top level control while any per-size controls were set to 'inherit' would be an >>>> error, and trying to set 'force' on any per-size control except the PMD-size >>>> would be an error? >>> >>> Right. >>> >>>> I don't really understand this logic. Shouldn't we just be looking at the >>>> per-size control settings (or the top-level control as a proxy for every >>>> per-size control that has 'inherit' set)? >>> >>> ‘force’ will apply the huge orders for anon shmem and tmpfs, so now we only >>> allow pmd-mapped THP to be forced. We should not look at per-size control >>> settings for tmpfs now (mTHP for tmpfs will be discussed in future). >>> >>>> >>>> Then for tmpfs, which doesn't support non-PMD-sizes yet, we just always use the >>>> PMD-size control for decisions. >>>> >>>> I'm also really struggling with the concept of shmem_is_huge() existing along >>>> side shmem_allowable_huge_orders(). Surely this needs to all be refactored into >>>> shmem_allowable_huge_orders()? >>> >>> I understood. But now they serve different purposes: shmem_is_huge() will be >>> used to check the huge orders for the top level, for *tmpfs* and anon shmem; >>> whereas shmem_allowable_huge_orders() will only be used to check the per-size >>> huge orders for anon shmem (excluding tmpfs now). However, as I plan to add >>> mTHP support for tmpfs, I think we can perform some cleanups. >> >> Please count me in, I'd be happy to contribute to the cleanup and enhancement >> process if I can. > > Good. If you have time, I think you can look at the shmem khugepaged issue from > the previous discussion [1], which I don't have time to look at now. > > " > (3) khugepaged > > khugepaged needs to handle larger folios properly as well. Until fixed, > using smaller THP sizes as fallback might prohibit collapsing a > PMD-sized THP later. But really, khugepaged needs to be fixed to handle > that. > " khugepaged can already collapse "folios of any order less then PMD-size" to PMD-size, for anon memory. Infact I modified the selftest to be able to test that in commit 9f0704eae8a4 ("selftests/mm/khugepaged: enlighten for multi-size THP"). I'd be surprised if khugepaged can't alreay handle the same for shmem? Although the test will definitely want to be extended to test it. Thanks, Ryan > > [1] > https://lore.kernel.org/all/f1783ff0-65bd-4b2b-8952-52b6822a0835@redhat.com/T/#u