From patchwork Thu Apr 6 14:45:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Ellerman X-Patchwork-Id: 671389 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 A7FCFC76196 for ; Thu, 6 Apr 2023 14:47:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239454AbjDFOru (ORCPT ); Thu, 6 Apr 2023 10:47:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229803AbjDFOrc (ORCPT ); Thu, 6 Apr 2023 10:47:32 -0400 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB481AD3D for ; Thu, 6 Apr 2023 07:45:57 -0700 (PDT) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4Psknr2BzMz4xFZ; Fri, 7 Apr 2023 00:45:52 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1680792352; bh=xPxa877hnQ/ia2BPQZXawdRAt1BVSr9MAYE3vUoMiCM=; h=From:To:Cc:Subject:Date:From; b=PERGucNT5wNEHwGDTCppTfkLRzkC8lfXfZ4hLd0Kwz8KF9tYXZHlwTm0tgJm+Ck+F E7ClYoQVTAq1fKAhosfoG2RT+t+/fn3HuJYsSDQBEH3SwzYdFRG/zJpvd89HM5iIfD /YUQFcC4r2EY/m/rBweeTjDEXsD9eLbj9kJGIDHftuXh3r2njGlTG6zyhh70kYCgp2 A316fNfar/OySOclvVeAVbo0y421BhYm88VgP9BiRjfmvT6s2RDZahma9QDYZS75WP 10iMH5vAPvQpDV+1O+KxWCv2XI7daErGiFjoHxk2wjVzesMM8Mm5UWQI+FyT997Qxg ln+h0XcYhsJyQ== From: Michael Ellerman To: Cc: , , linux-pm@vger.kernel.org Subject: [PATCH 1/4] powerpc/64: Mark prep_irq_for_idle() __cpuidle Date: Fri, 7 Apr 2023 00:45:32 +1000 Message-Id: <20230406144535.3786008-1-mpe@ellerman.id.au> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Code in the idle path is not allowed to be instrumented because RCU is disabled, see commit 0e985e9d2286 ("cpuidle: Add comments about noinstr/__cpuidle usage"). Mark prep_irq_for_idle() __cpuidle, which is equivalent to noinstr, to enforce that. Suggested-by: Peter Zijlstra Signed-off-by: Michael Ellerman --- arch/powerpc/kernel/irq_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/irq_64.c b/arch/powerpc/kernel/irq_64.c index c788c55512ed..2ab0e8d84c1d 100644 --- a/arch/powerpc/kernel/irq_64.c +++ b/arch/powerpc/kernel/irq_64.c @@ -354,7 +354,7 @@ EXPORT_SYMBOL(arch_local_irq_restore); * disabled and marked as such, so the local_irq_enable() call * in arch_cpu_idle() will properly re-enable everything. */ -bool prep_irq_for_idle(void) +__cpuidle bool prep_irq_for_idle(void) { /* * First we need to hard disable to ensure no interrupt From patchwork Thu Apr 6 14:45:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Ellerman X-Patchwork-Id: 670954 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 3C84CC77B6F for ; Thu, 6 Apr 2023 14:47:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238530AbjDFOrv (ORCPT ); Thu, 6 Apr 2023 10:47:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238145AbjDFOrd (ORCPT ); Thu, 6 Apr 2023 10:47:33 -0400 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB3CB9748 for ; Thu, 6 Apr 2023 07:45:57 -0700 (PDT) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4Psknr5wJ0z4xFf; Fri, 7 Apr 2023 00:45:52 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1680792352; bh=qodY2Q6CbcE/PBC3R4o7HdbOAge0infBVNAA92K2ITM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kaqSS7OIeEjpjtZkELzMk9V5UHap9SFDVhQEU8UA/HqCTcI7sas9JLN8XNzH/LJOm iziSdk9lq8QXDYKBnbxOKVLBgZwI/8bXMT6THnPtst17zYR8sBjkaEZ9hEoYsTZ4c2 IJdFCX686rb1UHn06jWbPbZhOIgAAiEpoOtnhUuD2M/inJn2SXkDkfudQC0UnbsOez RnK5r1DKlo1QAqkt2GmF4tSDT43o3TEZHkD+QRSIpcLvd4hR0JdM6SpDVI4FL1uJwN lKY8t6Q+20u7CrZlm+0RXkn/BselT3D+fumGMIRaaFB/EmKnUQvD0uAKUFdXN8r2xd tT4lpP6G/ygfQ== From: Michael Ellerman To: Cc: , , linux-pm@vger.kernel.org Subject: [PATCH 2/4] powerpc/64: Don't call trace_hardirqs_on() in prep_irq_for_idle() Date: Fri, 7 Apr 2023 00:45:33 +1000 Message-Id: <20230406144535.3786008-2-mpe@ellerman.id.au> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230406144535.3786008-1-mpe@ellerman.id.au> References: <20230406144535.3786008-1-mpe@ellerman.id.au> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Since commit a01353cf1896 ("cpuidle: Fix ct_idle_*() usage"), the cpuidle entry code calls trace_hardirqs_on() (actually trace_hardirqs_on_prepare()) in ct_cpuidle_enter() before calling into the cpuidle driver. Suggested-by: Peter Zijlstra Signed-off-by: Michael Ellerman --- arch/powerpc/kernel/irq_64.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/kernel/irq_64.c b/arch/powerpc/kernel/irq_64.c index 2ab0e8d84c1d..938e66829eae 100644 --- a/arch/powerpc/kernel/irq_64.c +++ b/arch/powerpc/kernel/irq_64.c @@ -348,9 +348,8 @@ EXPORT_SYMBOL(arch_local_irq_restore); * already the case when ppc_md.power_save is called). The function * will return whether to enter power save or just return. * - * In the former case, it will have notified lockdep of interrupts - * being re-enabled and generally sanitized the lazy irq state, - * and in the latter case it will leave with interrupts hard + * In the former case, it will have generally sanitized the lazy irq + * state, and in the latter case it will leave with interrupts hard * disabled and marked as such, so the local_irq_enable() call * in arch_cpu_idle() will properly re-enable everything. */ @@ -370,9 +369,6 @@ __cpuidle bool prep_irq_for_idle(void) if (lazy_irq_pending()) return false; - /* Tell lockdep we are about to re-enable */ - trace_hardirqs_on(); - /* * Mark interrupts as soft-enabled and clear the * PACA_IRQ_HARD_DIS from the pending mask since we From patchwork Thu Apr 6 14:45:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Ellerman X-Patchwork-Id: 671388 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 77204C761A6 for ; Thu, 6 Apr 2023 14:47:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238909AbjDFOrv (ORCPT ); Thu, 6 Apr 2023 10:47:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230111AbjDFOrd (ORCPT ); Thu, 6 Apr 2023 10:47:33 -0400 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8E4CBBAD for ; Thu, 6 Apr 2023 07:45:57 -0700 (PDT) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4Pskns2WsXz4xDt; Fri, 7 Apr 2023 00:45:53 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1680792353; bh=K5G4sSTXgNXS7YdhIg4VtzOB7UwPzbyCN9hXlUrIQvk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dzSZ31ZxAODsLSMGjrCaYgfR9gKyzhjdYKrfNIMn0CDQndzCxdPFO8KHIitb0bX4M GJASLOjAAAgJgqy3T7w8jhoi8tkKS6k5i9OYrfsCn6N4alSJvviCIZbr79a5MhzLRq GAl/hha49Aj5oMACTF5mFPJ+LjP382+LIJoE/9EYFjf3w8imVlvYO4WNmz4WdOa+R9 swSg9tVF4Owh6a+dAldDRH3NgwMdWQjNk5teVP/IRKP5LdlKN4B65/hDNMgMOFGr+d R/5xFryNVv+HkHxlHJOxRGxqyL6GQPmMJduocioTeJ2al9LUOWgj8K6ay5IeyXTAe+ PptM3lvbmt23Q== From: Michael Ellerman To: Cc: , , linux-pm@vger.kernel.org Subject: [PATCH 3/4] cpuidle: pseries: Mark ->enter() functions as __cpuidle Date: Fri, 7 Apr 2023 00:45:34 +1000 Message-Id: <20230406144535.3786008-3-mpe@ellerman.id.au> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230406144535.3786008-1-mpe@ellerman.id.au> References: <20230406144535.3786008-1-mpe@ellerman.id.au> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Code in the idle path is not allowed to be instrumented because RCU is disabled, see commit 0e985e9d2286 ("cpuidle: Add comments about noinstr/__cpuidle usage"). Mark the cpuidle ->enter() callbacks as __cpuidle and use the raw_local_irq_*() routines to ensure that is the case. Reported-by: Sachin Sant Suggested-by: Peter Zijlstra Signed-off-by: Michael Ellerman Tested-by: Sachin Sant --- drivers/cpuidle/cpuidle-pseries.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/cpuidle/cpuidle-pseries.c b/drivers/cpuidle/cpuidle-pseries.c index 1bad4d2b7be3..a7d33f3ee01e 100644 --- a/drivers/cpuidle/cpuidle-pseries.c +++ b/drivers/cpuidle/cpuidle-pseries.c @@ -33,16 +33,16 @@ static struct cpuidle_state *cpuidle_state_table __read_mostly; static u64 snooze_timeout __read_mostly; static bool snooze_timeout_en __read_mostly; -static int snooze_loop(struct cpuidle_device *dev, - struct cpuidle_driver *drv, - int index) +static __cpuidle +int snooze_loop(struct cpuidle_device *dev, struct cpuidle_driver *drv, + int index) { u64 snooze_exit_time; set_thread_flag(TIF_POLLING_NRFLAG); pseries_idle_prolog(); - local_irq_enable(); + raw_local_irq_enable(); snooze_exit_time = get_tb() + snooze_timeout; dev->poll_time_limit = false; @@ -65,14 +65,14 @@ static int snooze_loop(struct cpuidle_device *dev, HMT_medium(); clear_thread_flag(TIF_POLLING_NRFLAG); - local_irq_disable(); + raw_local_irq_disable(); pseries_idle_epilog(); return index; } -static void check_and_cede_processor(void) +static __cpuidle void check_and_cede_processor(void) { /* * Ensure our interrupt state is properly tracked, @@ -216,9 +216,9 @@ static int __init parse_cede_parameters(void) #define NR_DEDICATED_STATES 2 /* snooze, CEDE */ static u8 cede_latency_hint[NR_DEDICATED_STATES]; -static int dedicated_cede_loop(struct cpuidle_device *dev, - struct cpuidle_driver *drv, - int index) +static __cpuidle +int dedicated_cede_loop(struct cpuidle_device *dev, struct cpuidle_driver *drv, + int index) { u8 old_latency_hint; @@ -230,7 +230,7 @@ static int dedicated_cede_loop(struct cpuidle_device *dev, HMT_medium(); check_and_cede_processor(); - local_irq_disable(); + raw_local_irq_disable(); get_lppaca()->donate_dedicated_cpu = 0; get_lppaca()->cede_latency_hint = old_latency_hint; @@ -239,9 +239,9 @@ static int dedicated_cede_loop(struct cpuidle_device *dev, return index; } -static int shared_cede_loop(struct cpuidle_device *dev, - struct cpuidle_driver *drv, - int index) +static __cpuidle +int shared_cede_loop(struct cpuidle_device *dev, struct cpuidle_driver *drv, + int index) { pseries_idle_prolog(); @@ -255,7 +255,7 @@ static int shared_cede_loop(struct cpuidle_device *dev, */ check_and_cede_processor(); - local_irq_disable(); + raw_local_irq_disable(); pseries_idle_epilog(); return index; From patchwork Thu Apr 6 14:45:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Ellerman X-Patchwork-Id: 670953 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 5E0E9C76196 for ; Thu, 6 Apr 2023 14:48:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239125AbjDFOsC (ORCPT ); Thu, 6 Apr 2023 10:48:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239121AbjDFOrs (ORCPT ); Thu, 6 Apr 2023 10:47:48 -0400 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54FBFA5F8 for ; Thu, 6 Apr 2023 07:46:14 -0700 (PDT) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4Pskns5wjWz4xFg; Fri, 7 Apr 2023 00:45:53 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1680792353; bh=PhB58uze5HlGPHSG/12cRhkZxsbgZpkZh1JDz6mWDqo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PomG6mQ/2mwsj91pMOfaq7VGozCNnqo7xGd3TcNgdJaArP1yzdIS0/Bpt6jpF7Phy 52r4c0TlQIOisgmJjwevDhaUAhTS3uKcyviEoPj1EIX3qABFLwThWqVf/bBLw5BY0a WXXwhxJ5widHbtL8W9pfZBjN5Iuu3Wm7HlIxQJo90wa2gfqmSkcv8IaJBMrVgnxeju Ihor3ePVjXDjYZPyZLoHivHAaWLcuLlerVqilNBwEtvTal+xNU0xUjKfx9zCUB4xuP vIr/RAxYstKjPG3hw5x59OwxvjdZgVXoD76NsCjJY9EKbdA9QqudBXv9U+0LIEKm8c mK5Hk2K8Sm6uQ== From: Michael Ellerman To: Cc: , , linux-pm@vger.kernel.org Subject: [PATCH 4/4] powerpc/pseries: Always inline functions called from cpuidle Date: Fri, 7 Apr 2023 00:45:35 +1000 Message-Id: <20230406144535.3786008-4-mpe@ellerman.id.au> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230406144535.3786008-1-mpe@ellerman.id.au> References: <20230406144535.3786008-1-mpe@ellerman.id.au> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Code in the idle path is not allowed to be instrumented because RCU is disabled, see commit 0e985e9d2286 ("cpuidle: Add comments about noinstr/__cpuidle usage"). Force inlining of the inline functions called from cpuidle, to ensure they are not emitted out-of-line and then available for tracing. Signed-off-by: Michael Ellerman --- arch/powerpc/include/asm/idle.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/include/asm/idle.h b/arch/powerpc/include/asm/idle.h index accd1f50085a..00f360667391 100644 --- a/arch/powerpc/include/asm/idle.h +++ b/arch/powerpc/include/asm/idle.h @@ -9,17 +9,17 @@ DECLARE_PER_CPU(u64, idle_spurr_cycles); DECLARE_PER_CPU(u64, idle_entry_purr_snap); DECLARE_PER_CPU(u64, idle_entry_spurr_snap); -static inline void snapshot_purr_idle_entry(void) +static __always_inline void snapshot_purr_idle_entry(void) { *this_cpu_ptr(&idle_entry_purr_snap) = mfspr(SPRN_PURR); } -static inline void snapshot_spurr_idle_entry(void) +static __always_inline void snapshot_spurr_idle_entry(void) { *this_cpu_ptr(&idle_entry_spurr_snap) = mfspr(SPRN_SPURR); } -static inline void update_idle_purr_accounting(void) +static __always_inline void update_idle_purr_accounting(void) { u64 wait_cycles; u64 in_purr = *this_cpu_ptr(&idle_entry_purr_snap); @@ -29,7 +29,7 @@ static inline void update_idle_purr_accounting(void) get_lppaca()->wait_state_cycles = cpu_to_be64(wait_cycles); } -static inline void update_idle_spurr_accounting(void) +static __always_inline void update_idle_spurr_accounting(void) { u64 *idle_spurr_cycles_ptr = this_cpu_ptr(&idle_spurr_cycles); u64 in_spurr = *this_cpu_ptr(&idle_entry_spurr_snap); @@ -37,7 +37,7 @@ static inline void update_idle_spurr_accounting(void) *idle_spurr_cycles_ptr += mfspr(SPRN_SPURR) - in_spurr; } -static inline void pseries_idle_prolog(void) +static __always_inline void pseries_idle_prolog(void) { ppc64_runlatch_off(); snapshot_purr_idle_entry(); @@ -49,7 +49,7 @@ static inline void pseries_idle_prolog(void) get_lppaca()->idle = 1; } -static inline void pseries_idle_epilog(void) +static __always_inline void pseries_idle_epilog(void) { update_idle_purr_accounting(); update_idle_spurr_accounting();