Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp491056pxu; Thu, 3 Dec 2020 05:39:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJxRb9ouRqzrHkTK54i8BhjTGjNJQkJEA/ov1oP7a/XYK/6aV3r8+Hojc5pCJuaL255nP+/Y X-Received: by 2002:a05:6402:308b:: with SMTP id de11mr840249edb.205.1607002786110; Thu, 03 Dec 2020 05:39:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607002786; cv=none; d=google.com; s=arc-20160816; b=B7dVjhXxoO9NNC/5fSZmLefPt/g2+c8kSK9db8ScdJJwsSAROUod+xuVCQhjsGIQ6M bjFwOphYSq4x/TvTBIE9BH1XwehSXSHUHQfO9CLUhRH66DPRc4DhPiSAEy23R7zKnHdu Y1LNslOtsrQGAu9k1JunXRT9OvhpRpJluknBOCPSSfqXzcnS7v5SXuMeWS1nY3Pi6tR2 s/Pf83njDg3QKVI12IKxlgoMNMUBY82ph55Fw2pJZiHDJnDS1I8s8kQxMXXXreCoj/3+ i5xIUJEuf6TG6heFtytOjoYBvXhnEt11dIP8FEfJMgQvmn4eA860jQti7ZFMSUpOo1qr Z7gg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=WLV7cXmmz20kE5apJu+ZdLcAmDWHS60tqL3CXoqFRcg=; b=NBmFSuW2jbz/1+eqg56aEsXgD4EXm00EAqea9en1Gt+ZM1aSlKdxR6pcAVcdbaOwSQ 8S00T6WKaPWXObLNbPF+DwPchwPdEL/xROeToorygG8kTswZVGHrJ3MCne69ALYWKyBm m9Gi3lm/iONuXtrvHT9wsjgDXFM1EF5Z9DsWsb3sqjP/Isj8xsC0ir3aAjcBpP7Yfft3 kWQNEHWJV9PHnyEERO4jcsGHWG5uWhrcoQCgF6EaKIZaC1D+If6a/hRaWKsQgAjDvEY/ tRPO4tourQaup60+5kBkeI1/g9Q+jhLCn1wU9C0BsOAlkZOeoR3Mp6pGOKuBAdtLHrB0 Z9kg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t26si1064989ejx.4.2020.12.03.05.39.16; Thu, 03 Dec 2020 05:39:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730648AbgLCNhf (ORCPT + 99 others); Thu, 3 Dec 2020 08:37:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:47984 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436561AbgLCNaX (ORCPT ); Thu, 3 Dec 2020 08:30:23 -0500 From: Sasha Levin Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Peter Zijlstra , "Rafael J . Wysocki" , Sasha Levin , linux-pm@vger.kernel.org Subject: [PATCH AUTOSEL 5.9 28/39] intel_idle: Fix intel_idle() vs tracing Date: Thu, 3 Dec 2020 08:28:22 -0500 Message-Id: <20201203132834.930999-28-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201203132834.930999-1-sashal@kernel.org> References: <20201203132834.930999-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Zijlstra [ Upstream commit 6e1d2bc675bd57640f5658a4a657ae488db4c204 ] 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) Acked-by: Rafael J. Wysocki Link: https://lkml.kernel.org/r/20201123143510.GR3021@hirez.programming.kicks-ass.net Signed-off-by: Sasha Levin --- drivers/idle/intel_idle.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index d09b807e1c3a1..cc6d1b12388e1 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c @@ -122,26 +122,9 @@ static __cpuidle int intel_idle(struct cpuidle_device *dev, 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; } @@ -1223,6 +1206,20 @@ static bool __init intel_idle_acpi_cst_extract(void) return false; } +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. + */ + return !!((eax >> MWAIT_SUBSTATE_SIZE) & MWAIT_CSTATE_MASK); +} + static void __init intel_idle_init_cstates_acpi(struct cpuidle_driver *drv) { int cstate, limit = min_t(int, CPUIDLE_STATE_MAX, acpi_state_table.count); @@ -1265,6 +1262,9 @@ static void __init intel_idle_init_cstates_acpi(struct cpuidle_driver *drv) if (disabled_states_mask & BIT(cstate)) state->flags |= CPUIDLE_FLAG_OFF; + if (intel_idle_state_needs_timer_stop(state)) + state->flags |= CPUIDLE_FLAG_TIMER_STOP; + state->enter = intel_idle; state->enter_s2idle = intel_idle_s2idle; } @@ -1503,6 +1503,9 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv) !(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++; } -- 2.27.0