From nobody Mon Sep 15 07:35:03 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90ACBC54EBE for ; Fri, 13 Jan 2023 12:32:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241372AbjAMMcq (ORCPT ); Fri, 13 Jan 2023 07:32:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241208AbjAMMcH (ORCPT ); Fri, 13 Jan 2023 07:32:07 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB1FD4319C; Fri, 13 Jan 2023 04:31:06 -0800 (PST) Date: Fri, 13 Jan 2023 12:31:04 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1673613065; 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=48P8KVWCYjMGGvLZjw2r6s5bxt15ORTDOcSGZ3/Il2Q=; b=xTBd4OWCGmaNV4APjPCKnJixlVG65hrEm5Ok6jXl3FCyCorsFB3TNki09EghgZPw4CeHhF t/ZldtXAzNp6IhJelqmJFuyqPhByDrkfj8MaJiJsPXNVIu0FI8+c8as9gUI6+evTSDfbF4 uhJwlhqTTkv6IbAY8arEmoUfDfG1E/zSsqxbQDDPBvsIyR7Coj/ShvK44PxXwfeR7+9XPU QfK30Pb7aBYThjOnBvJNUb40HJqL79n8ODcF67Cq/AfHnUKuyDdnAEyXCGkm3gidPYnWga la7KSBgShJNS2MchnO9mMf7c1j1vyWD3w3lJODEGOcz4XeImn258UxIh8Wk/+g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1673613065; 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=48P8KVWCYjMGGvLZjw2r6s5bxt15ORTDOcSGZ3/Il2Q=; b=MLW5crS0wxMIz2rrWnMMu75203GVRbIZ0au/pJ7cDipr/UXG2YCyiBs8qwFsbnn/Lg/Jq2 l1LJ1a7KUMZ1k1DQ== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] cpuidle: Add comments about noinstr/__cpuidle usage Cc: "Peter Zijlstra (Intel)" , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230112195542.397238052@infradead.org> References: <20230112195542.397238052@infradead.org> MIME-Version: 1.0 Message-ID: <167361306473.4906.1967859270536906724.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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: 0e985e9d22864e29d5d2b3d909ad15134d7f6d46 Gitweb: https://git.kernel.org/tip/0e985e9d22864e29d5d2b3d909ad15134= d7f6d46 Author: Peter Zijlstra AuthorDate: Thu, 12 Jan 2023 20:44:04 +01:00 Committer: Ingo Molnar CommitterDate: Fri, 13 Jan 2023 11:48:18 +01:00 cpuidle: Add comments about noinstr/__cpuidle usage Add a few words on noinstr / __cpuidle usage. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20230112195542.397238052@infradead.org --- drivers/cpuidle/cpuidle.c | 12 ++++++++++++ include/linux/compiler_types.h | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 73f7d8b..500d172 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -252,6 +252,18 @@ noinstr int cpuidle_enter_state(struct cpuidle_device = *dev, instrumentation_begin(); } =20 + /* + * NOTE!! + * + * For cpuidle_state::enter() methods that do *NOT* set + * CPUIDLE_FLAG_RCU_IDLE RCU will be disabled here and these functions + * must be marked either noinstr or __cpuidle. + * + * For cpuidle_state::enter() methods that *DO* set + * CPUIDLE_FLAG_RCU_IDLE this isn't required, but they must mark the + * function calling ct_cpuidle_enter() as noinstr/__cpuidle and all + * functions called within the RCU-idle region. + */ entered_state =3D target_state->enter(dev, drv, index); =20 if (WARN_ONCE(!irqs_disabled(), "%ps leaked IRQ state", target_state->ent= er)) diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index d785890..dea5bf5 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -239,6 +239,16 @@ struct ftrace_likely_data { =20 #define noinstr __noinstr_section(".noinstr.text") =20 +/* + * The __cpuidle section is used twofold: + * + * 1) the original use -- identifying if a CPU is 'stuck' in idle state b= ased + * on it's instruction pointer. See cpu_in_idle(). + * + * 2) supressing instrumentation around where cpuidle disables RCU; where= the + * function isn't strictly required for #1, this is interchangeable wi= th + * noinstr. + */ #define __cpuidle __noinstr_section(".cpuidle.text") =20 #endif /* __KERNEL__ */