From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (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 2B2462C21C7 for ; Tue, 14 Apr 2026 13:44:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776174256; cv=none; b=iEJPXgxhAQfMdetXb+9v1XVcf7rvTO3vMffY9N5jSBKSDihCikhnphmLDiIBCf0NvI3ntC7FjETOQ2v0jAe06ZnfScFKy6XZOoCjTjmAd6O3k60dG65jWB7a4EzrzlDrTDdUSbIQjSWZ1++plIsgersuwKymvPACf5d0NQsQbeo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776174256; c=relaxed/simple; bh=FXyzhVd45QAGHhKvQiC316veEoapczrLxFSiWOE0fjs=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=pv8AyFtDa2DXxkcOGRfAD3t1GM4pbt7vShZ0nvrGlT8nAk0n3q8b1paW+jg1DeevBNobc0bp22WyrSzEh00XX6Zx0tKPQh1d1X3yf8fFOmQfUz2x1QIXqSb5I49cjdw2SECOvu53CACghOrM8lSeSB1Bn0EwA5GIh0xPiMrKrpg= 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=OPg1Xs+L; arc=none smtp.client-ip=209.85.214.202 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="OPg1Xs+L" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2b24af7ca99so78458355ad.1 for ; Tue, 14 Apr 2026 06:44:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776174254; x=1776779054; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Xk10vdZMvoF35vo2wryi4gcppRXNySBYTaE8DIavMRY=; b=OPg1Xs+LSxfX9JyBYrhrinHGucEcl6+761cOpmdXeBM4TM6ngdjSkxwaxrYtWKP2Mf CQPkcRlZ8BUfkLNtZkGE0dBtqZ+2gJfuae+0Rp4S8pOKurBGiHLq9O+acEa/03nbU7te c0Rlpv1xzqv3/T5TNW3AIXxZbiwKa2vrtxSTApgwXsHa/knSN+iwA7jqRM9sUtTWKa1E pQV+CPOJV9gh0FA0EdMonFHygZ/8PhDigDEm6wTz4WLOBlAX0butiS2HLavu2zw0sc7X 4g8GLZvXFCN1loBEBRfBUL0afLkPhWhUW2hrraV6TzVxmWNZz76gmKdb2nitAaHR9Sj3 btmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776174254; x=1776779054; h=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; bh=Xk10vdZMvoF35vo2wryi4gcppRXNySBYTaE8DIavMRY=; b=dRBqXOYylrEk67NRyvTNvG2Z3zUdQUylKW3Bw3WmGHXlo0/ZcnZ5nHd+YuJ7CiygUN plWXSOWxAlqe4kYlpfkDtTmoA26x2OxRN04fh5Q5dJSXY9IRYZTvzHwSaQ/bIcCggUuR 5ZzHWz4CvyQ/OyA1HBR6M0UmBJdqkPx8e5i3LkCZVayN11EKaTfMyoJjrhmQUm2GgzPQ 2Bc/czC5UchfPSkNhvkqjz6k3Xu6aP2BK9woLTLDTn/r3HU5zGtUOi9YOwHDPOzUyY5k KAjz08+ijIUFF2NI0hNE2Yy4C6VLRB7pbvw2MFLnN2V/K2WeQvXqhdZzscVEm+ILzzl6 GOVQ== X-Forwarded-Encrypted: i=1; AFNElJ9XI4JBjn4VFprSlpNygW3WTswRnO+HA3yaukEdEiQauGo74rxgyKvOsWurbPTI1jBBMteDM+sFJQKV0bY=@vger.kernel.org X-Gm-Message-State: AOJu0YxrxGSVmRpDrFiEr6zWYQusd3pyWc82eE/pLixFExvTqi5gjhVK bjZmWpTkDdt5KhTfez8e5UMaVrOCFnTI4CytCDZrpmOzm1ayzgTl9AvhMZO+8DmA+Hh/KZN6fEB oaZKQzg== X-Received: from pfbdi7.prod.google.com ([2002:a05:6a00:4807:b0:82a:ff5:27d5]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:7486:b0:398:b346:b13 with SMTP id adf61e73a8af0-39fe3d0dfafmr19709277637.16.1776174254172; Tue, 14 Apr 2026 06:44:14 -0700 (PDT) Date: Tue, 14 Apr 2026 06:44:02 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260409213333.1995382-1-seanjc@google.com> Message-ID: Subject: Re: [PATCH] KVM: Drop kvm_vcpu.ready to squash race where "ready" can get stuck "true" From: Sean Christopherson To: zhanghao <76824143@qq.com> Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, zhanghao , Wanpeng Li Content-Type: text/plain; charset="us-ascii" On Tue, Apr 14, 2026, zhanghao wrote: > On Thu, Apr 09, 2026, Sean Christopherson wrote: > > Drop kvm_vcpu.ready and instead detect the case where a recently awakened > > vCPU is runnable but not yet scheduled in by explicitly, manually checking > > for a target vCPU that is (a) scheduled out, (b) wants to run, (c) is > > marked as blocking in its stat, but (d) not actually flagged as blocking. > > I.e. treat a runnable vCPU that's in the blocking sequence but not truly > > blocking as a candidate for directed yield. > > > > Keying off vcpu->stat.generic.blocking will yield some number of false > > positives, e.g. if the vCPU is preempted _before_ blocking, but the rate of > > false positives should be roughly the same as the existing approach, as > > kvm_sched_out() would previously mark the vCPU as ready when it's scheduled > > out and runnable. > > > > Eliminating the write to vcpu->ready in kvm_vcpu_wake_up() fixes a race > > where vcpu->ready could be set *after* the target vCPU is scheduled in, > > e.g. if the task waking the target vCPU is preempted (or otherwise delayed) > > after waking the vCPU, but before setting vcpu->ready. Hitting the race > > leads to a very degraded state as KVM will constantly attempt to schedule > > in a vCPU that is already running. ... > kvm_vcpu.ready still exists in struct kvm_vcpu, but there are no remaining > users after this patch, so it looks like a leftover cleanup item. Gah, I intended to remove kvm_vcpu.ready, not sure how I didn't. Thanks!