Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1384166lqe; Mon, 8 Apr 2024 07:31:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWpHo3I7sHtU3ojigVtwZRPxcYzpCEWPRfw9H9Uignkd/GmcCWXh6fUD6R+dpLsrLfjHjlKIxBGdqPkilLXtGnwhFc/3BSKB2/Izb3Grg== X-Google-Smtp-Source: AGHT+IEn0dwkCBZ/AGV6RW/s+flpcZpbnB2HJ35qaWJVYhfkSgQJ0HY9p80zds839/QDMI8M03tl X-Received: by 2002:a05:6a00:92a4:b0:6e6:5396:ce43 with SMTP id jw36-20020a056a0092a400b006e65396ce43mr11289851pfb.7.1712586675046; Mon, 08 Apr 2024 07:31:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712586675; cv=pass; d=google.com; s=arc-20160816; b=aZyoZpdrFsOgJF4p+gHL2JXt6taqF0qp/wN580/29L8sJEuU177M+ASiIToWYGlKn1 TUikrB5oE4Uadodx/CUKEHOMBR5G7iXNRZYUZUKl/apsw9ED+I6IOk4oQEFuKayzEiYd 7x+l8mJfsgSvXCep9/MQL10RS/3oUywCUOOUJlncQC0u4NcQiBTu1xruhBo+ygMoO3n+ yovXNZspLaSAfAKuRKg56Q/z/QPTrPidQt/2H+ru1eV7AsuWDuhcLln1uc75DCoM/OQC XCWMXiTju9BOWscbJPoMl9ls6mnDDnKrwsPxuhhhI1CxbUkuuTwbSzk32JMjIKQr5Mr2 kkBQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=rmNJpHW5Hyb1elegWpLMoq/S1yVvTDK8DJLj5yKd5mI=; fh=UBPqZS8piTNmAU3cDggA9r1jiZbUe0fnfFQ4fcf0raw=; b=Kf4HzCOEsSm0lwJnmq/nUdH49mjWrtXuLrovMzSkX476+1Mht7/MgOX//6TsRYSS2N Xy/eVqgJKfswyhBXUwWp7dcIQX8ZaK0C+4tgBk30crmkioemb6e7jUNUVozG9Eo9UdZX hHtdCT/zcIvvuZfKU7NKbgiAgwb+nufTU+yaHYfb+Lmheip4pNOmRFrCpYPnrCrLHXry CJ8D2jhzvZkTLtSoJZn9n07bL492XdshnFZpAzGhNWDZ7HS/b/lCAaB1hVEun8vqg4ma 4ROjC6LKJgvLmAN5W5m9GPVjVUqOdZnvGBEfVH6PaJrGLMi7GwR2BvD7kUOxL6zzdcH9 rjfQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jSkc+D6j; 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-135471-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135471-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id a12-20020aa78e8c000000b006e69fd974cfsi6319790pfr.278.2024.04.08.07.31.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 07:31:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135471-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jSkc+D6j; 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-135471-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135471-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 336B2B297BE for ; Mon, 8 Apr 2024 13:56:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 874F97CF29; Mon, 8 Apr 2024 13:56:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jSkc+D6j" 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 D9DD87CF1A for ; Mon, 8 Apr 2024 13:56:26 +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=1712584588; cv=none; b=Oyr90x3c+v5XpH/kToGhnkgn2q2QUx1R9NWc/NNMSYtBT1g0fGU64NstqDA4MiiZZLlGg3avi5mjiUoSq2iENje8qnUZyR9Qpr6g0u2PDdhs6EucZgMeYMS3okDZVVhNTnBp/8l46+a2BLONEvpUqpk9sTFQeOwXSy5CfzcJgS0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712584588; c=relaxed/simple; bh=Sv1lonJMRVR+UVuirFpH2YmZNDikOQMGGjjjY3UJLc4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=s/oP6RAPIWILCyrtsymsBdbHK0FnW8Khj2t9jJw9mpTksvnE5Kjyl3dQrJwxvW8MA5oA7iXyB+COty2EYuCADmypgX0WRuru/llB5V4AgVo8XsThnvhg5FTjGybyaF8QBbU2zzDKwmFWCIHKdDdTFfT740l0k0tMRgMdmz9xpzw= 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=jSkc+D6j; 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=1712584586; 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: in-reply-to:in-reply-to:references:references; bh=rmNJpHW5Hyb1elegWpLMoq/S1yVvTDK8DJLj5yKd5mI=; b=jSkc+D6jQ67V96JT6DTwSNSLxH1rUBZFARNc5R/BSk3H3V2rn8hWEMn53rcmm7qECEhwzv 4DlNbLLRfAPjUgG4ztQxrrxWKNMTWd3TDmrn7o+jk2HQhR30ZhaNTPBH5Cvke1QkWwDuGc aITJkULCtA6UgkkomweJs2wnjLj5alE= Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-447-Ww0uSmuPM5GPSWdZCx43uQ-1; Mon, 08 Apr 2024 09:56:24 -0400 X-MC-Unique: Ww0uSmuPM5GPSWdZCx43uQ-1 Received: by mail-ot1-f71.google.com with SMTP id 46e09a7af769-6ea10c8093eso129550a34.1 for ; Mon, 08 Apr 2024 06:56:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712584584; x=1713189384; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rmNJpHW5Hyb1elegWpLMoq/S1yVvTDK8DJLj5yKd5mI=; b=GwrM8F65Y2l6ImNipl2RxaryE838bZQ4pNUw2Wrnl7DmSC/uGsFj1IY16ykwGgokCe b8+slQRTje9d4xkx2vIsBiCJfrYa2N2mI+u/z01VI4aFyHn9tx6+arPItObUBqqi4j4C bccuyfH4AfK8stDbdUvBQEgpZzHfCFvGM62p7+ivOAozgZqvnII4qNEt/KDq5CBFDmuk kFRZzTlovEpM6SpSFTIaOTE6ACUhdS7TrUZ8FCCw0KeYXJsTRn84lKgrmRsFqkVchPyW 1uLZllm8aGwRzppWaGo0ksuC7OvlviG502hqYH1OKn7GRoRB1fO0sHgO0iPg6O4l3oF3 UTVA== X-Gm-Message-State: AOJu0Yye/eu6sWH5Pd7dbbqku26+WhX6rESTKdRZH7pOCC3IhOlbK/WU HVM7pG/2Z67JP6YzhIGEDbhQ54aFnXCAxtjftVFmfr6/3qMS0feiBgnhpSPxEwx5dv2xh19bBFE IGKtKS7lJpxwjrd8BRO+IbVR5k8HM2qPB/tu00MkJwbzyP7wsfbBYhDNTj0Tf1w== X-Received: by 2002:a05:6830:a5a:b0:6e7:592:87ab with SMTP id g26-20020a0568300a5a00b006e7059287abmr9702506otu.2.1712584583694; Mon, 08 Apr 2024 06:56:23 -0700 (PDT) X-Received: by 2002:a05:6830:a5a:b0:6e7:592:87ab with SMTP id g26-20020a0568300a5a00b006e7059287abmr9702473otu.2.1712584583118; Mon, 08 Apr 2024 06:56:23 -0700 (PDT) Received: from x1n ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id vw25-20020a05620a565900b0078d63baf516sm1301217qkn.129.2024.04.08.06.56.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 06:56:22 -0700 (PDT) Date: Mon, 8 Apr 2024 09:56:20 -0400 From: Peter Xu To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Marc Zyngier , Oliver Upton , Tianrui Zhao , Bibo Mao , Thomas Bogendoerfer , Nicholas Piggin , Anup Patel , Atish Patra , Sean Christopherson , Andrew Morton , David Hildenbrand , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Andrea Arcangeli Subject: Re: [PATCH 1/4] KVM: delete .change_pte MMU notifier callback Message-ID: References: <20240405115815.3226315-1-pbonzini@redhat.com> <20240405115815.3226315-2-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240405115815.3226315-2-pbonzini@redhat.com> On Fri, Apr 05, 2024 at 07:58:12AM -0400, Paolo Bonzini wrote: > The .change_pte() MMU notifier callback was intended as an > optimization. The original point of it was that KSM could tell KVM to flip > its secondary PTE to a new location without having to first zap it. At > the time there was also an .invalidate_page() callback; both of them were > *not* bracketed by calls to mmu_notifier_invalidate_range_{start,end}(), > and .invalidate_page() also doubled as a fallback implementation of > .change_pte(). > > Later on, however, both callbacks were changed to occur within an > invalidate_range_start/end() block. > > In the case of .change_pte(), commit 6bdb913f0a70 ("mm: wrap calls to > set_pte_at_notify with invalidate_range_start and invalidate_range_end", > 2012-10-09) did so to remove the fallback from .invalidate_page() to > .change_pte() and allow sleepable .invalidate_page() hooks. > > This however made KVM's usage of the .change_pte() callback completely > moot, because KVM unmaps the sPTEs during .invalidate_range_start() > and therefore .change_pte() has no hope of finding a sPTE to change. > Drop the generic KVM code that dispatches to kvm_set_spte_gfn(), as > well as all the architecture specific implementations. Paolo, I may miss a bunch of details here (as I still remember some change_pte patches previously on the list..), however not sure whether we considered enable it? Asked because I remember Andrea used to have a custom tree maintaining that part: https://github.com/aagit/aa/commit/c761078df7a77d13ddfaeebe56a0f4bc128b1968 Maybe it can't be enabled for some reason that I overlooked in the current tree, or we just decided to not to? Thanks, -- Peter Xu