From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.198 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796332090; b=lNRFjB7iyLbEpjGv8lmyVbOquW0mZI9mENqIJvxEjVqnSzxHhJ/H7Llp4ryGkAx/uwSR V3GGUdFfQnBDZm4RyGr5rGS0fy3GDLT8LLaQ4Fneih7v3rW0Gq1YgT8Nnq1GK1WBC9l3y qWZSF/k2B4kt/MxF6MYy5g7SpbbYxH/3MvtVLYJU5cpAS82QZzWChEeS6FGQOlPXcXmNa 3OQYfmYIRoDDaRhz3paNktuKwhWmJq0Q+Faz9nIMQ7kOvAiqe5NqeshPbLE6eKzrHuzHR M+b/A7lL4p1S4OGrd5yNqNbuVDL3QHEjNcIGOxTqZ4OJVpezE9iMHOLEseXSNAH9M9A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796332090; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:Message-ID:Subject:From:To:Cc:Content-Type: Content-Transfer-Encoding; bh=Yf9qabtUIa4ru09yZx5o4AKbIFpVjjNmRnmBT4L7j/w=; b=p0MX2PtKqMcwWpwZ4OBNOSqXWJIcB6nKT1/sXGlFCxBtYIOCpTfbSN1dgCSdRWwOfTCv p1xs6HSIRuFl48azByy4wIVIcyX+P8xY5cSS7kr41wxdrlF9iXiwUHfiqa49/ISwwyX8/ 0ltlVzcf/YS3PsYMcn8YA64avUFxCSBWuTQPvGuRsYiZQlRMNvSdiv5+TQwciMpWBMgst Qk21J2pOjH0eYQ2ngZn0r5jNfaNmuxKbsQf6T8ldtej3MWaLquE43/jGXBTO27hSRZAJP LFzf4ZgrXuf5MBgl8PJpq9ErS/aRC76oMq+uRHke/YbTTaaXT7esfldMjnj3QtjQoLQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=ZaCfPfOO; arc=none smtp.remote-ip=209.85.214.198 Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2252606A322 for ; Thu, 3 Dec 2026 21:08:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D2252606A322 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.a=rsa-sha256 header.s=20260707 header.b=ZaCfPfOO Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2f0f5721453so2828995ad.0 for ; Thu, 03 Dec 2026 13:08:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796332089; x=1796936889; darn=vger.kernel.org; h=content-transfer-encoding:content-type:cc:to:from:subject :message-id:references:mime-version:in-reply-to:date:from:to:cc :subject:date:message-id:reply-to:content-type; bh=Yf9qabtUIa4ru09yZx5o4AKbIFpVjjNmRnmBT4L7j/w=; b=ZaCfPfOOPIjPGt0MmwTxNgIm4fbjmSWN+USwWbWzBHxDjJxWOqmI9/TcE82AhiXe4n tMD0XkagndcBHqxhLRPyvb5ol+Gc8hXqMXc0dZnV8tJP4H5pKK0xJ2s2GVpgvbjAVGTc W4t29/J12p/vGxzpNU2kbx3Mc+ghB0AefnXdBUZXV7HUEEQPpk4S6Fbqot1YLnX1Nmmt edhrq2qSOR6yIPj4ft0bEilLx4lI+HH7D+X5Ro9ejQwtTUc9YxfrRY+MgwzgdhKPsaJR nHDMHwXjYHPSWtOo+BIxZedikDeud7ZrRV6qIU+LopvWVVWybrBJ4Vr64XUsD4q1QPMc KC5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796332089; x=1796936889; h=content-transfer-encoding:content-type:cc:to:from:subject :message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Yf9qabtUIa4ru09yZx5o4AKbIFpVjjNmRnmBT4L7j/w=; b=IGNx0lhUYSqAiVqtBsIVsNZECva7LHyyaG69E5utCpgWUTT8d/94kCLVgBrWh3SRjs az1tySFXEpTrIoHHlivDqYLjx2+UsMYUT7RFHi0xrd+YxOZc3veHmp09bNRMQUPmx+5J zMzZ4Y8wafDr3ojTwlts37qHlPydbsKf6V3vX6NXys+45BAq+GEIlXuIagp0jVhvOXuJ ZnaBqoREs05BqIoWovsip2tFBIAeWTdvvNpUQyY4txNImwUa0lAFsxvQv4zfj7P19Aad Uuh70LyeTQPvoDeQZ7sMdT/ZbWTX/xtO8skOIC5hkAcTK/nxxX0crLysL+hDxa2rDKwe LnnA== X-Forwarded-Encrypted: i=1; AL+hErF2wucZ4ltTtSWtRpPB5cLFFgSI3Lxphlo0jO7ydp3wkiu9KHx88Ks7xwIYuS663GlJcwiyadZ3/aiI58Y=@vger.kernel.org X-Gm-Message-State: APuU4Z9XjBtyACcNjj7K/UGdXYhCyyQvD69Pzzi2i6qiF6pdDLN3kpZG qNgs2wdF/YcZnAbhEldxAch4EoiCW/KL9hgdMys8tpUwXr13f+sIPaGpSwWgKyx5WO1iXE6s+P9 vaH7Dhg== X-Received: from plru3.prod.google.com ([2002:a17:902:b283:b0:2f0:2b47:1980]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:f54c:b0:2ed:146c:cbb2 with SMTP id d9443c01a7336-2f03f0fcd67mr475042675ad.21.1796332088817; Thu, 03 Dec 2026 13:08:08 -0800 (PST) Date: Thu, 3 Dec 2026 13:08:08 -0800 In-Reply-To: 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 References: <179628948570.2061.8987479680072097733@gmail.com> <179629562424.2309.16534864585011503528@gmail.com> Message-ID: Subject: Re: [PATCH v2] KVM: x86/xen: defer timer event delivery on PREEMPT_RT From: Sean Christopherson To: David Woodhouse Cc: Yang Luohan , kvm@vger.kernel.org, Paul Durrant , Paolo Bonzini , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Thu, Dec 03, 2026, David Woodhouse wrote: > On Thu, 2026-12-03 at 07:13 -0800, Sean Christopherson wrote: > > On Thu, Dec 03, 2026, Yang Luohan wrote: > > > xen_timer_callback() runs from an hrtimer, so it executes with interr= upts > > > disabled. It calls kvm_xen_set_evtchn_fast(), which acquires gpc->loc= k with > > > read_lock_irqsave(). On PREEMPT_RT rwlock_t is a sleeping lock, and t= aking > > > it in that context reports: > > >=20 > > > =C2=A0 BUG: sleeping function called from invalid context at > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 kernel/locking/spinlock_rt.c:248 > > > =C2=A0 in_atomic(): 1, irqs_disabled(): 1 > > > =C2=A0 kvm_xen_set_evtchn_fast > > > =C2=A0 xen_timer_callback > > >=20 > > > The callback already handles -EWOULDBLOCK by recording the pending ti= mer > > > and raising KVM_REQ_UNBLOCK, and the delivery is then completed from > > > vCPU context by kvm_xen_inject_timer_irqs(). On PREEMPT_RT, skip the > > > fast path and let that deferred path run instead of taking a sleeping > > > lock from hardirq context. > > >=20 > > > Fixes: 77c9b9dea4fb ("KVM: x86/xen: Use fast path for Xen timer deliv= ery") > > > Signed-off-by: Yang Luohan > > > --- > > > =C2=A0arch/x86/kvm/xen.c | 6 +++++- > > > =C2=A01 file changed, 5 insertions(+), 1 deletion(-) > > >=20 > > > diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c > > > index 6aa00f7..5440b96 100644 > > > --- a/arch/x86/kvm/xen.c > > > +++ b/arch/x86/kvm/xen.c > > > @@ -136,7 +136,11 @@ static enum hrtimer_restart xen_timer_callback(s= truct hrtimer *timer) > > > =C2=A0 e.port =3D vcpu->arch.xen.timer_virq; > > > =C2=A0 e.priority =3D KVM_IRQ_ROUTING_XEN_EVTCHN_PRIO_2LEVEL; > > > =C2=A0 > > > - rc =3D kvm_xen_set_evtchn_fast(&e, vcpu->kvm); > > > + if (IS_ENABLED(CONFIG_PREEMPT_RT) && !preemptible()) > > > + rc =3D -EWOULDBLOCK; > > > + else > > > + rc =3D kvm_xen_set_evtchn_fast(&e, vcpu->kvm); > > > + > >=20 > > This is a long-known issue, and is being addressed by switching away fr= om rwlocks > > entirely. > >=20 > > Thanks! > >=20 > > https://lore.kernel.org/all/20261105020104.2507083-9-dwmw2@infradead.or= g >=20 > We said you'd pick up patches 1-9 of that series as-is, and I'd keep on > with refining the nested stuff in the latter half of the series later, > yes? Yep, I'm trying to get there.