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 2FD52C3DA42 for ; Sat, 13 Jul 2024 11:05:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC1A86B0085; Sat, 13 Jul 2024 07:05:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B71C76B0088; Sat, 13 Jul 2024 07:05:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A5FD36B0089; Sat, 13 Jul 2024 07:05:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 891EC6B0085 for ; Sat, 13 Jul 2024 07:05:37 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 33544C0EE0 for ; Sat, 13 Jul 2024 11:05:37 +0000 (UTC) X-FDA: 82334448714.07.FBD240B Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf18.hostedemail.com (Postfix) with ESMTP id 82DAF1C0010 for ; Sat, 13 Jul 2024 11:05:35 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf18.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=1720868696; 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=/2TPmWJBtyDPFa98xYT306lr05dbXimvbxo6S74yN4U=; b=431SeF3DpPkb5IwEXkLPoiZwtPWLd7uuu8N1R7ijl+IVJ68INtE5FUv2VX5GaJeOXm3mTl D5+3ryb4UZx7d4VhCeqJdBv/vYiZoayn3PfocqlhjjzF8X3wN5X6M0oLVsBJAQL+vsr607 Lu7coqEjH5k/pafsm3Wgw7twH63WAj0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720868696; a=rsa-sha256; cv=none; b=WtUbfkBK6LieqmmmeJ9yPCetcmPnNWEAotSvThVwb0hLBl4uvs7UbSlw8qBkNb+dCCiq0c zWqwtZSEV0Y6kwG+84mML9YrSeYNk/Y8okXsBNPMK9IIu7OPOZG9SaggRw7wUDvYiFC+95 gp21ds9cYemAcgjE254Cl7gzXu3fqjQ= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf18.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@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 EAC6B1007; Sat, 13 Jul 2024 04:05:59 -0700 (PDT) Received: from [10.57.77.253] (unknown [10.57.77.253]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 963F53F762; Sat, 13 Jul 2024 04:05:33 -0700 (PDT) Message-ID: Date: Sat, 13 Jul 2024 12:05:32 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm/huge_memory: Avoid PMD-size page cache if needed Content-Language: en-GB To: Matthew Wilcox , Gavin Shan Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, william.kucharski@oracle.com, david@redhat.com, shan.gavin@gmail.com References: <20240711104840.200573-1-gshan@redhat.com> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 82DAF1C0010 X-Stat-Signature: ep8nujwqdi98igfer81geisi69559ibq X-Rspam-User: X-HE-Tag: 1720868735-716554 X-HE-Meta: U2FsdGVkX1/JMCEc7KJkKHgDVzumEz1wIoEmaBBhWNtFJRgwDIGIxT5Wvky3xdRDgyyjq7JAf+4cGech3IrdgphgbU2R2M+aXk2pZKXJtwvGrkJ8w84BkFthmeyitSXLUF7vFACYt372WOhx05AO5a04G2G2z5uSpuWbPMRL3RW+D+c88x3xunnEZsqXeRuLvDFDcQFmvhqYXgfXh1PzsughFVbuM2kx5K4YqnDcb0A0+vHgn0lLGouP8T3ckv3KpWsJN3stWf4bsY5dCARxaC9Ux2fEDHVV2e+aTHAOkaexNBJX4eMudpKq8eCpaqpV23RC8cm6on07E4Q8+IvBF/SicRnRVmLrxn6vuFEb5OHk1C5QFjMK2GxvsCjzwajTyClgazE6a8iAvekR/97bAwom712eFq0KChlLdE92kDI4O+qD6gb6x5fS2vwbNeY2W47/QycFes6nwhOOXpkvELQwXUZEENoTSZp71I6ygRNLC2CPVMbeMmjDqUMCmgdX3hEKIClil0HdYcW/Lrlp2DwKsUTbI6RU02mWu5fv0thuFZBFs84lI5Jh7/ro6cGjJ2Lp//HRlpojyx6l9i5MgvuWSwHzBM5hbO+FMgmidnTk3wxe7J0InbEU4Rsp+FiHkLAcHLtM2wauhuS33bPiOSDUnA3ay2ZlxlMQEehPmg38/n9Q7NiblhyjThyHeXgQC2G1EN+ICW2dbeg2tLo3drTDgeRGFpo+ar7JkV0uX2DowZ4wtceoXU+ci3S8R23SJ5w1wgXsqegOFYrXtdCT+4tSYm5l1iDoFGXiwAlxZo1Fy5WCPVenfO/GYwRYumTYbphb+eYDwVc+a8U877emvCmlVWJPROQ8WKpSX7xmrRl6yO++o0ZE1iu0l0i/lCmXnl8rx3hdnXOPY7kNwV0YvNA1jqxD4rehDZIl+doeBRvoauI+eVFd6TfJZqAgr5x7c1x62US5628xQ0sRft4 O48CQ19d x34HvDKUgPaw+/uaB57bEu8TWNcMUQD3CkJyzlwNO++naU8KT/lwJxjoaeYRn6AdnKwf8c1dGA/r7mb8PXA05B/tGNy/ynyHh5jKcnQuz7qzq1uI9GmBiqrfcxBZ9ouzjGUCYUIN4GAWJQBkWQIAaIVpUs2J57tvgH8lH1QVgNLMGJYL0WumxfLBd4G7gjb2WEVuhF0w3ogz/rbep07arzP2yllio9rY5UhC9aOTTSdZJlP72N3flqxtjMKbm5BEPvL15 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 11/07/2024 21:46, Matthew Wilcox wrote: > On Thu, Jul 11, 2024 at 08:48:40PM +1000, Gavin Shan wrote: >> +++ b/mm/huge_memory.c >> @@ -136,7 +136,8 @@ unsigned long __thp_vma_allowable_orders(struct vm_area_struct *vma, >> >> while (orders) { >> addr = vma->vm_end - (PAGE_SIZE << order); >> - if (thp_vma_suitable_order(vma, addr, order)) >> + if (!(vma->vm_file && order > MAX_PAGECACHE_ORDER) && >> + thp_vma_suitable_order(vma, addr, order)) >> break; > > Why does 'orders' even contain potential orders that are larger than > MAX_PAGECACHE_ORDER? > > We do this at the top: > > orders &= vma_is_anonymous(vma) ? > THP_ORDERS_ALL_ANON : THP_ORDERS_ALL_FILE; > > include/linux/huge_mm.h:#define THP_ORDERS_ALL_FILE (BIT(PMD_ORDER) | BIT(PUD_ORDER)) > > ... and that seems very wrong. We support all kinds of orders for > files, not just PMD order. We don't support PUD order at all. > > What the hell is going on here? Just to try to justify this a little, it was my perspective when adding (anon) mTHP that memory was either anon or file; Anything that populated vma->vm_file was file, including shmem, DAX, etc. Before my change THP could install PMD size mappings for anon, and PMD or PUD size mappings for file memory (but yes, PUD was only really applicable to DAX in practice, I believe). I agree it would be good to clean this up, but I don't think the current code is quite as mad as you're implying, Matthew?