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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C948CE79D8 for ; Wed, 20 Sep 2023 13:56:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236537AbjITN4J (ORCPT ); Wed, 20 Sep 2023 09:56:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236533AbjITNzi (ORCPT ); Wed, 20 Sep 2023 09:55:38 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 769A1DD for ; Wed, 20 Sep 2023 06:55:07 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5924b2aac52so89054627b3.2 for ; Wed, 20 Sep 2023 06:55:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695218106; x=1695822906; 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=0APReAt4bNnnd5kx+NahuCYj0tgbUgwxY6/xmv3q1x8=; b=qYN6MLIfTj4icmmBpIkd0WLhJxjSRWRnp5CVrZ5zO23Hc6SEWKaxnDv2NJItwfDuFQ 6RVvMGhZPLFVWocauiDyLryXn63S6KPTLdALA3Qsdgqj3uuPB/A2o/4ptf1HYp9bQI/0 1cYLmwlGz2SJqRrIPPncawpZ4aDzCTJ8sW2gL6tfKGnzilsZLa6El4ASlO1PaFkjNm/O bYywfPO/0UW/nevxIlFfp0aeaozdgulhoho9Sa50zXYSvg9W6zOTkgKB/8FODKp3Zw2Z dwA7/f8AInE7LDVv1jVJABSqsl1VCpa8fzDiXuUQzjW4V/dFydMGpeKFv2KS3ghLlvrS QzZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695218106; x=1695822906; 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=0APReAt4bNnnd5kx+NahuCYj0tgbUgwxY6/xmv3q1x8=; b=RzRaYkBXrAgiktUOfUVjR5GgoaSA9u+X2e7PKFLTzzlr68y2Ed66/y8e5va7Lz9SWS l084oW8BNNuRInOJHxbwNzd6bVQfwBIcSgZtopVfTMz6Z8Rie/yJ0UyOyktZeLpETGnt 7Aq46kHQ8Bswj0I2AO9LLOSVf26DC9lWVxtunbivWxUGq/wohSTguxoV0w8PBisD4EeD 1/OtjQC2vKq9SCmKNvEil+bKFlFf84fsageoXuI79CsVtcrKDEWEIrmXv271YWYaMgSu c8EenUjOQrr4wR6c9ZfhVlklneYAZptoNy+2w7fFw6SUcA5YdgFW6iQMyN6i3QYLvcQI 6Ekg== X-Gm-Message-State: AOJu0YxaIVLYJyWMk6xiKZR8PfC7S1k902soaume8umBj240inN+ue9x hCM6evsxh0M1ZIX80ThWsvKQmK0/Dn4= X-Google-Smtp-Source: AGHT+IHuQ24Hy0wlZqpKThD2hndi3rYWapG+J/d1L/ai4z7W/k7rmZdxNg2zwHr4zmYKJTJyjaSKmjFgB/U= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:ae57:0:b0:59b:ee27:bbe9 with SMTP id g23-20020a81ae57000000b0059bee27bbe9mr35901ywk.9.1695218106527; Wed, 20 Sep 2023 06:55:06 -0700 (PDT) Date: Wed, 20 Sep 2023 06:55:05 -0700 In-Reply-To: Mime-Version: 1.0 References: <20230914015531.1419405-1-seanjc@google.com> <20230914015531.1419405-3-seanjc@google.com> Message-ID: Subject: Re: [RFC PATCH v12 02/33] KVM: Use gfn instead of hva for mmu_notifier_retry From: Sean Christopherson To: Xu Yilun Cc: Paolo Bonzini , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Matthew Wilcox (Oracle)" , Andrew Morton , Paul Moore , James Morris , "Serge E. Hallyn" , 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-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Chao Peng , Fuad Tabba , Jarkko Sakkinen , Anish Moorthy , Yu Zhang , Isaku Yamahata , 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="us-ascii" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 20, 2023, Xu Yilun wrote: > On 2023-09-13 at 18:55:00 -0700, Sean Christopherson wrote: > > +void kvm_mmu_invalidate_range_add(struct kvm *kvm, gfn_t start, gfn_t end) > > +{ > > + lockdep_assert_held_write(&kvm->mmu_lock); > > + > > + WARN_ON_ONCE(!kvm->mmu_invalidate_in_progress); > > + > > if (likely(kvm->mmu_invalidate_in_progress == 1)) { > > kvm->mmu_invalidate_range_start = start; > > kvm->mmu_invalidate_range_end = end; > > IIUC, Now we only add or override a part of the invalidate range in > these fields, IOW only the range in last slot is stored when we unlock. Ouch. Good catch! > That may break mmu_invalidate_retry_gfn() cause it can never know the > whole invalidate range. > > How about we extend the mmu_invalidate_range_start/end everytime so that > it records the whole invalidate range: > > if (kvm->mmu_invalidate_range_start == INVALID_GPA) { > kvm->mmu_invalidate_range_start = start; > kvm->mmu_invalidate_range_end = end; > } else { > kvm->mmu_invalidate_range_start = > min(kvm->mmu_invalidate_range_start, start); > kvm->mmu_invalidate_range_end = > max(kvm->mmu_invalidate_range_end, end); > } Yeah, that does seem to be the easiest solution. I'll post a fixup patch, unless you want the honors.