Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp783438lqt; Fri, 19 Apr 2024 10:13:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXaKD2QGjvGT8HrIPRsEbJiMZB5VwMdjQzRJxyLTggON0A0Kdm+6Q5vdPiHb4r4GJFp/Ba4iySCDoni2ecPbYrQMQsD7bTSL0LxGVqk0g== X-Google-Smtp-Source: AGHT+IE3q1VhQmhLf5H1gr5eIymyMmwOjfXM9Nl8CXrfWd7Do4axN9lJDU070qNG5g5E1Mao/xvE X-Received: by 2002:a05:6214:4b98:b0:69b:1ae5:bc2e with SMTP id qf24-20020a0562144b9800b0069b1ae5bc2emr3233736qvb.40.1713546791809; Fri, 19 Apr 2024 10:13:11 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id o1-20020ad45c81000000b0069b7a50a402si4624351qvh.196.2024.04.19.10.13.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 10:13:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-151810-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@redhat.com header.s=mimecast20190719 header.b=XLArRZ9N; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-151810-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151810-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3F69A1C210EB for ; Fri, 19 Apr 2024 17:13:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 382A2139599; Fri, 19 Apr 2024 17:13:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XLArRZ9N" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6453A85284 for ; Fri, 19 Apr 2024 17:13:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713546786; cv=none; b=sWaqCgrdCJYiVdreVhQgXW6I1QHv/CTgmxsA1TiZPwqw3IHa50d0720xsUf8QGjHoWxvUW0QCZaKNbhgJbeJ+nq0jWu8627r6GjlJEcaAFk2R2M7xAl9jshU7OvGYgRGmmYNnhXiLGisorrM3j9sjVtynuB6MKVMJFWshBoSq2Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713546786; c=relaxed/simple; bh=6mkNayftPML6pT2KciKfd4FFbXSB1RlhvOicRs6zOX4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=mpX+JBppBP+RbAPtec3LNS1Uzd5pEBECegfPCZOVtITjZZrrYaOCIjpEaItWZJ8LH+GYW2whMa5NSzhtpW+y9A2eA9jZZdW+WeZc8OYwPiW2zeKLsarKn89Rj236pTGsV4hsU5ysNECl30VWwSj+gOVxdXJunP6GqpsUZs9wXpc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=XLArRZ9N; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713546783; 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=ffWzMqu7mdQbYGoN2ZnXETKJDhCQefY93Dtj+EcLpGM=; b=XLArRZ9NTWtGZh+8VtuUKKg45B0Kv2VbArL1arvAeIm+i1hy+7ixBN2z4quAIyw7fmJ7v6 Vrxcq1CXuHi2JVM+m0RHC/Ce1OL7knmuk6U/YsvwPCov7ogti/FllgSEz4s+lw3mcdUkAv WYNJAs8wzJLYDMIF+OQVEeRsj1eCVv0= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-50-17A0bYekMAyQnYMB4mnmsg-1; Fri, 19 Apr 2024 13:12:59 -0400 X-MC-Unique: 17A0bYekMAyQnYMB4mnmsg-1 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2d45c064742so23346901fa.3 for ; Fri, 19 Apr 2024 10:12:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713546778; x=1714151578; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ffWzMqu7mdQbYGoN2ZnXETKJDhCQefY93Dtj+EcLpGM=; b=ZMYtbDHN+/TXf29FAFEP+0ibinOwYBNNfcUHnGI5dXtvU6ZlxwLHGG5FOk31GWJAlk 7co8PwkdFvI+iD7HdX3H5fjNv/IxObYsx7sGNAhh1YLHpKXQEI9YcTIZuNRA+daKTnxx HxzL4HKGSkX3QvkN4Iskiym7j+h7pze0MneT2woNrrYE4y6rC3lNgcHXWItXJhZxq3vc W8MN8/k5R7JrIsnEFKO4jdvCo7uzSwSu8qXBSE+Lb18S8xVroXLfs4JCYTFo9gPAkZ/u 39gUWR7AMhAvlHyN6FZlgu0W8XwUinrORnmis8N51dzrQlaueYEUcpACNOE0tgdbMBqz m3uQ== X-Forwarded-Encrypted: i=1; AJvYcCXvdJoaegSa/3ZelOlE0TrYpWONSKBMjtvNrBNZJ2Ls3+oMAbnOaHJBkZ4uF2tkT1IKKtbUT+Hoq+qgaK14esWFfCbTGd/rR6LIjPi1 X-Gm-Message-State: AOJu0YwTaSGHLV4DkC2mOFnpsP/fg5yavBCXfTx+98h4GXy3pZ3qpHOr MT5xtx4Pt2xD0UDs2c/Y55WmaPviE2lvkVT1bF52+x/UPVn0+ScKGA8ClQtXNHl6wr9oX+E73FQ hh3mnl0z5O1B2+ag70HNnyC4bQIpPdrADUaHIhzWXS38zeijgWiwZcQe8NFDWRA== X-Received: by 2002:a2e:834b:0:b0:2d8:4158:cbaa with SMTP id l11-20020a2e834b000000b002d84158cbaamr1754470ljh.7.1713546778052; Fri, 19 Apr 2024 10:12:58 -0700 (PDT) X-Received: by 2002:a2e:834b:0:b0:2d8:4158:cbaa with SMTP id l11-20020a2e834b000000b002d84158cbaamr1754446ljh.7.1713546777511; Fri, 19 Apr 2024 10:12:57 -0700 (PDT) Received: from ?IPV6:2003:cb:c716:f300:c9f0:f643:6aa2:16? (p200300cbc716f300c9f0f6436aa20016.dip0.t-ipconnect.de. [2003:cb:c716:f300:c9f0:f643:6aa2:16]) by smtp.gmail.com with ESMTPSA id fc14-20020a05600c524e00b004161af729f4sm7214198wmb.31.2024.04.19.10.12.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Apr 2024 10:12:57 -0700 (PDT) Message-ID: Date: Fri, 19 Apr 2024 19:12:56 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 0/5] arm64/mm: uffd write-protect and soft-dirty tracking To: Mike Rapoport Cc: Shivansh Vij , Ryan Roberts , Catalin Marinas , Will Deacon , Andrew Morton , Shuah Khan , Joey Gouly , Ard Biesheuvel , Mark Rutland , Anshuman Khandual , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kselftest@vger.kernel.org" References: <20240419074344.2643212-1-ryan.roberts@arm.com> <24999e38-e4f7-4616-8eae-dfdeba327558@arm.com> Content-Language: en-US From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9 PXFNNgV5jXMQRwU0O/ztJIQqsE5LsUomE//bLwzj9IVsaQpKDqW6TAPjcdBDPLHvriq7kGjt WhVhdl0qEYB8lkBEU7V2Yb+SYhmhpDrti9Fq1EsmhiHSkxJcGREoMK/63r9WLZYI3+4W2rAc UucZa4OT27U5ZISjNg3Ev0rxU5UH2/pT4wJCfxw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TrJz3++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: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 19.04.24 18:30, Mike Rapoport wrote: > On Fri, Apr 19, 2024 at 11:45:14AM +0200, David Hildenbrand wrote: >> On 19.04.24 10:33, Shivansh Vij wrote: >>>> On 19/04/2024 08:43, Ryan Roberts wrote: >>>>> Hi All, >>>>> >>>>> This series adds uffd write-protect and soft-dirty tracking support for arm64. I >>>>> consider the soft-dirty support (patches 3 and 4) as RFC - see rationale below. >>>>> >>>>> That said, these are the last 2 SW bits and we may want to keep 1 bit in reserve >>>>> for future use. soft-dirty is only used for CRIU to my knowledge, and it is >>>>> thought that their use case could be solved with the more generic uffd-wp. So >>>>> unless somebody makes a clear case for the inclusion of soft-dirty support, we >>>>> are probably better off dropping patches 3 and 4 and keeping bit 63 for future >>>>> use. Although note that the most recent attempt to add soft-dirty for arm64 was >>>>> last month [1] so I'd like to give Shivansh Vij the opportunity to make the >>>>> case. >>> >>> Appreciate the opportunity to provide input here. >>> >>> I picked option one (dirty tracking in arm) because it seems to be the >>> simplest way to move forward, whereas it would be a relatively heavy >>> effort to add uffd-wp support to CRIU. >>> >>> From a performance perspective I am also a little worried that uffd >>> will be slower than just tracking the dirty bits asynchronously with >>> sw dirty, but maybe that's not as much of a concern with the addition >>> of uffd-wp async. >>> >>> With all this being said, I'll defer to the wisdom of the crowd about >>> which approach makes more sense - after all, with this patch we should >>> get uffd-wp support on arm so at least there will be _a_ way forward >>> for CRIU (albeit one requiring slightly more work). >> >> Ccing Mike and Peter. In 2017, Mike gave a presentation "Memory tracking for >> iterative container migration"[1] at LPC >> >> Some key points are still true I think: >> (1) More flexible and robust than soft-dirty >> (2) May obsolete soft-dirty >> >> We further recently added a new UFFD_FEATURE_WP_ASYNC feature as part of >> [2], because getting soft-dirty return reliable results in some cases turned >> out rather hard to fix. >> >> We might still have to optimize that approach for some very sparse large >> VMAs, but that should be solvable. >> >> "The major defect of this approach of dirty tracking is we need to >> populate the pgtables when tracking starts. Soft-dirty doesn't do it >> like that. It's unwanted in the case where the range of memory to track >> is huge and unpopulated (e.g., tracking updates on a 10G file with >> mmap() on top, without having any page cache installed yet). One way to >> improve this is to allow pte markers exist for larger than PTE level >> for PMD+. That will not change the interface if to implemented, so we >> can leave that for later.")[3] >> >> >> If we can avoid adding soft-dirty on arm64 that would be great. This will >> require work on the CRIU side. One downside of uffd-wp is that it is >> currently not as avilable on architectures as soft-dirty. > > Using uffd-wp instead of soft-dirty in CRIU will require quite some work on > CRIU side and probably on the kernel side too. > > And as of now we'll anyway have to maintain soft-dirty because powerpc and > s390 don't have uffd-wp. > > With UFFD_FEATURE_WP_ASYNC the concern that uffd-wp will be slower than > soft-dirty probably doesn't exist, but we won't know for sure until > somebody will try. > > But there were other limitations, the most prominent was checkpointing an > application that uses uffd. If CRIU is to use uffd-wp for tracking of the > dirty pages, there should be some support for multiple uffd contexts for a > VMA and that's surely a lot of work. Is it even already supported to checkpoint an application that is using uffd? Hard to believe, what if the monitor is running in a completely different process than the one being checkpointed? Further ... isn't CRIU already using uffd in some cases? ..documentation mentions [1] that it is used for "lazy (or post-copy) restore in CRIU". At least if the documentation is correct and its actually implemented. [1] https://criu.org/Userfaultfd > >> But I'll throw in another idea: do we really need soft-dirty and uffd-wp to >> exist at the same time in the same process (or the VMA?). In theory, we > > For instance to have dirty memory tracking in CRIU for an application that > uses uffd-wp :) > Hah! Not a concern for application on architectures where uffd-wp does not exist yet! Well, initially, until these applications exist and make use of it :P Also, I'm not sure if CRIU can checkpoint each and every application ... I suspect one has to draw a line what can be supported and what not. Case in point: how should CRIU checkpoint an application that is using softdirty tracking itself? If I'm not missing something important, that might not work .... If the answer is "no other application is using soft-dirty tracking", then it's really a shame we have to carry this baggage (+waste precious PTE bits) only for one application ... -- Cheers, David / dhildenb