Received: by 2002:a05:7412:d024:b0:f9:90c9:de9f with SMTP id bd36csp38693rdb; Wed, 20 Dec 2023 05:51:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IGZhAYdeAGwfG/CU4aPyvLvIBOVdENu60D9WrvGJ3A4KczSOetgtVmWsZlCjDgrVUeTvSkR X-Received: by 2002:a17:902:dacf:b0:1d3:d489:f99d with SMTP id q15-20020a170902dacf00b001d3d489f99dmr3585014plx.58.1703080317650; Wed, 20 Dec 2023 05:51:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703080317; cv=none; d=google.com; s=arc-20160816; b=mZEPN89r/PhHMNDhu7lllZRwSyJKiUi9FTXSRSuc0ULxCft85xq9dFjqiKK63nWS4M 6l4bi7XgSmYHayrSFW8z2piuPxN39EX4sOtHgeOcGQCyBTs3tM/vxHDrfBJ+9v9RaR8G cFLyyXRyBny/81J8lsj05vHpiRA18NWY4FE9mOdXOdgNnS9aMK0O8rUJTgAewsHYeF/H CmBkkhOeXQ8zDot29+AVYbAOb39pwjodEInInCSKdAwYHRvqM1gpkS1iILrTNwRQews4 AoFnEZS12nWSfquqGoH7mGhYv5VwF86BNfN8jeBQ2IWu3K3sHQEFEIC7lLmToCUm8ze2 0r6g== 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=Rei5fD9NGFINnaZoP+B7hv3sKvx8MD4zubiuSki3juc=; fh=w6eFdHAuZsAGf0b2QwNmPQNEgPvhwmunmxCCwlMfGLc=; b=vJvO5knc6ByDnZjiGU86ksAxvK/MfDveh5tMMDghdunZOrEe/XpQQx54Ts3yHU138s ZFvuUNdu/87K5uK+hu+amZC7BuHuhOWhGRZsd41/bmT48T43QivuKvFl4wJctUXNm+GM GBbOw17NcdLMfqUbZlyYeeECxTg5EwzLNr0RGGHYykubrr4//Zrp+h3s7ZO0cAWmda+B 75j/GyTw3DKJfv2NTMPOa3mAAKEbJxQ7o4OSPgUN02lyh//uXAnBoPniQyYOVy2R7DUy 6lQE8NvYl9qhAzTnXKjqYX7pn2SAa7xY555RzaJRDgkVQCCWmg3NA5FXkStaea4qIzWH eGDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YejMj6yO; spf=pass (google.com: domain of linux-kernel+bounces-6993-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6993-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id z5-20020a170902834500b001d06d30071dsi20915481pln.651.2023.12.20.05.51.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 05:51:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6993-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YejMj6yO; spf=pass (google.com: domain of linux-kernel+bounces-6993-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6993-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 34421B23BE6 for ; Wed, 20 Dec 2023 13:51:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F5373716B; Wed, 20 Dec 2023 13:51:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YejMj6yO" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (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 14DC538DD5; Wed, 20 Dec 2023 13:51:37 +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-f174.google.com with SMTP id 38308e7fff4ca-2cc7d80324dso22215801fa.2; Wed, 20 Dec 2023 05:51:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703080296; x=1703685096; 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=Rei5fD9NGFINnaZoP+B7hv3sKvx8MD4zubiuSki3juc=; b=YejMj6yOZeG5bM5ZgEYx3UThHgaA25TGnd/euJ7ThvX4DSeA8xlKrMxqegGQdEUAQW duid4aS3Y/TsDAvr93C6YABOMX4j2L+eNu9jLpKYOTR8UbgY9he4PXjb/rHBQ+XshI5i ycmGejwhp++i20eHFmCQM5NbBYOqVgu9IY07Vct58knkckqEQniPq3bn2Z72ad1jJpiU 8lefpUeJHnLwhXEzkEeF02fYPEGvMqOVU3aDWysCrxtt5bAd44o8u4+s00/vfOviHIvY AF7RlSoNthexes7OgjYM4b6/8YCZlazbr9HRI6gmknDjxApL6DwmmdHaaeKcmHKOR7GJ fW7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703080296; x=1703685096; 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=Rei5fD9NGFINnaZoP+B7hv3sKvx8MD4zubiuSki3juc=; b=YfogNEFkhmxY7BvumRirQNkv8VCGusc/TxU5L0NIQBiU0Yk35xDwTkMbeAodSezI1V 9RL8T81tXy1wbW1zXKbgwVQodNDDHlPZ/DLBVSM6/5pbhtbnUwAifm6OgfVwiIW2LycQ m8pM8nrAOdvsjpj0AKBLEeq0mWSrrkbkFxkHwh8+ODRr4ZciGK1/PcKcq5Xetv98TXjK Oy7WpvLHPH+q0bY7Kag6Zi2p8FbqPEwsI6U3Y4ATJQ8JPzmBu4FpJyY/LJWdkHq8RyS5 PNQEOa3LJyLf6041komhHKzbvhPbtUKTzdCljP5XvuNdqaT9Dd0NG8E7Ei11UN+FDb2m 2Lmw== X-Gm-Message-State: AOJu0YzXfnM5LEyYGM+c3vCttZI49mViTBCP4oekqDha5PmeGAuyL8Y4 2D7lR2JJJJyFJjsOnmVhxX0rhkpX23tnr8njlHA= X-Received: by 2002:a05:651c:1055:b0:2cc:8481:f21e with SMTP id x21-20020a05651c105500b002cc8481f21emr712056ljm.39.1703080295789; Wed, 20 Dec 2023 05:51:35 -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> In-Reply-To: From: Haibo Xu Date: Wed, 20 Dec 2023 21:51:24 +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 5:00=E2=80=AFPM Marc Zyngier wrote= : > > On 2023-12-20 06:50, Haibo Xu wrote: > > On Wed, Dec 20, 2023 at 2:22=E2=80=AFAM Marc Zyngier w= rote: > >> > >> On Tue, 12 Dec 2023 09:31:20 +0000, > >> Haibo Xu wrote: > >> > > @@ -216,6 +221,9 @@ static bool parse_args(int argc, char *argv[]) > >> > case 'm': > >> > test_args.migration_freq_ms =3D atoi_non_negat= ive("Frequency", optarg); > >> > break; > >> > + case 'e': > >> > + test_args.timer_err_margin_us =3D atoi_non_neg= ative("Error Margin", optarg); > >> > + break; > >> > >> So your error margin is always unsigned... > >> > > > > The error margin was supposed to be a non-negative [0, INT_MAX]. > > (May be need to define a Max for the input, instead of INT_MAX) > > > >> > case 'o': > >> > test_args.counter_offset =3D strtol(optarg, NU= LL, 0); > >> > test_args.reserved =3D 0; > >> > diff --git a/tools/testing/selftests/kvm/include/timer_test.h b/tool= s/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 consistency > >> 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 error > > 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? > 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(). Thanks, Haibo > I don't see how you can justify this. > > M. > -- > Jazz is not dead. It just smells funny...