Message ID | 20230421165305.804301-1-vipinsh@google.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1226230vqo; Fri, 21 Apr 2023 10:21:00 -0700 (PDT) X-Google-Smtp-Source: AKy350bKvLj13ugRTaLAhJ0xsY5QY+tBmiV1Ke5+irK836bBOmHyr4IO6NwF6+NO2Kw1SHO+XkYj X-Received: by 2002:a05:6a20:8e1b:b0:d9:77f7:d62e with SMTP id y27-20020a056a208e1b00b000d977f7d62emr8815465pzj.36.1682097660265; Fri, 21 Apr 2023 10:21:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682097660; cv=none; d=google.com; s=arc-20160816; b=sn+2o9Z3j/F67xgETcvga71EZqLUFzoXHdMFmIJsiiRepOBikj4XlYzt4wFT/nhGJt tM9MB7V4k5AS/BcygqtdfxERpQKF44rWInCJ4kOdZBhpnl9/nemy24xr1jRhTSZIIt3Z VwomYRcKnvDKE/gCFbMDFCDPq7l4jSEXo+rFjffCLd0dNhbGL7DAhw31oKxlNBeUJITH FnkfLj7ZHmpmHw1JZlMmO1/gDaOOUjCNtzJvEDa6G703M4dzvN5nQ7B32bMc8rJWhXrP ekH6V2zc/0qPrpaiaRGPlGHnBWegSTYdG1bBbpf/hl5ZKjBQtl8pHrI1FJkIMWOJySrQ ftkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=Bpz9GCI4OFqr9DlnIkg8fh50O4zOZAPmw/GqyWI1sUY=; b=sVFipfzQ8XoOwXmu0eYz1da4cnOSZYPoUu4NeBksWYWFLxJ26SM+U4IzanuXA3TVpx pJaSA3PVE8BRuG2FvPWPP+KbmdK7Mxe8s6rInyDDjWhRO5cFONQbxE2z0cshnPWdrjxo P23iawqNKz/ldrJOKuZgYrYRHdZQD1IxUeRctZvFWbI5IbSMZpKpVrGx1ynKVFN8WWSJ Rdy0D6xIwu2qSiUgSPRAWX2TqoJZo8U/zyVwYnzMzIctL8VD/SYdia6kox+1iOXcWb7Y 8v5Yqw1omX69O6ugAQjoLsr+ZId4U2XWKWo0tbrFgNp1DyYwVoc/RkokcBk2Y/d1yhww 8DqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=DGn7gCyk; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z19-20020a63e113000000b00521e4b138fcsi4957136pgh.148.2023.04.21.10.20.43; Fri, 21 Apr 2023 10:21:00 -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=@google.com header.s=20221208 header.b=DGn7gCyk; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233281AbjDUQ7g (ORCPT <rfc822;cjcooper78@gmail.com> + 99 others); Fri, 21 Apr 2023 12:59:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233241AbjDUQ73 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 21 Apr 2023 12:59:29 -0400 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97EAE15A0C for <linux-kernel@vger.kernel.org>; Fri, 21 Apr 2023 09:59:08 -0700 (PDT) Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-63b5e149dc2so1757607b3a.0 for <linux-kernel@vger.kernel.org>; Fri, 21 Apr 2023 09:59:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682095989; x=1684687989; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=Bpz9GCI4OFqr9DlnIkg8fh50O4zOZAPmw/GqyWI1sUY=; b=DGn7gCykqxE1wl2tXEHxtzFbscSQI+JYs1BOyBXnwpOUa0v37O5EWPBn/ZgODYtQlN ucm2bl+oRpYs66hkDH2OsTMMwYnJjHqmfL1Gfoz55eaPsC+KkP0XkEqAwZ6rs8pd6Rpz FUqoTwNDb4fdpZO/bATUsOleiUawwODIJsv2oBaDLHov514nHeOp01TeHl5biXsvmD+B drB6ioShN8gZ615eSTgzwj90uRL3MtckEF9+PdrDWulnCx0CuSxldhcUkAHan3z7jBnk tHJsR2+7JQcAF/jPDdgXfTyng+EIcBFq/MixhtIbZMOElAUZCqnEM9rZEPv1BqgcbQ1G Ek/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682095989; x=1684687989; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Bpz9GCI4OFqr9DlnIkg8fh50O4zOZAPmw/GqyWI1sUY=; b=k+whUXXKeUMVfKcH2P2fvRQASSGtnZlzUzcZGHx0ERBTXlemcj/4PqNJ5I5suQK7TJ AMkCOBs74bbx+IyGbFKvLzMTbAU97iQK4EAQl0MNvdzYX3aQX8dls0MrqlHCqdHwL87J XEt1jNVg0NZZeMEeLOD2A+d7u8yVxhkSJxVir7pOGY/KMSoWJccifgl3nOR7MO11Et4w SjOv/KmCPX6Q2G25LkLGTnFem0sNAJh6hEYWu1k1G66RNkI+7UtPTzDM4ejl5iRHNPVj V0Z/pqsFUkZkIWymBJclfeCxobBCy/1GffFkLIIvH2jaC+OpO1GXEBSnVGBPiUDq8fDk bh2Q== X-Gm-Message-State: AAQBX9eWkX6UGxQsl5V+yFBLV5if0362UFNNM1rsYxTn8jD4VrEyoI5E hG/TureP0fRIQWXqYdQbhFG7qutTmMsU X-Received: from vipin.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:479f]) (user=vipinsh job=sendgmr) by 2002:a05:6a00:b94:b0:63d:397a:8fdd with SMTP id g20-20020a056a000b9400b0063d397a8fddmr2339440pfj.0.1682095989138; Fri, 21 Apr 2023 09:53:09 -0700 (PDT) Date: Fri, 21 Apr 2023 09:52:56 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230421165305.804301-1-vipinsh@google.com> Subject: [PATCH 0/9] KVM: arm64: Use MMU read lock for clearing dirty logs From: Vipin Sharma <vipinsh@google.com> To: maz@kernel.org, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, chenhuacai@kernel.org, aleksandar.qemu.devel@gmail.com, tsbogend@alpha.franken.de, anup@brainfault.org, atishp@atishpatra.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, seanjc@google.com, pbonzini@redhat.com, dmatlack@google.com, ricarkol@google.com Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kselftest@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Vipin Sharma <vipinsh@google.com> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763807236339694351?= X-GMAIL-MSGID: =?utf-8?q?1763807236339694351?= |
Series |
KVM: arm64: Use MMU read lock for clearing dirty logs
|
|
Message
Vipin Sharma
April 21, 2023, 4:52 p.m. UTC
This patch series improves guest vCPUs performances on Arm during clearing dirty log operations by taking MMU read lock instead of MMU write lock. vCPUs write protection faults are fixed in Arm using MMU read locks. However, when userspace is clearing dirty logs via KVM_CLEAR_DIRTY_LOG ioctl, then kernel code takes MMU write lock. This will block vCPUs write protection faults and degrade guest performance. This degradation gets worse as guest VM size increases in terms of memory and vCPU count. In this series, MMU read lock adoption is made possible by using KVM_PGTABLE_WALK_SHARED flag in page walker. Patches 1 to 5: These patches are modifying dirty_log_perf_test. Intent is to mimic production scenarios where guest keeps on executing while userspace threads collect and clear dirty logs independently. Three new command line options are added: 1. j: Allows to run guest vCPUs and main thread collecting dirty logs independently of each other after initialization is complete. 2. k: Allows to clear dirty logs in smaller chunks compared to existing whole memslot clear in one call. 3. l: Allows to add customizable wait time between consecutive clear dirty log calls to mimic sending dirty memory to destination. Patch 7-8: These patches refactor code to move MMU lock operations to arch specific code, refactor Arm's page table walker APIs, and change MMU write lock for clearing dirty logs to read lock. Patch 8 has results showing improvements based on dirty_log_perf_test. Vipin Sharma (9): KVM: selftests: Allow dirty_log_perf_test to clear dirty memory in chunks KVM: selftests: Add optional delay between consecutive Clear-Dirty-Log calls KVM: selftests: Pass count of read and write accesses from guest to host KVM: selftests: Print read and write accesses of pages by vCPUs in dirty_log_perf_test KVM: selftests: Allow independent execution of vCPUs in dirty_log_perf_test KVM: arm64: Correct the kvm_pgtable_stage2_flush() documentation KVM: mmu: Move mmu lock/unlock to arch code for clear dirty log KMV: arm64: Allow stage2_apply_range_sched() to pass page table walker flags KVM: arm64: Run clear-dirty-log under MMU read lock arch/arm64/include/asm/kvm_pgtable.h | 17 ++- arch/arm64/kvm/hyp/nvhe/mem_protect.c | 4 +- arch/arm64/kvm/hyp/pgtable.c | 16 ++- arch/arm64/kvm/mmu.c | 36 ++++-- arch/mips/kvm/mmu.c | 2 + arch/riscv/kvm/mmu.c | 2 + arch/x86/kvm/mmu/mmu.c | 3 + .../selftests/kvm/dirty_log_perf_test.c | 108 ++++++++++++++---- .../testing/selftests/kvm/include/memstress.h | 13 ++- tools/testing/selftests/kvm/lib/memstress.c | 43 +++++-- virt/kvm/dirty_ring.c | 2 - virt/kvm/kvm_main.c | 4 - 12 files changed, 185 insertions(+), 65 deletions(-) base-commit: 95b9779c1758f03cf494e8550d6249a40089ed1c