Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1065730rdb; Sat, 7 Oct 2023 10:11:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGNklFHUrLf12v1H3Ow4UcYXqQlQPrJ3exlvsu3gNHhUN+7ef3suhSvIRLSKsOiaEiZaYIe X-Received: by 2002:a17:90a:db8a:b0:274:945b:6979 with SMTP id h10-20020a17090adb8a00b00274945b6979mr10479598pjv.16.1696698672849; Sat, 07 Oct 2023 10:11:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696698672; cv=none; d=google.com; s=arc-20160816; b=g3joPa6HX407a0l3fP4Oq1+yxwyPPc1W9m6dj5PjwwGD89iQD+ic6+w+4iaKi1VaR+ QvaxFFDTXWr/eC6W7Z+cnNwnG7H6d639094lLMlirWJtRXVjQMy0cQRK4psL1yHAWnnl T6etFk4WmZ3/twCe0b82IEJm1hritgsa3HQGe2UBY8m12nzz5A+YjZ+tiOu2Sde9l2nM YVc+FVkK/Ir8upeD1mRdQFF86yNDbhpEEznlEd/gmlgvr11l9EpLJ9grSVIEQrAI/jd5 ejNAPO5lOwjUVEzq7JA0nW23UnfZFY5vO7/ojfFXhDWS8i0jnTaZjOKkLQL57pbKGKkx aJIQ== 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=SAONc9WOBgvp1ZGsbpOFNuRJBUWaPIv7XR4QPQyRKsQ=; fh=9hbCrlT43iXm4uesi0nu9AJusJzEgkVU2SuAPew9Phs=; b=Gnv8xnwq4Ye8iBSLesvhrD60PLsCWS4287MUuxBbflnTmdDyl38JxITWuZLtle3Nzu tIe9drtQOgEpZpxun9zZz7pKDF6mWjpreeYVBOPrXhj0iZ3yiE129Jekoo2oRj8xx6Kx ZGBnP8UExFmDzmosY7T6Bvr0RJyYem16hJ5tySs0yYgXurlFyMFML3d+OVdpKJ18Ftse 9kEi2vDJg0H/kuvobsnFT3hdZDNxA04SLQVwUylqJMHDlHYx56Tm2s9KzIP1YzF3DRWm lISadMB5y2FBZvZ3DjiEWQ0pUsjosP4fv6w9mWbUM4VU2me3+tDUOEoxh3uk34H5gQD6 wllw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=EdmAzSKx; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=exLohR97; 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 Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id o2-20020a17090a5b0200b0027909685905si6060108pji.149.2023.10.07.10.11.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 10:11:12 -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=EdmAzSKx; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=exLohR97; 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 0563680BBC69; Sat, 7 Oct 2023 10:11:12 -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 S1344132AbjJGRLF (ORCPT + 99 others); Sat, 7 Oct 2023 13:11:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344113AbjJGRLE (ORCPT ); Sat, 7 Oct 2023 13:11:04 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5611B9F; Sat, 7 Oct 2023 10:11:01 -0700 (PDT) Date: Sat, 07 Oct 2023 17:10:58 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696698660; 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=SAONc9WOBgvp1ZGsbpOFNuRJBUWaPIv7XR4QPQyRKsQ=; b=EdmAzSKxZ4wl8gyFRqgNq549vgm0LAtmrz5MQMP+iKC6i7i3HfSvskegIZ05rzVaA3Qo3/ a+3uTBTGrBhzOMKvw8Lz1koTYERPKeMF61Guth3sVBS38yNutydRDOvKr/uTT/mOzpAm62 CnrLzEIVSmrKBF51WBYrRFJqv7n3ZnQAu3vckgqRW7R0s9of6OSZHLdom8Bat/2bhnQD8n 8Ko8CEsNxwPFzkKIb7WhSaS6oN5cv5q6MOumQyzx4gghY8Y8WqFIj3KiCULxXawIgrIVbQ VeBp03rTW5RxUTS2sH4kY6lV8eR0CImgFH5fvT3VTHTdhUTlrS4EQpuicsDX6g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696698660; 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=SAONc9WOBgvp1ZGsbpOFNuRJBUWaPIv7XR4QPQyRKsQ=; b=exLohR973qAL3A9BeHy47VV1sK1J1Z+3QAlPOOSmZFY7sOM9VpHCaqR8AwshTorUdLLWXE ivYQCOe4K64gmvAg== From: "tip-bot2 for Waiman Long" 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 , Ingo Molnar , "Rafael J. Wysocki" , Linus Torvalds , 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: <169669865877.3135.4050101364714116656.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact 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 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: 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]); Sat, 07 Oct 2023 10:11:12 -0700 (PDT) The following commit has been merged into the sched/core branch of tip: Commit-ID: 2743fe89d4d41616ffbe1e7e96e443ae7a4b1cc6 Gitweb: https://git.kernel.org/tip/2743fe89d4d41616ffbe1e7e96e443ae7a4b1cc6 Author: Waiman Long AuthorDate: Thu, 27 Jul 2023 14:45:58 -04:00 Committer: Ingo Molnar CommitterDate: Sat, 07 Oct 2023 11:33:28 +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 Signed-off-by: Ingo Molnar Acked-by: Rafael J. Wysocki Cc: Linus Torvalds 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 #include #include +#include /* 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);