From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 679AE80E7E for ; Fri, 6 Nov 2026 16:36:57 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A6GZVXo019974; Fri, 6 Nov 2026 19:35:32 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A6GZVXo019974 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=default; t=1793982936; bh=qT2+9d0UYIshVYy8fyW4cTItNLWOgYD9ER9N+3i4TfU=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=sTWqm7ynBskMgg6Qfn0qYPRNKpV1VN3R7MnAIoMIDB7Jb9OxJJWkYInb9bBMoBbDe WBqog/JuXZDGeACFdjmNfXqzsWOhg7PKePKwV9566Qtg1eXyZaM9QPxHJHe3VaDsgd Tq0w/8hX9RoJgmufHpx5kJ/oL+XjfMJ1gGFCWymAzh141BDyrYS2WJoZKlFnGe8SzU UYpCZSgXB3MnFxVz0SOKdJz8g6BGLPl3wUcCiYYJwcNIIJ0uC5I7q4fsH/wgbr2bZF pI+DW3ZLbyx4rhlNi3BUCWELcMwuIE8xcxk2u/YvwbLgEsKRA46Upln14vSFSnqa1m AtXGEstl4bydg== Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A6GZTOq019970 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Fri, 6 Nov 2026 19:35:30 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A6GZTOq019970 Authentication-Results: mail.openvz.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b="pApfh82m" Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-4902ce85f72so940381f8f.2 for ; Fri, 06 Nov 2026 08:35:30 -0800 (PST) X-Forwarded-Encrypted: i=2; AKwUvBzg8q+uuPnEy322xg9Z/RSOg3waAzn0pJpZKh9ZarUx0Wn/ghHzVX59v9+u+KFLNGjvLOW4cg==@openvz.org X-Gm-Message-State: APuU4Z9al5wZ1PUqp7dNhcDWag1tURr+36MyFZNCl9naQKzyB/XdokV0 LsdY1LA7x8Uh08+x8w0pYCMmapWG/L7AjE4FIQrMUDVftBDVSOJ+E6ggzyWUMkFc0YAdUbhPIgM RlqbJWFwh8CnXXp6Z+GvP7oMQcBH3pac2tTKTlgAkGWyqsGNA4nWEVQ== X-Gm-Gg: AYBFou3fDBGD/q25Qymppl7T4UG40qHV+AIIm0uymFWOioPhPU7c5dUoRPOFMt7mSEo V+dsEIk+xc7QU4ArCnzgLXSoCecNV7sPJ8mZF0dW6joBkHigt1OlB5Ae+eGk28i9ONjw3ITXnl1 cWy3NDbJQvDMg3fYYr57D26SJ4oBkYQFm8NJi11p1uo/w4hjp5C+tmZGoFzqpvRpL1wPySH2yEZ VF/T78Q6KExwP/Ca57AT6YtmpeXy5AXIDznQiuKRui6gxvfrOZXPSyJkYR73yyEIH+HyHyMrWp9 PqYrJzRHuQ== X-Received: by 2002:a05:600c:310f:b0:4b2:2ec5:8a2b with SMTP id 5b1f17b1804b1-4b6de788952mr47358285e9.10.1793982928644; Fri, 06 Nov 2026 08:35:28 -0800 (PST) X-Received: by 2002:a05:600c:310f:b0:4b2:2ec5:8a2b with SMTP id 5b1f17b1804b1-4b6de788952mr47358005e9.10.1793982928203; Fri, 06 Nov 2026 08:35:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1793982928; cv=none; d=google.com; s=arc-20260327; b=GQt8gGmUFO1Wyd7XZMh6TVVXIUTODQOlF5VTFKaBYJ014AHGmYxFfodaewaZ/p+rCX DMyOp6i1NkMSEvweC2yMr31/H9yKbw+Co9iU2rezHUsBX8t6/O3pAJEWh21j4MGnZ942 7pU+F6AbCRxTOnWpmFoRz3JzwMWWHK2I45O9W2Ohg8FG0ajdRDyyA+pzb0NIpjhUBHmK CXPrEa7a1OR3tQR8aa3N5th7VG/urBsMMKDSkTLpo4kXEzLarpjrpe51Ed7qOdzv/hSn 9FWWFqU1Lum3xOXKoHTxL+HTTh152ZZ0vOU5WCtKrLyl+dctBBOfjixuDTBW1O3j+jM+ Pyvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=EWWkVcBhT2K+7L4EgNOwv3AQgKXNyJrvy+XvqP3Nj+8=; fh=eIZ5f17YeQatxoXGGqqPGBhCBvxtYigeQNycfDuS49A=; b=CbJ8BGJfKeViUJSEqVPmlBuRhqhSbf8ib5WscgoL5DDtcua7eJdbae8laKrBqyW/qh P0RNjGtBKb2F+hGAIjCDfDZZTpUZPWqT/pW+yKqBsedSv0ukgpSJq/j513p9+4QSh5y8 tcsqsPmWGBt5yqyGt+vCuVLXSsUdUBE53KaG0SC0UclfembBg943U6TGihs4uk6ilTBv Nrj0nEI0C4Gj4qaQodQxPCOaQlFjhnPh5AjVJJtVkd3htwGPkzI6hMCJFy/uhUEym1m1 BL9y8GApxRpD96S3drjhmWc/AMwiOOFO1+svYZhY0BorXvXj+bgg8lQ3mWYyi4wPS0eS Lw0g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=pApfh82m; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:1488:8e51:f958:9448 as permitted sender) smtp.mailfrom=den@openvz.org; dara=neutral header.i=@openvz.org Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id ffacd0b85a97d-492d60e6e38sor584489f8f.3.2026.11.06.08.35.28 for (Google Transport Security); Fri, 06 Nov 2026 08:35:28 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:1488:8e51:f958:9448 as permitted sender) client-ip=2a06:5b06:b600:300:1488:8e51:f958:9448; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=pApfh82m; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:1488:8e51:f958:9448 as permitted sender) smtp.mailfrom=den@openvz.org; dara=neutral header.i=@openvz.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1793982928; x=1794587728; darn=openvz.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=EWWkVcBhT2K+7L4EgNOwv3AQgKXNyJrvy+XvqP3Nj+8=; b=pApfh82mOtWXac2ixYxw9L0iI3/YdUw9A93ICaUQ0Sj1vlnBwS7UGLN6qf/jkqGPho VZ7F6cOgo6umY7Ait70dZwHV49zktsQA4lIk/8cehfhoW/zZ39MHNhIB+3USLSG9s1eL lBLugUN8tqW/uOpVBTik2jMcf7ckxvoyCi8iJDXdvUv4W/n807966tI9UI+g08gzi1wD jjMe+VI8bVcwnl6x+v1QfHlynfJDuXGKQUAHn+rBLYl8xQIVgdlSpjavPWJMgZkBMX9A 5n76eg5F2PPKoywjwuPu6XfndCyaskvoQKXI9EwBIivreCYDEO4l3fqouxG9g5pwFn5k OVKw== X-Forwarded-Encrypted: i=1; AL+hErG0dyYeajbLsPlc2KRlfVyaUQr7hnLTkGI2Hx7PJeZUnTEZL3XrS29ti7GTP7/0kArwWHzegw==@openvz.org X-Received: by 2002:a05:6000:460c:b0:48f:bb92:c5a7 with SMTP id ffacd0b85a97d-49275373a03mr5835534f8f.9.1793982927547; Fri, 06 Nov 2026 08:35:27 -0800 (PST) Received: from athena.sw.ru ([2a06:5b06:b600:300:1488:8e51:f958:9448]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-492d6d63b6esm4725233f8f.10.2026.11.06.08.35.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Nov 2026 08:35:27 -0800 (PST) From: "Denis V. Lunev" To: Eva Kurchatova Date: Fri, 6 Nov 2026 17:35:23 +0100 Message-ID: <20261106173116.review-nvmx-pt-v2@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261106151535.138563-1-eva.kurchatova@virtuozzo.com> References: <20261106151535.138563-1-eva.kurchatova@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: Re: [Devel] [PATCH hci-8.1 v2] KVM: nVMX: Keep the emulated VMX-preemption timer on L1's TSC X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org On 06.11.2026 17:09, Eva Kurchatova wrote: > KVM emulates L2's VMX-preemption timer with an hrtimer, but the hrtimer > runs on CLOCK_MONOTONIC, which NTP slews against the TSC. The VM-exit > then comes late or early in L1's TSC, and vmx_preemption_timer_test > fails. NAK. NTP did not fail the test. The node's TSC did. The journal of sqvm2-4019 for the boot that produced VSTOR-152991: 13:58:47 clocksource: timekeeping watchdog on CPU0: Marking clocksource 'tsc' as unstable because the skew is too large: 13:58:47 clocksource: Clocksource 'tsc' skewed -42289835 ns (-42 ms) over watchdog 'kvm-clock' interval of 495964472 ns (495 ms) 13:58:47 tsc: Marking TSC unstable due to clocksource watchdog 15:38:36 kvm: SMP vm created on host with unstable TSC; guest TSC will not be reliable 15:39:14 vmx_preemption_timer_test: not ok sqvm2-4019 is itself a VM, and its hypervisor moved the TSC by 42 ms within half a second. KVM warned that the guest TSC would not be reliable 38 seconds before the test ran. With an unstable host TSC, KVM rewrites L1's TSC offset on every vcpu_load and catches it up later, so no emulation keyed on L1's TSC can be exact there, including this patch's. The test does not need an exact timer either. L2 computes its deadline after the VMCALL round trip, so the exit may land anywhere in a window of about 0.8 ms at 2.8 GHz. That is about 700 ppm of disagreement between CLOCK_MONOTONIC and the TSC over the whole timer, and far more over the part re-armed after the save/restore. NTP slews at most 500 ppm, so it cannot fail this test on a sane node. On the other side of the scale, the patch changes timer emulation on production hosts: - the hrtimer now fires up to 8 times per period instead of once, and each extra firing is an exit from the running L2; - the callback now follows every change of l1_tsc_offset while L2 runs. An L2 write to IA32_TSC that L1 does not intercept, S3 with a TSC reset, or the unstable-TSC offset rewrite each make it re-arm for up to U32_MAX ticks (about 48 s), where the old countdown fired on time. Upstream knows the emulation is imprecise and has not taken a fix either (https://bugzilla.kernel.org/show_bug.cgi?id=216177, and https://bugzilla.kernel.org/show_bug.cgi?id=218025 with the same "L2 PT expiry TSC > L2 TSC deadline" failure). I do not want to carry a downstream-only rework of it to cover a test run on a broken clock. What I would like instead: 1. QA: skip vmx_preemption_timer_test on nodes with an unstable TSC. The watchdog clears CLOCK_SOURCE_VALID_FOR_HRES on the TSC, which drops it from available_clocksource, so the check survives a wrapped dmesg: grep -qw tsc /sys/devices/system/clocksource/clocksource0/available_clocksource sys_clocksource_is_based_on_tsc() from the selftest library is not the right guard: it rejects kvm-clock and would skip the test on every sqvm. 2. There is one real bug you found along the way, and I would take a patch for it on its own. vmx_calc_preemption_timer_value() returns preemption_timer_deadline - l1_scaled_tsc unclamped. When the deadline has already passed, after RSM from a long SMM handler or KVM_SET_NESTED_STATE after a long downtime, it underflows and vmx_start_preemption_timer() arms the hrtimer for up to about two hours instead of exiting at once. Clamping it to 0 is a few lines that do not touch the hrtimer callback. Mainline has the same code, so please send it upstream as well. So there is no v3 of this patch. Please send the clamp as a new patch to mainstream first. Den _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel