Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5799526rdb; Wed, 13 Dec 2023 22:44:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGsHsesxL+uTeCDjWvq6z5cQOgTttpg0qoTBXfuekCCun24hlVTYyvN2CUpfnqXgGsR6r1+ X-Received: by 2002:a05:620a:7f9:b0:77f:2e1:5168 with SMTP id k25-20020a05620a07f900b0077f02e15168mr8409686qkk.60.1702536289890; Wed, 13 Dec 2023 22:44:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702536289; cv=none; d=google.com; s=arc-20160816; b=zx8QNXlmIPNN34q/QEh9vHIKoJAfnrmAxmYw8Wf1IxhiW0WC+E+badkOpgije3RhU1 ioWr3uYdbw/WF+KCH8A9ZZHgEG7VSVLLM9TL8GWngTVxUec5BS/mBQ3k64NMGS+9ROgb cA6gNrGVZ2hxIBICQZJkZrzE0ticSvMAvXqlQfpLpvsumlwUlSc+xJIsZ0s4/uUBnMT6 2mUxjRiCyt7zesnOv3wvXtzT4DwEIfWeDukChgFxpTszfdHGCPcfRq+ouh1ZrLYT+/ja zk275PzqPVX9fXYdh/lRJVIlsubH8yOOiOalto6yRgDaP2CD/bEzlKTG0sPa8azWMbqw ayPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=gxtiy01D8WpTYbLcMD+XHOmT3EOIKEJTAtmXTdX58vM=; fh=2n6JbDh+kFm5bKXTkzr9Au4sq5kZzF/rV58oDrmHx6I=; b=Xle48nvkVjZ+gX7rAYzWPELb+7nALzFDfP6A4PgyzdZhkDEIU7kVuZGZHki+by74bq gG+ZDHrw5VmW1G4pQw9JdnmMgm+xN5ARlgXlaPKwH9to1AizY9ZFjSeDDr/s9cJvARWT 1Dze2tnl8QgLKB/6o1XK5bfAZiMZVr3IWGj6SqDn3g0jMmYjWeRaaOR1f9kXt7kJuKOp JCVYdmvkmMj8P300m9H8MmXTRIc3V+AHvjSwGmZwcVGTEmXp14lp3zJEUzhjq3QO6VJT c2ePzhur7I5Nos9z7uLgPgaMR8n6JD/AUaxgG1RlsbmmKO1O5M+rZsNrIFQnawmEUXQN akAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20230601.gappssmtp.com header.s=20230601 header.b="lhFWUWZ/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id k2-20020a17090a62c200b00280479459f7si1533706pjs.50.2023.12.13.22.44.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 22:44:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20230601.gappssmtp.com header.s=20230601 header.b="lhFWUWZ/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 07BB9802F27D; Wed, 13 Dec 2023 22:44:46 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234303AbjLNGoa (ORCPT + 99 others); Thu, 14 Dec 2023 01:44:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229629AbjLNGo2 (ORCPT ); Thu, 14 Dec 2023 01:44:28 -0500 Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AD56A6 for ; Wed, 13 Dec 2023 22:44:34 -0800 (PST) Received: by mail-ot1-x32b.google.com with SMTP id 46e09a7af769-6d9f879f784so4636993a34.2 for ; Wed, 13 Dec 2023 22:44:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20230601.gappssmtp.com; s=20230601; t=1702536274; x=1703141074; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=gxtiy01D8WpTYbLcMD+XHOmT3EOIKEJTAtmXTdX58vM=; b=lhFWUWZ/M5A9H75XVqXeeaRQLoxE1agNv2KgPpbL7X8QG2cJY446sqLefE9oRtcoEJ kHKBwWDECGK1Y8cdZOizt0NAN3I3iaI0liL8RFPGG/yuDgySlhINBzDF5joPmdzOjgEn BXrWnJn1ln9EtyZgDwqDyNZb9I5KtqVkF5XKV2Bgli90TXVFKzwS+N9HBy/Ylr/v0iLL hZXo/WErCLavzHhToLrZLCHh10LLOk9O5NXJeQfCicNu3XS+koQn4PpNY6Kq96hV5G9Q WYnIKACI3nt/ONIvahrFKdGVZp6MdWCrj9wnsTYNl91Q5WO5QOP0De15l83SCug/gdL5 WdKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702536274; x=1703141074; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gxtiy01D8WpTYbLcMD+XHOmT3EOIKEJTAtmXTdX58vM=; b=I6zs3xjJTsLeIgdaQnhzct5sq5yswxYk52fkxA6ot73WUDLZlfsPen6i4fAi2d97Ce CDOn+qnGO+ZjLMnA5pSsLpWcpiDnnOMk5rVVbfwMR0Og8qBC6CKIrxB4GFPpX99A/+Tk A1oF+okaiP1NtQJoMSPUWAErU++dN1nR5KmD3AXj6M4gPU5r6roZY6q4Gy3ukYApA4dI Fro0Bitejg3bsve3AY4OjCThpB3kbqTjYWXLdqhDmOUcAVnFc0X9+AsnSqq9PK7nSwMn H+rRw0PqhJFxHQpCNdwdrfjvF1PXTZdp1TlmolI1wIhOnkPPTvUCzy9nTV87lBaIHtfj txog== X-Gm-Message-State: AOJu0Yznxmbq7RPEMUVhVbIACgrcmA4kK4YriDftvALtkAzfw/5V7WSL k7dn8+8nwyKPGdPF7hl9ypoL8XKhzacwZ1DeXwQ1qg== X-Received: by 2002:a05:6808:13c4:b0:3b9:dea6:f336 with SMTP id d4-20020a05680813c400b003b9dea6f336mr11212909oiw.50.1702536273720; Wed, 13 Dec 2023 22:44:33 -0800 (PST) MIME-Version: 1.0 References: <0343a9e4bfa8011fbb6bca0286cee7eab1f17d5d.1702371136.git.haibo1.xu@intel.com> In-Reply-To: <0343a9e4bfa8011fbb6bca0286cee7eab1f17d5d.1702371136.git.haibo1.xu@intel.com> From: Anup Patel Date: Thu, 14 Dec 2023 12:14:22 +0530 Message-ID: Subject: Re: [PATCH v4 11/11] KVM: selftests: Enable tunning of err_margin_us in arch timer test To: Marc Zyngier , Oliver Upton Cc: xiaobo55x@gmail.com, haibo1.xu@intel.com, ajones@ventanamicro.com, Paul Walmsley , Palmer Dabbelt , Albert Ou , Paolo Bonzini , Shuah Khan , James Morse , Suzuki K Poulose , Zenghui Yu , Atish Patra , Guo Ren , Mayuresh Chitale , Greentime Hu , wchen , Conor Dooley , Heiko Stuebner , Minda Chen , Samuel Holland , Jisheng Zhang , Sean Christopherson , Peter Xu , Like Xu , Vipin Sharma , Maciej Wieczor-Retman , Aaron Lewis , Thomas Huth , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm-riscv@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 13 Dec 2023 22:44:47 -0800 (PST) Hi Marc, Hi Oliver, On Tue, Dec 12, 2023 at 2:52=E2=80=AFPM Haibo Xu wrot= e: > > There are intermittent failures occured when stressing the > arch-timer test in a Qemu VM: > > Guest assert failed, vcpu 0; stage; 4; iter: 3 > =3D=3D=3D=3D Test Assertion Failure =3D=3D=3D=3D > aarch64/arch_timer.c:196: config_iter + 1 =3D=3D irq_iter > pid=3D4048 tid=3D4049 errno=3D4 - Interrupted system call > 1 0x000000000040253b: test_vcpu_run at arch_timer.c:248 > 2 0x0000ffffb60dd5c7: ?? ??:0 > 3 0x0000ffffb6145d1b: ?? ??:0 > 0x3 !=3D 0x2 (config_iter + 1 !=3D irq_iter)e > > Further test and debug show that the timeout for an interrupt > to arrive do have random high fluctuation, espectially when > testing in an virtual environment. > > To alleviate this issue, just expose the timeout value as user > configurable and print some hint message to increase the value > when hitting the failure.. > > Signed-off-by: Haibo Xu Can you please review this patch ? We want to take this entire series through the KVM RISC-V tree. Regards, Anup > --- > .../selftests/kvm/aarch64/arch_timer.c | 8 +++++-- > tools/testing/selftests/kvm/arch_timer.c | 22 +++++++++++++------ > .../selftests/kvm/include/timer_test.h | 1 + > .../testing/selftests/kvm/riscv/arch_timer.c | 8 +++++-- > 4 files changed, 28 insertions(+), 11 deletions(-) > > diff --git a/tools/testing/selftests/kvm/aarch64/arch_timer.c b/tools/tes= ting/selftests/kvm/aarch64/arch_timer.c > index 4b421d421c3f..139eecbf77e7 100644 > --- a/tools/testing/selftests/kvm/aarch64/arch_timer.c > +++ b/tools/testing/selftests/kvm/aarch64/arch_timer.c > @@ -131,10 +131,14 @@ static void guest_run_stage(struct test_vcpu_shared= _data *shared_data, > > /* Setup a timeout for the interrupt to arrive */ > udelay(msecs_to_usecs(test_args.timer_period_ms) + > - TIMER_TEST_ERR_MARGIN_US); > + test_args.timer_err_margin_us); > > irq_iter =3D READ_ONCE(shared_data->nr_iter); > - GUEST_ASSERT_EQ(config_iter + 1, irq_iter); > + __GUEST_ASSERT(config_iter + 1 =3D=3D irq_iter, > + "config_iter + 1 =3D 0x%lx, irq_iter =3D 0x%lx.\n= " > + " Guest timer interrupt was not trigged within t= he specified\n" > + " interval, try to increase the error margin by = [-e] option.\n", > + config_iter + 1, irq_iter); > } > } > > diff --git a/tools/testing/selftests/kvm/arch_timer.c b/tools/testing/sel= ftests/kvm/arch_timer.c > index 60963fce16f2..5050022fd345 100644 > --- a/tools/testing/selftests/kvm/arch_timer.c > +++ b/tools/testing/selftests/kvm/arch_timer.c > @@ -5,16 +5,17 @@ > * The guest's main thread configures the timer interrupt and waits > * for it to fire, with a timeout equal to the timer period. > * It asserts that the timeout doesn't exceed the timer period plus > - * an error margin of 100us. > + * an user configurable error margin(default to 100us). > * > * On the other hand, upon receipt of an interrupt, the guest's interrup= t > * handler validates the interrupt by checking if the architectural stat= e > * is in compliance with the specifications. > * > * The test provides command-line options to configure the timer's > - * period (-p), number of vCPUs (-n), and iterations per stage (-i). > - * To stress-test the timer stack even more, an option to migrate the > - * vCPUs across pCPUs (-m), at a particular rate, is also provided. > + * period (-p), number of vCPUs (-n), iterations per stage (-i), and tim= er > + * interrupt arrival error margin (-e). To stress-test the timer stack e= ven > + * more, an option to migrate the vCPUs across pCPUs (-m), at a particul= ar > + * rate, is also provided. > * > * Copyright (c) 2021, Google LLC. > */ > @@ -34,6 +35,7 @@ struct test_args test_args =3D { > .nr_iter =3D NR_TEST_ITERS_DEF, > .timer_period_ms =3D TIMER_TEST_PERIOD_MS_DEF, > .migration_freq_ms =3D TIMER_TEST_MIGRATION_FREQ_MS, > + .timer_err_margin_us =3D TIMER_TEST_ERR_MARGIN_US, > .reserved =3D 1, > }; > > @@ -179,8 +181,9 @@ static void test_run(struct kvm_vm *vm) > > static void test_print_help(char *name) > { > - pr_info("Usage: %s [-h] [-n nr_vcpus] [-i iterations] [-p timer_p= eriod_ms]\n", > - name); > + pr_info("Usage: %s [-h] [-n nr_vcpus] [-i iterations] [-p timer_p= eriod_ms]\n" > + "\t\t [-m migration_freq_ms] [-o counter_offset]\n" > + "\t\t [-e timer_err_margin_us]\n", name); > pr_info("\t-n: Number of vCPUs to configure (default: %u; max: %u= )\n", > NR_VCPUS_DEF, KVM_MAX_VCPUS); > pr_info("\t-i: Number of iterations per stage (default: %u)\n", > @@ -190,6 +193,8 @@ static void test_print_help(char *name) > pr_info("\t-m: Frequency (in ms) of vCPUs to migrate to different= pCPU. 0 to turn off (default: %u)\n", > TIMER_TEST_MIGRATION_FREQ_MS); > pr_info("\t-o: Counter offset (in counter cycles, default: 0) [aa= rch64-only]\n"); > + pr_info("\t-e: Interrupt arrival error margin(in us) of the guest= timer (default: %u)\n", > + TIMER_TEST_ERR_MARGIN_US); > pr_info("\t-h: print this help screen\n"); > } > > @@ -197,7 +202,7 @@ static bool parse_args(int argc, char *argv[]) > { > int opt; > > - while ((opt =3D getopt(argc, argv, "hn:i:p:m:o:")) !=3D -1) { > + while ((opt =3D getopt(argc, argv, "hn:i:p:m:o:e:")) !=3D -1) { > switch (opt) { > case 'n': > test_args.nr_vcpus =3D atoi_positive("Number of v= CPUs", optarg); > @@ -216,6 +221,9 @@ static bool parse_args(int argc, char *argv[]) > case 'm': > test_args.migration_freq_ms =3D atoi_non_negative= ("Frequency", optarg); > break; > + case 'e': > + test_args.timer_err_margin_us =3D atoi_non_negati= ve("Error Margin", optarg); > + break; > case 'o': > test_args.counter_offset =3D strtol(optarg, NULL,= 0); > test_args.reserved =3D 0; > diff --git a/tools/testing/selftests/kvm/include/timer_test.h b/tools/tes= ting/selftests/kvm/include/timer_test.h > index 968257b893a7..b1d405e7157d 100644 > --- a/tools/testing/selftests/kvm/include/timer_test.h > +++ b/tools/testing/selftests/kvm/include/timer_test.h > @@ -22,6 +22,7 @@ struct test_args { > int nr_iter; > int timer_period_ms; > int migration_freq_ms; > + int timer_err_margin_us; > /* Members of struct kvm_arm_counter_offset */ > uint64_t counter_offset; > uint64_t reserved; > diff --git a/tools/testing/selftests/kvm/riscv/arch_timer.c b/tools/testi= ng/selftests/kvm/riscv/arch_timer.c > index 13bf184d1ff5..45a139dc7ce3 100644 > --- a/tools/testing/selftests/kvm/riscv/arch_timer.c > +++ b/tools/testing/selftests/kvm/riscv/arch_timer.c > @@ -55,10 +55,14 @@ static void guest_run(struct test_vcpu_shared_data *s= hared_data) > > /* Setup a timeout for the interrupt to arrive */ > udelay(msecs_to_usecs(test_args.timer_period_ms) + > - TIMER_TEST_ERR_MARGIN_US); > + test_args.timer_err_margin_us); > > irq_iter =3D READ_ONCE(shared_data->nr_iter); > - GUEST_ASSERT_EQ(config_iter + 1, irq_iter); > + __GUEST_ASSERT(config_iter + 1 =3D=3D irq_iter, > + "config_iter + 1 =3D 0x%lx, irq_iter =3D 0x%lx.\n= " > + " Guest timer interrupt was not trigged within t= he specified\n" > + " interval, try to increase the error margin by = [-e] option.\n", > + config_iter + 1, irq_iter); > } > } > > -- > 2.34.1 >