[tip:,sched/core] x86/idle: Disable IBRS when CPU is offline to improve single-threaded performance
Message ID | 169643443299.3135.10404749389371354446.tip-bot2@tip-bot2 |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:254a:b0:403:3b70:6f57 with SMTP id hf10csp225780vqb; Wed, 4 Oct 2023 08:47:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG9N3YlFmAtQJbQdidYGZCB3hYBEI9SKJEs3oqEYPg1zE9k+C3XBNhGD+DlGiMMWF7v8YLS X-Received: by 2002:a05:6358:788:b0:133:428:35dc with SMTP id n8-20020a056358078800b00133042835dcmr2979320rwj.11.1696434446266; Wed, 04 Oct 2023 08:47:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696434446; cv=none; d=google.com; s=arc-20160816; b=HoucRN6xwXcy8oyMkUln+mOFeL/mQ1aAgUFHZoeJPrjN5aWivzVjTbWYs8WUchciQ1 cEW54b9kRMoG/jqI+IVVFhjjt7KougSKURu2QRTyDERnpgbnhjCiEAt3wdmiXJhp8D84 /tpIuQ/y61TceGLfmX7v/EuCjgK/iEJt+a01PgQQj3+CCnTiebZWYiRpm73/km3R5O7l oObM6D9NzZAg6bcxs24WOhR9F7YwvhXYsSgMAX3ck8dwu1HBv/xqxDSWfau9oOiFHvOj d7Y9TykOyMPImVPPDUt5YAN+ig722sLe+t8qAS/0VMP+ydZDOV/x0gi+M/oB1IvOJOrY hsMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=IY/4LSYrmKOjHyh4TuahT+p2n+E3pAPQMItJAR6DqwI=; fh=9hbCrlT43iXm4uesi0nu9AJusJzEgkVU2SuAPew9Phs=; b=wqpspTjK4IfLnjgB8rbheNOMLH1QV8Cb+pCkNrtsj/r6V2xFkZssg1LoN7/ua3iWJ0 OBGN+oqrxtnLVX1/61dSjrea96Mw955ZnnXc5RAj0mpTqBqff9bl5HSe6J+/1f9Ud2Zn 4AftVwNWXt7TOySjqcUNXmWcumv7mJksgP4ysm+PSoWjb45+4BJe6Ry34LUW1jEsofkU KqRzn3OUmeP4KhT4j5S05c9jxEmkskXzq9BAiEapYeIWZdEjk3kAQ64azPIDPl2CSu2S QeZV4gXWpaHYOe+rYhRkI4vVANBWLtqmK3GWkeEhcu43jum8H2QSiJRhv49RoUoaHtLY KyqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=LyX4a0wU; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="4/M8TnT1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id r27-20020a638f5b000000b005775a0cd009si4044383pgn.331.2023.10.04.08.47.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 08:47:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=LyX4a0wU; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="4/M8TnT1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 56656822CF91; Wed, 4 Oct 2023 08:47:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242908AbjJDPrW (ORCPT <rfc822;pusanteemu@gmail.com> + 18 others); Wed, 4 Oct 2023 11:47:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233658AbjJDPrS (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 4 Oct 2023 11:47:18 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12CE8BF; Wed, 4 Oct 2023 08:47:15 -0700 (PDT) Date: Wed, 04 Oct 2023 15:47:12 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696434433; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IY/4LSYrmKOjHyh4TuahT+p2n+E3pAPQMItJAR6DqwI=; b=LyX4a0wUqwbipqCJ5uofwV+d+o7XBm9jiOkxLECAOYxr2YD2N5Ls4+j+rETZy64WX0Tgca zCX24rOzOLNgXOumFYjcU1T6pwu13QV/d7dNjlleMn2jHQxUG7Evu7xRVrXn1ml1VMfMyI PjU/5KJ6rrSD9vpYL5aCidxZMIX7ATBwCqUXwqeugm1ko0uDaGxKGeAmCK6mVr2cSPXxik X53M1viUKEPgGDgx91CKEfmG3jOt8+/SA7DdjZmm/AdLIEUmQgDMiiewYoiiiH50mfTLcI Q6e1ZpGFvnFMsXzoDQA1F+wvLuYTu05sw09Sto+OY7rhJkU1jsCX7j8EL6NnHw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696434433; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IY/4LSYrmKOjHyh4TuahT+p2n+E3pAPQMItJAR6DqwI=; b=4/M8TnT1w6l6kTvMlFKc5AZIPUPvFLYyoDZyH2YTCwMxTo1kt5VAFoqwSEOWCM5Hwi4upM a51pLxi+DFZ2IdDQ== From: "tip-bot2 for Waiman Long" <tip-bot2@linutronix.de> Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] x86/idle: Disable IBRS when CPU is offline to improve single-threaded performance Cc: Waiman Long <longman@redhat.com>, Ingo Molnar <mingo@kernel.org>, "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>, Linus Torvalds <torvalds@linux-foundation.org>, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230727184600.26768-3-longman@redhat.com> References: <20230727184600.26768-3-longman@redhat.com> MIME-Version: 1.0 Message-ID: <169643443299.3135.10404749389371354446.tip-bot2@tip-bot2> Robot-ID: <tip-bot2@linutronix.de> Robot-Unsubscribe: Contact <mailto:tglx@linutronix.de> to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 04 Oct 2023 08:47:25 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778840445683414143 X-GMAIL-MSGID: 1778840445683414143 |
Series |
[tip:,sched/core] x86/idle: Disable IBRS when CPU is offline to improve single-threaded performance
|
|
Commit Message
tip-bot2 for Thomas Gleixner
Oct. 4, 2023, 3:47 p.m. UTC
The following commit has been merged into the sched/core branch of tip: Commit-ID: 8c7a9b1bb45060b6e67456c3cf28475f6e0bd65d Gitweb: https://git.kernel.org/tip/8c7a9b1bb45060b6e67456c3cf28475f6e0bd65d Author: Waiman Long <longman@redhat.com> AuthorDate: Thu, 27 Jul 2023 14:45:58 -04:00 Committer: Ingo Molnar <mingo@kernel.org> CommitterDate: Wed, 04 Oct 2023 13:48:48 +02:00 x86/idle: Disable IBRS when CPU is offline to improve single-threaded performance Commit bf5835bcdb96 ("intel_idle: Disable IBRS during long idle") disables IBRS when the CPU enters long idle. However, when a CPU becomes offline, the IBRS bit is still set when X86_FEATURE_KERNEL_IBRS is enabled. That will impact the performance of a sibling CPU. Mitigate this performance impact by clearing all the mitigation bits in SPEC_CTRL MSR when offline. When the CPU is online again, it will be re-initialized and so restoring the SPEC_CTRL value isn't needed. Add a comment to say that native_play_dead() is a __noreturn function, but it can't be marked as such to avoid confusion about the missing MSR restoration code. When DPDK is running on an isolated CPU thread processing network packets in user space while its sibling thread is idle. The performance of the busy DPDK thread with IBRS on and off in the sibling idle thread are: IBRS on IBRS off ------- -------- packets/second: 7.8M 10.4M avg tsc cycles/packet: 282.26 209.86 This is a 25% performance degradation. The test system is a Intel Xeon 4114 CPU @ 2.20GHz. [ mingo: Extended the changelog with performance data from the 0/4 mail. ] Signed-off-by: Waiman Long <longman@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lore.kernel.org/r/20230727184600.26768-3-longman@redhat.com --- arch/x86/kernel/smpboot.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 48e0406..02765d9 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -87,6 +87,7 @@ #include <asm/hw_irq.h> #include <asm/stackprotector.h> #include <asm/sev.h> +#include <asm/spec-ctrl.h> /* representing HT siblings of each logical CPU */ DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_sibling_map); @@ -1623,8 +1624,15 @@ void __noreturn hlt_play_dead(void) native_halt(); } +/* + * native_play_dead() is essentially a __noreturn function, but it can't + * be marked as such as the compiler may complain about it. + */ void native_play_dead(void) { + if (cpu_feature_enabled(X86_FEATURE_KERNEL_IBRS)) + __update_spec_ctrl(0); + play_dead_common(); tboot_shutdown(TB_SHUTDOWN_WFS);