From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796407428; b=qRwaFH5sT81KwS9skKYQXw65hw4t3iPdaC7Na+GFhkeFnuxxfB1sLECOyChktJnGyZSx gqV+LYCeWE1c5Uy/XUo0QJRBp+inXUluGa1YsL8YgiKnS93kah377dq29x7BiknaxuAEo yf1/vhZchY9OYeHAzhtUwBxEm6O6Rug5vqAJ6789leUNSqACH7y+tuZUl5LwXKmTvDI9L SxzBac+j8qTR95o1Cn6F4tpd19fEsM1bnP4v54BN98KEozxqW5Hsu5c8w6baylfVY9uBK zyiB1BOSX4HwfLbtZ1iskVRR4Q73X25c9ZDZ1RnoghxG9t+gcvw57Z9rmct6TnwtCcA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796407428; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:From:To:Cc:Subject:Date: Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Scanned-By; bh=QanH1xQDiMT/w9FNWKUgYzHManE8m0q8n5sggNUQSKo=; b=h+A+8/hHGPEEJ/Wvdp0ITWuMtxM3BDuw8KERbVIXOpX2mI1jLsxXwSXE4aQr1W8/ASXU msNFxPNWJRkYnvDfFzJOBlypia0KnxbteHLyH2d2Y4Riw35jzU32ODDHknGsF3ncafRWd XzBItvEvY4AvLhl8vHcBko66mD+aqejnGJzzAzLvLia7IdgeIj/cnssOoagZ5Bd+gYqbB FMVxsZbcM6djWErNx+ddjPmA4chcqlGK8vkuDHzcvGLAZLuaPArbwp9VE9hA4VN3NCHwO fjIMw3og1F2V/uX9Yba/THi5CpqL8vgqFwu+2LMf6G1JRwnUp6heNtZj85yCdJL4pJw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=X4JCjqTW; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF9D760A380F for ; Fri, 4 Dec 2026 18:03:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DF9D760A380F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=X4JCjqTW DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796407428; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QanH1xQDiMT/w9FNWKUgYzHManE8m0q8n5sggNUQSKo=; b=X4JCjqTWGMNW4utYfLmD5FKTh2aPpmLhgO4We2dbddf85ZMhHkXVRanWWDjVNVpI7J1h6i 1TW5oDJHEuoJNXoJ9uib9TZUxBocZWMfJTS2XW9RRslqZR0svD5hPt6wdaUdGwOtkhzVCO Lz9kSVD47e+0EaREkg3xi0xwxwmhVTE= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS with 8BITMIME (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-125-DZ1sMTQgN4eUbg-v7piU6A-1; Fri, 4 Dec 2026 18:03:42 +0000 X-MC-Unique: DZ1sMTQgN4eUbg-v7piU6A-1 X-Mimecast-MFC-AGG-ID: DZ1sMTQgN4eUbg-v7piU6A_1796407421 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 997F818C0D81; Fri, 4 Dec 2026 18:03:41 +0000 (UTC) Received: from pbonzini-thinkpadx1carbon6th.rmtit.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8928E18019CC; Fri, 4 Dec 2026 18:03:40 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Sean Christopherson Subject: [PATCH 6.6.y 01/17] KVM: x86: Grab lapic_timer in a local variable to cleanup periodic code Date: Fri, 4 Dec 2026 19:03:21 +0100 Message-ID: <20261204180337.2168031-2-pbonzini@redhat.com> In-Reply-To: <20261204180337.2168031-1-pbonzini@redhat.com> References: <20261204180337.2168031-1-pbonzini@redhat.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 From: Sean Christopherson [ Upstream commit a091fe60c2d3943b058132a64682a509d55bd325 ] Stash apic->lapic_timer in a local "ktimer" variable in advance_periodic_target_expiration() to eliminate a few unaligned wraps, and to make the code easier to read overall. No functional change intended. Link: https://patch.msgid.link/20251113205114.1647493-5-seanjc@google.com Signed-off-by: Sean Christopherson Signed-off-by: Paolo Bonzini --- arch/x86/kvm/lapic.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index a750ec8057cc..346e6688109a 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -2053,6 +2053,7 @@ static bool set_target_expiration(struct kvm_lapic *apic, u32 count_reg) static void advance_periodic_target_expiration(struct kvm_lapic *apic) { + struct kvm_timer *ktimer = &apic->lapic_timer; ktime_t now = ktime_get(); u64 tscl = rdtsc(); ktime_t delta; @@ -2064,9 +2065,8 @@ static void advance_periodic_target_expiration(struct kvm_lapic *apic) * over time as differences in the periods accumulate, e.g. due to * differences in the underlying clocks or numerical approximation errors. */ - apic->lapic_timer.target_expiration = - ktime_add_ns(apic->lapic_timer.target_expiration, - apic->lapic_timer.period); + ktimer->target_expiration = ktime_add_ns(ktimer->target_expiration, + ktimer->period); /* * If the new expiration is in the past, e.g. because userspace stopped @@ -2077,17 +2077,17 @@ static void advance_periodic_target_expiration(struct kvm_lapic *apic) * past will do nothing more than waste host cycles, and can even lead * to a hard lockup in extreme cases. */ - if (ktime_before(apic->lapic_timer.target_expiration, now)) - apic->lapic_timer.target_expiration = now; + if (ktime_before(ktimer->target_expiration, now)) + ktimer->target_expiration = now; /* * Note, ensuring the expiration isn't in the past also prevents delta * from going negative, which could cause the TSC deadline to become * excessively large due to it an unsigned value. */ - delta = ktime_sub(apic->lapic_timer.target_expiration, now); - apic->lapic_timer.tscdeadline = kvm_read_l1_tsc(apic->vcpu, tscl) + - nsec_to_cycles(apic->vcpu, delta); + delta = ktime_sub(ktimer->target_expiration, now); + ktimer->tscdeadline = kvm_read_l1_tsc(apic->vcpu, tscl) + + nsec_to_cycles(apic->vcpu, delta); } static void start_sw_period(struct kvm_lapic *apic) -- 2.56.1