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=1796407377; b=2NwtjtbmCx2pDik21y0R2J+4c8mvCUtB+vuzQt76os84rhHUZMoar/+hYVG+abAJd+t+ W2BmzgTpELlsfG7Yc658afeBjKzrMpB/4Wnfv9jwmoGF1ePkQocLoEaSOScu28II1QdBh 5y4MNBYN0HEwuniXQEtBfc0gMHdK4khHJ1R3BZUtHLbob9m/Wr9CyXuT0UZeKp32ESNOH PPqu4M+jJO0FIsDS0skQUH5s6+EXjGOb9eD7JZiqSVdY78u9Ws4LBWgayvVi9kIWzdf4G 5GEWiHulyeepqd4TNFcTXnlECJyAitPpMDfAlHSPLaM8zMdd+T0wykzRlILZT9GHjAQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796407377; 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=ApvCnJhCwy9uYyjSx9e+yjce/MOvzszgOyhtvQz26HE=; b=Eeqeam1mSIX5Dv+tfB9cda3UrRuIAYsxH+B8S3oso0gPrDzmx/W9P+MdTgbWAVVHePdC NoZpUAduVmCXssGw2Jfx5nL2pZE4OeGgWeolMsbV9LU/mULGd/cVitsI3RBZNQ9q5/tP1 4ym0IBRf3829EavvLP0+ytQA2augQz/PLnYo22ojtPzg76htfWcD/1+NjdeyMDBlsBe9f 2QAIcHBDS3qXyBn9n9OysmnBrT5jQYzmrWcOFIz5dx4eAt+lzFcDF8tZxVNqemyjiBtkQ TzFfbNOCbi9fDabpi3GCbyhqmDLgGW/nHPI8LzowTQd95HBR/H09VYvrt50mr3nkM7Q== 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=IgP1dleP; 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 26B2F606A68E for ; Fri, 4 Dec 2026 18:02:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 26B2F606A68E 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=IgP1dleP DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796407376; 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=ApvCnJhCwy9uYyjSx9e+yjce/MOvzszgOyhtvQz26HE=; b=IgP1dlePvWROHqDIe88d4lSIufRyg40s9gRuPlDvHWn7+7K03tjqpr+TaT6pI8Fmy8hv6j ywkg4EDng1CUOnKhTPjv0Ryc49k1gkSffhQaBbtgpzVKfn84zOHsZ0L9WTPMADofqjyisF WOSmerfLCmoatPf+HNvMOTQZTBpOdeg= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS with 8BITMIME (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-301-GA-FBXsMNImTcEgCbO8Qfw-1; Fri, 4 Dec 2026 18:02:50 +0000 X-MC-Unique: GA-FBXsMNImTcEgCbO8Qfw-1 X-Mimecast-MFC-AGG-ID: GA-FBXsMNImTcEgCbO8Qfw_1796407369 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5E4E91909054; Fri, 4 Dec 2026 18:02:49 +0000 (UTC) Received: from pbonzini-thinkpadx1carbon6th.rmtit.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4E495BAC; Fri, 4 Dec 2026 18:02:48 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Sean Christopherson Subject: [PATCH 6.12.y 01/17] KVM: x86: Grab lapic_timer in a local variable to cleanup periodic code Date: Fri, 4 Dec 2026 19:02:29 +0100 Message-ID: <20261204180245.2166967-2-pbonzini@redhat.com> In-Reply-To: <20261204180245.2166967-1-pbonzini@redhat.com> References: <20261204180245.2166967-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.6 on 10.30.177.95 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 6e6d00b3c042..dedae7a9260f 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -2067,6 +2067,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; @@ -2078,9 +2079,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 @@ -2091,17 +2091,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