Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp496385rwe; Fri, 26 Aug 2022 08:44:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR5osILQUWcKNYOk1CesfRQuXSwQpLK3MrclUlqOJ2rpuWjS9lhP4RCQrpaXioRTdH+W22+z X-Received: by 2002:a17:907:2d91:b0:731:2aeb:793d with SMTP id gt17-20020a1709072d9100b007312aeb793dmr5644958ejc.212.1661528697895; Fri, 26 Aug 2022 08:44:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661528697; cv=none; d=google.com; s=arc-20160816; b=MBGnuLpkKpaCtpWMF8bSfc7L5MItP9IKFM63UtxVWE0GSxrbj3X4XT471yFtJ21yI8 NteRfuZbScKvcAD4MY3wfjmmkLjMW9+cY7SSTXFH+IRqZmXinhiTLvcPOFivwNb6U9El TKbMUChOw0kj+LDVTvM5xEpKsFXCs3OElXMYkTASn30f3TCWLe4KF5ooFCQbPP2OSUTm BFjD4/63QtbkLZ7DidcTtQykcQ+XpHiAOqWjvUqHkdHfItkqxPxiHBI/JZDs32/5385l AtQwyizhoOaf2vbhp0C9reOgEw4vnOowRkFpXOPKidH3FX8mrLsd5+dI5yB4Tg6KA9dc 6ejQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=JvAoW6FLc4i36t5qsVDds4VJn1VYQEbdw4Ur5OTLXvA=; b=cuUis/Ptg0z+1ukwveVN099C1F3My558zLGWPkd7GT8F2op/K57iODiVLRx5JKFEFG Fb2OYfZL9i6kkJS/3c1ymLVLiI33ok+s8vKDlELo4pv2sRh5IKeCONMueUbD7E5HMTep ayHnh/S23rashGc3aCQ7FESSsZscQM4JIvbvFWwV01YrYuJniwiX419jNYs20b4oKj8z G/lGfF3mVvJjIsY4VbRfJvOeTO5JrmdHiJu3nTXI/vVsfcA5/O/OTgx878Ae4XyQNYTU 1iTIQvESG18SkVy4UIR9SGqcbxheXSJGgv7HsDTsJuk5nPOzgBAsvAIYR4KbygrlVH/s RzOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NtVyh+M7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id he36-20020a1709073da400b00730f0106afesi1678976ejc.510.2022.08.26.08.44.32; Fri, 26 Aug 2022 08:44:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NtVyh+M7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344441AbiHZPaI (ORCPT + 99 others); Fri, 26 Aug 2022 11:30:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229922AbiHZP3n (ORCPT ); Fri, 26 Aug 2022 11:29:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 488F227FE5; Fri, 26 Aug 2022 08:28:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A6FD1B8319A; Fri, 26 Aug 2022 15:28:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43CC0C433C1; Fri, 26 Aug 2022 15:28:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661527734; bh=9sSbYtj6HrSqCiQbWoqDnd2lqwf/GjZezh1mnrUlOIo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NtVyh+M70kH2bajohPpEeO+dqnJzQ9HQupJyzrcFn50OC3kiLZ649xujbopMiHgP0 dd04NWb9xkhl5vwcX9pEz+tZNTXdoE4fzTnJkVPl/gtzDz9RxprHVg4uL1ZZna9iDZ LIiMoklsMJwqsAMubakiBrGULCW5pnIedneig2F0BrOFjE2hVLbQnsvN8HntK/FUWK KtO3QI/essFpL9JMjKf1JM2bx74fSFbirYfhslnPtbzNy/u6G9wRgngckG0UIVBiaJ HpGRdcaMfiCUHYpCwTeMtCpCY9o6UudtTjHDt1s8m/PCMS7/w+3TPCMOKSfUGVYF0S GLLDiSMn5nNxA== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oRbGO-005z5p-0G; Fri, 26 Aug 2022 16:28:52 +0100 Date: Fri, 26 Aug 2022 16:28:51 +0100 Message-ID: <874jxzvxak.wl-maz@kernel.org> From: Marc Zyngier To: Paolo Bonzini Cc: Oliver Upton , Gavin Shan , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, peterx@redhat.com, corbet@lwn.net, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, shuah@kernel.org, seanjc@google.com, drjones@redhat.com, dmatlack@google.com, bgardon@google.com, ricarkol@google.com, zhenyzha@redhat.com, shan.gavin@gmail.com Subject: Re: [PATCH v1 1/5] KVM: arm64: Enable ring-based dirty memory tracking In-Reply-To: <99364855-b4e9-8a69-e1ca-ed09d103e4c8@redhat.com> References: <20220819005601.198436-1-gshan@redhat.com> <20220819005601.198436-2-gshan@redhat.com> <87lerkwtm5.wl-maz@kernel.org> <41fb5a1f-29a9-e6bb-9fab-4c83a2a8fce5@redhat.com> <87fshovtu0.wl-maz@kernel.org> <87a67uwve8.wl-maz@kernel.org> <99364855-b4e9-8a69-e1ca-ed09d103e4c8@redhat.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: pbonzini@redhat.com, oliver.upton@linux.dev, gshan@redhat.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, peterx@redhat.com, corbet@lwn.net, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, shuah@kernel.org, seanjc@google.com, drjones@redhat.com, dmatlack@google.com, bgardon@google.com, ricarkol@google.com, zhenyzha@redhat.com, shan.gavin@gmail.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 26 Aug 2022 11:58:08 +0100, Paolo Bonzini wrote: > > On 8/23/22 22:35, Marc Zyngier wrote: > >> Heh, yeah I need to get that out the door. I'll also note that Gavin's > >> changes are still relevant without that series, as we do write unprotect > >> in parallel at PTE granularity after commit f783ef1c0e82 ("KVM: arm64: > >> Add fast path to handle permission relaxation during dirty logging"). > > > > Ah, true. Now if only someone could explain how the whole > > producer-consumer thing works without a trace of a barrier, that'd be > > great... > > Do you mean this? > > void kvm_dirty_ring_push(struct kvm_dirty_ring *ring, u32 slot, u64 offset) Of course not. I mean this: static int kvm_vm_ioctl_reset_dirty_pages(struct kvm *kvm) { unsigned long i; struct kvm_vcpu *vcpu; int cleared = 0; if (!kvm->dirty_ring_size) return -EINVAL; mutex_lock(&kvm->slots_lock); kvm_for_each_vcpu(i, vcpu, kvm) cleared += kvm_dirty_ring_reset(vcpu->kvm, &vcpu->dirty_ring); [...] } and this int kvm_dirty_ring_reset(struct kvm *kvm, struct kvm_dirty_ring *ring) { u32 cur_slot, next_slot; u64 cur_offset, next_offset; unsigned long mask; int count = 0; struct kvm_dirty_gfn *entry; bool first_round = true; /* This is only needed to make compilers happy */ cur_slot = cur_offset = mask = 0; while (true) { entry = &ring->dirty_gfns[ring->reset_index & (ring->size - 1)]; if (!kvm_dirty_gfn_harvested(entry)) break; [...] } which provides no ordering whatsoever when a ring is updated from one CPU and reset from another. M. -- Without deviation from the norm, progress is not possible.