Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2872997rdh; Mon, 30 Oct 2023 10:02:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEt7jsM97SBJdBoB1ZcFsxHXgM1RvYWTL1/47HGbsqoHqy71STILGcr98F5XPt8PQ9weNM4 X-Received: by 2002:a05:6a20:e686:b0:17b:4f43:afe1 with SMTP id mz6-20020a056a20e68600b0017b4f43afe1mr7855099pzb.55.1698685340937; Mon, 30 Oct 2023 10:02:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698685340; cv=none; d=google.com; s=arc-20160816; b=j+i83y6HxvMZJ1nDfXP9ivnHJpAbX22NHenKrQhnqnw9AXyxt3ehUXphI8f7vK5ZO4 BJQpRypV2GRirjeYtNBdfP7o7n6EZf25r4OitXTwNBERTQ/eOrTpmH56tjlaaYFbNWxU k5KELrdhIhQ+mb1IfeXFdPJcaKZGTBXhUk3PQft3hRkHAEeS9feE/CNhGIrXy7ulJQek mP92LwCbsSiWLh0hqR5UiSA1hiFnulI3HZeHkm59VPM9VRGgpEL94Mb+JpO2ZLEwUPKV geo6MUb+wDCEAywn0SFtbOGXBZxTsilIlMgN6FdEYha0QJJG1+exSA7hKf/iWCLzvUEw BkaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=ySiJbXtvuo/ap347BrtctuG5UsffPvyxiWszBOWPpzU=; fh=dd1qk0TuCSuPGH/MegaJXeJhuoyH532DckGUO8GW++U=; b=ape7TWcsE7e/1Q1PulfVJzBFgK+pM18IYPBgBSwEVfPohqqU+CU39dNDDAYvxikU8l 7ocsYKMOwp3moqy9s0qTKs4emgc6DhRxNOASv/xmFHVsGlsdvMo8ncPNO0taixy5z4qf dQpCJtR8Xs50mthhieBxf9ZYg2pPy1t1hYIbCDakj9PcIW1yFXV5JCWrKQBgR6DvW+Lb LnXw4wXwDVw6pz63zZVlh1rDGFPJ8bXOd8KLRGkOg0zHaV0VZucq03qcN1MGcJ/EAEx5 /CuZaLJDFk/Mi7yvWqjdHMB02zNv7bK3lXi+2BUNC7mA5JvVuoTOzY/HC9w7mFHwQ26I opVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=epivPqVf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id h71-20020a63834a000000b005abe19be7e9si5271903pge.543.2023.10.30.10.02.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 10:02:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=epivPqVf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 32D9780A5670; Mon, 30 Oct 2023 10:02:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232800AbjJ3RCC (ORCPT + 99 others); Mon, 30 Oct 2023 13:02:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbjJ3RCB (ORCPT ); Mon, 30 Oct 2023 13:02:01 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D83FBD for ; Mon, 30 Oct 2023 10:01:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698685275; 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; bh=ySiJbXtvuo/ap347BrtctuG5UsffPvyxiWszBOWPpzU=; b=epivPqVfgnCJNYBmfemuPQlMjAd95iLt+9n8CgLLQ/pKpU0NypxZ/DO+2SurWx944YA724 iqev2rzocDx9N1Uf0sqdSyyqg2NkfZP7xJReXA9UF7vtthWZgvH1MaAZmJUst1ZpKKFkaG qnCfa8RljIqAwhokyDP/AB3zAt/y3lA= Received: from mail-oa1-f71.google.com (mail-oa1-f71.google.com [209.85.160.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-623-rcKSiQtPOteuQJLX9yzOzg-1; Mon, 30 Oct 2023 13:01:11 -0400 X-MC-Unique: rcKSiQtPOteuQJLX9yzOzg-1 Received: by mail-oa1-f71.google.com with SMTP id 586e51a60fabf-1e9a324c12fso6460442fac.2 for ; Mon, 30 Oct 2023 10:01:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698685267; x=1699290067; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ySiJbXtvuo/ap347BrtctuG5UsffPvyxiWszBOWPpzU=; b=nTAvslUVXUhuVXIIuQZ/I6Jmtk1qV2Xcd6suhKv+cCirx+LEACDB697lnQ0vsF0Gss Jj+US9FlqJfIc5hsHDRpXGhj7dKZaLL0Wch9Mh166hy9TXDodQDXXSIr45ussgXRuczU ls9613g/099yjPETHtPHzjhqv9ETENGYbymhp+7YMu3pz3sM+HpSYDI61BPkQ6mdaR4/ gJzvU54+3mvAvgP12x7oguw/4vhAvk7awZ/rn68+VcAXCSq3q2ZC2vxu00Njub8Dem0l mC8ISgapBSRLuSye02hOQCdY1OmsPHZenaXafx1SNI2aP6jImrNVHirZ+M0cv478U6pI vAJA== X-Gm-Message-State: AOJu0YzB6gVsOWyBdO32n+l6UyY+iAC+ZQJK26s3ahRuBiZ6FBKuH6o7 DIcprymzyk8DKyYP2rdg3zKvGXJgrrrNq0J/U29J1fPa9ji1t7pFLkaqNnGh6iPOlbckVmXyYQ4 91ACTyLwdQBj+r4TH1nWPaIegzOMC2UAuMMWLpXW5 X-Received: by 2002:a05:6871:5c45:b0:1ea:3f79:defb with SMTP id os5-20020a0568715c4500b001ea3f79defbmr14807560oac.52.1698685265978; Mon, 30 Oct 2023 10:01:05 -0700 (PDT) X-Received: by 2002:a05:6871:5c45:b0:1ea:3f79:defb with SMTP id os5-20020a0568715c4500b001ea3f79defbmr14807416oac.52.1698685264406; Mon, 30 Oct 2023 10:01:04 -0700 (PDT) MIME-Version: 1.0 References: <20231027182217.3615211-1-seanjc@google.com> <20231027182217.3615211-4-seanjc@google.com> In-Reply-To: From: Paolo Bonzini Date: Mon, 30 Oct 2023 18:00:49 +0100 Message-ID: Subject: Re: [PATCH v13 03/35] KVM: Use gfn instead of hva for mmu_notifier_retry To: David Matlack Cc: Sean Christopherson , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Viro , Christian Brauner , "Matthew Wilcox (Oracle)" , Andrew Morton , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Xiaoyao Li , Xu Yilun , Chao Peng , Fuad Tabba , Jarkko Sakkinen , Anish Moorthy , Yu Zhang , Isaku Yamahata , =?UTF-8?B?TWlja2HDq2wgU2FsYcO8bg==?= , Vlastimil Babka , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A . Shutemov" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 30 Oct 2023 10:02:18 -0700 (PDT) On Mon, Oct 30, 2023 at 5:53=E2=80=AFPM David Matlack = wrote: > > On 2023-10-27 11:21 AM, Sean Christopherson wrote: > > From: Chao Peng > > > > Currently in mmu_notifier invalidate path, hva range is recorded and > > then checked against by mmu_notifier_retry_hva() in the page fault > > handling path. However, for the to be introduced private memory, a page > ^^^^^^^^^^^^^^^^^^^^^^^^ > > Is there a missing word here? No but there could be missing hyphens ("for the to-be-introduced private memory"); possibly a "soon" could help parsing and that is what you were talking about? > > if (likely(kvm->mmu_invalidate_in_progress =3D=3D 1)) { > > + kvm->mmu_invalidate_range_start =3D INVALID_GPA; > > + kvm->mmu_invalidate_range_end =3D INVALID_GPA; > > I don't think this is incorrect, but I was a little suprised to see this > here rather than in end() when mmu_invalidate_in_progress decrements to > 0. I think that would be incorrect on the very first start? > > + } > > +} > > + > > +void kvm_mmu_invalidate_range_add(struct kvm *kvm, gfn_t start, gfn_t = end) > > +{ > > + lockdep_assert_held_write(&kvm->mmu_lock); > > Does this compile/function on KVM architectures with > !KVM_HAVE_MMU_RWLOCK? Yes: #define lockdep_assert_held_write(l) \ lockdep_assert(lockdep_is_held_type(l, 0)) where 0 is the lock-held type used by lock_acquire_exclusive. In turn is what you get for a spinlock or mutex, in addition to a rwlock or rwsem that is taken for write. Instead, lockdep_assert_held() asserts that the lock is taken without asserting a particular lock-held type. > > @@ -834,6 +851,12 @@ void kvm_mmu_invalidate_end(struct kvm *kvm, unsig= ned long start, > > Let's add a lockdep_assert_held_write(&kvm->mmu_lock) here too while > we're at it? Yes, good idea. Paolo