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 2439BEB64DC for ; Thu, 20 Jul 2023 09:41:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 538062800E8; Thu, 20 Jul 2023 05:41:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4C0BA28004C; Thu, 20 Jul 2023 05:41:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3604D2800E8; Thu, 20 Jul 2023 05:41:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1F6A228004C for ; Thu, 20 Jul 2023 05:41:13 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E0876A0267 for ; Thu, 20 Jul 2023 09:41:12 +0000 (UTC) X-FDA: 81031496784.09.977E75B Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf10.hostedemail.com (Postfix) with ESMTP id 22FD0C0007 for ; Thu, 20 Jul 2023 09:41:10 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.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=1689846071; 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: references; bh=Z94+yVunakH7nzJzj4+nHN2kUXtxTtzO/h15GeZ8Tuk=; b=UI/eZmM1lT0VyYAl5OMYhKGDxd4/RMTNSmlQKzV4yCdtTTV9IVfPU9T2j0Ln7YrYQnSWaC e4I5gm0X4qZX0vmw6OF+FvHl6Dk48DX862bvvB4kxxx3hkWCTU4HRBu7bixVwGJVhIUsZj yiE0wA4LaTBmwp5Zd7p1O7hTQ1NhxGc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689846071; a=rsa-sha256; cv=none; b=iV9lm200NZo07KENmZph78INIZtNEpTIuQCljBQ8iViglrDpz0SZDOkdCTeJnecDXWXnqC 2jpuaOHbw26fldpnoTTD8JaxTMpW2wN3aqa6dWPeM2+G5nIzKy/0fyzot3NfGzxRhZOfdl QG/iDZBN8a9hMitaxcF3fb/3TvKlXNw= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; spf=pass (imf10.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 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 508662F4; Thu, 20 Jul 2023 02:41:53 -0700 (PDT) Received: from [10.1.38.38] (C02Z41KALVDN.cambridge.arm.com [10.1.38.38]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 269193F6C4; Thu, 20 Jul 2023 02:41:09 -0700 (PDT) Message-ID: Date: Thu, 20 Jul 2023 10:41:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 From: Ryan Roberts To: "Yin, Fengwei" , Zi Yan , Matthew Wilcox , David Hildenbrand , Yu Zhao Subject: Prerequisites for Large Anon Folios Cc: Linux-MM Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Stat-Signature: oyeuzje5wy3me9ysn8oek7opas6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5Z/asoFcHRT54AUkkSCmSQvsCxFbP3WKrBb/iGdlhEiGNtJvgCGHQB43mPfyrPLN08V23Q0KCltHmIgYU3fEiJZWnWMkn4TNwa4eP0tZoudxQXTS/tQ3jT/bTp0d4Yh41pjtZEIZT8OHmYCaGZERBV78htYCn+O432ZSbKsZ1WvkOkKU/8jhNpDqhLIVucGkrRqgStbvpjOkJ+pPw24sdTHWJj4JpxwGpD2wS95fftUnpxZomujXnDV/4fdJIVkU71LpzmKcsvow9IXrwffr0h7KOBUAX7EBNkOo7UcU35UV8VHgvid0+mwoSOEiTQJQYr3paMrGdTkudi7HMhuUGHMwkmrK+kQQCgDCJL3C5YpUxgCAroerF3 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: Hi All, As discussed at Matthew's call yesterday evening, I've put together a list of items that need to be done as prerequisites for merging large anonymous folios support. It would be great to get some review and confirmation as to whether anything is missing or incorrect. Most items have an assignee - in that case it would be good to check that my understanding that you are working on the item is correct. I think most things are independent, with the exception of "shared vs exclusive mappings", which I think becomes a dependency for a couple of things (marked in depender description); again would be good to confirm. Finally, although I'm concentrating on the prerequisites to clear the path for merging an MVP Large Anon Folios implementation, I've included one "enhancement" item ("large folios in swap cache"), solely because we explicitly discussed it last night. My view is that enhancements can come after the initial large anon folios merge. Over time, I plan to add other enhancements (e.g. retain large folios over COW, etc). I'm posting the table as yaml as that seemed easiest for email. You can convert to csv with something like this in Python: import yaml import pandas as pd pd.DataFrame(yaml.safe_load(open('work-items.yml'))).to_csv('work-items.csv') Thanks, Ryan ----- - item: shared vs exclusive mappings priority: prerequisite description: >- New mechanism to allow us to easily determine precisely whether a given folio is mapped exclusively or shared between multiple processes. Required for (from David H): (1) Detecting shared folios, to not mess with them while they are shared. MADV_PAGEOUT, user-triggered page migration, NUMA hinting, khugepaged ... replace cases where folio_estimated_sharers() == 1 would currently be the best we can do (and in some cases, page_mapcount() == 1). (2) COW improvements for PTE-mapped large anon folios after fork(). Before fork(), PageAnonExclusive would have been reliable, after fork() it's not. For (1), "MADV_PAGEOUT" maps to the "madvise" item captured in this list. I *think* "NUMA hinting" maps to "numa balancing" (but need confirmation!). "user-triggered page migration" and "khugepaged" not yet captured (would appreciate someone fleshing it out). I previously understood migration to be working for large folios - is "user-triggered page migration" some specific aspect that does not work? For (2), this relates to Large Anon Folio enhancements which I plan to tackle after we get the basic series merged. links: - 'email thread: Mapcount games: "exclusive mapped" vs. "mapped shared"' location: - shrink_folio_list() assignee: David Hildenbrand - item: compaction priority: prerequisite description: >- Raised at LSFMM: Compaction skips non-order-0 pages. Already problem for page-cache pages today. links: - https://lore.kernel.org/linux-mm/ZKgPIXSrxqymWrsv@casper.infradead.org/ - https://lore.kernel.org/linux-mm/C56EA745-E112-4887-8C22-B74FCB6A14EB@nvidia.com/ location: - compaction_alloc() assignee: Zi Yan - item: mlock priority: prerequisite description: >- Large, pte-mapped folios are ignored when mlock is requested. Code comment for mlock_vma_folio() says "...filter out pte mappings of THPs, which cannot be consistently counted: a pte mapping of the THP head cannot be distinguished by the page alone." location: - mlock_pte_range() - mlock_vma_folio() links: - https://lore.kernel.org/linux-mm/20230712060144.3006358-1-fengwei.yin@intel.com/ assignee: Yin, Fengwei - item: madvise priority: prerequisite description: >- MADV_COLD, MADV_PAGEOUT, MADV_FREE: For large folios, code assumes exclusive only if mapcount==1, else skips remainder of operation. For large, pte-mapped folios, exclusive folios can have mapcount upto nr_pages and still be exclusive. Even better; don't split the folio if it fits entirely within the range. Likely depends on "shared vs exclusive mappings". links: - https://lore.kernel.org/linux-mm/20230713150558.200545-1-fengwei.yin@intel.com/ location: - madvise_cold_or_pageout_pte_range() - madvise_free_pte_range() assignee: Yin, Fengwei - item: deferred_split_folio priority: prerequisite description: >- zap_pte_range() will remove each page of a large folio from the rmap, one at a time, causing the rmap code to see the folio as partially mapped and call deferred_split_folio() for it. Then it subsquently becmes fully unmapped and it is removed from the queue. This can cause some lock contention. Proposed fix is to modify to zap_pte_range() to "batch zap" a whole pte range that corresponds to a folio to avoid the unneccessary deferred_split_folio() call. links: - https://lore.kernel.org/linux-mm/20230719135450.545227-1-ryan.roberts@arm.com/ location: - zap_pte_range() assignee: Ryan Roberts - item: numa balancing priority: prerequisite description: >- Large, pte-mapped folios are ignored by numa-balancing code. Commit comment (e81c480): "We're going to have THP mapped with PTEs. It will confuse numabalancing. Let's skip them for now." Likely depends on "shared vs exclusive mappings". links: [] location: - do_numa_page() assignee: - item: large folios in swap cache priority: enhancement description: >- shrink_folio_list() currently splits large folios to single pages before adding them to the swap cache. It would be preferred to add the large folio as an atomic unit to the swap cache. It is still expected that each page would use a separate swap entry when swapped out. This represents an efficiency improvement. There is risk that this change will expose bad assumptions in the swap cache that assume any large folio is pmd-mappable. links: - https://lore.kernel.org/linux-mm/CAOUHufbC76OdP16mRsY3i920qB7khcu8FM+nUOG0kx5BMRdKXw@mail.gmail.com/ location: - shrink_folio_list() assignee: -----