Received: by 2002:a05:7412:d024:b0:f9:90c9:de9f with SMTP id bd36csp42019rdb; Wed, 20 Dec 2023 05:59:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IHy5BL3E66qMk0xs6n5l0RbAc+poeB3utbCab4gfpPlSthqwek/SWlcwV0JHDqiJ2rGHc9C X-Received: by 2002:a05:600c:34c6:b0:40d:3ade:9fac with SMTP id d6-20020a05600c34c600b0040d3ade9facmr34409wmq.75.1703080745525; Wed, 20 Dec 2023 05:59:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703080745; cv=none; d=google.com; s=arc-20160816; b=ynK1Dv2aYvABM52UUMELWdySjUPL4xdRZcojxza3r+5Vj28CN9H9HMBuQvhqfCBEpq 604SK1DlmtKChi6SToNk22xqx3/DnqF4EnA0g2ddycmKTC3NQoZp7qrYEpztml+vOHn8 z7Q317VUu2bzy6gTPP1KB9Y1KqaJpqheCVoTxnxAq7vW0Oa2A+tvCiKUR/wRnR1iZezz DmVSRNltgytDTS8iNIQA+JSH9GAig+0g4MmoigvTfVPHa9Z+2Mp7G7aR6RV3di1T/vmj sKJBzLs+5TS8jg0gI9gin/GiaxVhvrPdQDA6b8W1eL5C1hSm75i4xelJZmq2jyLZ8KPH tjFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=MAQQtPL0a+U7X2vhkDTcO9XAKPpRMfwD6di/04KjAd4=; fh=sHZSoRZfahgv4JHww7QVLBRLjVAHCJqkvK3REtZ018k=; b=HrmwD2VSo1Lq+MrZChwaUFHL9xFx27W3bbAJbNRZxcXRSayfy13f4MWJxqHg7XsQdf fsZCTtrDoDslNk5MH8h5SHx3NUKv1NY6wnWMiqZkNsRrypiLqZ8Dvv4OYtZ46bmj7ylK WdbGOXL5IIA4K0a/fSo41S4odtM3/k0bfDO+6EigSbshsKZAsRkyH1Orh6z4yvcMqUni DA45E9zwKdNngWi8FueFpZ81ULBUxjn4kPURva64GZg1Q8S1dBVmKCNyZ+AbP6EbW1zG TwJdCHna6BWbPRIIk3drfA2dAWdB4GBYLYeGk7CgKi1EsSPK3LeIz+/eawmTKFN5HaJK oblQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NwM8+cbY; spf=pass (google.com: domain of linux-kernel+bounces-7005-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7005-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id x26-20020a1709065ada00b00a234f1df9basi3017605ejs.398.2023.12.20.05.59.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 05:59:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7005-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NwM8+cbY; spf=pass (google.com: domain of linux-kernel+bounces-7005-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7005-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 42A931F225B8 for ; Wed, 20 Dec 2023 13:59:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4451638DDF; Wed, 20 Dec 2023 13:58:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NwM8+cbY" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F6AD38DD5; Wed, 20 Dec 2023 13:58:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51FAAC433C8; Wed, 20 Dec 2023 13:58:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703080686; bh=FX4VAPxyEVKvbbJffi2oi0T7IYc01Fhx2zd5wWkz3wc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NwM8+cbYhkZDjaSPH54gM/FtSQx6WK56VcCUrgaSheWX7L6662Q9fpHMey/F+cXZg LtFvlGYJcQXNjGKH3q6PORLqW8xfTVeMW+qmdar9AMN+2hdBfaCbaiH4Dd2wDHodsP 6FXgC3IFwnVC0v9tZgGSNbk0asM4KrATuC53simrWj1wtcSYwZ7eMZWO41nOb3MUa2 1H0UHtmiEvgTJW85oLccXjlzIY0tGG0UBoOT5XJVBoWPiUHiiuKIzK2kohUG0eyu0w hZNhih9om2p+wdoGzMhF251x4XXMoN20Z9/D3usDXePXY2dt3r/kXxyFTMy6Hgqdl+ a3TCwLcOZfNkg== Received: from [104.132.45.104] (helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rFx5H-005hDm-0g; Wed, 20 Dec 2023 13:58:03 +0000 Date: Wed, 20 Dec 2023 13:58:02 +0000 Message-ID: <87zfy5t1qt.wl-maz@kernel.org> From: Marc Zyngier To: Haibo Xu Cc: Haibo Xu , ajones@ventanamicro.com, Paul Walmsley , Palmer Dabbelt , Albert Ou , Paolo Bonzini , Shuah Khan , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Anup Patel , 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 Subject: Re: [PATCH v4 11/11] KVM: selftests: Enable tunning of err_margin_us in arch timer test In-Reply-To: References: <0343a9e4bfa8011fbb6bca0286cee7eab1f17d5d.1702371136.git.haibo1.xu@intel.com> <8734vy832j.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 104.132.45.104 X-SA-Exim-Rcpt-To: xiaobo55x@gmail.com, haibo1.xu@intel.com, ajones@ventanamicro.com, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, pbonzini@redhat.com, shuah@kernel.org, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, anup@brainfault.org, atishp@atishpatra.org, guoren@kernel.org, mchitale@ventanamicro.com, greentime.hu@sifive.com, waylingii@gmail.com, conor.dooley@microchip.com, heiko@sntech.de, minda.chen@starfivetech.com, samuel@sholland.org, jszhang@kernel.org, seanjc@google.com, peterx@redhat.com, likexu@tencent.com, vipinsh@google.com, maciej.wieczor-retman@intel.com, aaronlewis@google.com, thuth@redhat.com, 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 X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Wed, 20 Dec 2023 13:51:24 +0000, Haibo Xu wrote: >=20 > On Wed, Dec 20, 2023 at 5:00=E2=80=AFPM Marc Zyngier wro= te: > > > > On 2023-12-20 06:50, Haibo Xu wrote: > > > On Wed, Dec 20, 2023 at 2:22=E2=80=AFAM Marc Zyngier = wrote: > > >> > > >> On Tue, 12 Dec 2023 09:31:20 +0000, > > >> Haibo Xu wrote: > > >> > diff --git a/tools/testing/selftests/kvm/include/timer_test.h b/to= ols/testing/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; > > >> > > >> ... except that you are storing it as a signed value. Some consisten= cy > > >> wouldn't hurt, really, and would avoid issues when passing large > > >> values. > > >> > > > > > > Yes, it's more proper to use an unsigned int for the non-negative err= or > > > margin. > > > Storing as signed here is just to keep the type consistent with that > > > of timer_period_ms > > > since there will be '+' operation in other places. > > > > > > tools/testing/selftests/kvm/aarch64/arch_timer.c > > > /* Setup a timeout for the interrupt to arrive */ > > > udelay(msecs_to_usecs(test_args.timer_period_ms) + > > > test_args.timer_err_margin_us); > > > > But that's exactly why using a signed quantity is wrong. > > What does it mean to have a huge *negative* margin? > > >=20 > Hi Marc, >=20 > I agree that negative values are meaningless for the margin. > If I understand correctly, the negative margin should be filtered by > assertion in atoi_non_negative(). No. Please. atoi_non_negative() returns a uint32_t, which is what it should do. The bug is squarely in the use of an 'int' to store such value, and it is the *storage* that turns a positive value into a negative one. M. --=20 Without deviation from the norm, progress is not possible.