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 38805C7618A for ; Fri, 17 Mar 2023 16:21:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230350AbjCQQVE (ORCPT ); Fri, 17 Mar 2023 12:21:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230214AbjCQQVC (ORCPT ); Fri, 17 Mar 2023 12:21:02 -0400 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EDC4C16D for ; Fri, 17 Mar 2023 09:21:00 -0700 (PDT) Received: by mail-pf1-x449.google.com with SMTP id t30-20020a056a00139e00b006228307e71bso2904695pfg.0 for ; Fri, 17 Mar 2023 09:21:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1679070060; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=7o24l6fiOGywvlphm2ivpMOdYXRizefraPoQnT9L//E=; b=Q6gE273gkihi8mp0lUkxiT8ezb4i1bDN5mWojYXiFSbCt1gdV+GSm119e73GRHWveU BX7oyl+NnMHXsGN0MoPCc5ADNRD9sMejdGVqQyg1BFFO+uKHTSqgfBCRkwOUFIMy3VRm e9vrQ82Ak82Vfdr9u6yGZj6llbXvEMnk70DuJ6YhG9BhuixwafqpMoEX7hMO/92chbuY bowzGc908/CczWahD6JUJnaErwDYpFxrNsajMOceS8iF7nwQloz2BK0RucdP6gGBXynX TFjqAiKOslA8OqK+bdesF3cFxwkvsaaR83lJqgaTZQjWZJ8ETLkbSOmv3RxQ5lOu3Quv FfgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679070060; 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=7o24l6fiOGywvlphm2ivpMOdYXRizefraPoQnT9L//E=; b=5wIrTuE4+jkvl2znL3ngt+C7xGxewuH2tpYC7sSFWLOKDP4J2CF2SHo6RF6R/PdfwD Tn6pLzwsbKYFFmPtbpIstIxoNZ+rF0HgyVSu+MT9v+YDAnvDJ+kZm7B2qiWl0RmJkDOj 1deQUuz171KcOXK864UUqSvO1V+6cltSPVn85kGOprccNIMub/nzYPCEUfFoO8rZyK6j l+aMZ30KRkFmLKRQhleYfW4pKpSnEqPdmUU7kqK74B8LbSZ87Lrx/hdSkAUSiXetITEL BD8xPh/euV6wcuch6s+9fwXkaMJLR2HkfYO0AxCaiArvKkKHWGYHPr1ex0nt6NyGAmK8 eCrQ== X-Gm-Message-State: AO0yUKVqwiU3ZSC5BWlutxVL6IZ0csFQrVSTYVHBAQZMVTL9BGVqlYHX eE+Kdf9SxnS2KG8BBlnLWey9rkL1G58= X-Google-Smtp-Source: AK7set/8zojERNqCXTgL/pFzMwr+KZPa+uB5aM7ijsiHAnfP0EdMkqyDGbo32YXbT/II5YP93V991/QrGl8= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:90a:17a7:b0:23d:34db:f5be with SMTP id q36-20020a17090a17a700b0023d34dbf5bemr2467306pja.4.1679070059931; Fri, 17 Mar 2023 09:20:59 -0700 (PDT) Date: Fri, 17 Mar 2023 09:20:58 -0700 In-Reply-To: Mime-Version: 1.0 References: <20230311002258.852397-1-seanjc@google.com> <20230311002258.852397-17-seanjc@google.com> Message-ID: Subject: Re: [PATCH v2 16/27] KVM: x86: Add a new page-track hook to handle memslot deletion From: Sean Christopherson To: Yan Zhao Cc: Paolo Bonzini , Zhenyu Wang , Zhi Wang , kvm@vger.kernel.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, Ben Gardon Content-Type: text/plain; charset="us-ascii" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 17, 2023, Yan Zhao wrote: > On Fri, Mar 10, 2023 at 04:22:47PM -0800, Sean Christopherson wrote: > > From: Yan Zhao > > > > Add a new page-track hook, track_remove_region(), that is called when a > > memslot DELETE operation is about to be committed. The "remove" hook > > will be used by KVMGT and will effectively replace the existing > > track_flush_slot() altogether now that KVM itself doesn't rely on the > > "flush" hook either. > > > > The "flush" hook is flawed as it's invoked before the memslot operation > > is guaranteed to succeed, i.e. KVM might ultimately keep the existing > > memslot without notifying external page track users, a.k.a. KVMGT. In > > practice, this can't currently happen on x86, but there are no guarantees > > that won't change in the future, not to mention that "flush" does a very > > poor job of describing what is happening. > > > > Pass in the gfn+nr_pages instead of the slot itself so external users, > > i.e. KVMGT, don't need to exposed to KVM internals (memslots). This will > > help set the stage for additional cleanups to the page-track APIs. > > > > Cc: Zhenyu Wang > > Signed-off-by: Yan Zhao > > Co-developed-by: Sean Christopherson > > Signed-off-by: Sean Christopherson > ... > > > +void kvm_page_track_delete_slot(struct kvm *kvm, struct kvm_memory_slot *slot) > > +{ > > + struct kvm_page_track_notifier_head *head; > > + struct kvm_page_track_notifier_node *n; > > + int idx; > > + > > + head = &kvm->arch.track_notifier_head; > > + > > + if (hlist_empty(&head->track_notifier_list)) > > + return; > > + > > + idx = srcu_read_lock(&head->track_srcu); > > + hlist_for_each_entry_srcu(n, &head->track_notifier_list, node, > > + srcu_read_lock_held(&head->track_srcu)) > Sorry, not sure why the alignment here is not right. > Patchwork just sent me a mail to complain about it. > Would you mind helping fix it in the next version? Ah, it's off by two spaces, should be hlist_for_each_entry_srcu(n, &head->track_notifier_list, node, srcu_read_lock_held(&head->track_srcu)) I'll get it fixed in the next version.