From patchwork Fri Jan 13 12:31:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 43244 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp243574wrt; Fri, 13 Jan 2023 04:36:13 -0800 (PST) X-Google-Smtp-Source: AMrXdXv5UIGGV892dpvunIj3U9XR3foW29ePsa/VSxknbolpa1zIMrm/QREtF9jU84KQnH23lfmQ X-Received: by 2002:aa7:d30d:0:b0:499:1ed2:6459 with SMTP id p13-20020aa7d30d000000b004991ed26459mr18171802edq.20.1673613372972; Fri, 13 Jan 2023 04:36:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673613372; cv=none; d=google.com; s=arc-20160816; b=yH4sLjScOBGjcgzvSGUIgoaqJpeFv/wVaMpe/69DDqbHKOIlc4mJm/Lj7NV1yWFYpX c2oIv2VNfYJDoFd6I08/0mcY+oabWnODN61rIFud47CSIUzxj/rbELfUkjcEdCQ6pUcD JX7g8Iv9rIEVmiAloYOl09+ocq0Qqv0PPYiqEqVLhZngp9izv/y1Qh1JrXoJU5iKpFSJ 9LwTqpr4o6H7/wc+tBIIOXEWSwBtOCHt6EWi7LGZyG2aRoiLzNkGceVEm9ETUZedUwld yMMaieI9udfeUQJ9hwNjuyAL9KMSnAuX+hKt9/tfd89KtJOgyQGL6JkvBdN3GGWCFBOj +tRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=ZScG3rP7uVfoE13aE9dCeQr5jYORwblUn6nax2uOQMs=; b=bOjVoxP8Xi9R2Yl/rk4BZnrNTy+tXlA5RE1J/aIlSacgcSIj08mpmc+XRC6PfajHcc bFUmtGo7QkR9C9KXqFEC9agCcAeQffoPXk9xp3B9WwG9PODyTaCR9/ANOq2jEWnnixF9 NfcsCWQnAR8nk4cwuGGl3wDRJ1sei5tIq8K/qAY9PTOcqUGIooxSN/dz1dZJqQbPlMIC W2X0pS3tOL0GKI2+ycfgSz3GxxzgJDzBtvD45gshGRTOfhxwSNJVbNuhMbW1R6MFKhAT xzcHk6fbwpyeT3yw8kH1pE3C9QbqCtoMs6iTQxV3j3UwF4/ymFSYwjqlZmVLabLJ16EU po5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=JsqQPVy8; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=lQE4Cecw; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d15-20020aa7d68f000000b00499d35c5784si8696077edr.559.2023.01.13.04.35.47; Fri, 13 Jan 2023 04:36:12 -0800 (PST) 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=@linutronix.de header.s=2020 header.b=JsqQPVy8; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=lQE4Cecw; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241652AbjAMMe7 (ORCPT + 99 others); Fri, 13 Jan 2023 07:34:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241244AbjAMMcP (ORCPT ); Fri, 13 Jan 2023 07:32:15 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1645551D3; Fri, 13 Jan 2023 04:31:12 -0800 (PST) Date: Fri, 13 Jan 2023 12:31:09 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1673613070; 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=ZScG3rP7uVfoE13aE9dCeQr5jYORwblUn6nax2uOQMs=; b=JsqQPVy8Pkzg6i79GvY1yWIAc0qk4Ozm7KqSJlla/hoTlB7/yzMRgVDu2CazIluvLzVSBe s+YRAJIA3mZXS4cogwTThmTpfLlpoFpqkaFNU4rNvcyz4w0zRSAXZnvqlLDySyh5Gf7q+K tTDlIG/F/lNpwUGJYDEDijaHXNU43xiiROskTmSnVsbO4ypKai2YpYGe50fynKcA/cDQyE FeGuHIe4Gy4EbFTq7DGUtpz6EoUOMFx7WAn1lsmbEuUSMLzrWwXb40FzujyPYlgSeX+aab YeStYggeLRBKLoFFMOWg6i2M1TL/PyknJrngietPhIsnnFD/YjJEpki97mU9zQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1673613070; 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=ZScG3rP7uVfoE13aE9dCeQr5jYORwblUn6nax2uOQMs=; b=lQE4Cecwc7EuMYAaxXEUgLnTbw+C22J/PDtCaVJE368QT8o+mGqneE7NA8pH6bdzVRT/mI 4WLSeWDCZyf/FlBg== 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, sched: Remove instrumentation from TIF_{POLLING_NRFLAG,NEED_RESCHED} Cc: "Peter Zijlstra (Intel)" , Ingo Molnar , Tony Lindgren , Ulf Hansson , "Rafael J. Wysocki" , Frederic Weisbecker , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230112195540.988741683@infradead.org> References: <20230112195540.988741683@infradead.org> MIME-Version: 1.0 Message-ID: <167361306962.4906.12963081149493363429.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754910816323111993?= X-GMAIL-MSGID: =?utf-8?q?1754910816323111993?= The following commit has been merged into the sched/core branch of tip: Commit-ID: e4df1511e1f4bcaa0d590aa7bbffe8bbbd6dfb49 Gitweb: https://git.kernel.org/tip/e4df1511e1f4bcaa0d590aa7bbffe8bbbd6dfb49 Author: Peter Zijlstra AuthorDate: Thu, 12 Jan 2023 20:43:41 +01:00 Committer: Ingo Molnar CommitterDate: Fri, 13 Jan 2023 11:48:16 +01:00 cpuidle, sched: Remove instrumentation from TIF_{POLLING_NRFLAG,NEED_RESCHED} objtool pointed out that various idle-TIF management methods have instrumentation: vmlinux.o: warning: objtool: mwait_idle+0x5: call to current_set_polling_and_test() leaves .noinstr.text section vmlinux.o: warning: objtool: acpi_processor_ffh_cstate_enter+0xc5: call to current_set_polling_and_test() leaves .noinstr.text section vmlinux.o: warning: objtool: cpu_idle_poll.isra.0+0x73: call to test_ti_thread_flag() leaves .noinstr.text section vmlinux.o: warning: objtool: intel_idle+0xbc: call to current_set_polling_and_test() leaves .noinstr.text section vmlinux.o: warning: objtool: intel_idle_irq+0xea: call to current_set_polling_and_test() leaves .noinstr.text section vmlinux.o: warning: objtool: intel_idle_s2idle+0xb4: call to current_set_polling_and_test() leaves .noinstr.text section vmlinux.o: warning: objtool: intel_idle+0xa6: call to current_clr_polling() leaves .noinstr.text section vmlinux.o: warning: objtool: intel_idle_irq+0xbf: call to current_clr_polling() leaves .noinstr.text section vmlinux.o: warning: objtool: intel_idle_s2idle+0xa1: call to current_clr_polling() leaves .noinstr.text section vmlinux.o: warning: objtool: mwait_idle+0xe: call to __current_set_polling() leaves .noinstr.text section vmlinux.o: warning: objtool: acpi_processor_ffh_cstate_enter+0xc5: call to __current_set_polling() leaves .noinstr.text section vmlinux.o: warning: objtool: cpu_idle_poll.isra.0+0x73: call to test_ti_thread_flag() leaves .noinstr.text section vmlinux.o: warning: objtool: intel_idle+0xbc: call to __current_set_polling() leaves .noinstr.text section vmlinux.o: warning: objtool: intel_idle_irq+0xea: call to __current_set_polling() leaves .noinstr.text section vmlinux.o: warning: objtool: intel_idle_s2idle+0xb4: call to __current_set_polling() leaves .noinstr.text section vmlinux.o: warning: objtool: cpu_idle_poll.isra.0+0x73: call to test_ti_thread_flag() leaves .noinstr.text section vmlinux.o: warning: objtool: intel_idle_s2idle+0x73: call to test_ti_thread_flag.constprop.0() leaves .noinstr.text section vmlinux.o: warning: objtool: intel_idle_irq+0x91: call to test_ti_thread_flag.constprop.0() leaves .noinstr.text section vmlinux.o: warning: objtool: intel_idle+0x78: call to test_ti_thread_flag.constprop.0() leaves .noinstr.text section vmlinux.o: warning: objtool: acpi_safe_halt+0xf: call to test_ti_thread_flag.constprop.0() leaves .noinstr.text section Remove the instrumentation, because these methods are used in low-level cpuidle code moving between states, that should not be instrumented. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Tested-by: Tony Lindgren Tested-by: Ulf Hansson Acked-by: Rafael J. Wysocki Acked-by: Frederic Weisbecker Link: https://lore.kernel.org/r/20230112195540.988741683@infradead.org --- include/linux/sched/idle.h | 40 +++++++++++++++++++++++++++--------- include/linux/thread_info.h | 18 +++++++++++++++- 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/include/linux/sched/idle.h b/include/linux/sched/idle.h index d73d314..478084f 100644 --- a/include/linux/sched/idle.h +++ b/include/linux/sched/idle.h @@ -23,12 +23,37 @@ static inline void wake_up_if_idle(int cpu) { } */ #ifdef TIF_POLLING_NRFLAG -static inline void __current_set_polling(void) +#ifdef _ASM_GENERIC_BITOPS_INSTRUMENTED_ATOMIC_H + +static __always_inline void __current_set_polling(void) { - set_thread_flag(TIF_POLLING_NRFLAG); + arch_set_bit(TIF_POLLING_NRFLAG, + (unsigned long *)(¤t_thread_info()->flags)); } -static inline bool __must_check current_set_polling_and_test(void) +static __always_inline void __current_clr_polling(void) +{ + arch_clear_bit(TIF_POLLING_NRFLAG, + (unsigned long *)(¤t_thread_info()->flags)); +} + +#else + +static __always_inline void __current_set_polling(void) +{ + set_bit(TIF_POLLING_NRFLAG, + (unsigned long *)(¤t_thread_info()->flags)); +} + +static __always_inline void __current_clr_polling(void) +{ + clear_bit(TIF_POLLING_NRFLAG, + (unsigned long *)(¤t_thread_info()->flags)); +} + +#endif /* _ASM_GENERIC_BITOPS_INSTRUMENTED_ATOMIC_H */ + +static __always_inline bool __must_check current_set_polling_and_test(void) { __current_set_polling(); @@ -41,12 +66,7 @@ static inline bool __must_check current_set_polling_and_test(void) return unlikely(tif_need_resched()); } -static inline void __current_clr_polling(void) -{ - clear_thread_flag(TIF_POLLING_NRFLAG); -} - -static inline bool __must_check current_clr_polling_and_test(void) +static __always_inline bool __must_check current_clr_polling_and_test(void) { __current_clr_polling(); @@ -73,7 +93,7 @@ static inline bool __must_check current_clr_polling_and_test(void) } #endif -static inline void current_clr_polling(void) +static __always_inline void current_clr_polling(void) { __current_clr_polling(); diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h index 9f392ec..c026468 100644 --- a/include/linux/thread_info.h +++ b/include/linux/thread_info.h @@ -177,7 +177,23 @@ static __always_inline unsigned long read_ti_thread_flags(struct thread_info *ti clear_ti_thread_flag(task_thread_info(t), TIF_##fl) #endif /* !CONFIG_GENERIC_ENTRY */ -#define tif_need_resched() test_thread_flag(TIF_NEED_RESCHED) +#ifdef _ASM_GENERIC_BITOPS_INSTRUMENTED_NON_ATOMIC_H + +static __always_inline bool tif_need_resched(void) +{ + return arch_test_bit(TIF_NEED_RESCHED, + (unsigned long *)(¤t_thread_info()->flags)); +} + +#else + +static __always_inline bool tif_need_resched(void) +{ + return test_bit(TIF_NEED_RESCHED, + (unsigned long *)(¤t_thread_info()->flags)); +} + +#endif /* _ASM_GENERIC_BITOPS_INSTRUMENTED_NON_ATOMIC_H */ #ifndef CONFIG_HAVE_ARCH_WITHIN_STACK_FRAMES static inline int arch_within_stack_frames(const void * const stack,