From patchwork Thu Jan 12 19:44:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 13098842 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81A05C54EBE for ; Thu, 12 Jan 2023 19:58:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D1348001D; Thu, 12 Jan 2023 14:57:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E4FD80022; Thu, 12 Jan 2023 14:57:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2C1FF8001D; Thu, 12 Jan 2023 14:57:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E8C3480022 for ; Thu, 12 Jan 2023 14:57:48 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CC303C08E5 for ; Thu, 12 Jan 2023 19:57:48 +0000 (UTC) X-FDA: 80347207416.29.3C00F1D Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf13.hostedemail.com (Postfix) with ESMTP id 50CA620010 for ; Thu, 12 Jan 2023 19:57:47 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=Cm0cZvx6; dmarc=none; spf=none (imf13.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673553467; h=from:from:sender: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:in-reply-to: references:references:dkim-signature; bh=Un035BTYhsjREpZ4dpy/MHkkoifcKtLiH3nYidAuKL8=; b=sGPwI9n6FO6zWkc23YhDVrVDqHXOzgYmDQqBXTZnTUetqkoweONVaRKBIzv6d7Z/KTnyac Qx56uTC5QgNbQG5PISLZz2DTOi7oHWItqugQCn+mr/LyxgURQDkJJNoCcAopLYtICP2VBp GrCdAdQI3vicQ58WKdsnymZ6M6hxPCw= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=Cm0cZvx6; dmarc=none; spf=none (imf13.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673553467; a=rsa-sha256; cv=none; b=TzhhBhDaq9v9gVkwAONBqkobzp0NZSRDFRxBN71FeiYQeGqoG82IWAqLP0zsOhvPQzgu0w 6MMXeZlGtf7pgR/gRXdYj5Z1VkFnnK7a0UAE1i9SikW/b2zDZuM3wIBplVXTcnZ5tLilCb HhQO/INwmCE19mFDxmhD7/UD/keBB54= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=Un035BTYhsjREpZ4dpy/MHkkoifcKtLiH3nYidAuKL8=; b=Cm0cZvx68fOfy3spcfZv1mTyVN I+8nrlfsPTd1YX3ddHPT1tHDaXW6BjutPk9wWpEkW/bLt/CWl0wIYVqUtY/RdgLL1CXyaqx22TN13 FVZ1Pu0U/vSbCFKDZV31A7dnMTEMlJVmC5JGl3kdM1NWuU5ROH7eP9w1vfRDaocn4JsSLc4YrPw5Q 92CcZo9NDx6pgppJhIre9PG6+hEZcTjM22p8n4v6T0CGJXpMaxOqy0BIl6Hi1HTM4//PS/Q9GRA+r r+JvkRTeh7iePDi9/CdHQ2TT4CowIVH97n1vCAGs/Zkz6o47jhi7eL2nyxXG48k7aP4oDQHY9NYIK bJ7NrLVg==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1pG3hZ-0045wj-2V; Thu, 12 Jan 2023 19:57:33 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 4DBD1300293; Thu, 12 Jan 2023 20:57:14 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 7C19A2CD066F8; Thu, 12 Jan 2023 20:57:08 +0100 (CET) Message-ID: <20230112195542.397238052@infradead.org> User-Agent: quilt/0.66 Date: Thu, 12 Jan 2023 20:44:04 +0100 From: Peter Zijlstra To: peterz@infradead.org Cc: richard.henderson@linaro.org, ink@jurassic.park.msu.ru, mattst88@gmail.com, vgupta@kernel.org, linux@armlinux.org.uk, nsekhar@ti.com, brgl@bgdev.pl, ulli.kroll@googlemail.com, linus.walleij@linaro.org, shawnguo@kernel.org, Sascha Hauer , kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, tony@atomide.com, khilman@kernel.org, krzysztof.kozlowski@linaro.org, alim.akhtar@samsung.com, catalin.marinas@arm.com, will@kernel.org, guoren@kernel.org, bcain@quicinc.com, chenhuacai@kernel.org, kernel@xen0n.name, geert@linux-m68k.org, sammy@sammy.net, monstr@monstr.eu, tsbogend@alpha.franken.de, dinguyen@kernel.org, jonas@southpole.se, stefan.kristiansson@saunalahti.fi, shorne@gmail.com, James.Bottomley@HansenPartnership.com, deller@gmx.de, mpe@ellerman.id.au, npiggin@gmail.com, christophe.leroy@csgroup.eu, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, ysato@users.sourceforge.jp, dalias@libc.org, davem@davemloft.net, richard@nod.at, anton.ivanov@cambridgegreys.com, johannes@sipsolutions.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, jgross@suse.com, srivatsa@csail.mit.edu, amakhalov@vmware.com, pv-drivers@vmware.com, boris.ostrovsky@oracle.com, chris@zankel.net, jcmvbkbc@gmail.com, rafael@kernel.org, lenb@kernel.org, pavel@ucw.cz, gregkh@linuxfoundation.org, mturquette@baylibre.com, sboyd@kernel.org, daniel.lezcano@linaro.org, lpieralisi@kernel.org, sudeep.holla@arm.com, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, anup@brainfault.org, thierry.reding@gmail.com, jonathanh@nvidia.com, jacob.jun.pan@linux.intel.com, atishp@atishpatra.org, Arnd Bergmann , yury.norov@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, dennis@kernel.org, tj@kernel.org, cl@linux.com, rostedt@goodmis.org, mhiramat@kernel.org, frederic@kernel.org, paulmck@kernel.org, pmladek@suse.com, senozhatsky@chromium.org, john.ogness@linutronix.de, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, ryabinin.a.a@gmail.com, glider@google.com, andreyknvl@gmail.com, dvyukov@google.com, vincenzo.frascino@arm.com, Andrew Morton , jpoimboe@kernel.org, linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-omap@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-ia64@vger.kernel.org, loongarch@lists.linux.dev, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-um@lists.infradead.org, linux-perf-users@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-xtensa@linux-xtensa.org, linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org, kasan-dev@googlegroups.com Subject: [PATCH v3 50/51] cpuidle: Comments about noinstr/__cpuidle References: <20230112194314.845371875@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 50CA620010 X-Stat-Signature: i1kyz1a9pai8jg6gfiiswx14whxbp39h X-HE-Tag: 1673553467-953152 X-HE-Meta: U2FsdGVkX19H4UiXBa0GaKvzEBCdlFBUrB2NMvu3JstFy0fMKnmShkIAR5JelsCWONoeIKzbqrz0jwgT1YfuQXNpMjez7gwF17eOQ9UR68gBuYcaCAPXJ4l0i0vbbOVtNIsu4scB9BOYbq5wSlqKgzmUUPM9PPybuY84QV/ZFnFyycD5r/KI7DshsXqYGSIo0xwYyTuOGD0rSmfeYR00KZecOE/OWddA0WWRmrhbgkBGBlHmvF1ZxWwEeQ/JvM/XlLoJPI3XipHs6hyBY2RwNHyGD54W1qFZG6Y785Tm7FSuqERU5dMEj33flDFkGM4WOt4EMohctXiIwrnGwn28eoZf87Pq2FobapfvLviJvw6p1x7by7ywx63rd/Xc2TlWrlVErYNYhP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xN0dmaUyLNoclXMx7N5ub4Ki/nKtBNH8gbluSRPPRmgqa/1IJte/LPIe6vJFJJMlT/QOfGAUfT+erlk9Ski84Vmz4TYRRzTaMQ4rfUuAkPEHdeXZ7gzW7dYE3cRrN2h6B/Cj4apD2XnX9q0bfuAhDLY8Gl2r9j0asKJsaAdUoG/AkXkYAPJ9QcNM51vfM26P3L7b6aGVS8plKxPrir/YHnybvUj+J0RSGDqaXLbf1hDaQRHmkI5WuHRNIGAEUF6xUDGkdkHBzhcN94esd6FTNhm7PWYqBAcx1t4aMNYSEOLISYTl4D2NP9x+Q8NPKdLshPyQ7RtoZ ukL47xj+ apx09Iaqk4DTqwVqLKMm4GAk/Ya9kas9VBYkIIJw22/PEOJ+zrIGhvAOq1xiXUzKucM+4RRDya55jFPx+CPlnEpHYMzrfJ4SO4YquSekb1DR0ss7Paj2hqyp/bX8D5xni2outPtu+8nb1RCsYykqeK X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Add a few words on noinstr / __cpuidle usage. Signed-off-by: Peter Zijlstra (Intel) --- drivers/cpuidle/cpuidle.c | 12 ++++++++++++ include/linux/compiler_types.h | 10 ++++++++++ 2 files changed, 22 insertions(+) --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -252,6 +252,18 @@ noinstr int cpuidle_enter_state(struct c instrumentation_begin(); } + /* + * 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 = target_state->enter(dev, drv, index); if (WARN_ONCE(!irqs_disabled(), "%ps leaked IRQ state", target_state->enter)) --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -233,6 +233,16 @@ struct ftrace_likely_data { #define noinstr __noinstr_section(".noinstr.text") +/* + * The __cpuidle section is used twofold: + * + * 1) the original use -- identifying if a CPU is 'stuck' in idle state based + * 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 with + * noinstr. + */ #define __cpuidle __noinstr_section(".cpuidle.text") #endif /* __KERNEL__ */