From patchwork Thu May 20 08:22:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 12269477 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 060A2C43460 for ; Thu, 20 May 2021 08:44:05 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B933A611AB for ; Thu, 20 May 2021 08:44:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B933A611AB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljeHj-00041U-Vy for qemu-devel@archiver.kernel.org; Thu, 20 May 2021 04:44:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50652) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljdxm-0005RV-Ol for qemu-devel@nongnu.org; Thu, 20 May 2021 04:23:29 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:45022) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ljdxf-0001Xl-1R for qemu-devel@nongnu.org; Thu, 20 May 2021 04:23:24 -0400 Received: by mail-wm1-x32a.google.com with SMTP id y184-20020a1ce1c10000b02901769b409001so4671242wmg.3 for ; Thu, 20 May 2021 01:23:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9/dX3PC3FCiO5p7uuZf1RyQ9MDHL5qIlrYK5aAJJIeY=; b=FVTer/RJhNN4vLa0lm9lSSm7+lL5wAyRn5BQZ5IG2RCgGcX4aJixkFw66Y5EXMb/k5 qYgDs0CfQFN9e+zzPYWOEgZ68AV8Xf1YHo9TXFVDVTScswyinz7Royv2T34dgVhYELOp nKVehjm/7F/+VcJE74u+cS/h4ZPuUW8ZfwrIJAldtCLWMgftmOLj9KMsEJZyY7P2o2mD m09y59BPkTlsANTVJX+QCYOdNc7X6EVKn/l8r2UqP0cIAgLtDPW8KqDuNKgTNUCJoB+G 9dVinB4GtznXaLpwtTfuZNNx1N1jI9TRRnNNcud7MZTdfW95Ue8V280KL5g6FCWoxk0y ygZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=9/dX3PC3FCiO5p7uuZf1RyQ9MDHL5qIlrYK5aAJJIeY=; b=V2KRZAbtUPUvqZrVk2IJOcRZ6q1Ynt+tB0FhEspklQZcWgUfCGZUvUGrp1FulHgt5f aQSsgsC+66PYGTYsehcbJS07fsryBkLE5GUN9XonvwdrwZa0+PqThv9tDhlrf6VUNGq1 RH7TYeMhhf5fJcspfXSWsZnjw/oNTialQLxzoYcbl60rQc3PwwP05r402KjIUac1sZly jBVSv8CuYtvHun7X4Mf4BR9XSYPhqHvQSCHC94SNyFnjGeePts1NWzn57/3v1THXmHhp RAnzrA2cFjG5yw+ReVtWTz8lsUuwoAQVGQxccSp0Ub0nsKo8BuMxTxu9+shW0+eVMUGS Io8g== X-Gm-Message-State: AOAM5336Zc253K4aWV4XA1yIQzWNiB0J+pZpmV3kJuWlMCo1Ilhr1xf7 Ny2elm5X1Pkd6PB8gZEDQpiK5Z5+KjYkfA== X-Google-Smtp-Source: ABdhPJzoWqW+BUvItzVLsj8dsAj6wmxcY4QRbN3eEh37FE0+fLnLcatdFaLzVPiCoyh2TTTjOHog5A== X-Received: by 2002:a05:600c:da:: with SMTP id u26mr2346821wmm.128.1621498988402; Thu, 20 May 2021 01:23:08 -0700 (PDT) Received: from avogadro.redhat.com ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id v10sm2603506wrq.0.2021.05.20.01.23.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 01:23:08 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 15/26] KVM: Simplify dirty log sync in kvm_set_phys_mem Date: Thu, 20 May 2021 10:22:46 +0200 Message-Id: <20210520082257.187061-16-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520082257.187061-1-pbonzini@redhat.com> References: <20210520082257.187061-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=paolo.bonzini@gmail.com; helo=mail-wm1-x32a.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Xu Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Peter Xu kvm_physical_sync_dirty_bitmap() on the whole section is inaccurate, because the section can be a superset of the memslot that we're working on. The result is that if the section covers multiple kvm memslots, we could be doing the synchronization for multiple times for each kvmslot in the section. With the two helpers that we just introduced, it's very easy to do it right now by calling the helpers. Signed-off-by: Peter Xu Message-Id: <20210506160549.130416-7-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 7031dd4250..0ba6d48120 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1161,7 +1161,8 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml, goto out; } if (mem->flags & KVM_MEM_LOG_DIRTY_PAGES) { - kvm_physical_sync_dirty_bitmap(kml, section); + kvm_slot_get_dirty_log(kvm_state, mem); + kvm_slot_sync_dirty_pages(mem); } /* unregister the slot */