Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp8986840rwd; Wed, 21 Jun 2023 01:14:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ65rah5Ph6kBGd5cD/CmIN9GA0NyFmMEUs8avAJcQOeao8iKnMVXxSH0FSyrt/y8PGShrUK X-Received: by 2002:a05:6a20:3ca6:b0:121:6413:a08e with SMTP id b38-20020a056a203ca600b001216413a08emr11369225pzj.32.1687335248329; Wed, 21 Jun 2023 01:14:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687335248; cv=none; d=google.com; s=arc-20160816; b=wgfzi2dse2ssf1qku7glqHlP0zIWaH8CVZNcypaVZfE5Cq+7h1jTLsYb9SiGCmuh8n 1mqij2IoMtCrWk12fnI2QWDlPR1zoFe7bI8JlAKwZmXT4ZQNzQQ0tjjMYxPpradg44Tq VlA0KPM55q3M9m7EW1htDiTuHPceGJ7pgHK+sYo+3vYwwpTdzn8hKKconSaFSVYub1E4 IgOsuC0TXGTnrsozUisQYQv4kgFimmKpCEh8eVpMC/pqkjYm28q/Hs+zRaNcoljL95Sv VePzlLx/ofcnsEcQbKUZvwo0qh77oAyFIflJipo27NmThCdOhRpEOYuaRRot4HXzinke NtMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=NaqaQxah/FrLZHICWXU12yQMjvpRgrOIvBO2ioW93AY=; b=H2r0xJ77YoNVyuwSyBHJK8XyEGkYvMG6GxIycq/VtwUs7cT6Sd0KpNzKlBSxVTaaOq pZKKxjjjNBVywDd+kvgKo6c2BS+hou3uGIt0wFij55QiVtssw/6s9QRUbwznoV5OCnbD hw5kvDT1WhqxlWJQUz7+BsS//3IpIDBNVzCWKdYEfvDp8PCkJiyN6fbZj+w0V7+pHckU 7E6ZJgH1sR6wmKUGIz9q8hz1d4Sr8lETkpqF6YfVPQTvtGwmxoT045PefIQsVWaybaCt Tl7VmQo+OxLxbUWh5jubyDb3LdbbQ5586eE+HoSFPOC2fIwbiViJSFXfGeFv7+AwPufL 6XzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=KHNtTWbS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t7-20020a63b247000000b00553cb7e51e5si3405815pgo.818.2023.06.21.01.13.55; Wed, 21 Jun 2023 01:14:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=KHNtTWbS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231313AbjFUHby (ORCPT + 99 others); Wed, 21 Jun 2023 03:31:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230280AbjFUHbv (ORCPT ); Wed, 21 Jun 2023 03:31:51 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A4AD1710; Wed, 21 Jun 2023 00:31:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=NaqaQxah/FrLZHICWXU12yQMjvpRgrOIvBO2ioW93AY=; b=KHNtTWbSJEl/nBGTJsXuEeIdgW qVjhcFPOFwYWiaWIa0LK1iFSvpDOOTZdB/Ozowojefd0Wvjq7x38/6KcqWQkDs/ZsGNRIe9ZzzNlC UAqFWAsLDDF3K1ujtfh0z18i/p46ELqQRAL2VzBhCbH+XNYUE60eADsxslcLBB0d737i7/MvbaNYf b1f6qfzS4YrNERERk5tSlre56eoPRP1Me7tOxjzrTtS41Qbxi6PXLf9FbbIFITU69OFrDIUU+v6Wy z/X2ILqzrNvfFfeXToHnHuiqj3/HqMiGuF39YrsJEWV4htcqVMeQrq2ODCecMJoP0NXXCZKNO8H+Q nm4NeHAw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qBsIr-00E6Ol-4c; Wed, 21 Jun 2023 07:30:57 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id BA10A3002A9; Wed, 21 Jun 2023 09:30:56 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 9F4EC2419FDEF; Wed, 21 Jun 2023 09:30:56 +0200 (CEST) Date: Wed, 21 Jun 2023 09:30:56 +0200 From: Peter Zijlstra To: Waiman Long Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Josh Poimboeuf , Pawan Gupta , Jacob Pan , Len Brown , linux-kernel@vger.kernel.org, x86@kernel.org, linux-pm@vger.kernel.org, Robin Jarry , Joe Mario Subject: Re: [PATCH v2 4/5] intel_idle: Add no_ibrs module parameter to force disable IBRS Message-ID: <20230621073056.GB2046280@hirez.programming.kicks-ass.net> References: <20230620140625.1001886-1-longman@redhat.com> <20230620140625.1001886-5-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230620140625.1001886-5-longman@redhat.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,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: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 20, 2023 at 10:06:24AM -0400, Waiman Long wrote: > Commit bf5835bcdb96 ("intel_idle: Disable IBRS during long idle") > disables IBRS when the cstate is 6 or lower. However, there are > some use cases where a customer may want to use max_cstate=1 to > lower latency. And then add the WRMSRs to increase latency again... Since you're mucking about with all this, perhaps see if you can measure the latency impact of all this. > Such use cases will suffer from the performance > degradation caused by the enabling of IBRS in the sibling idle thread. > Add a "no_ibrs" module parameter to force disable IBRS and the > CPUIDLE_FLAG_IRQ_ENABLE flag if set. > > In the case of a Skylake server with max_cstate=1, this new no_ibrs > option will increase the IRQ response latency as IRQ will now be > disabled. > > Signed-off-by: Waiman Long > --- > drivers/idle/intel_idle.c | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c > index 07fa23707b3c..366dacccc971 100644 > --- a/drivers/idle/intel_idle.c > +++ b/drivers/idle/intel_idle.c > @@ -69,6 +69,7 @@ static int max_cstate = CPUIDLE_STATE_MAX - 1; > static unsigned int disabled_states_mask __read_mostly; > static unsigned int preferred_states_mask __read_mostly; > static bool force_irq_on __read_mostly; > +static bool no_ibrs __read_mostly; > > static struct cpuidle_device __percpu *intel_idle_cpuidle_devices; > > @@ -1907,12 +1908,15 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv) > WARN_ON_ONCE(state->flags & CPUIDLE_FLAG_IRQ_ENABLE); > state->enter = intel_idle_xstate; > } else if (cpu_feature_enabled(X86_FEATURE_KERNEL_IBRS) && > - state->flags & CPUIDLE_FLAG_IBRS) { > + ((state->flags & CPUIDLE_FLAG_IBRS) || no_ibrs)) { > /* > * IBRS mitigation requires that C-states are entered > * with interrupts disabled. > */ > - WARN_ON_ONCE(state->flags & CPUIDLE_FLAG_IRQ_ENABLE); > + if (no_ibrs && (state->flags & CPUIDLE_FLAG_IRQ_ENABLE)) > + state->flags &= ~CPUIDLE_FLAG_IRQ_ENABLE; > + else > + WARN_ON_ONCE(state->flags & CPUIDLE_FLAG_IRQ_ENABLE); > state->enter = intel_idle_ibrs; > } else if (state->flags & CPUIDLE_FLAG_IRQ_ENABLE) { > state->enter = intel_idle_irq; > @@ -2165,3 +2169,9 @@ MODULE_PARM_DESC(preferred_cstates, "Mask of preferred idle states"); > * 'CPUIDLE_FLAG_INIT_XSTATE' and 'CPUIDLE_FLAG_IBRS' flags. > */ > module_param(force_irq_on, bool, 0444); > +/* > + * Force the disabling of IBRS when X86_FEATURE_KERNEL_IBRS is on and > + * CPUIDLE_FLAG_IRQ_ENABLE isn't set. > + */ > +module_param(no_ibrs, bool, 0444); > +MODULE_PARM_DESC(no_ibrs, "Disable IBRS when idle"); Urgghhh.. the flag is CPUIDLE_FLAG_IBRS, so "no_ibrs" implies clearing that flag.