From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52CB4C388F9 for ; Mon, 23 Nov 2020 13:46:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE9A9206F1 for ; Mon, 23 Nov 2020 13:46:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="dx9rZZeX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388065AbgKWNq1 (ORCPT ); Mon, 23 Nov 2020 08:46:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387672AbgKWNqZ (ORCPT ); Mon, 23 Nov 2020 08:46:25 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20704C0613CF for ; Mon, 23 Nov 2020 05:46:25 -0800 (PST) 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=eqo+5xtEEChY6Yq+NrnAD5DS1fVhv2fF+uY8pMNKUoY=; b=dx9rZZeX0w2VnNC6liFUcqYbpV RYhMYe6HKsbb0o5u3CtMpp6Ds+78K9FaZjZ7GduiKaOo7Z4EwaZrLQHCS00a9dm4HKSmVeb4xG27U 2Lmgf2w3x0FhXGXPKf9muzRdy6wq2VuD1uctE5roHoD50cHFexzskejYSUQh1+PICEIkGVz6aPFtY ctC7UVrSaUIQNUQQKx0YdJMEt75L9lu8R8SUW1n8aoiGEAk6YA5j5geOT809XCFH+CERxwQWgYW0C dmO/wQ5msYZW3Ni8m0qotGCz3v98X8xAe17YaZwbFu8JZzwpOp2+6Gk52y3dzLw0SxyBplLjvleWK 38aJJ/jw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1khCAd-0005vj-9x; Mon, 23 Nov 2020 13:46:19 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 5797F3069B1; Mon, 23 Nov 2020 14:46:18 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 427C7210782E4; Mon, 23 Nov 2020 14:46:18 +0100 (CET) Date: Mon, 23 Nov 2020 14:46:18 +0100 From: Peter Zijlstra To: "Rafael J. Wysocki" Cc: Viresh Kumar , Ingo Molnar , the arch/x86 maintainers , Mark Rutland , Will Deacon , svens@linux.ibm.com, Linux Kernel Mailing List Subject: Re: [PATCH 2/2] intel_idle: Fix intel_idle() vs tracing Message-ID: <20201123134618.GL3021@hirez.programming.kicks-ass.net> References: <20201120114145.197714127@infradead.org> <20201120114925.652731270@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 23, 2020 at 11:26:39AM +0100, Rafael J. Wysocki wrote: > On Fri, Nov 20, 2020 at 12:50 PM Peter Zijlstra wrote: > > > > cpuidle->enter() callbacks should not call into tracing because RCU > > has already been disabled. Instead of doing the broadcast thing > > itself, simply advertise to the cpuidle core that those states stop > > the timer. > > > > Signed-off-by: Peter Zijlstra (Intel) > > --- > > drivers/idle/intel_idle.c | 37 ++++++++++++++++++++----------------- > > 1 file changed, 20 insertions(+), 17 deletions(-) > > > > --- a/drivers/idle/intel_idle.c > > +++ b/drivers/idle/intel_idle.c > > @@ -126,26 +126,9 @@ static __cpuidle int intel_idle(struct c > > struct cpuidle_state *state = &drv->states[index]; > > unsigned long eax = flg2MWAIT(state->flags); > > unsigned long ecx = 1; /* break on interrupt flag */ > > - bool tick; > > - > > - if (!static_cpu_has(X86_FEATURE_ARAT)) { > > - /* > > - * Switch over to one-shot tick broadcast if the target C-state > > - * is deeper than C1. > > - */ > > - if ((eax >> MWAIT_SUBSTATE_SIZE) & MWAIT_CSTATE_MASK) { > > - tick = true; > > - tick_broadcast_enter(); > > - } else { > > - tick = false; > > - } > > - } > > > > mwait_idle_with_hints(eax, ecx); > > > > - if (!static_cpu_has(X86_FEATURE_ARAT) && tick) > > - tick_broadcast_exit(); > > - > > return index; > > } > > > > @@ -1460,6 +1443,23 @@ static bool __init intel_idle_verify_cst > > return true; > > } > > > > +static bool __init intel_idle_state_needs_timer_stop(struct cpuidle_state *state) > > +{ > > + unsigned long eax = flg2MWAIT(state->flags); > > + > > + if (boot_cpu_has(X86_FEATURE_ARAT)) > > + return false; > > + > > + /* > > + * Switch over to one-shot tick broadcast if the target C-state > > + * is deeper than C1. > > + */ > > + if ((eax >> MWAIT_SUBSTATE_SIZE) & MWAIT_CSTATE_MASK) > > + return true; > > + > > + return false; > > +} > > + > > static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv) > > { > > int cstate; > > @@ -1507,6 +1507,9 @@ static void __init intel_idle_init_cstat > > !(cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_ALWAYS_ENABLE))) > > drv->states[drv->state_count].flags |= CPUIDLE_FLAG_OFF; > > > > + if (intel_idle_state_needs_timer_stop(&drv->states[drv->state_count])) > > + drv->states[drv->state_count].flags |= CPUIDLE_FLAG_TIMER_STOP; > > + > > drv->state_count++; > > } > > This doesn't cover the ACPI case AFAICS. aa6b43d57f99 ("ACPI: processor: Use CPUIDLE_FLAG_TIMER_STOP") did that, no?