Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1753041lqe; Mon, 8 Apr 2024 21:27:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVZWpdda3/gUsTaOWorSyLlYwSK1vwvN0xLIX/s35DKaiEcfxp5I79ddUWbLnb0MVtN+ShxJHHR8WvyeAN6ZwAJs6EMZ7WRQbytSgPq8g== X-Google-Smtp-Source: AGHT+IGHoeacAiyfCae7a/iuyAoJ1slMsvPHw5pHXBkyneuanIacupmaNfQ3ZsOOaagQbJL2OOD+ X-Received: by 2002:a17:903:1d2:b0:1e4:3f8d:12ca with SMTP id e18-20020a17090301d200b001e43f8d12camr3626071plh.14.1712636825717; Mon, 08 Apr 2024 21:27:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712636825; cv=pass; d=google.com; s=arc-20160816; b=McVxe67BK8Y/iAjFkPVAuab4JowBE78sK4wfgKm1+WmGMRNTjEvr2U0woG8OC5YA3o tBytaQWsRpzZaUTJ0udDZ4/P0n4KhwLIMX7rWXi3aiFEGTBJ4mTxKyGEY0vU0Oq0iL14 Sc4E8JwiYmueFTczgv5FTETebvow6xCF8U+SAlIwCC43YoyOuGUcIKzvt2GhECRTNuoy N8my3l0ocoTsV+OqvcuujgW53HGDjm1oTx/wJgiK9Ss0hWk2Ruom+ftiFic7ruAeZuRh FC+nZDHD6yUQwRg33GAHo5hJ0ul97XaTv+cWiVq25WSWDLXq36UUUIf97XtRQw6diTji tKMg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from; bh=pgEvXZ25dRWmySiYMFRISCJDg29RjT709UwKafutfjg=; fh=URudYr1j3fUKHyQcM3dl+3+t2f10grBntHPd9NFJ4ko=; b=UCgWU3hWZgNN/aUsMFEO9XNVJYK62fUNtj6JJsNtmjvjWgdxkkPDMf4QkXohjAQAaE ACg82eY3bDoSloJh0s8e/+XaJvj42jRdO2DXJ4HR3cf6fZaminwYdpyB37NoB+E+mtgW Zm0629yLaBFaVgEU2kG6CZyEU67funXqFxrRiRiP7CkaQjbtibcOpldS4hCDfO32r8GJ 5NgLLOGfO8eDekPGfmRZ+A2rCpFc2vlfoONP/6xkYqDDsXElYDYxj0HP7pwVJfvFRYx8 4UEq/moQWGHDhmLXBbHdg58rvgbv083vgI6AD+P2tiwP4iFDfmMzuECEROmasXAlwfiT PuzQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=baidu.com dmarc=pass fromdomain=baidu.com); spf=pass (google.com: domain of linux-kernel+bounces-136229-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136229-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=baidu.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id mf13-20020a170902fc8d00b001e4a76f6d89si290774plb.184.2024.04.08.21.27.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 21:27:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136229-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=baidu.com dmarc=pass fromdomain=baidu.com); spf=pass (google.com: domain of linux-kernel+bounces-136229-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136229-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=baidu.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 56DC7284492 for ; Tue, 9 Apr 2024 04:27:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E7C725FB96; Tue, 9 Apr 2024 04:26:56 +0000 (UTC) Received: from njjs-sys-mailin01.njjs.baidu.com (mx312.baidu.com [180.101.52.108]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7C29355E49; Tue, 9 Apr 2024 04:26:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=180.101.52.108 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712636816; cv=none; b=ToLPWQZQ0LcdFlIOPvuJdmS4hmFXzRnVK17aEGSMQ6yn6nr5ikwkgsvO0/wbkeSkidID0t3KmgrpQMN9LqmPQh7NF/EhKiT67ufSFRZQ/jWOC0qzigPTGetmO9bmeg1Rx42qHtmhxMTR+t66nExQcbWN0QxqLRR+46j0jzlIASA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712636816; c=relaxed/simple; bh=jGNXxHR/Fh4U/7Tq9uNGVzYyZsoPbyiNVcG5X3Bq9MM=; h=From:To:Cc:Subject:Date:Message-Id; b=Qt1OBnSE4vZgXD+IppGThMrcX/jHGH8HI0MZBjEuY/C8ylwgKVw7t0bOxDimnmuH8x2f204MsVZP4n8wtuxuGnmCTlMG5h3yPKA8KnV9YbbmlywpYH2SEhC/8ltZ0DH83hpqgWWAWsJc+dxEy7DANUw1i73pmvMdh4aaANWeb2I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=baidu.com; spf=pass smtp.mailfrom=baidu.com; arc=none smtp.client-ip=180.101.52.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=baidu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baidu.com Received: from localhost (bjhw-sys-rpm015653cc5.bjhw.baidu.com [10.227.53.39]) by njjs-sys-mailin01.njjs.baidu.com (Postfix) with ESMTP id 4BFD87F00045; Tue, 9 Apr 2024 12:20:59 +0800 (CST) From: Li RongQing To: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, peterz@infradead.org, linux-kernel@vger.kernel.org, pbonzini@redhat.com, kvm@vger.kernel.org, seanjc@google.com, szy0127@sjtu.edu.cn, thomas.lendacky@amd.com Cc: Li RongQing Subject: [PATCH][RFC] x86,lib: Add wbinvd_on_many_cpus helpers Date: Tue, 9 Apr 2024 12:20:56 +0800 Message-Id: <20240409042056.51757-1-lirongqing@baidu.com> X-Mailer: git-send-email 2.9.4 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: wbinvd_on_many_cpus will call smp_call_function_many(), which should be more efficient that iterating cpus since it would run wbinvd() concurrently locally and remotely it can be used by the below patch https://patchwork.kernel.org/project/kvm/patch/1860502863.219296.1710395908135.JavaMail.zimbra@sjtu.edu.cn/ Cc: Zheyun Shen Cc: Tom Lendacky Signed-off-by: Li RongQing --- arch/x86/include/asm/smp.h | 7 +++++++ arch/x86/lib/cache-smp.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h index a35936b..70973de 100644 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -111,6 +111,7 @@ void native_play_dead(void); void play_dead_common(void); void wbinvd_on_cpu(int cpu); int wbinvd_on_all_cpus(void); +int wbinvd_on_many_cpus(const struct cpumask *mask); void smp_kick_mwait_play_dead(void); @@ -159,6 +160,12 @@ static inline int wbinvd_on_all_cpus(void) return 0; } +static inline int wbinvd_on_many_cpus(const struct cpumask *mask) +{ + wbinvd(); + return 0; +} + static inline struct cpumask *cpu_llc_shared_mask(int cpu) { return (struct cpumask *)cpumask_of(0); diff --git a/arch/x86/lib/cache-smp.c b/arch/x86/lib/cache-smp.c index 7af743b..5950d1b 100644 --- a/arch/x86/lib/cache-smp.c +++ b/arch/x86/lib/cache-smp.c @@ -20,3 +20,10 @@ int wbinvd_on_all_cpus(void) return 0; } EXPORT_SYMBOL(wbinvd_on_all_cpus); + +int wbinvd_on_many_cpus(const struct cpumask *mask) +{ + smp_call_function_many(mask, __wbinvd, NULL, 1); + return 0; +} +EXPORT_SYMBOL(wbinvd_on_many_cpus); -- 2.9.4