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 59040C41535 for ; Tue, 19 Dec 2023 11:29:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BCD6D6B0078; Tue, 19 Dec 2023 06:29:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B555B6B007B; Tue, 19 Dec 2023 06:29:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 981D46B007D; Tue, 19 Dec 2023 06:29:31 -0500 (EST) 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 6FB396B0078 for ; Tue, 19 Dec 2023 06:29:31 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 43B06A0AFE for ; Tue, 19 Dec 2023 11:29:31 +0000 (UTC) X-FDA: 81583347342.02.D0DAF1F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id E6A8B180012 for ; Tue, 19 Dec 2023 11:29:28 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XNm5nSbI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702985369; a=rsa-sha256; cv=none; b=A5EbDn3HFiNxuh6y/vuWZ9fYw5t0jhrYoHmmpG/KohS0QcPBTI00Rolp29TIF3tt7szUjn UC538YVlFXjEYBCxHNV5sN3NyrORWKC3X1bYOfcqDHn2TPYscMRk1wIoOy3uwYtIE40Nvp /K3Lkv6pQ64u8ag5aqLf4V3Ckzq3iFY= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XNm5nSbI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702985369; 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:dkim-signature; bh=GyPEyE0WEjjBo9Kf0C8VvnNmeq7SiNAcilBv+DXpUj8=; b=H5c5JnPkIs15QD3HYAy0ud3clpCG8L93NfswDkHaAsyROq/oZWcwt8jpE0vLgs1xxjoh3C cxPwlLSBIe//7NC6Ib7FJlR5qms+gWJF5RRjkpuIf7IhPEWxKBJ9+xH+W4wcfs+KBS9CAl P2ErAhdQMzTOYYWynVtLQXriSidMxXk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702985368; h=from:from: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:autocrypt:autocrypt; bh=GyPEyE0WEjjBo9Kf0C8VvnNmeq7SiNAcilBv+DXpUj8=; b=XNm5nSbI3Rh+yyVO4yM9zgc5NUbVctsgJgPzva6TvVUdlN9IAx0P41GL4gkDn3S7Gq5sMW EPmt3fMTGP0IIvqM4JqfjpqtYu3cZXHjsb5a073cwFqBV1XHVftM2s4ruIm6wVH3XV32sk S9RYxnVdtdifJrS+GKUHrXoH8y/XlBA= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-463-wV0BtHTiMHCMiyIrEqWSZg-1; Tue, 19 Dec 2023 06:29:26 -0500 X-MC-Unique: wV0BtHTiMHCMiyIrEqWSZg-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-40c514f9243so29359335e9.3 for ; Tue, 19 Dec 2023 03:29:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702985365; x=1703590165; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=GyPEyE0WEjjBo9Kf0C8VvnNmeq7SiNAcilBv+DXpUj8=; b=JZigf8RgEPGoOd2cdEMRwSZpVj6OBrxLxA2IxiRtCPeTeG7WMUaGSyewGZA8N0aNhh WMKHE64oKeZAGhBHczWwfqOBnKbe2DvvCzaJA93/qbJBXKktXPOr+RktcXcWmO0KvCFN B43DpZ0Oji0rahkYlDXq8wmKh+UCjXfCTv9EzEBpZjUNwC70jmdIyIIc2EM1ROfKbr3k jzd/c8wZt3wSc8yntds5mQMULCFOWSbYpUcYSqUxpLVR5y4mtHX3KuT8WkvCK22ahoQr q5w6Crcs7ZAa/gQAWx4B3VtwckRhUzlCUAtl9Kt7C0kNLz5RYjXHpDKOrilYuHhEfZBs aVYA== X-Gm-Message-State: AOJu0Yykp47D3bvL9pxb+DvG2RgA7nrassEWrEeDRTwn3/MfyUCHzZI+ tZ/Q9qJcD3HhabCHcx62HA4lK8+l9ZoMHE1n7GHtfFWecT3E0+6lIFjEBtjI38dVVjVeeRvdN/U v4hB4tWaGwR4= X-Received: by 2002:a1c:6a19:0:b0:40c:319b:6a72 with SMTP id f25-20020a1c6a19000000b0040c319b6a72mr10430459wmc.9.1702985365353; Tue, 19 Dec 2023 03:29:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IHnYzVetPAKaG3VKY68f41+X0PXHbjp7TWeq6p2VTlx0IX8KHgF5OtpBtipnZAhphOEpIFzHA== X-Received: by 2002:a1c:6a19:0:b0:40c:319b:6a72 with SMTP id f25-20020a1c6a19000000b0040c319b6a72mr10430436wmc.9.1702985364843; Tue, 19 Dec 2023 03:29:24 -0800 (PST) Received: from ?IPV6:2a09:80c0:192:0:5dac:bf3d:c41:c3e7? ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with ESMTPSA id s21-20020a05600c45d500b0040c3953cda5sm2417995wmo.45.2023.12.19.03.29.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 19 Dec 2023 03:29:24 -0800 (PST) Message-ID: <9d473ac7-ef52-4fa4-bb54-900176d987c9@redhat.com> Date: Tue, 19 Dec 2023 12:29:23 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 02/16] mm: Batch-copy PTE ranges during fork() To: Ryan Roberts , Catalin Marinas , Will Deacon , Ard Biesheuvel , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Andrew Morton , Anshuman Khandual , Matthew Wilcox , Yu Zhao , Mark Rutland , Kefeng Wang , John Hubbard , Zi Yan , Barry Song <21cnbao@gmail.com>, Alistair Popple , Yang Shi Cc: linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20231218105100.172635-1-ryan.roberts@arm.com> <20231218105100.172635-3-ryan.roberts@arm.com> <0bef5423-6eea-446b-8854-980e9c23a948@redhat.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQ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4Gusdqx8nPEpfOqCtbbwJMATbHyqLt7/oz/5deGuwxgb65pWIzufa N7eop7uh+6bezi+rugUI+w6DABEBAAHCwXwEGAEIACYCGwwWIQQb2cqtc1xMOkYN/MpN3hD3 AP+DWgUCXw7HsgUJEqkpoQAKCRBN3hD3AP+DWrrpD/4qS3dyVRxDcDHIlmguXjC1Q5tZTwNB boaBTPHSy/Nksu0eY7x6HfQJ3xajVH32Ms6t1trDQmPx2iP5+7iDsb7OKAb5eOS8h+BEBDeq 3ecsQDv0fFJOA9ag5O3LLNk+3x3q7e0uo06XMaY7UHS341ozXUUI7wC7iKfoUTv03iO9El5f XpNMx/YrIMduZ2+nd9Di7o5+KIwlb2mAB9sTNHdMrXesX8eBL6T9b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E6A8B180012 X-Stat-Signature: ecr8e6o4udrdm19y7u6mcnwbxzdx3pbf X-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Un4ODP6KXG4sJvpnG2qeRVdYZkNegCln2vhMXAD74Qkyh8JaTCuz1/HDx5iMqD9kVFq9/2cKjmEvJtjw00vtl9e7H6I8VZtZ5sAFt6gBYd4061JUMNqvThGNplh8b37jiVKrn9gwRa2jb4lAs4HqNavyPKHISxZDPoG7wEwEboOAwLZZl+64arO1k1+LWrORjjusa0suPX7Vh7l4MzXtHdLPOwa5jswBASuff7xqpxYLOYP6B1sBrzLANL462l6KoE6Ff6qncP5mka3+rohv5/aq5RPIm5nU7RaFUAxEADSMblaXd+Hk2HS1fN0mO+uuC9QzGrU2uLo8T6zhyRm338+ahzYs0zl0uiMPzDxnXJtLY5YjfpWX1dAmrnt0f7a5n8jEdrOXIQKrFu76k7PI7ERC4nmkcZlX2sYqqezBN2G4JPaO1ZDpf95jWSk3mBYWYFmgYltELYnPAd+MlVh0ekZ54SpETiVTlXxQWXyda93j/KbPbK6WkZlNjCluXCxMbABvdKvR+y96IJmhZ 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 19.12.23 09:30, Ryan Roberts wrote: > On 18/12/2023 17:47, David Hildenbrand wrote: >> On 18.12.23 11:50, Ryan Roberts wrote: >>> Convert copy_pte_range() to copy a batch of ptes in one go. A given >>> batch is determined by the architecture with the new helper, >>> pte_batch_remaining(), and maps a physically contiguous block of memory, >>> all belonging to the same folio. A pte batch is then write-protected in >>> one go in the parent using the new helper, ptep_set_wrprotects() and is >>> set in one go in the child using the new helper, set_ptes_full(). >>> >>> The primary motivation for this change is to reduce the number of tlb >>> maintenance operations that the arm64 backend has to perform during >>> fork, as it is about to add transparent support for the "contiguous bit" >>> in its ptes. By write-protecting the parent using the new >>> ptep_set_wrprotects() (note the 's' at the end) function, the backend >>> can avoid having to unfold contig ranges of PTEs, which is expensive, >>> when all ptes in the range are being write-protected. Similarly, by >>> using set_ptes_full() rather than set_pte_at() to set up ptes in the >>> child, the backend does not need to fold a contiguous range once they >>> are all populated - they can be initially populated as a contiguous >>> range in the first place. >>> >>> This code is very performance sensitive, and a significant amount of >>> effort has been put into not regressing performance for the order-0 >>> folio case. By default, pte_batch_remaining() is compile constant 1, >>> which enables the compiler to simplify the extra loops that are added >>> for batching and produce code that is equivalent (and equally >>> performant) as the previous implementation. >>> >>> This change addresses the core-mm refactoring only and a separate change >>> will implement pte_batch_remaining(), ptep_set_wrprotects() and >>> set_ptes_full() in the arm64 backend to realize the performance >>> improvement as part of the work to enable contpte mappings. >>> >>> To ensure the arm64 is performant once implemented, this change is very >>> careful to only call ptep_get() once per pte batch. >>> >>> The following microbenchmark results demonstate that there is no >>> significant performance change after this patch. Fork is called in a >>> tight loop in a process with 1G of populated memory and the time for the >>> function to execute is measured. 100 iterations per run, 8 runs >>> performed on both Apple M2 (VM) and Ampere Altra (bare metal). Tests >>> performed for case where 1G memory is comprised of order-0 folios and >>> case where comprised of pte-mapped order-9 folios. Negative is faster, >>> positive is slower, compared to baseline upon which the series is based: >>> >>> | Apple M2 VM   | order-0 (pte-map) | order-9 (pte-map) | >>> | fork          |-------------------|-------------------| >>> | microbench    |    mean |   stdev |    mean |   stdev | >>> |---------------|---------|---------|---------|---------| >>> | baseline      |    0.0% |    1.1% |    0.0% |    1.2% | >>> | after-change  |   -1.0% |    2.0% |   -0.1% |    1.1% | >>> >>> | Ampere Altra  | order-0 (pte-map) | order-9 (pte-map) | >>> | fork          |-------------------|-------------------| >>> | microbench    |    mean |   stdev |    mean |   stdev | >>> |---------------|---------|---------|---------|---------| >>> | baseline      |    0.0% |    1.0% |    0.0% |    0.1% | >>> | after-change  |   -0.1% |    1.2% |   -0.1% |    0.1% | >>> >>> Tested-by: John Hubbard >>> Reviewed-by: Alistair Popple >>> Signed-off-by: Ryan Roberts >>> --- >>>   include/linux/pgtable.h | 80 +++++++++++++++++++++++++++++++++++ >>>   mm/memory.c             | 92 ++++++++++++++++++++++++++--------------- >>>   2 files changed, 139 insertions(+), 33 deletions(-) >>> >>> diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h >>> index af7639c3b0a3..db93fb81465a 100644 >>> --- a/include/linux/pgtable.h >>> +++ b/include/linux/pgtable.h >>> @@ -205,6 +205,27 @@ static inline int pmd_young(pmd_t pmd) >>>   #define arch_flush_lazy_mmu_mode()    do {} while (0) >>>   #endif >>>   +#ifndef pte_batch_remaining >>> +/** >>> + * pte_batch_remaining - Number of pages from addr to next batch boundary. >>> + * @pte: Page table entry for the first page. >>> + * @addr: Address of the first page. >>> + * @end: Batch ceiling (e.g. end of vma). >>> + * >>> + * Some architectures (arm64) can efficiently modify a contiguous batch of ptes. >>> + * In such cases, this function returns the remaining number of pages to the end >>> + * of the current batch, as defined by addr. This can be useful when iterating >>> + * over ptes. >>> + * >>> + * May be overridden by the architecture, else batch size is always 1. >>> + */ >>> +static inline unsigned int pte_batch_remaining(pte_t pte, unsigned long addr, >>> +                        unsigned long end) >>> +{ >>> +    return 1; >>> +} >>> +#endif >> >> It's a shame we now lose the optimization for all other archtiectures. >> >> Was there no way to have some basic batching mechanism that doesn't require arch >> specifics? > > I tried a bunch of things but ultimately the way I've done it was the only way > to reduce the order-0 fork regression to 0. Let me give it a churn today. I think we should really focus on having only a single folio_test_large() check on the fast path for order-0. And not even try doing batching for anything that works on bare PFNs. Off to prototyping ... :) -- Cheers, David / dhildenb