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 AE7AAC04A6A for ; Wed, 2 Aug 2023 16:42:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F235B2801C5; Wed, 2 Aug 2023 12:42:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EACF12801AA; Wed, 2 Aug 2023 12:42:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D4D012801C5; Wed, 2 Aug 2023 12:42:31 -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 C1C0A2801AA for ; Wed, 2 Aug 2023 12:42:31 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 90AB5140384 for ; Wed, 2 Aug 2023 16:42:31 +0000 (UTC) X-FDA: 81079732902.26.172BB0E Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf02.hostedemail.com (Postfix) with ESMTP id 8D3F680002 for ; Wed, 2 Aug 2023 16:42:28 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf02.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=1690994549; 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=jhKfbd/nBXMyknRSTtv5Kgnog2uFLjt/H6KBgEvMZo0=; b=Bt746yMYP8vRmF0lc9TnTSMBYi6GhuwzY7hNo8tCXLWufV6QSGs7dfpfOQFcZd6bSFQJL4 P3cynMNJil06rjOEcURtXY+LqZwhi0/oQsnbk7Ignlb34QJY0+78P4UoXXeNqZkurk3cNI x7XpG2piyrx9lnPezBbSXIYiyNnmMpU= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf02.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=1690994549; a=rsa-sha256; cv=none; b=hTJ63Alj9zVKAyhLUm6+89k1A3z6SWHTPbKA93RBY36/huA4IXqKryN6v5mOawtfn6UC2m 53g6oaxVOaXEiRiAsdLc4vnOtp4pmT8bICFynw520RpawLez81OSUn/jMycmwUWJ+kVV6C tm89O1Bj4fYTTfC7fpSCa2/Tc9HVIts= 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 90C41113E; Wed, 2 Aug 2023 09:43:10 -0700 (PDT) Received: from [10.57.77.90] (unknown [10.57.77.90]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 359D63F6C4; Wed, 2 Aug 2023 09:42:25 -0700 (PDT) Message-ID: Date: Wed, 2 Aug 2023 17:42:23 +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 Subject: Re: [PATCH v4 0/3] Optimize large folio interaction with deferred split To: Andrew Morton , Matthew Wilcox , Yin Fengwei , David Hildenbrand , Yu Zhao , Yang Shi , "Huang, Ying" , Zi Yan , Nathan Chancellor , Alexander Gordeev , Gerald Schaefer , "Kirill A. Shutemov" Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20230727141837.3386072-1-ryan.roberts@arm.com> From: Ryan Roberts In-Reply-To: <20230727141837.3386072-1-ryan.roberts@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 8D3F680002 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: riagrxbe6hr9n3fz6takhwo1wd98khwg X-HE-Tag: 1690994548-980110 X-HE-Meta: U2FsdGVkX18X/CMXXqDaVNkRvpdOq+KJx9DJrilEXD2iGIsWKf90Q9Rv+5rSLU8PzlxuCw/3OozDc8+JwqI7AW34IergKJNBhdjE9bwixojmyoI0gR+MtdPe6AkDVeYAs+QooA2tZca/GB5E9KVnLanCXtzLoD8F84nGbkORuuLpTbshw3rWS4Ltf+hNbA7kj9JShTvf62b/xdTJloAagYSW/Fr5O1/6hALXmKCLVZZn9TiLQ0Zxe1fd8K3nMf/nNomA78O9wQRKqTTBWbCL9WFThLjDc5xF0uG+a9adS/QZgGXeMwYFRyIrautHT9CT5agnoW4t9G8RaM3gS27yOlyJQa66rIob6a9nzkysUyIv2aQ91C0oubgi9ElKZt1VU2y+SsQD1IJJxQODtdjYdFyByJzwyBNhqL/S80/J6U8ZyL/XSVOMmzYhohF0q9TwXgy4nNZ5kI64XfpAy5sMzbOwEOypgLDj9KS2/nznD27zwktVtVlTrSD2MF3etES9RI530is9/8zWq7uCbiLF2QrJMWMs6S41iKrkqtJ4PCa1rAAiWoz5NGndObugUtIrsgY/Ux8tWUArP33n1rmqd6gu5Lm8oG+oN6mFTOIjXq6thyxFwC3Kpt6Z8NUvpCMx5vc6DWzyxZFnPks0V1F4M0REc8Vnh3PgkSYUoyW2awgoCH2z5H6HUg1hBHb+jkDHSfc/b98aSa77IDxh3DZp0f01VF60Ra1GMz0ES3DBeOmcNz76w+yMbcCAj0PsgKX4IayTfQuQbfYM/u9birvtbNoB6inDmwNX2v8srLjJCZBFMWfuhAj2h8ijj+AxFDVdeRTpmsuZcbIvkuiQvuTf9e5YZVXqKmv3SaTn1PKIye4oJnBQx1Zlx2EqLzk2fYU24dNwJVJZ4ifCJTRBgUl0O8TD7F7v0KLjgcUgcAMnS0AH0KOIDjM9T7bczZ6MOybtkPcwYjA1TZDZRiU+ZSM Fj0NU+FJ 3xEHQXJqW/kl8eXOVuDU45zmUJa7Yq/91fv7r9vSuClrbvsohM6urlnJwsrk+khPADu9fIkiXGds6jwoJkN72Ki872CkNG1q9Ov+KtTRPr8sgf1oR7DRtxc/1S6DweGMuZFboEJZNkOSP0aqFA0ewifTM0/TPuROMJFnjWR8wckOK39N9OBd5sJqlNHDRnY7JtBvsPGrQ8x23tJ8hitDENCmof9KKkgeCxL8g 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 Andrew, After discussion about this in Matthew's THP Cabal, we have decided to take a different approach with this patch set. Could you therefore remove it from mm-unstable, please? Sorry about the noise. I'm going to try 2 different approaches: - avoid the split lock contention by using mmu gather (suggested by Kirill) - expand the zap pte batching to also cover file folios (as requested by Yu). Thanks, Ryan On 27/07/2023 15:18, Ryan Roberts wrote: > Hi All, > > This is v4 of a small series in support of my work to enable the use of large > folios for anonymous memory (known as "FLEXIBLE_THP" or "LARGE_ANON_FOLIO") [5]. > It first makes it possible to add large, non-pmd-mappable folios to the deferred > split queue. Then it modifies zap_pte_range() to batch-remove spans of > physically contiguous pages from the rmap, which means that in the common case, > we elide the need to ever put the folio on the deferred split queue, thus > reducing lock contention and improving performance. > > This becomes more visible once we have lots of large anonymous folios in the > system, and Huang Ying has suggested solving this needs to be a prerequisit for > merging the main FLEXIBLE_THP/LARGE_ANON_FOLIO work. > > The series applies on top of v6.5-rc3 and a branch is available at [4]. > > NOTE: v3 is currently in mm-unstable and has a bug that affects s390, which this > version fixes. > > > Changes since v3 [3] > -------------------- > > - Fixed bug reported on s390 [6] > - Since s390 enables MMU_GATHER_NO_GATHER, __tlb_remove_page() causes a ref > to be dropped on the page, but we were still using the page after that > function call. > - Fix by using folio_get()/folio_put() to guarrantee lifetime of page > - Thanks to Nathan Chancellor for the bug report and helping me get set up > with s390! > - Don't use batch path if folio is not large > > > Changes since v2 [2] > -------------------- > > - patch 2: Reworked at Yu Zhou's request to reduce duplicated code. > - page_remove_rmap() now forwards to folio_remove_rmap_range() for the > !compound (PMD mapped) case. > - Both page_remove_rmap() and folio_remove_rmap_range() share common > epilogue via new helper function __remove_rmap_finish(). > - As a result of the changes, I've removed the previous Reviewed-bys. > - other 2 patches are unchanged. > > > Changes since v1 [1] > -------------------- > > - patch 2: Modified doc comment for folio_remove_rmap_range() > - patch 2: Hoisted _nr_pages_mapped manipulation out of page loop so its now > modified once per folio_remove_rmap_range() call. > - patch 2: Added check that page range is fully contained by folio in > folio_remove_rmap_range() > - patch 2: Fixed some nits raised by Huang, Ying for folio_remove_rmap_range() > - patch 3: Support batch-zap of all anon pages, not just those in anon vmas > - patch 3: Renamed various functions to make their use clear > - patch 3: Various minor refactoring/cleanups > - Added Reviewed-By tags - thanks! > > > [1] https://lore.kernel.org/linux-mm/20230717143110.260162-1-ryan.roberts@arm.com/ > [2] https://lore.kernel.org/linux-mm/20230719135450.545227-1-ryan.roberts@arm.com/ > [3] https://lore.kernel.org/linux-mm/20230720112955.643283-1-ryan.roberts@arm.com/ > [4] https://gitlab.arm.com/linux-arm/linux-rr/-/tree/features/granule_perf/deferredsplit-lkml_v4 > [5] https://lore.kernel.org/linux-mm/20230714160407.4142030-1-ryan.roberts@arm.com/ > [6] https://lore.kernel.org/linux-mm/20230726161942.GA1123863@dev-arch.thelio-3990X/ > > Thanks, > Ryan > > > Ryan Roberts (3): > mm: Allow deferred splitting of arbitrary large anon folios > mm: Implement folio_remove_rmap_range() > mm: Batch-zap large anonymous folio PTE mappings > > include/linux/rmap.h | 2 + > mm/memory.c | 132 +++++++++++++++++++++++++++++++++++++++++++ > mm/rmap.c | 125 ++++++++++++++++++++++++++++++---------- > 3 files changed, 229 insertions(+), 30 deletions(-) > > -- > 2.25.1 >