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 56D32EB64D9 for ; Mon, 10 Jul 2023 08:30:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DBCE86B0072; Mon, 10 Jul 2023 04:30:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D6D106B0074; Mon, 10 Jul 2023 04:30:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C3D6C6B0075; Mon, 10 Jul 2023 04:30:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id B36376B0072 for ; Mon, 10 Jul 2023 04:30:04 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 78A4A1602DE for ; Mon, 10 Jul 2023 08:30:04 +0000 (UTC) X-FDA: 80995029528.06.2C59129 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf10.hostedemail.com (Postfix) with ESMTP id 4B268C0013 for ; Mon, 10 Jul 2023 08:30:02 +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=1688977802; 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=f8zthcqOg40MozqpMq/zELsZkZswNGqzU94obtmQu4k=; b=qStDyVtkV8ZZ4lUCkHzboZ5L3cEhnK779MJEKmi8xWL37XVVe0dQMKr1E6QbT6UkcbKiHe tBxGEnHTvTaM9VM7178fF/FERpWSN91eB673+iKB4y0M+YqxaT69FIf0Kd+swaWXlq5/Hb 52jQ7mDQL5y0p4KLKRtwfCSTjyO2ftM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688977802; a=rsa-sha256; cv=none; b=7viu9rOGI1b5fQFCT1XKzsSvX4vmU/R1SkKjSHzvJmXMgKFm2v2zCytBHBjgiYgso6M72d Q4qwzcqYxFJBbH9VlJXuTD/BBbm2IC89dV2bBSTi0vVIjq/2fcxwCW1cONALWfB4BfrjXV +HKkwN1/PCgGEqA7D59ecAinbhZWzfI= 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 38AFC2B; Mon, 10 Jul 2023 01:30:43 -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 D063B3F740; Mon, 10 Jul 2023 01:29:58 -0700 (PDT) Message-ID: Date: Mon, 10 Jul 2023 09:29:57 +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: [PATCH v2 2/5] mm: Allow deferred splitting of arbitrary large anon folios To: "Huang, Ying" Cc: Andrew Morton , Matthew Wilcox , "Kirill A. Shutemov" , Yin Fengwei , David Hildenbrand , Yu Zhao , Catalin Marinas , Will Deacon , Anshuman Khandual , Yang Shi , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20230703135330.1865927-1-ryan.roberts@arm.com> <20230703135330.1865927-3-ryan.roberts@arm.com> <877crcgmj1.fsf@yhuang6-desk2.ccr.corp.intel.com> <6379dd13-551e-3c73-422a-56ce40b27deb@arm.com> <87ttucfht7.fsf@yhuang6-desk2.ccr.corp.intel.com> From: Ryan Roberts In-Reply-To: <87ttucfht7.fsf@yhuang6-desk2.ccr.corp.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4B268C0013 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: zwxq1gujukceot3u1sjrbw1zfemi5giq X-HE-Tag: 1688977802-601700 X-HE-Meta: U2FsdGVkX1/+6hgGIcpjCPjegres+3T6Wytb94OJenOmV4j28f1WYFW9pN5i5zC1b64mFaVjc5KPSo+aH2cwO0CNpFr98DaWOBNe0hEulZRCMV34mdfLJbV5WVWh4D8lZuJO8waBJ+2Ua0ykrY0ousOUeh6Dx7DY4IG3dcq5T1OgTPDo4tGlcVdOgMnC1GX1LrvouJcmDX1+qmr9dGzN5V8HcVyOL920JxjAAuDFq7EiqMC3QFei/juhiXW0LqxYNxvpEUyZpDMqmyRjd8Jd223P6l3m12PicMzvWbCeEtUbGO/P2EohRgTc6gAt5qK33CUfDQzPZVrDbYoukNTl6b3vZ4cTd/UWbTdQBfuP1EnbrS/okjlRr2+w3zLFdayJARa1yffi7jjbfow7SroP09xqISBBLE8EQhGg29nkp4pXGy30Am+pQK/tisXXX6IkdgRVGjq3tf9jsaFkK4Kv/SSMgK7hlb2iNYlKnTSRoLPhTIswg9pQScsNq+vVVoqR2s6VbuTkc+ytDmVzitx7kpV9rfC6D4bPALosc5QpC7pQgB9XXrAqW1nZOX95y126JhZqLzz18+tPqpqFtWghZP8csLOOE0QkaKLLFBDK3x5uAqJ9s/nC0VuPNduxtibQcWEwWFz7UPQXdWpTOAGzBQPPBvSW6HV/B5AzUGwHvyicD09W8XRZ0grVmcDTrMEuXE+GS1x/3AORga/NuL1bKO0F4PxK08YjT/mNh9d8kdcrUsTYKcMBMA5r1w6wRNnzuX/6IXaHhqCQOxOdYnDrD4I+7985gdF/gwgcb2d38UvP8GejtjLMSdrASvTGWgMOjfd8jhgJwooNtqQ3SPfkDdbUYiA7zgKQaO/q4GhAM7t38pwon90/ywsWuIq0I1mbBqs5isYJBDBZBL9IzQm9bvvQ4jtxeXXaDQUutqEqyjii62rw/Jl3imbwYV7Owh4Yh4ZeD5ClC3hDEvNLu4N Nejf7z/K n9F+etG+fYJsCCXqnIDrTn5YUCsquOGJMSmmgy/IykstKayD2AX3zzIOSRIXurvES29B+BUUOsP6jvsFBJJ5ovf3FbFo1QazIhBCl3cPV8Y9lY53jWgBnpZZa+TWbUKF9sE2qfMGzq+eiSn1Q1QmwS1vgKtto0eFtS2YCxf7F8HJfNL1K/dRIvccZAEZLZCb2veXNHrgOWLlMubvl7xPDcVbUXuF16tL9yqZvjalByKvJ8xCXcUS64+k1j0wczroeFwtezLnx8c+Tvq0rZjbYV8N/Gx42WAMaIolxmzRbMqGZGoouhw9SX0x/49k4e3ZZOciu4nb6q1izO6Ad9scZRq3XqLU54R0nl2pynDmyerNqQQk= 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 10/07/2023 06:37, Huang, Ying wrote: > Ryan Roberts writes: > >> Somehow I managed to reply only to the linux-arm-kernel list on first attempt so >> resending: >> >> On 07/07/2023 09:21, Huang, Ying wrote: >>> Ryan Roberts writes: >>> >>>> With the introduction of large folios for anonymous memory, we would >>>> like to be able to split them when they have unmapped subpages, in order >>>> to free those unused pages under memory pressure. So remove the >>>> artificial requirement that the large folio needed to be at least >>>> PMD-sized. >>>> >>>> Signed-off-by: Ryan Roberts >>>> Reviewed-by: Yu Zhao >>>> Reviewed-by: Yin Fengwei >>>> --- >>>> mm/rmap.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/mm/rmap.c b/mm/rmap.c >>>> index 82ef5ba363d1..bbcb2308a1c5 100644 >>>> --- a/mm/rmap.c >>>> +++ b/mm/rmap.c >>>> @@ -1474,7 +1474,7 @@ void page_remove_rmap(struct page *page, struct vm_area_struct *vma, >>>> * page of the folio is unmapped and at least one page >>>> * is still mapped. >>>> */ >>>> - if (folio_test_pmd_mappable(folio) && folio_test_anon(folio)) >>>> + if (folio_test_large(folio) && folio_test_anon(folio)) >>>> if (!compound || nr < nr_pmdmapped) >>>> deferred_split_folio(folio); >>>> } >>> >>> One possible issue is that even for large folios mapped only in one >>> process, in zap_pte_range(), we will always call deferred_split_folio() >>> unnecessarily before freeing a large folio. >> >> Hi Huang, thanks for reviewing! >> >> I have a patch that solves this problem by determining a range of ptes covered >> by a single folio and doing a "batch zap". This prevents the need to add the >> folio to the deferred split queue, only to remove it again shortly afterwards. >> This reduces lock contention and I can measure a performance improvement for the >> kernel compilation benchmark. See [1]. >> >> However, I decided to remove it from this patch set on Yu Zhao's advice. We are >> aiming for the minimal patch set to start with and wanted to focus people on >> that. I intend to submit it separately later on. >> >> [1] https://lore.kernel.org/linux-mm/20230626171430.3167004-8-ryan.roberts@arm.com/ > > Thanks for your information! "batch zap" can solve the problem. > > And, I agree with Matthew's comments to fix the large folios interaction > issues before merging the patches to allocate large folios as in the > following email. > > https://lore.kernel.org/linux-mm/ZKVdUDuwNWDUCWc5@casper.infradead.org/ > > If so, we don't need to introduce the above problem or a large patchset. I appreciate Matthew's and others position about not wanting to merge a minimal implementation while there are some fundamental features (e.g. compaction) it doesn't play well with - I'm working to create a definitive list so these items can be tracked and tackled. That said, I don't see this "batch zap" patch as an example of this. It's just a performance enhancement that improves things even further than large anon folios on their own. I'd rather concentrate on the core changes first then deal with this type of thing later. Does that work for you? > > Best Regards, > Huang, Ying