Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp650865lqb; Fri, 15 Mar 2024 02:30:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXPvcH3M8p/lwMfdxsQWEu4msIF9UpYimstTWX23X4qJcm0FUAw/OplZvFw2j73wt095HITXjo6LVXcUtZkVibeYPoQl1D572wFiEJw/w== X-Google-Smtp-Source: AGHT+IHb48ygcH98kaP4EQC3nRfc8zqbfk5xlCQOYTiDsmnHVQurjp4g7uXbecxW46b0ErIZE43Y X-Received: by 2002:a92:c989:0:b0:366:9220:821f with SMTP id y9-20020a92c989000000b003669220821fmr2222566iln.7.1710495045999; Fri, 15 Mar 2024 02:30:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710495045; cv=pass; d=google.com; s=arc-20160816; b=YWRj1aSM6LyyhRo0qA/UeRDL+VizAYLX4p/6kCTEKatVMBaIaeJo8AaC/00UELhzVN YfOdESYsbE73iMRzlp/ZjWIxh1zXWdTWJ7dJujVPgp3SzHn+ZW+TQ3ykFG9bxB0QAMVv YmFmrQCxN2XUQ3hA/XIfh3uGoqwnD93PVB3ovMUEtCx9EdBz4onXij0Cl+ppuZqQ09Ww PC2R2sVPlCyUJlfLnzK279JuCXBlGtadBMhXWDadeW1y1vcsR5O/Dd4snW0YxIzKF1GR ck83CYd5KErAFmYD2JdODtFqw/S+wm4RIRWxwLH8R1SaVU+T6gR51QTsE4x+pELGGXP9 6KFA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=40Zr+nDs3kuA0ooVpJfDyIYkyX5ZFovqluzneizYYw8=; fh=E/nOOOH1vksB1p03aO03hmoJOT4Y/c6i5gbapTeOMOs=; b=RgzQx0gQ2F+/05B2jIH99XEm428J8q8mhVtl1Iwc7yp75RxYlQd56OZc7nmU1P6wtI 4Nyp8EnG119cRTSxRYZQ0w1RobZcP2SfRtfFOcRw2fiI/YFU+z/5SRFfsb6f+aLChg9F P0UKom031nIlHDlurX3dR6ADt/85kB4kD5zZhVzTUJF/Zlr08rD0rsuqBhNUkSp44K+R mmmk+lNgIJczx1UDtzBOaKlWzSD/475rb+oM+G8oTGDSuXMawRMfyo5oDkQKBmn+REhR 1Lmx8+/QHU/CPeuo9YQIabMMSPa+T2aF0hSyP/SXCyi+pkLqg2sLDLKz5rq9cn/0ZOzi AWVQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KgM7KuJS; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-104210-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104210-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 15-20020a63164f000000b005dc875b87ddsi2311025pgw.223.2024.03.15.02.30.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 02:30:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104210-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KgM7KuJS; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-104210-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104210-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A0D472840DE for ; Fri, 15 Mar 2024 09:30:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1CCB17C6B; Fri, 15 Mar 2024 09:30:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KgM7KuJS" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 EA67713AC5 for ; Fri, 15 Mar 2024 09:30:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710495040; cv=none; b=hVaThCbqCNnHkvmSKtUHgQYVtUVEU/uxKcmLRIoeEuQ3wFTvvLWOXrXurrfeOSwuOSdm42aguGhK+dCCoYD+mwAaSWStyd8e3vQDE4VYxfJSYjyaY6OgYzmbxe/o68g/b6B7Ce8C71CmZYDHUtXWWz6M+xDpe5C/+vKdrnl9MsI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710495040; c=relaxed/simple; bh=Au2WA24KOGm8FFAVvYolf7bzqfEfbKmRL43HKzXoRJc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=QbE1Isz92mmSYXWn128cNLC89zTtJuxxIOngacAn2udvAHcSR60Wb71FUCWlKNbxd7VVNg8jSsiZi4cSVO+yMUvyPyon0GyFtzHfI+0RUudK+PHtkB3ar1WEKcyncyk8mSHVGLiR2tb4oeepqGZBvFyriiaiqqqqvNNsQ/GPURQ= 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=KgM7KuJS; arc=none smtp.client-ip=170.10.129.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=1710495037; 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=40Zr+nDs3kuA0ooVpJfDyIYkyX5ZFovqluzneizYYw8=; b=KgM7KuJSe6Pb+OQF8DWvyuvqisCgEj6xCzDqH/uUij6M8QQ8zXQBtTF0V/tdQoVTQTO8H6 pq9E5H5UKi3HmCtE40J9hBa4YFdZ/ti2n6eu/qPsOgrc3IfGNLIHGS9v0hDaCghdG6P9L+ 2397Ob7XChcMXXBpi3VVOTOQLfDEtYI= Received: from mail-yw1-f199.google.com (mail-yw1-f199.google.com [209.85.128.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-635-kja3BsOvPcawcnEC_5AMmA-1; Fri, 15 Mar 2024 05:30:34 -0400 X-MC-Unique: kja3BsOvPcawcnEC_5AMmA-1 Received: by mail-yw1-f199.google.com with SMTP id 00721157ae682-60cd073522cso24790707b3.1 for ; Fri, 15 Mar 2024 02:30:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710495034; x=1711099834; 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=40Zr+nDs3kuA0ooVpJfDyIYkyX5ZFovqluzneizYYw8=; b=X1F4roT3S9mihQouV1cr9k9f+t8lRezFHgs1JS6328R0p3zVRqTbMqYRob55+ZMaZX u8l5nn6UPW166jFJcUb/V4fp6o83oPUtY4xkeArxz2amxKN3Sme55cCHkz4ZY+6aZZ9q 7yOzBOCBt2+l6QCjeG/tuS6dmueYuSroothwrnwUp0mqDWhwta/RRTEQA+iCP0o8YPe0 XdSsi67clxUMcdIqhdhAOuhjepDU8wWie1Q/fCSBr8MVPC5nfduCBln2RsuX1wwt9qOO AQ4tf/0D2knu1oKSwVq0bmKKYYTaLSZwWg5QJWgWuPi9BGrL2zgmEigAvrKpST0iexPQ TuVg== X-Forwarded-Encrypted: i=1; AJvYcCVbXNtlyq50jxxpv6Vj4jcrbtg/6Ffey1ic/y1h5CINLSP/vEPCrGXzyN7ZZuIFQUvy5MlotxGvbwxqF/ayFdD49XNxFyMoZ1N8XtgX X-Gm-Message-State: AOJu0Yy4o7HugObJBVMXbY2dDPMLng6hKVu65MaRF/GszyY4O20B1Xqh VfAijFgnP7lKPJVZ46RSrSkbqMmLn4j+tQDVyD3h6UHxeswsa7TYH5TME3Txw+fYFDgOOVty+mf 1WaOHTVnXZouzif2dEofkPZxXe1iA3e2F/9jJVmF4L2Xe59uN9LVxSv9uEg9nvQ== X-Received: by 2002:a81:7103:0:b0:60a:470:d1bb with SMTP id m3-20020a817103000000b0060a0470d1bbmr4538617ywc.20.1710495034241; Fri, 15 Mar 2024 02:30:34 -0700 (PDT) X-Received: by 2002:a81:7103:0:b0:60a:470:d1bb with SMTP id m3-20020a817103000000b0060a0470d1bbmr4538596ywc.20.1710495033828; Fri, 15 Mar 2024 02:30:33 -0700 (PDT) Received: from ?IPV6:2003:cb:c719:7700:ef08:112b:278d:7d90? (p200300cbc7197700ef08112b278d7d90.dip0.t-ipconnect.de. [2003:cb:c719:7700:ef08:112b:278d:7d90]) by smtp.gmail.com with ESMTPSA id x193-20020a81a0ca000000b00609eb9472a7sm649924ywg.41.2024.03.15.02.30.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Mar 2024 02:30:33 -0700 (PDT) Message-ID: <8bba487c-83ac-4c34-ba29-4ab0408bdfa6@redhat.com> Date: Fri, 15 Mar 2024 10:30:29 +0100 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] arm64/mm: adds soft dirty page tracking To: Shivansh Vij Cc: shivanshvij@loopholelabs.io, Catalin Marinas , Will Deacon , Joey Gouly , Ryan Roberts , Mark Rutland , Marc Zyngier , Andrew Morton , Kemeng Shi , "Mike Rapoport (IBM)" , "Matthew Wilcox (Oracle)" , Anshuman Khandual , James Houghton , Rick Edgecombe , Peter Collingbourne , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: 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/E8M7TE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A9ag5O3LLNk+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: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12.03.24 23:32, Shivansh Vij wrote: > Hi David, > > On Tue, Mar 12, 2024 at 09:22:25AM +0100, David Hildenbrand wrote: >> On 12.03.24 02:16, Shivansh Vij wrote: >> >> Hi, >> >>> Checkpoint-Restore in Userspace (CRIU) needs to be able >>> to track a memory page's changes if we want to enable >>> pre-dumping, which is important for live migrations. >>> >>> The PTE_DIRTY bit (defined in pgtable-prot.h) is already >>> used to track software dirty pages, and the PTE_WRITE and >>> PTE_READ bits are used to track hardware dirty pages. >>> >>> This patch enables full soft dirty page tracking >>> (including swap PTE support) for arm64 systems, and is >>> based very closely on the x86 implementation. >>> >>> It is based on an unfinished patch by >>> Bin Lu (bin.lu@arm.com) from 2017 >>> (https://patchwork.kernel.org/project/linux-arm-kernel/patch/1512029649-61312-1-git-send-email-bin.lu@arm.com/), >>> but has been updated for newer 6.x kernels as well as >>> tested on various 5.x kernels. >> >> There has also been more recently: >> >> https://lore.kernel.org/lkml/20230703135526.930004-1-npache@redhat.com/#r >> >> I recall that we are short on SW PTE bits: >> >> " >> So if you need software dirty, it can only be done with another software >> PTE bit. The problem is that we are short of such bits (only one left if >> we move PTE_PROT_NONE to a different location). The userfaultfd people >> also want such bit. >> >> Personally I'd reuse the four PBHA bits but I keep hearing that they may >> be used with some out of tree patches. >> " >> >> https://lore.kernel.org/lkml/ZLQIaSMI74KpqsQQ@arm.com/ > > If I'm understanding the previous discussion (https://patchwork.kernel.org/project/linux-arm-kernel/patch/20230703135526.930004-1-npache@redhat.com/) correctly, the core issue is that we actually do need to use a special SW PTE bit (like the PTE_SOFT_DIRTY that's in this patch) - but at the same time, the PTE bits are highly contentious so it would be ideal if we could reuse an existing bit (maybe one of the PBHA bits like you suggested) instead of creating a new one. > > Is my understanding correct? Yes, that matches my understanding. As Joey noted, the bit you chose is defined by HW and might soon get used. As Catalin wrote, some OOT patches might use the PBHA bits; although I am not sure what the latest state on that is and if we really should care about OOT patches. Maybe it would be good enough to allow driver use only in PFNMAP mappings, and simply not use the bit for softdirty/uffd-wp in there. I don't know much about PBHA, this [1] never got merged but is an interesting read. We are certainly short on sw bits in any case. There was recently some discussions around why soft-dirty tracking is not suitable (unfixable) for some cases, buried in previous iterations of [2]. The outcome of that was a new UFFD_FEATURE_WP_ASYNC mode as a replacement for soft-dirty tracking. So long-term, avoiding introducing soft-dirty tracking and instead supporting uffd-wp might be the better choice on arm64. [1] https://lkml.kernel.org/r/20211015161416.2196-8-james.morse@arm.com [2] https://lore.kernel.org/all/20230821141518.870589-1-usama.anjum@collabora.com/ -- Cheers, David / dhildenb