From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) (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 ABAE75678CC for ; Wed, 30 Sep 2026 17:37:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.70 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790789874; cv=none; b=u9I5iMWKmo6BpSHFMiFpt0Ccly5JvVe1s+yzpVT0HRsvnkB5DjHI4gjPNrRRBWEgFb6FsKT7hqYkvlnqDpGBjX1bj5+KVQnYassxitb+DojyVkVUZyZw7BLzmqEXEdybaEzd16OrWWs9+UnVYWzfxUZJ1Oxsg55CpZSFtraba58= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790789874; c=relaxed/simple; bh=sE4UstFJJDm93z/2C9nKFZnEiOFJRS3FGWFplpg9Q10=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=HpyUN4uoYCzgiABTN8fghXvUQgC3EhuLeMEosLY9xTmrHJvQcHptp9iTzgHrCLGuNnWCA1qbzu+rL+Ea1NKB1l/1n3YcT56uydJgCgXytZ2yc/yuZkxVHZ+3PgGhs2K3wjKrux9O5G+GDyxiZvuXPjyedaIul14mc6+M+zrs5iQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=NAzz6aQQ; arc=none smtp.client-ip=209.85.216.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NAzz6aQQ" Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-3a4b70941efso1394852a91.0 for ; Wed, 30 Sep 2026 10:37:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1790789872; x=1791394672; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:from:to:cc:subject:date:message-id :reply-to:content-type; bh=3P34w1qL2JSmunI16hl66RzEZyrUpXazIWUsoHq6By4=; b=NAzz6aQQjb8GNYpWZqPX7kxq6dWhZ3yeXEqh3V/qeL1Rs/1fvDdl8GDRUr5NdeHoV9 I1CjCQXNbMgdd9cj7gDTX5jovfLsv7KfyjqilcJg7o8rbdxX/6VHtCMahL+Ol8nYxs+N e37bm7r2jRsL5lp7Quobc+TQhzOUduvkZ8u7Vw0v6Ocx1CQemiM5i0Kpg1O+ePWttAA+ Eh2Bd1tmdWTCbd+AgrstN4Y/mW5xIZHQiTNwcMnWZhE0lU3MiukpAl1YD6hgj+geSixx 2LSfJJVE/sQF9fzj7MBtyu+AT08LskpxTMxaGOG/UoWFikFCMmN95QWslF1HhJE6UjXW lQmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790789872; x=1791394672; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=3P34w1qL2JSmunI16hl66RzEZyrUpXazIWUsoHq6By4=; b=JLhbHnlcqtwn4ET/uSlSAOoK+dbAUe9Vf7u5jfEN21qJiypLxuhO6BQXbu9zzWY98S unPxBgMh+875dxbbp+m1utnFyu+CiiCudS6CzyCSvvaBdSKLcUYkABS8pGAhIon6UmwV plAcgdqwfwOaX/174h+wpbhB0IWBwd1uM6E36Y4JJIzopNrjbeoBDToQD0NGveRxUmuz ElI98NjIwNVtQwWVTy1TdWJ/wwfALRbUdbCskE/ddJCwPJYjKDMJn4iQDWdAMD3POzBc aEkHjPotETrJVxAnCcTaT33OQ8u78oA97rePeQiBEPQUb9ywfg/cvfFaScA3+kmR6o6j VAAQ== X-Forwarded-Encrypted: i=1; AKwUvByKvhKDlg3dLWLsuG5AYs86mS/aR07WIaa/q/DRZyVAhcl/JGzTNwFaUaCjA3BXcLjMqNM0l0pOoN737oY=@vger.kernel.org X-Gm-Message-State: AFq9FYLZkQLfngpwUHrEcmebfoYoJntXD55dq1azAYRWSf25A2limWVe h82To4ML5azQ/7a6+7fnYfl7YLzPlhAfZ/Sf+1SMGPl8r6Ir/9hkVXcOHDHbTkrXOa4kiOndXH4 9h8DOFg== X-Received: from plco20.prod.google.com ([2002:a17:902:e294:b0:2e2:f0ff:32fb]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:3c4b:b0:39e:6c6a:4b77 with SMTP id 98e67ed59e1d1-3a4d1ddb4c7mr1601152a91.65.1790789871901; Wed, 30 Sep 2026 10:37:51 -0700 (PDT) Reply-To: Sean Christopherson Date: Wed, 30 Sep 2026 10:36:26 -0700 In-Reply-To: <20260930173635.3362655-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260930173635.3362655-1-seanjc@google.com> X-Mailer: git-send-email 2.56.0.rc1.315.gc6ed9934b7-goog Message-ID: <20260930173635.3362655-13-seanjc@google.com> Subject: [PATCH v3 12/21] KVM: selftests: Allow +/- 1 tolerance if expected TSC frequency is <100 From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Amirmohammad Eftekhar , Sashiko Bot Content-Type: text/plain; charset="UTF-8" Massage the nested TSC scaling test's checker to allow for validating an expected TSC frequency of 1Hz, which is achievable for L2 since L1 can use a completely arbitrary fractional ratio. To do so, set the minimum tolerance to 1, and make the thresholds inclusive, i.e. for an expected frequency of 1, allow the actual frequency to be in the range of [0,2]. Because scaling L2's frequency down to a single Hz makes the virtual TSC run soooo comically slow, and because all of the math is done with basic integer arithmetic, it's very easy for the test to observe what appears to be a frequency of 0. Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/x86/nested_tsc_scaling_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kvm/x86/nested_tsc_scaling_test.c b/tools/testing/selftests/kvm/x86/nested_tsc_scaling_test.c index 8c96b8e501f9..d790ab36a198 100644 --- a/tools/testing/selftests/kvm/x86/nested_tsc_scaling_test.c +++ b/tools/testing/selftests/kvm/x86/nested_tsc_scaling_test.c @@ -36,11 +36,11 @@ static void host_check_tsc_freq(int level, u64 actual, u64 expected) { u64 tolerance, thresh_low, thresh_high; - tolerance = expected / 100; + tolerance = max(expected / 100, (u64)1); thresh_low = expected - tolerance; thresh_high = expected + tolerance; - TEST_ASSERT(thresh_low < actual && thresh_high > actual, + TEST_ASSERT(thresh_low <= actual && thresh_high >= actual, "L%u TSC freq is '%lu', expected to be between %lu and %lu", level, actual, thresh_low, thresh_high); } -- 2.56.0.rc1.315.gc6ed9934b7-goog