From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Xu Date: Mon, 8 Apr 2024 09:56:20 -0400 Subject: [PATCH 1/4] KVM: delete .change_pte MMU notifier callback In-Reply-To: <20240405115815.3226315-2-pbonzini@redhat.com> References: <20240405115815.3226315-1-pbonzini@redhat.com> <20240405115815.3226315-2-pbonzini@redhat.com> Message-ID: List-Id: To: kvm-riscv@lists.infradead.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 From mboxrd@z Thu Jan 1 00:00:00 1970 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 DA7347CF25 for ; Mon, 8 Apr 2024 13:56:26 +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=1712584588; cv=none; b=A2m350JghXLUOyn9geZeg2DZKCdu/Gii4D7vSsWoruv7Ot0mCGe8Do/o/rYW6k74jPWmLht5zcICa2RdAA8PjHocaaRUSotCzKcjUhZkzUxq1oz/4s7/GY5pEfr0ShPQIede0hxG4ZWmLueOyWhzWfAsVVcxAe1n8b1J3HuAm1I= 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: In-Reply-To:Content-Type:Content-Disposition; b=INJCpkiif4mq7GoYezPWgNrahQODCrh4v02qu+CzEcpC6F1P0D05+tiaOjlhE1R79Se00tBLiMACDQr05LhbToWFNparPDBfyYmUr/pvNNssT+X/TNw7zkNt2B8a7Un6b+ELhnqufScn4uBzzy/LIzqb61rh1L7fCy5dLOXUUE0= 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.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jSkc+D6j" 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-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-604-XqOK1wTKOZGQP8as-YFUrg-1; Mon, 08 Apr 2024 09:56:24 -0400 X-MC-Unique: XqOK1wTKOZGQP8as-YFUrg-1 Received: by mail-ot1-f72.google.com with SMTP id 46e09a7af769-6ea20a966b0so46684a34.0 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=oNbXS8mRZGdoYgbjI9gGuJwnzC4TaK9JoPiPQBR8lA27KQsa5t3FJhdOqmUqYLkiFL 6w3sGsU7+OlZZ4lvxUiIWiEI9/9u6wDC23gmjpXGeFnsBor7B7C1jrH4FyJsCZcIeS1Y /5sfqoKnoJfLzfUtA7NXNUjkzvLtOlM+LhOHYPm9rZgjErxkqe/3K5ClLO3YUKO8a95E f9wAdHUs8ic7OawsqRJkMxowxgaavLUKW0O5GaDaqbKcrFA5nqIfIp+9JLjVFEz/dlIy Cje8Q0BMXySDIpPsirC2q140skmmW/2BrBwI87S6ZyEfwYr19RKsUtxwqWSH250H5K4O rCaw== X-Forwarded-Encrypted: i=1; AJvYcCXKPMd+ZiVMsXJOsXvOnKtsamWQqjB2Mzojp4rFhhPlNbSLJEKXOBbw+1+dShrjP1C3+rIgu42kbxWZKe04dUaCQYJHuxs+ X-Gm-Message-State: AOJu0YxtGn3byTRXek6XsORsnIkoS3hMiYdSmZAbHh7gW/VwuRgOnkZW SlqOJbvo8cKmSIShmC9MsGOqGDoJqs28FqETgYpruK2fQreTlvcXc8suELgzap47BmtChhqjnRf uj4tNbZvm6L8l9J1pH63E0EsnNSxRBFjplajJfzA6IvXkFX4f6LVktQ== X-Received: by 2002:a05:6830:a5a:b0:6e7:592:87ab with SMTP id g26-20020a0568300a5a00b006e7059287abmr9702525otu.2.1712584583704; Mon, 08 Apr 2024 06:56:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/6cZVOu40ZE5XkeceEvB5GWIk5ESL9MdZGK/RmwIM5NG0Lyufyd1ejET8K1FRMeVweFzXgg== 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: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20240405115815.3226315-2-pbonzini@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline 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 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D9521C67861 for ; Mon, 8 Apr 2024 13:57:19 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=jSkc+D6j; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=jSkc+D6j; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4VCrHy1D4Zz3vXk for ; Mon, 8 Apr 2024 23:57:18 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=jSkc+D6j; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=jSkc+D6j; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=peterx@redhat.com; receiver=lists.ozlabs.org) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4VCrH42B4Lz2xdp for ; Mon, 8 Apr 2024 23:56:30 +1000 (AEST) 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= 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-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-581-0KsBXrq8M1Wfb3H9Ed0ClQ-1; Mon, 08 Apr 2024 09:56:24 -0400 X-MC-Unique: 0KsBXrq8M1Wfb3H9Ed0ClQ-1 Received: by mail-ot1-f72.google.com with SMTP id 46e09a7af769-6ea20a966b0so46685a34.0 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=ui9Xs2nzNrpAzvLAHL1vR7QSf7LxJ4nuNFmCx6/Uf70or88MVqZgdy2Wo/4bwUaUEl ftcRPZVhWAX551oqZTbG6XFO9riY7oNeiTVtvMaB/m5LjWaqHazFEgE8XOnpjybJ9Eoa RH8EC390Do6KW2CBUYRYUazZvZt3sBBr9aGAFRSzqXolwefEsqHfPVCidlBmQIhnPjpi 68RCpRu7KpnWhESWSwPwtTkDicFjnRRAyBli7IZk5tHCJKghCiCDsjyWgHwdRuThBJR8 FNw/FDQcREABEN83RBIfRXbd2veC0XaETIgYa8Ui89ntTfwOuPS58cqqlWd9SqRh/1RE LC1Q== X-Forwarded-Encrypted: i=1; AJvYcCV0jX2ieB7zFkcZW3Ugr/52tuAhNAYk4q3tD2IfuqD1N7i8o3zGZxNG//9mvk4b5H8Xdh8DtmeOwEZjtEbHjmLghyGylz6sHqvK3rV8tw== X-Gm-Message-State: AOJu0YxZVrvG+eDafNVLsBIM7/faMOzjm+UJ3gHLKtrSKAVRtLZ7i3Tn jzzstEaOv/EHbCnN6I4y3hpO4AM6PagZbdTe/7cDeAGhSmAsGAz/sh6sdk+qOJ4WUy3NFG9iGJp CeuTE++kXXt2+Ua4idrMATqXD3Dd8aCZU8L/5CoeSjQxlohy2ZIo9dEeh0bIeXCs= X-Received: by 2002:a05:6830:a5a:b0:6e7:592:87ab with SMTP id g26-20020a0568300a5a00b006e7059287abmr9702510otu.2.1712584583696; Mon, 08 Apr 2024 06:56:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/6cZVOu40ZE5XkeceEvB5GWIk5ESL9MdZGK/RmwIM5NG0Lyufyd1ejET8K1FRMeVweFzXgg== 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 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> MIME-Version: 1.0 In-Reply-To: <20240405115815.3226315-2-pbonzini@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, David Hildenbrand , linux-mips@vger.kernel.org, linux-mm@kvack.org, Andrea Arcangeli , Marc Zyngier , linux-trace-kernel@vger.kernel.org, Nicholas Piggin , Bibo Mao , loongarch@lists.linux.dev, Atish Patra , kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Thomas Bogendoerfer , Sean Christopherson , linux-kernel@vger.kernel.org, Oliver Upton , linux-perf-users@vger.kernel.org, kvm-riscv@lists.infradead.org, Anup Patel , Andrew Morton , Tianrui Zhao , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4A993CD128A for ; Mon, 8 Apr 2024 13:56:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DCOkJHqk3RWyA1WCvEkAKSEHq2IFCk9vlmxIkJkIFig=; b=2OwNuLGQaKhe+d SZ8MsrGVWRQy5Km2qQRh6VlETTYg7oTZJ8ukf5gFdJ+K/fUoR2ku4VtuTPOdaCTuqpEc+57kVZO01 dKYydbk68EbE6/CGjTXQFF0yAvkPKloPXvw14YDhlKsZIcqF1ZiKXdPFg0whyAf8hdxDfkJ+Y9r4O jFnGFR8PYtQkeRyZupkP1UGeFEujqww7jXNy/U/70MkO/XtCJXiujUbVp382m5ynWJg4oEnJeinsz OAf8d+Yd68l6751zxkpBDa1mCrGzKgIdrxnVciA1ql5QnP5kffRX+5IdK/RtIVHQovtedSv/Ghx9o ETUsfCaxBV0OJx0m3t2g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rtpUL-0000000FnAO-45wc; Mon, 08 Apr 2024 13:56:46 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rtpUF-0000000Fn5Q-3h3m for linux-arm-kernel@lists.infradead.org; Mon, 08 Apr 2024 13:56:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712584585; 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=YknS0oZnF7n6p+YJDgLkjAUF/d5DU8J3xGo2qEWOu1Bers3mCY8BKYoRgMlPuhw4hypGPc K8cj+M2M7przg0Q6oC5Jma/GDs/840REKdyR4dnR0HWRO88geWwKBj6iXvsHbE6CVdhUQo uUsWii6QyJcjnHe260gnYCQ3zr4o63s= 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-529-JXFjDyQOOvGFe5LQjMOjLw-1; Mon, 08 Apr 2024 09:56:24 -0400 X-MC-Unique: JXFjDyQOOvGFe5LQjMOjLw-1 Received: by mail-ot1-f71.google.com with SMTP id 46e09a7af769-6ea20a966b0so46683a34.0 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=sXgg3+0z2GOWhTd9jFKpg/HEmdrrydGLBHDpZ+vDRO54y6LVBgTjGM25+baXR7tG0k MuppLDlEXOMxNhE9BoR6jw688mTPwsnQjK9LbfQQX4lxKmor9fUet0OILmbnQqfLMbJC PqMD1uc2scqCvlixvuzmyo/x2T68iNS0yAm8tPi7YviYi6Za646hK7nDnaGnAgqv5YOg WxAH1+Is/7c3qC05/Zy5otLfS/K/onKtuCTwmzUWFSYG1JNKVl1fHFpU8uby5dKVKE0l RJeoWkgyZs1kiXrKmiCT/nTPMNJ9K7V85+4SmBHRfV/j5btfYRboIhZ6NHv2MdZ4RQYp DB0A== X-Forwarded-Encrypted: i=1; AJvYcCWqbfECbCl3BO46QK0S00JByfT44o3AynAip/5OjfdT6UQEZ93kSvcBlJq9aGtT3aI8Lkqkm54CUoNaDlWkjYBZcWTxoMsHlIbYZ8WlunqXbMAzZT4= X-Gm-Message-State: AOJu0Yw7fCh0Q7fHl3E3Ujfh3/lXmM6rB0jORgsbj9k2RvKZ8tTYZGmn t/zFd0BBUVgEmT7u1EPoKg3MlzIWXnPjNEn43lquHYfW0jkAEXuxzUytmgaSmlp/xAtuH2Kk3JJ 0PFpIY7ZMZPtrUex64r9Zgwn4QYKL+qANYuBolp5EoaHG8Xqphip8jhc0mOGPIsF6FuCLe4ha X-Received: by 2002:a05:6830:a5a:b0:6e7:592:87ab with SMTP id g26-20020a0568300a5a00b006e7059287abmr9702512otu.2.1712584583697; Mon, 08 Apr 2024 06:56:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/6cZVOu40ZE5XkeceEvB5GWIk5ESL9MdZGK/RmwIM5NG0Lyufyd1ejET8K1FRMeVweFzXgg== 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> MIME-Version: 1.0 In-Reply-To: <20240405115815.3226315-2-pbonzini@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240408_065640_066389_6AD4803B X-CRM114-Status: GOOD ( 17.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel