Received: by 2002:a05:7412:a9a8:b0:f9:92ae:e617 with SMTP id o40csp124705rdh; Wed, 20 Dec 2023 18:59:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IHusp9WWCKpDQ5STaRdQfOV2Vnj6EUNoHTksjFYm+BMw68yAaW2VovuVflvDP7VYJQlFPu8 X-Received: by 2002:a05:620a:2456:b0:77e:fba3:a229 with SMTP id h22-20020a05620a245600b0077efba3a229mr26702120qkn.131.1703127565299; Wed, 20 Dec 2023 18:59:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703127565; cv=none; d=google.com; s=arc-20160816; b=RHRmTudas9D+DtKVt2BL8wbCPtQkywCaMHlUqmXAAbPLPv/LJ0P4QXTBDTxMReA9s9 AgYPmXwSsxtKHNlJOVeaDVsLv4MCWzEAEe++Yjw95loY4HM3MyugbxBA5eoQVcnRVgrM q0HxIFaLkAVSmZDKrwDhHqGVvykp37vL+saMYK7hxdWxbP2mj7qimp3k4/qN3NomU99e j2rArSrlB5qhKwXg+S9krt0woHdD9STyCbmydPbbSZc6lemg2T1dBZC2pPQkKeNeBqbZ ZdDYg5DqCDClq8gyEqZR3657L+JoCUICsXBgVnS0HV6UiL1qaY57lEkI2kSc3MFtU2Or 8R/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=6bBzkO/x8C7pW+ybw+V7AQ5yP+2vx9qyk2y1ClRHSZw=; fh=w6eFdHAuZsAGf0b2QwNmPQNEgPvhwmunmxCCwlMfGLc=; b=YEDK0Vr2hlsxhvT8yVMMdHKXGcFgRw/pqqBrztRnSSHxTc9Dmjv6OImiWFa6Lcn+K5 QQ97qZRjedYI3B9RQfPmu0TXRrB6L4VwPJJsBBQDAhj/MstlG24agsGg9A98sqAoWMlA B0PfJRJOzJjChPtWxMzNrYtKaFGtm+qR5/HUO0HMVLZ98TE822bfxOwd7Li/dqx5lSpg Exw/BgZZWGcj6O/yDbB1kVPMeC53VmZ89cAQzwB0RdDxdQkQArNTOEiX/50ppGr4JFM1 1ixQQC/EZxHPkh0aFjwXNckeYtMc+qncvZL2wMJWimRMadfRDPluD55H99AsA7+1jADe SvHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=epYHyAl7; spf=pass (google.com: domain of linux-kernel+bounces-7768-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7768-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id z22-20020a17090ad79600b0028b9011dd0dsi836262pju.105.2023.12.20.18.59.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 18:59:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7768-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=epYHyAl7; spf=pass (google.com: domain of linux-kernel+bounces-7768-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7768-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id AB3BC2840DE for ; Thu, 21 Dec 2023 02:59:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 08E596FBC; Thu, 21 Dec 2023 02:58:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="epYHyAl7" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FCB24691; Thu, 21 Dec 2023 02:58:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2cc259392a6so2918521fa.2; Wed, 20 Dec 2023 18:58:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703127533; x=1703732333; 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=6bBzkO/x8C7pW+ybw+V7AQ5yP+2vx9qyk2y1ClRHSZw=; b=epYHyAl7TiA75ynKga5al2BKz1HG4HUHczes0Xfbr3Z+dTwcBCehybaT4KHMWS10uO yG9alFvIbmjCL64lHfimte6bpdTeyQNQs5S2oMZqS+OVuFJ4+f+1oLvUvUZEMDKtIjpi TSBI10xhk/jW1ddVgR3YG6VUtUJa+TDpzL5FEKgfE9UXdImGQwatqGZG9O0wlmgfol0x vr9GEPdtVRIWpMrEJImxDzIIUmzzVsFBl/iRCre8JdPiakhjPQwNWKsxfZlFU53offK5 yEusJCTZ0/ybWG3cepjXmIbxkREi2ipognsGq3yWwFIue1P1/Bfx2IRU6X4IYzWR6gtg e0+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703127533; x=1703732333; 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=6bBzkO/x8C7pW+ybw+V7AQ5yP+2vx9qyk2y1ClRHSZw=; b=HYd+ibw9j9lph2x+VxtCKy2IP16IgMlC4D99D8IM8Rs7iPBs/WZThE8djeUr04+R0m sOw5BP47/7Ow2b3biS4CI1UeOttLSCKAuEJ5vupTjXoOjRvp+Rbjna/JPXiJQjlr0acy c4t7/FCPKH76K1En4jmJVfngL+ny1BsQvyVxEcyIVYm0/jBcInAmiENETX3zf5xoO/iv KvSKe8rjdSl39cnAPZpKSZikiAJ/LTCWNevSNssip6gSuWRwXUbAxByYciG3syymNc1n 57rRpyNAYfRiyqYTFN4kVPE8sQfCiOSMo5mMjwddo4q9tLl8cqjrs4AWXbI/YOXb4Nol +H9w== X-Gm-Message-State: AOJu0YzPRXqDFqHi34JtY0kzBRzx/fQNYO43M1w7Vusm7othV2JUIL5c 50bUN/NxwZMejgKrh7DkDUi9Jt1MDwvFG9T8yBI= X-Received: by 2002:a2e:95d2:0:b0:2cc:7c8c:574b with SMTP id y18-20020a2e95d2000000b002cc7c8c574bmr1956176ljh.77.1703127532313; Wed, 20 Dec 2023 18:58:52 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <0343a9e4bfa8011fbb6bca0286cee7eab1f17d5d.1702371136.git.haibo1.xu@intel.com> <8734vy832j.wl-maz@kernel.org> <87zfy5t1qt.wl-maz@kernel.org> In-Reply-To: <87zfy5t1qt.wl-maz@kernel.org> From: Haibo Xu Date: Thu, 21 Dec 2023 10:58:40 +0800 Message-ID: Subject: Re: [PATCH v4 11/11] KVM: selftests: Enable tunning of err_margin_us in arch timer test To: Marc Zyngier 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Dec 20, 2023 at 9:58=E2=80=AFPM Marc Zyngier wrote= : > > On Wed, 20 Dec 2023 13:51:24 +0000, > Haibo Xu wrote: > > > > On Wed, Dec 20, 2023 at 5:00=E2=80=AFPM Marc Zyngier w= rote: > > > > > > 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/= tools/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 consist= ency > > > >> 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 e= rror > > > > margin. > > > > Storing as signed here is just to keep the type consistent with tha= t > > > > 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? > > > > > > > Hi Marc, > > > > 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. > Thanks for the detailed info! May I understand that your concern is mainly for a platform with 64bit int = type, which may trigger the positive to negative convert? If so, I think we may need to do a clean up for the test code since several other places have the same issue. Regards, Haibo > M. > > -- > Without deviation from the norm, progress is not possible.