Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp200419lqp; Thu, 4 Apr 2024 10:31:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVVcrDlQSyEzsWBLtNuJSgna7Rnrlx4lDCTGJ1FP9u/NAtDqfobXjd3Laj2LITvJpMByXSDg2Paua1UoBcIjAa8HNGg2oVUjAXG6O2S0A== X-Google-Smtp-Source: AGHT+IH8gjq/5AON7OmybkGAT0UuO50AY7kC/feujppf6iT+zO6p0P4mBHs8o/THwmNsOnl06fDi X-Received: by 2002:a05:6102:6c9:b0:479:d846:588a with SMTP id m9-20020a05610206c900b00479d846588amr185219vsg.2.1712251878710; Thu, 04 Apr 2024 10:31:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712251878; cv=pass; d=google.com; s=arc-20160816; b=iAEXTHor3YkORUUkEMZQWBpQVUsiUmWu9e1aLxKthLlZyENHTIxF9R8eVsTyBZagi+ sGBx9kDhdgWodVVIHtk2+SB5Cv+emj9cN2AY+Z/0hoBgv/Y3r3rtw6OkASZBvrnBiq5m 5/OhrH9TCMEkEHlpH4P9ttG80CNpGBqsLBc5tZR5RSqn3E1NTJ7yDxNn7xQg5hdhUBUs nb70ngfn6acsF0W2un7bmNciF3y2wsYM09u8iYwskL4Wra/ElrMxNgY5notxhAHXNfLP SEyz/2tCxLW+ozC4+jVZM79JR69o5wY/CIFBuj56WzNJnNKVr+WfsE/yrfe/EnL+aPdI 76/Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=Eo/SkK+TlNjp4T3bV1tp4QVg1mYvFjNY2jevZHmIKp0=; fh=7qG+I/hyqi4e+necEPl8KM+5oGzmgo/9P1r5gqOuKLQ=; b=doHRIphVbFT7MdFfbQkMr/ez/OE0Yv1Nax47JXKBaxHVjaPBC6tRSCna9+KTKYQgwM S+aJSk0El7QSL7afbw7guMPcf/1gthlGuvTmgJNljkimTTntTS9rsk5IYKGml8LFAVBn 0VYViq514p0V03YmhjJ10VKhMYZLCXfktX4Ho/0wzP1uxav3l666ESFx2vivsQ1pqWOx ceBsH70JZATQQxXFhx6NPz5V7er8qnD2fyNv6mihZhpd+c+5lASI91QoAjcvPgiUWmUj RumN9lCS16gYUXP9l1lOhkpj2D7iKuuW3d74pkxWU8I81kb56pGTyXGPezzS5q4Ujj75 i7WA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=r7UDiK71; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-131888-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131888-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id w20-20020a056102305400b00472ab895f8bsi2450813vsa.550.2024.04.04.10.31.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 10:31:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131888-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=r7UDiK71; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-131888-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131888-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 487201C2327C for ; Thu, 4 Apr 2024 17:31:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 564D712DDA4; Thu, 4 Apr 2024 17:31:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="r7UDiK71" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07D1112D1ED for ; Thu, 4 Apr 2024 17:31:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712251868; cv=none; b=mbF+9r9sVMUh/rDE3wCBegHFoWSJKjeaDU0Q/YabElgZTp7KbhvqP4gyCG9vr9YUejkKAhdUvb4Obg3lyb8MttRlxb16i3Lo9o8znUMIkvnpqQGOt+lr5AnLsJPBoAmmfBgUGNX66jctgsPx6ntOZlIujL69q4166AuTsNjc3XY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712251868; c=relaxed/simple; bh=9+nALMnWqMtktQiKdj6h/JJPaQ9s+Le7L/1VmoPzmqY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=pKR8tl2n4y0MpYJojh9vE9+FjT6rKa0rnwuquK950XcZxzLNWcVvmA43Dl7f5rvLnE8RMTF9Qx+kFkMCjCUSixDOVAHlR3TIgZoZLbDwa4fmCm32nIxI6chavdivYtx5f/+JqlaIhpxAlnGGJP8nD7lPewsz16DGRfdDM5cjK/Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=r7UDiK71; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-615073c8dfbso24259207b3.1 for ; Thu, 04 Apr 2024 10:31:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712251866; x=1712856666; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Eo/SkK+TlNjp4T3bV1tp4QVg1mYvFjNY2jevZHmIKp0=; b=r7UDiK71LM6DruG/FsIRIuqNzoW6t90LwF4qzeciOZZCTsSmReW6k1JHrPqJdQ9TDt oVxF6pmJrh3E9bEo5cXjj1lJmw4wpqotgNwCzFE4g4ms9wwvCeB3UfF4woGfJriTSUI2 NNqSA9hvOLJBAjNe94PdfBnpOyk32fCRp+wK+40StG2SNVY9d8xhzfRvtZThS5UagBuX YCrfxYKSuzzy7c8JUkd3t6cVsRz34mEyStgNKzSdCS22WC0wQv6N5RrYURAnpCjbGCoY 0dmD9+BojCjl/zTMutkoM1FZltaN21BlLPqpjw+z11oEOSZSAxnEjUwUdVsK8zUn6Y/i Os8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712251866; x=1712856666; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Eo/SkK+TlNjp4T3bV1tp4QVg1mYvFjNY2jevZHmIKp0=; b=T7s0I6Rjrlb9zg4XGQY8/FhOWwBYLbsal5Y2PRmfZjQlb2UMc97bdkCiKZyIz+uadd lw23fhgoSuQ7I+P/o6cIvY8jiQYHJCavoB4WJRT3nZcNKswZGp2YTbDxVdZxDKG0e5ym VX982WHXU1rz7hjTfkBvMmpo+QSt6vq1HdSeVoQSr+jKwDKoB5DFaMwmFLkoTkhBkmMe Ua/aEYTGCVXIZFu9ASqi/ou6C/pMEqo2Ki/0CgxatsBOGI0Gb/GiAXZme5q65wcKNzxM AMvM8aimJusfcgzuo6e35y979pl/f+9vToMuLJI/xGXk7TBN1L+8TRjV5FcGe+RaByQK WZiQ== X-Forwarded-Encrypted: i=1; AJvYcCW0FA2tFLcHfIjBR2vP+1hp5lBUex8EOqvPbFP/7fghNTIo5tvgc6QzDVpQoqTItuv84VAVyYI3oVZfx5vwZ1nTkw+YyHduryG3dvav X-Gm-Message-State: AOJu0YwNzHxXcYlljRJcLQQ5B5pCRmZ6Ac8zpFLMVoZvlMhTZjax3gIj SxhKu/ozDnUI7K7u7HtvH/kOBxmX0P6k5eCpQukAulNs1KWEI/gCMmSclwbSAiQgFFz2i5cSP1A A+g== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:2d05:b0:dc2:2ace:860 with SMTP id fo5-20020a0569022d0500b00dc22ace0860mr20394ybb.2.1712251866075; Thu, 04 Apr 2024 10:31:06 -0700 (PDT) Date: Thu, 4 Apr 2024 10:31:04 -0700 In-Reply-To: <42dbf562-5eab-4f82-ad77-5ee5b8c79285@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240320005024.3216282-1-seanjc@google.com> <4d04b010-98f3-4eae-b320-a7dd6104b0bf@redhat.com> <42dbf562-5eab-4f82-ad77-5ee5b8c79285@redhat.com> Message-ID: Subject: Re: [RFC PATCH 0/4] KVM: x86/mmu: Rework marking folios dirty/accessed From: Sean Christopherson To: David Hildenbrand Cc: David Matlack , Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, David Stevens , Matthew Wilcox Content-Type: text/plain; charset="us-ascii" On Thu, Apr 04, 2024, David Hildenbrand wrote: > On 04.04.24 00:19, Sean Christopherson wrote: > > Hmm, we essentially already have an mmu_notifier today, since secondary MMUs need > > to be invalidated before consuming dirty status. Isn't the end result essentially > > a sane FOLL_TOUCH? > > Likely. As stated in my first mail, FOLL_TOUCH is a bit of a mess right now. > > Having something that makes sure the writable PTE/PMD is dirty (or > alternatively sets it dirty), paired with MMU notifiers notifying on any > mkclean would be one option that would leave handling how to handle dirtying > of folios completely to the core. It would behave just like a CPU writing to > the page table, which would set the pte dirty. > > Of course, if frequent clearing of the dirty PTE/PMD bit would be a problem > (like we discussed for the accessed bit), that would not be an option. But > from what I recall, only clearing the PTE/PMD dirty bit is rather rare. And AFAICT, all cases already invalidate secondary MMUs anyways, so if anything it would probably be a net positive, e.g. the notification could more precisely say that SPTEs need to be read-only, not blasted away completely.