Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp901078iol; Thu, 9 Jun 2022 17:07:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTp+8EGcCW588vWsSytzhz451cSqkVzJZBXVxOwFBEPlBowGB/QEynoxPZ/iVCp9hPSUQ4 X-Received: by 2002:a17:903:210a:b0:167:78c0:dd70 with SMTP id o10-20020a170903210a00b0016778c0dd70mr24666923ple.157.1654819633085; Thu, 09 Jun 2022 17:07:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654819633; cv=none; d=google.com; s=arc-20160816; b=mlU25zAfkneWEEQYg9fKgtylPlMdyy145eI0PPRNLEDmT/6oLTEGpDE2Zfkixs8FX0 O/GUEI9By6MtpdYa/Hp5LeRbN5ROzURZ+iEV8uGbL5y0ARNYMMyCpFV+0EDw5EFoU3Gi GYXiV1Bsluhg6zAw1i4QN9kzbEOwfYIYNOJ5AW46yjuMJWggCU49C0ICpo55mQ0ZYOih ApBajS0/gIMtNO3JuhXZf4WUEap243SRCGVi9j159xnV8gGWJADic+JR2CmQhyuskcuK WbK0802YIBPto4h0cUbN1oJF3b/sJ9Ow0Q6saOxx5OBKxM27WCpEeV+/PvfmdMoDHJ13 evFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=6fCZUlxGiFsWn8MV8hd6HCQPILJupLdtPX8/ISEromA=; b=HCH4YowGcrp6VDHkVoc0bHMVB785JjmaKfHSlulW/HZ06RNnQ3bYzS6QqDloRBxa/I mGWhI8jjbMf2rlmQoxjXsuDRZYvoWP9Yvna7f5mc1WoFUz5q1aJoCVfVZsv3azxrtrsJ brNTKvvHptaCBruA3N2KjqVyt/EXiSMwnocOu0joV6akfzDgJGX5GnBfJ20AcBlDAO6E Dvg6o8oduTZMxfuTATj4ouM7qVk7fKNCiY1IGzLH6vd0k8a79hCWPCTsFGIbTfNRKFm+ 57apZzpK2Db9F+dT0xpUslUIi678B/TykxGdQ710UkXdIPIVKStiz+yPzX5BS98jdckf ID4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EkaTUs0r; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x1-20020a170902fe8100b001635f7dccffsi33798303plm.493.2022.06.09.17.06.58; Thu, 09 Jun 2022 17:07:13 -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=@intel.com header.s=Intel header.b=EkaTUs0r; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239628AbiFIXp1 (ORCPT + 99 others); Thu, 9 Jun 2022 19:45:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232670AbiFIXpY (ORCPT ); Thu, 9 Jun 2022 19:45:24 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E963A60ABF; Thu, 9 Jun 2022 16:45:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654818322; x=1686354322; h=date:from:to:cc:subject:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/qix89+4Yux2UyS3QMBWmKLCne+VvkXES21cCGFIhLs=; b=EkaTUs0rea+454rYaBsqSroRFg0PamD4jU6O0eq1wv/5itn58fVYLUXz hlWtv1Ogpl7/5XIS618tIb0uG/q2+eGCMXsttxiOJDTm6dvjif29rcsmN nWpOfx8wOz2WQB1f6Ul8b7EGNqASBsmk3lVSAAbjuyEvvEhAIHeX8zQmg +ufj+64/oRf3ev5vJZH5Yejs7zEtNES51/2LxU4etWbj7BVv+kw0q1QiP unGfwpuQghUcTK8rXLxr286tVxF9gYfN+irF5pYrEItvr0xmkc2yTnQok EbNfwxaIzp9UCsQ8gskKbD4HfjRVXi6KKS6myyqzqnJkOJaWOKufoYQaK A==; X-IronPort-AV: E=McAfee;i="6400,9594,10373"; a="278263539" X-IronPort-AV: E=Sophos;i="5.91,288,1647327600"; d="scan'208";a="278263539" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2022 16:45:19 -0700 X-IronPort-AV: E=Sophos;i="5.91,288,1647327600"; d="scan'208";a="610480359" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.7.198.157]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2022 16:45:19 -0700 Date: Thu, 9 Jun 2022 16:49:21 -0700 From: Jacob Pan To: Peter Zijlstra Cc: rth@twiddle.net, ink@jurassic.park.msu.ru, mattst88@gmail.com, vgupta@kernel.org, linux@armlinux.org.uk, ulli.kroll@googlemail.com, linus.walleij@linaro.org, shawnguo@kernel.org, Sascha Hauer , kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, tony@atomide.com, khilman@kernel.org, catalin.marinas@arm.com, will@kernel.org, guoren@kernel.org, bcain@quicinc.com, chenhuacai@kernel.org, kernel@xen0n.name, geert@linux-m68k.org, sammy@sammy.net, monstr@monstr.eu, tsbogend@alpha.franken.de, dinguyen@kernel.org, jonas@southpole.se, stefan.kristiansson@saunalahti.fi, shorne@gmail.com, James.Bottomley@HansenPartnership.com, deller@gmx.de, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, ysato@users.sourceforge.jp, dalias@libc.org, davem@davemloft.net, richard@nod.at, anton.ivanov@cambridgegreys.com, johannes@sipsolutions.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, jgross@suse.com, srivatsa@csail.mit.edu, amakhalov@vmware.com, pv-drivers@vmware.com, boris.ostrovsky@oracle.com, chris@zankel.net, jcmvbkbc@gmail.com, rafael@kernel.org, lenb@kernel.org, pavel@ucw.cz, gregkh@linuxfoundation.org, mturquette@baylibre.com, sboyd@kernel.org, daniel.lezcano@linaro.org, lpieralisi@kernel.org, sudeep.holla@arm.com, agross@kernel.org, bjorn.andersson@linaro.org, anup@brainfault.org, thierry.reding@gmail.com, jonathanh@nvidia.com, Arnd Bergmann , yury.norov@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, rostedt@goodmis.org, pmladek@suse.com, senozhatsky@chromium.org, john.ogness@linutronix.de, paulmck@kernel.org, frederic@kernel.org, quic_neeraju@quicinc.com, josh@joshtriplett.org, mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com, joel@joelfernandes.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, jpoimboe@kernel.org, linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-um@lists.infradead.org, linux-perf-users@vger.kernel.org, virtualization@lists.linux-foundation.org, xen-devel@lists.xenproject.org, linux-xtensa@linux-xtensa.org, linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org, jacob.jun.pan@linux.intel.com Subject: Re: [PATCH 04/36] cpuidle,intel_idle: Fix CPUIDLE_FLAG_IRQ_ENABLE Message-ID: <20220609164921.5e61711d@jacob-builder> In-Reply-To: <20220608144516.172460444@infradead.org> References: <20220608142723.103523089@infradead.org> <20220608144516.172460444@infradead.org> Organization: OTC X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 Hi Peter, On Wed, 08 Jun 2022 16:27:27 +0200, Peter Zijlstra wrote: > Commit c227233ad64c ("intel_idle: enable interrupts before C1 on > Xeons") wrecked intel_idle in two ways: > > - must not have tracing in idle functions > - must return with IRQs disabled > > Additionally, it added a branch for no good reason. > > Fixes: c227233ad64c ("intel_idle: enable interrupts before C1 on Xeons") > Signed-off-by: Peter Zijlstra (Intel) > --- > drivers/idle/intel_idle.c | 48 > +++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 > insertions(+), 11 deletions(-) > > --- a/drivers/idle/intel_idle.c > +++ b/drivers/idle/intel_idle.c > @@ -129,21 +137,37 @@ static unsigned int mwait_substates __in > * > * Must be called under local_irq_disable(). > */ nit: this comment is no long true, right? > + > -static __cpuidle int intel_idle(struct cpuidle_device *dev, > - struct cpuidle_driver *drv, int index) > +static __always_inline int __intel_idle(struct cpuidle_device *dev, > + struct cpuidle_driver *drv, int > index) { > struct cpuidle_state *state = &drv->states[index]; > unsigned long eax = flg2MWAIT(state->flags); > unsigned long ecx = 1; /* break on interrupt flag */ > > - if (state->flags & CPUIDLE_FLAG_IRQ_ENABLE) > - local_irq_enable(); > - > mwait_idle_with_hints(eax, ecx); > > return index; > } > > +static __cpuidle int intel_idle(struct cpuidle_device *dev, > + struct cpuidle_driver *drv, int index) > +{ > + return __intel_idle(dev, drv, index); > +} > + > +static __cpuidle int intel_idle_irq(struct cpuidle_device *dev, > + struct cpuidle_driver *drv, int > index) +{ > + int ret; > + > + raw_local_irq_enable(); > + ret = __intel_idle(dev, drv, index); > + raw_local_irq_disable(); > + > + return ret; > +} > + > /** > * intel_idle_s2idle - Ask the processor to enter the given idle state. > * @dev: cpuidle device of the target CPU. > @@ -1801,6 +1824,9 @@ static void __init intel_idle_init_cstat > /* Structure copy. */ > drv->states[drv->state_count] = > cpuidle_state_table[cstate]; > + if (cpuidle_state_table[cstate].flags & > CPUIDLE_FLAG_IRQ_ENABLE) > + drv->states[drv->state_count].enter = > intel_idle_irq; + > if ((disabled_states_mask & BIT(drv->state_count)) || > ((icpu->use_acpi || force_use_acpi) && > intel_idle_off_by_default(mwait_hint) && > > Thanks, Jacob