From patchwork Fri Nov 18 21:15:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 22509 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp412004wrr; Fri, 18 Nov 2022 13:15:55 -0800 (PST) X-Google-Smtp-Source: AA0mqf4QuMTCH7OpEK3YPDd1/l30yp22VzjaDNIwWztSWXs7RMYCWVGtgCzukYh+y2CEBLEayqX8 X-Received: by 2002:a62:18c7:0:b0:572:725f:338d with SMTP id 190-20020a6218c7000000b00572725f338dmr9765939pfy.1.1668806154808; Fri, 18 Nov 2022 13:15:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668806154; cv=none; d=google.com; s=arc-20160816; b=g8g5tKFInI/UrzEhHTQJNw2nKNorgJOmucpacJLU1ZceWaFJYG4Pd9KmqrfSnprK0Q HnC1/d7rhVeuY1hQOy+nrgmTqQgCwHLmngIJFUN6Fp7Fp4nP+OwdawncXogep722jq+I UXxgs/m+tItohz7/69JhHKSylGYYgUFkj5iM6ScsoNu9JFu/S4semZYX8JNQrY+GThqf 4gLimqjrp/Xl7GnN+QmHf8+YwvMownU2y/c42thG/fPkBF5OjpAcctD7hS03kcYBFftr iuwpHsJAiLtNqSUD1FYw3yQqgACFcggQ+DViuF5Xxn1xD4pdVx28MtYHgpVCEPk8GREc pGgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xCYUGaupX5cvs453r6y2KLObby9QVEfhtajAIprPxEc=; b=Rzahi+SIa+HyhN2M9MbVNZKs0vFavIuEkE8IiY+huZ1DrfpP8nYH16dP5IqsywWGep I9rE84dA8M0VJEV2PWgwV1UyZ8S6f3jdbLyGkHJAbbiZ46Ms5s5brEGiSwg9d6pe1zhe uhnAnUt12NzOHU6RK+CfH0g6sNiMlQPbDSX0aTlQnv2hlGJQ1RP9kq37+hpVBufaiOn7 /BmiTW+XL4aNfsylAznf5Rl2ENc1oU8wRAvKNV/DlinPyRlKgzEb2A31ccmbvA2z3itD gVOpxLtUS68JZuKmb2ls/EbXEm0hTIw0WHAYkNJdDYUzvKl73SmLn4Xqf1/diwopj8iw ejVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Fx49S7yw; 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=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z16-20020a63e110000000b00476a08c5d87si4321189pgh.713.2022.11.18.13.15.40; Fri, 18 Nov 2022 13:15:54 -0800 (PST) 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=@linux.dev header.s=key1 header.b=Fx49S7yw; 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=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230398AbiKRVP2 (ORCPT + 99 others); Fri, 18 Nov 2022 16:15:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230131AbiKRVP0 (ORCPT ); Fri, 18 Nov 2022 16:15:26 -0500 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 450D492B52; Fri, 18 Nov 2022 13:15:25 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1668806123; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xCYUGaupX5cvs453r6y2KLObby9QVEfhtajAIprPxEc=; b=Fx49S7ywYMGdFD/E2m89wuPcBkOOaNariIsk6xwrf0cC8m9A1le4R7byvtN8e9Zws+iYs4 PFX0XSDRyjA9eUO3YO0WryXgbm9Y/7dQX3OuDzGoihEHDD+vQVGQFlxiokm4Edj+bLtO/k TRm4SvgtwTlNem4WVM9PGCB4mGf+ZC4= From: Oliver Upton To: Marc Zyngier , James Morse , Alexandru Elisei , Paolo Bonzini , Shuah Khan Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kvmarm@lists.linux.dev, Sean Christopherson , Gavin Shan , Oliver Upton , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] KVM: selftests: Have perf_test_util signal when to stop vCPUs Date: Fri, 18 Nov 2022 21:15:02 +0000 Message-Id: <20221118211503.4049023-2-oliver.upton@linux.dev> In-Reply-To: <20221118211503.4049023-1-oliver.upton@linux.dev> References: <20221118211503.4049023-1-oliver.upton@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749870082645439687?= X-GMAIL-MSGID: =?utf-8?q?1749870082645439687?= Signal that a test run is complete through perf_test_args instead of having tests open code a similar solution. Ensure that the field resets to false at the beginning of a test run as the structure is reused between test runs, eliminating a couple of bugs: access_tracking_perf_test hangs indefinitely on a subsequent test run, as 'done' remains true. The bug doesn't amount to much right now, as x86 supports a single guest mode. However, this is a precondition of enabling the test for other architectures with >1 guest mode, like arm64. memslot_modification_stress_test has the exact opposite problem, where subsequent test runs complete immediately as 'run_vcpus' remains false. Co-developed-by: Sean Christopherson Signed-off-by: Sean Christopherson [oliver: added commit message, preserve spin_wait_for_next_iteration()] Signed-off-by: Oliver Upton Reviewed-by: Gavin Shan --- tools/testing/selftests/kvm/access_tracking_perf_test.c | 8 +------- tools/testing/selftests/kvm/include/perf_test_util.h | 3 +++ tools/testing/selftests/kvm/lib/perf_test_util.c | 3 +++ .../selftests/kvm/memslot_modification_stress_test.c | 6 +----- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/kvm/access_tracking_perf_test.c b/tools/testing/selftests/kvm/access_tracking_perf_test.c index 76c583a07ea2..942370d57392 100644 --- a/tools/testing/selftests/kvm/access_tracking_perf_test.c +++ b/tools/testing/selftests/kvm/access_tracking_perf_test.c @@ -58,9 +58,6 @@ static enum { ITERATION_MARK_IDLE, } iteration_work; -/* Set to true when vCPU threads should exit. */ -static bool done; - /* The iteration that was last completed by each vCPU. */ static int vcpu_last_completed_iteration[KVM_MAX_VCPUS]; @@ -211,7 +208,7 @@ static bool spin_wait_for_next_iteration(int *current_iteration) int last_iteration = *current_iteration; do { - if (READ_ONCE(done)) + if (READ_ONCE(perf_test_args.stop_vcpus)) return false; *current_iteration = READ_ONCE(iteration); @@ -321,9 +318,6 @@ static void run_test(enum vm_guest_mode mode, void *arg) mark_memory_idle(vm, nr_vcpus); access_memory(vm, nr_vcpus, ACCESS_READ, "Reading from idle memory"); - /* Set done to signal the vCPU threads to exit */ - done = true; - perf_test_join_vcpu_threads(nr_vcpus); perf_test_destroy_vm(vm); } diff --git a/tools/testing/selftests/kvm/include/perf_test_util.h b/tools/testing/selftests/kvm/include/perf_test_util.h index eaa88df0555a..536d7c3c3f14 100644 --- a/tools/testing/selftests/kvm/include/perf_test_util.h +++ b/tools/testing/selftests/kvm/include/perf_test_util.h @@ -40,6 +40,9 @@ struct perf_test_args { /* Run vCPUs in L2 instead of L1, if the architecture supports it. */ bool nested; + /* Test is done, stop running vCPUs. */ + bool stop_vcpus; + struct perf_test_vcpu_args vcpu_args[KVM_MAX_VCPUS]; }; diff --git a/tools/testing/selftests/kvm/lib/perf_test_util.c b/tools/testing/selftests/kvm/lib/perf_test_util.c index 9618b37c66f7..ee3f499ccbd2 100644 --- a/tools/testing/selftests/kvm/lib/perf_test_util.c +++ b/tools/testing/selftests/kvm/lib/perf_test_util.c @@ -267,6 +267,7 @@ void perf_test_start_vcpu_threads(int nr_vcpus, vcpu_thread_fn = vcpu_fn; WRITE_ONCE(all_vcpu_threads_running, false); + WRITE_ONCE(perf_test_args.stop_vcpus, false); for (i = 0; i < nr_vcpus; i++) { struct vcpu_thread *vcpu = &vcpu_threads[i]; @@ -289,6 +290,8 @@ void perf_test_join_vcpu_threads(int nr_vcpus) { int i; + WRITE_ONCE(perf_test_args.stop_vcpus, true); + for (i = 0; i < nr_vcpus; i++) pthread_join(vcpu_threads[i].thread, NULL); } diff --git a/tools/testing/selftests/kvm/memslot_modification_stress_test.c b/tools/testing/selftests/kvm/memslot_modification_stress_test.c index bb1d17a1171b..3a5e4518307c 100644 --- a/tools/testing/selftests/kvm/memslot_modification_stress_test.c +++ b/tools/testing/selftests/kvm/memslot_modification_stress_test.c @@ -34,8 +34,6 @@ static int nr_vcpus = 1; static uint64_t guest_percpu_mem_size = DEFAULT_PER_VCPU_MEM_SIZE; -static bool run_vcpus = true; - static void vcpu_worker(struct perf_test_vcpu_args *vcpu_args) { struct kvm_vcpu *vcpu = vcpu_args->vcpu; @@ -45,7 +43,7 @@ static void vcpu_worker(struct perf_test_vcpu_args *vcpu_args) run = vcpu->run; /* Let the guest access its memory until a stop signal is received */ - while (READ_ONCE(run_vcpus)) { + while (!READ_ONCE(perf_test_args.stop_vcpus)) { ret = _vcpu_run(vcpu); TEST_ASSERT(ret == 0, "vcpu_run failed: %d\n", ret); @@ -110,8 +108,6 @@ static void run_test(enum vm_guest_mode mode, void *arg) add_remove_memslot(vm, p->memslot_modification_delay, p->nr_memslot_modifications); - run_vcpus = false; - perf_test_join_vcpu_threads(nr_vcpus); pr_info("All vCPU threads joined\n"); From patchwork Fri Nov 18 21:15:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 22511 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp416385wrr; Fri, 18 Nov 2022 13:28:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf7yWSl8zALBiumKHx+wXSrsEVvMdKWvC7vRolfzyOnhIZN/fhnSZuuKJtLco3FFcFDnV23R X-Received: by 2002:a62:19c9:0:b0:56b:f7ca:9cf9 with SMTP id 192-20020a6219c9000000b0056bf7ca9cf9mr9864955pfz.68.1668806888010; Fri, 18 Nov 2022 13:28:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668806888; cv=none; d=google.com; s=arc-20160816; b=AXi6Fp7MkGoyEN7WThOxa4yTibUPm8CmN8BpFdVnHkWIcFZr677qh1Gg6dwp65Saeg 5m+SB0+SVhK1O/ALpV6bmS4urZ5t4EDwQna3Sn0fqCiYgKpmB1D2g9trOa0ziFJ2hr+M B4m2EAOxBNdiehQQcpmtEbbnRXuJ8g9sQUPdF8pgiZAeSV/OgHRiyK8ZXV/9WuyIJgVy y628UBTELi1e8S5cM0awpvAIBGrupMoTUcsXo9W15SkT+S6hFSC0zV/Mq64CyrHHOD9+ fW9Bak/ADxvpV/5d7do5Q5GrMiSXpgxlNmpbHPiunUsAovWl59/Git368hHsGv41meZk Haaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SoeoR80PV/I/rJnKhi6LFTTPG99Qc3nASuSBHKetOac=; b=ew+HUcXuD1k2MqzGPDY4ZyHOx/Pj6w6yLjAjJq+3EMcF+ZYc06Xcjr3bLjXt2+gA1j mPSBc1050VeaTwCX/KiXV6rD2Rw2TbhNamlJftNVML9DKLUQKXk5LAe3NFNKiHwbVgE1 2hl5s6fO2L9ozsC0Trq4WiwmyBUhdXdGzFOsAPosijqx7qIacvaERatZ7Ngxc9REEHG2 Ztq+juW58kIBJzY9hhxGndHYl0cXNy6LKOlnBYXOWlEjrjJLgBa9nVeqq+ANsy4DUCCn vwMifyLQh0oO8RBvnCG1Osya009kFCA/jBnN350UPIutKu77h3pxhs3OPBUa6zX3kIC/ GOQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=WDtooANP; 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=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020a1709027fc800b0017bcea4e6b6si4657207plb.234.2022.11.18.13.27.49; Fri, 18 Nov 2022 13:28:07 -0800 (PST) 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=@linux.dev header.s=key1 header.b=WDtooANP; 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=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230475AbiKRVPb (ORCPT + 99 others); Fri, 18 Nov 2022 16:15:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230409AbiKRVP3 (ORCPT ); Fri, 18 Nov 2022 16:15:29 -0500 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7338C942D7; Fri, 18 Nov 2022 13:15:28 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1668806126; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SoeoR80PV/I/rJnKhi6LFTTPG99Qc3nASuSBHKetOac=; b=WDtooANP+yRelVErrNeqgt4cQi0k6omVWrwHBibo8mwlz9/dnJiYituBfqMEkU+R1Yu6Iw 0ktpj8yIhA0vkeXZxLFP14S3tuskayzXcaksLQ67965SQ5aNXKfpZg1g1ZxXcv9ngGjhlA 0KTgkhxFawEcjevHowItlrlVog+/Ou4= From: Oliver Upton To: Marc Zyngier , James Morse , Alexandru Elisei , Paolo Bonzini , Shuah Khan Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kvmarm@lists.linux.dev, Sean Christopherson , Gavin Shan , Oliver Upton , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] KVM: selftests: Build access_tracking_perf_test for arm64 Date: Fri, 18 Nov 2022 21:15:03 +0000 Message-Id: <20221118211503.4049023-3-oliver.upton@linux.dev> In-Reply-To: <20221118211503.4049023-1-oliver.upton@linux.dev> References: <20221118211503.4049023-1-oliver.upton@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749870851538269313?= X-GMAIL-MSGID: =?utf-8?q?1749870851538269313?= Does exactly what it says on the tin. Reviewed-by: Gavin Shan Signed-off-by: Oliver Upton --- tools/testing/selftests/kvm/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile index 0172eb6cb6ee..4c0ff91a8964 100644 --- a/tools/testing/selftests/kvm/Makefile +++ b/tools/testing/selftests/kvm/Makefile @@ -156,6 +156,7 @@ TEST_GEN_PROGS_aarch64 += aarch64/psci_test TEST_GEN_PROGS_aarch64 += aarch64/vcpu_width_config TEST_GEN_PROGS_aarch64 += aarch64/vgic_init TEST_GEN_PROGS_aarch64 += aarch64/vgic_irq +TEST_GEN_PROGS_aarch64 += access_tracking_perf_test TEST_GEN_PROGS_aarch64 += demand_paging_test TEST_GEN_PROGS_aarch64 += dirty_log_test TEST_GEN_PROGS_aarch64 += dirty_log_perf_test