From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 58B491854 for ; Mon, 19 May 2025 16:03:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747670582; cv=none; b=nlzGM9FNpysRll3GJJ9W0I4OBeTACDI4EIa5ank7KzXFWnjTFEy+7UEuRp6BFRyX+SCV9tf0cxA3A7t/DPuVjfj5Nkn7g+Qu9+wJaD5m6pVniFcwVU9uHAR8F/NlCW3THbC6o8oyS9ZYYir+U2fXQRqgDS/HlqvMKAwCXLeMVIg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747670582; c=relaxed/simple; bh=jJebhOC5pck9JgTcHl2pSKfcuNTMt61u6YUTJ5kvTUw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=JWh4yf5/QE0CXnuN6EqakjGCfO+vaV0uiZ5txb7QebpxW+0nL7daTtDrBhE383qAuGVRDktF8eU3DrF4TcnE7Wgvlh9sCFm0UAjykyiYHloyXC67v7JGFdC8tsBYFC20vFyjdGXGKYK9LIF8jnBQRv4m+6duN4EtvmFy6nwY7MA= 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=coH15fm8; arc=none smtp.client-ip=209.85.216.73 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="coH15fm8" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-30e78145dc4so4712751a91.2 for ; Mon, 19 May 2025 09:03:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1747670580; x=1748275380; 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=ebJzx1LorPbf1NWqtTpnidvsrFRDAcdzNorkYWG1GY4=; b=coH15fm8DVgjJ9oVSK3pCxJlawUFPoHKISQE8BhpNKYwmBUliHUCewwDchSulcNumd LdvmKH3uF3FH//WFA4pI67zykejtgvMNAdvTUD1Mp4uXq3283uHUkZ74/RTmm3etKu+G KKsfUjsPXPBH3T3X3S8FDrfMdQmtfCzap8btLV53zHZIYl20gfP888Vc8EFwksn04HnD HbnKZxqcwDmzFmYvD7mo2U/nWYtoVrM/w8/K/ek2s3Xv/23sNjEVwZprupLZZkZIlhK/ d7peMsu1j3yHtyNIpKxcWjgaS2TgKUrlxl3UpUkW0biPVs8xqJQiM5okPefBDAXzQDXk L2Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747670580; x=1748275380; 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=ebJzx1LorPbf1NWqtTpnidvsrFRDAcdzNorkYWG1GY4=; b=b+cWE74TnvgTEuUUf8f8IHTq/88R8TwDMgQ2pPl1kK/DyOubn9IommIjotgFSt/lZ7 I+MwZfo1+d9BvPEpfiya8Ai2u2Py7mCuJzt8pxl1IismpgWdSzEVnubFtms0WjLq5GAO nKwBmTmml6MmBWUF0RXlWNMNyfXCWFCKviG4RfL0xBcsC62D4IY4TufQEp8BJFg9PAo5 JULiLSp1oQ9AdcvBiTI1qs0/aVooONDi59D4uI1iG+l2R4hPfEYYOdxpYKXKhf+8TPzu 4ha1AIEWTfTMrWIOhjy9q9nYCpY/qmjYunobyYdUEIdyKhdu08G9D1gmp4BOuNTChJ6k +fLQ== X-Forwarded-Encrypted: i=1; AJvYcCVa0FCg/KfcgCtGpuMxgkqXmhqpGS3KH1FepmAIB4nCmswHk+MIlYxY69OxaWHFRZvaVWj6l/BA+ygXyPc=@vger.kernel.org X-Gm-Message-State: AOJu0YyT2ssZZKkDVie/ok3fd0t+vw1yWHEUThpwYljvApY+gB71Nvw7 8ONXbT8FwWzqBfRKLbB6Vq3mC8osiu50F3DqUTu3Q+XSHKs4SSUfJQ+FrjVGmDOXyBOuV49Bpz4 Okl1OWg== X-Google-Smtp-Source: AGHT+IGgPwGOMBLaCWE5KFajgM1k5GAAtbgHFzAkvoKLZILtRQoRL0lrXZ29F1zNrZz+oqAiBi5JJlM1Uas= X-Received: from pja16.prod.google.com ([2002:a17:90b:5490:b0:30a:3021:c1af]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90a:d888:b0:30e:823f:ef3c with SMTP id 98e67ed59e1d1-30e823ff09dmr21512162a91.25.1747670580528; Mon, 19 May 2025 09:03:00 -0700 (PDT) Date: Mon, 19 May 2025 09:02:59 -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: <20250516212833.2544737-1-seanjc@google.com> <20250516212833.2544737-8-seanjc@google.com> Message-ID: Subject: Re: [PATCH v2 7/8] x86, lib: Add wbinvd and wbnoinvd helpers to target multiple CPUs From: Sean Christopherson To: Ingo Molnar Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Paolo Bonzini , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, dri-devel@lists.freedesktop.org, Zheyun Shen , Tom Lendacky , Kevin Loughlin , Kai Huang , Mingwei Zhang Content-Type: text/plain; charset="us-ascii" On Sat, May 17, 2025, Ingo Molnar wrote: > > * Sean Christopherson wrote: > > > From: Zheyun Shen > > > > Extract KVM's open-coded calls to do writeback caches on multiple CPUs to > > common library helpers for both WBINVD and WBNOINVD (KVM will use both). > > Put the onus on the caller to check for a non-empty mask to simplify the > > SMP=n implementation, e.g. so that it doesn't need to check that the one > > and only CPU in the system is present in the mask. > > > > Signed-off-by: Zheyun Shen > > Reviewed-by: Tom Lendacky > > Link: https://lore.kernel.org/r/20250128015345.7929-2-szy0127@sjtu.edu.cn > > [sean: move to lib, add SMP=n helpers, clarify usage] > > Acked-by: Kai Huang > > Signed-off-by: Sean Christopherson > > --- > > arch/x86/include/asm/smp.h | 12 ++++++++++++ > > arch/x86/kvm/x86.c | 8 +------- > > arch/x86/lib/cache-smp.c | 12 ++++++++++++ > > 3 files changed, 25 insertions(+), 7 deletions(-) > > > > diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h > > index e08f1ae25401..fe98e021f7f8 100644 > > --- a/arch/x86/include/asm/smp.h > > +++ b/arch/x86/include/asm/smp.h > > @@ -113,7 +113,9 @@ void native_play_dead(void); > > void play_dead_common(void); > > void wbinvd_on_cpu(int cpu); > > void wbinvd_on_all_cpus(void); > > +void wbinvd_on_many_cpus(struct cpumask *cpus); > > void wbnoinvd_on_all_cpus(void); > > +void wbnoinvd_on_many_cpus(struct cpumask *cpus); > > Let's go with the _on_cpumask() suffix: > > void wbinvd_on_cpu(int cpu); > +void wbinvd_on_cpumask(struct cpumask *cpus); > void wbinvd_on_all_cpus(void); > > And the wb*invd_all_cpus() methods should probably be inlined wrappers > with -1 as the cpumask, or so - not two separate functions? Using two separate functions allows _on_all_cpus() to defer the mask generation to on_each_cpu(), i.e. avoids having to duplicate the passing of cpu_online_mask. IMO, duplicating passing __wbinvd is preferable to duplicating the use of cpu_online_mask. > In fact it would be nice to have the DRM preparatory patch and all the > x86 patches at the beginning of the next version of the series, so > those 4 patches can be applied to the x86 tree. Can make it a separate > permanent branch based on v6.15-rc6/rc7. Can do, assuming there's no lurking dependency I'm missing.