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 5D62B2C08DC for ; Wed, 25 Feb 2026 20:11:33 +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=1772050294; cv=none; b=Jv+RXxCI7IOZsNWL/rgwtBzPPTEGVtkTGx/tgmEZy6Uo5gD1S+xfbylp7vYovmZ5ZNS8czhppjw5UxXR5SBeNsypcNAtZYZ7rq/Gn4eIvgWN5iblvgMEG5CyI8r4KMEv/wPmiVovmqcbunzVuusafRZPWFGBc0QUfKXZuaZtbzQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772050294; c=relaxed/simple; bh=xb240UHeJZUpSheryUetfPnHX+Or5u1jl7cIe9qLxno=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=F5+CObAQGnIJCP5g4vuCM8B6WRmPrmKaU9rHQw32fnd0Ccv3g4tLrDoxAb4/SQ74YhOT/Dx7BvFTygVCE0EngA/M4TqF7HLfkyAwLWAPhSr9P0519xTpqJ/ci0OlA8cRpN6ShmBRdX0in1vlkcijn1hSetUqOg+MbQqIw15wNgg= 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=A+5JWYKQ; 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="A+5JWYKQ" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2ab0b2e804cso171435ad.3 for ; Wed, 25 Feb 2026 12:11:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772050293; x=1772655093; 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=l12W4BbMOvS46dH8NvG0bfSFtU9wMtIxMN8ZzhevNqI=; b=A+5JWYKQxnVD5EXVFIur1MWNAwKcG9bCb8KIfudNJB8x0qwjHebgxy/crsMHdJS24L DRcQrW5JWjwpIrdX3ETKgM7lz1RAl1c88RBgO0nXmcuqQvL0k+IgQLKfjxAO/s8PGzkr 8l0dP8jzHoDSTvbWPf+rn08l4cDvJ7msSoYWUwT3i5jOoowTFyFzam2Yfj3rlrdBH2ws YGnPh9CVxlIRbawpGDzLKdqUi23IJXk9psAhftBDBxwUfm7LZeN7/4mUP2WuDNwW094x lPjVHmBp/j/bVXqjtiKRH9l6YS5B6XVkHKxfltIjKCsTJDhAxYj971NXDZaTwW1vAa5u z9Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772050293; x=1772655093; 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=l12W4BbMOvS46dH8NvG0bfSFtU9wMtIxMN8ZzhevNqI=; b=KqsTnG5ywQBvxADdOeUN4/lGEdzhqpotPNnlyvRhFoaEdx3thjcdOLoIdzOxPU8JXb wey/PKAJxQaVPjQXULnk9IoOon6xnl1vRkE231QWS1BHOhIks+j9sOHfohDij1MMLKtO hT+fsiLm4KADE0x2wL0qO/fNl7m1Lyu/9y4GDoZMe5g72EiaTDzjwiX7AL19XxPncTDk dO7dxsrxHSq6F56T0Nz9gQWuByPV5vxkDAIF8Vmm8+pzh3SIVwXssmMBJqfySF0Yy1U/ +2DttX45Q46FhC9MkI//j7pHaLQVO/eGHCMitTTb0Y7rx9BalBzt4B0FjqetvIMOCUJg 1Ueg== X-Forwarded-Encrypted: i=1; AJvYcCWxtM8QW/LEAM3PhPCX7gla9AD3nDMUkigrRjRg9LVeW58P5/35QwXXGYvKpG8HlMRoL/PSXBNUorScbcM=@vger.kernel.org X-Gm-Message-State: AOJu0YxjMKFGoR897EmOjPZy0z/iXFNYAgBVLh1uxMz4FGDuV7VLoWeM 3rsXXZk/cv0Snmf5o5caW3pysO878NxqrTMWkHinEeXfRtw8tRsyrACrp88Yt4rAZlJqxIXaIgh iNPbGgw== X-Received: from pghq22.prod.google.com ([2002:a63:e216:0:b0:c6e:700a:2902]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:72a3:b0:371:53a7:a4aa with SMTP id adf61e73a8af0-39545ebb5a6mr14949603637.29.1772050292456; Wed, 25 Feb 2026 12:11:32 -0800 (PST) Date: Wed, 25 Feb 2026 12:11:30 -0800 In-Reply-To: <20260202074557.16544-4-lance.yang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260202074557.16544-1-lance.yang@linux.dev> <20260202074557.16544-4-lance.yang@linux.dev> Message-ID: Subject: Re: [PATCH v4 3/3] x86/tlb: add architecture-specific TLB IPI optimization support From: Sean Christopherson To: Lance Yang Cc: akpm@linux-foundation.org, david@kernel.org, dave.hansen@intel.com, dave.hansen@linux.intel.com, ypodemsk@redhat.com, hughd@google.com, will@kernel.org, aneesh.kumar@kernel.org, npiggin@gmail.com, peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, arnd@arndb.de, lorenzo.stoakes@oracle.com, ziy@nvidia.com, baolin.wang@linux.alibaba.com, Liam.Howlett@oracle.com, npache@redhat.com, ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org, shy828301@gmail.com, riel@surriel.com, jannh@google.com, jgross@suse.com, pbonzini@redhat.com, boris.ostrovsky@oracle.com, virtualization@lists.linux.dev, kvm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, ioworker0@gmail.com Content-Type: text/plain; charset="us-ascii" On Mon, Feb 02, 2026, Lance Yang wrote: > diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c > index 37dc8465e0f5..6a5e47ee4eb6 100644 > --- a/arch/x86/kernel/kvm.c > +++ b/arch/x86/kernel/kvm.c > @@ -856,6 +856,12 @@ static void __init kvm_guest_init(void) > #ifdef CONFIG_SMP > if (pv_tlb_flush_supported()) { > pv_ops.mmu.flush_tlb_multi = kvm_flush_tlb_multi; > + /* > + * KVM's flush implementation calls native_flush_tlb_multi(), > + * which sends real IPIs when INVLPGB is not available. Not on all (virtual) CPUs. The entire point of KVM's PV TLB flush is to elide the IPIs. If a vCPU was scheduled out by the host, the guest sets a flag and relies on the host to flush the TLB on behalf of the guest prior to the next VM-Enter. for_each_cpu(cpu, flushmask) { /* * The local vCPU is never preempted, so we do not explicitly * skip check for local vCPU - it will never be cleared from * flushmask. */ src = &per_cpu(steal_time, cpu); state = READ_ONCE(src->preempted); if ((state & KVM_VCPU_PREEMPTED)) { if (try_cmpxchg(&src->preempted, &state, state | KVM_VCPU_FLUSH_TLB)) __cpumask_clear_cpu(cpu, flushmask); <=== removes CPU from the IPI set } } native_flush_tlb_multi(flushmask, info); > + if (!cpu_feature_enabled(X86_FEATURE_INVLPGB)) > + pv_ops.mmu.flush_tlb_multi_implies_ipi_broadcast = true; > pr_info("KVM setup pv remote TLB flush\n"); > }