From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9F2A606A31A for ; Tue, 1 Dec 2026 04:22:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=LLDrXv7F; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CltBXl3r DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Unsubscribe-Post:List-Owner; bh=hZMpM49PX8nWdUQzRIJX6vuqVhN286CowzmTPJgtyPM=; b=LLDrXv7FerS3EjJuE48G11eDLL sPINb+DQOqP0GmVhCzf8egY7ZJuJbgXDxHxsVXKX3+oT4TQPKSImMnn3mjpYlCBugxZ0nhSPFBpJT rDhTnNsu3NQN7HoY6yvnclK+HuH7i9btR68j+/eOoAtOkWnd+rH4q0q2+qfZ4dHv4X9BKEjZO9g6Y YIMZILHt+YLttTG5gsohXvHv/MblKLKC8BVkRNUkr21dp1fVa/ieubmy3EamAX/HKBKDAGRsswhAK R+8sx5oD/8Ac68Xm5DJfov4EvJKP8P7hgMya7ocxYUxrYBYaLc6Lb/YmiboBoSjMAdWoOSUMC7y/9 TU1rPItw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYFNp-00000006W31-193V; Tue, 01 Dec 2026 04:22:25 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYFNo-00000006W2q-2sy1; Tue, 01 Dec 2026 04:22:24 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 1FDF24109C; Tue, 1 Dec 2026 04:22:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17E1A1F000C1; Tue, 1 Dec 2026 04:22:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796098944; bh=hZMpM49PX8nWdUQzRIJX6vuqVhN286CowzmTPJgtyPM=; h=From:To:Cc:Subject:Date; b=CltBXl3r4FGARZkG3TlLm5Mab/VPWAKUBxY7rfeeKI+5F9++46xiKhLNZWWDm/Plg w9OR4oZK1oVE2egz9X5bOh6FAREgHMwTSHoMo5LA6Dhq24bfxhXcH95x9Kwjj2jlt6 CRWg7P7SvPyAQBurSPrrUuNGrSnmXJzrPx+B8n5JGKjbAgH/GUR3UtLQMwfugnU2Nj IlSvC3uT68GQyd+Yx7g4G0ehUMa4KOte672fF8LpDt755zdWhp/aRj4QH0Gf7+zIYQ LgZaUNwukiiYg2v7TrHgPPucp4Xl9pVNX+BCCj271RQ6+OMMOtuxxFts/FaVMUhGEb w+eXiDa33QQXQ== From: Song Liu To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, live-patching@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, bpf@vger.kernel.org Cc: rostedt@goodmis.org, mhiramat@kernel.org, mark.rutland@arm.com, peterz@infradead.org, tglx@kernel.org, frederic@kernel.org, paulmck@kernel.org, catalin.marinas@arm.com, will@kernel.org, maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com, chleroy@kernel.org, pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, ojeda@kernel.org, kernel-team@meta.com, Song Liu Subject: [PATCH v3 00/22] Move notrace from inline to __always_inline Date: Mon, 30 Nov 2026 20:21:39 -0800 Message-ID: <20261201042201.3199928-1-song@kernel.org> X-Mailer: git-send-email 2.53.1 X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-13.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Since commit 45959ee7aa64 ("ftrace: Do not function trace inlined functions"), every function marked inline is also notrace. When the compiler does not inline such a function, the out-of-line copy cannot be traced with ftrace, cannot be a BPF fentry/fexit target, and cannot be livepatched. This series moves notrace from inline to __always_inline, so these copies become traceable. __always_inline functions, which are mostly low-level helpers, stay untraced. Patches 1-21 add notrace explicitly to the inline helpers that need it. While inline still implies notrace, they do not change the generated code: vmlinux .text is byte-identical with and without them on x86_64 (gcc 11.5), and on arm64, powerpc and riscv (clang 22). - 1-2: x86 paravirt native helpers, and the helpers used by resume and kexec. - 3-6: helpers used by bpf_spin_lock, the BPF trampoline and bpf_mem_alloc, where an fentry program on one of them could deadlock, recurse without bound or corrupt the free lists. - 7-8: tracepoint and SRCU helpers used by tracing. - 9-12: helpers used by ftrace recursion protection: the accessors behind preempt_count() and current on arm64, powerpc, csky, mips and sh, the Tiny RCU rcu_is_watching(), and the tracing_gen_ctx helpers. - 13-15: helpers called by notrace code in the trace clocks, core_kernel_text() and the nofault accessors. - 16-21 (new in v3): helpers that noinstr code calls while RCU is not watching or before NMI entry: exception_enter(), the thread flag helpers, and helpers on arm64, powerpc and riscv, including the arm64 stack unwinder helpers. To find these, I compared builds with and without patch 22, and listed the functions that become traceable and are called from code without an fentry call (notrace, noinstr, or built without -pg). On x86_64 this includes calls through pv_ops, and objtool's noinstr validation checks that the noinstr callers call them inside instrumentation windows. For v2, I repeated the x86_64 analysis with -fno-inline, to also cover helpers that gcc happens to inline today. For v3, I also ran the analysis on arm64, powerpc and riscv, built with clang. These architectures do not have objtool's noinstr validation, and their noinstr code calls out-of-line copies of plain inline helpers, some of them before entry code has made RCU watch, in the cpuidle RCU-idle windows, or in NMI-like handlers. Patches 16-21 mark these helpers. The remaining untraced callers on these architectures are the same kinds as on x86_64: noinstr code that calls them while RCU is watching, __schedule(), the TRACE_EVENT() output functions, and directories built without -pg. I could not build loongarch or 32-bit arm, so they are only covered for ftrace recursion protection. The series makes 712 more functions traceable on x86_64 with CONFIG_PARAVIRT_XXL and gcc 11.5, and 1464, 1429 and 1128 on arm64, powerpc and riscv defconfigs with clang 22. None become untraceable. In QEMU, with ftrace filtered to native_load_idt(), a kernel with v1 dies on resume from S3, as Sashiko predicted. With this series, S3 suspend/resume, CPU hotplug and hibernation test mode pass with ftrace on all native_* functions, repeated kexec passes with ftrace on all functions, and the function and function_graph tracers on all functions show no warnings. The series also builds for i386. Changes v2 => v3: - Rebase on v7.4-rc5 (Steven Rostedt). Patch 9 now applies on top of these changes to arch/arm64/include/asm/preempt.h: commit 1bee18253c2e ("arm64: preempt: Simplify and optimize __preempt_count_dec_and_test()") commit 6254b223153d ("arm64: preempt: Treat should_resched() as unlikely") - Add patches 16-21, found by running the analysis on arm64, powerpc and riscv. - Add Acked-by from Steven to patch 7. v2: https://lore.kernel.org/all/20261023011049.1164625-1-song@kernel.org/ v1: https://lore.kernel.org/all/20261021222255.3124940-1-song@kernel.org/ Song Liu (22): x86/paravirt: Mark native pv_ops helpers notrace x86: Mark CPU state helpers used by resume and kexec notrace bpf: Mark bpf_spin_lock helpers notrace bpf: Mark the BPF trampoline helpers notrace bpf: Mark the bpf_mem_alloc fast path helpers notrace u64_stats: Mark the update helpers used by BPF notrace tracepoint: Mark __do_trace_##name() notrace srcu: Mark the fast notrace read-side helpers notrace arm64: Mark the preempt count helpers notrace powerpc, csky, mips, sh: Mark the accessors behind current notrace rcu: Mark the Tiny RCU rcu_is_watching() notrace tracing: Mark the tracing_gen_ctx helpers notrace ktime: Mark ktime_to_ns() notrace kallsyms: Mark the kernel text address checks notrace uaccess: Mark pagefault_disable() and pagefault_enable() notrace context_tracking: Mark exception_enter() and exception_exit() notrace thread_info: Mark the thread flag helpers notrace arm64: Mark helpers called from noinstr code notrace arm64: Mark the stack unwinder helpers notrace powerpc: Mark helpers called from noinstr code notrace riscv: Mark helpers called from noinstr code notrace compiler_types: Move notrace from inline to __always_inline arch/arm64/include/asm/cpufeature.h | 4 +- arch/arm64/include/asm/memory.h | 2 +- arch/arm64/include/asm/mmu.h | 2 +- arch/arm64/include/asm/percpu.h | 2 +- arch/arm64/include/asm/preempt.h | 12 ++-- arch/arm64/include/asm/ptrace.h | 2 +- arch/arm64/include/asm/stacktrace.h | 16 ++--- arch/arm64/include/asm/stacktrace/common.h | 10 ++-- arch/arm64/include/asm/vdso/processor.h | 2 +- arch/arm64/include/asm/virt.h | 2 +- arch/csky/include/asm/thread_info.h | 2 +- arch/mips/include/asm/thread_info.h | 2 +- arch/powerpc/include/asm/atomic.h | 38 ++++++------ arch/powerpc/include/asm/bitops.h | 29 ++++----- arch/powerpc/include/asm/cmpxchg.h | 2 +- arch/powerpc/include/asm/current.h | 2 +- arch/powerpc/include/asm/entry-common.h | 32 +++++----- arch/powerpc/include/asm/hw_irq.h | 68 +++++++++++----------- arch/powerpc/include/asm/interrupt.h | 2 +- arch/powerpc/include/asm/io.h | 16 ++--- arch/powerpc/include/asm/plpar_wrappers.h | 4 +- arch/powerpc/include/asm/ptrace.h | 14 ++--- arch/powerpc/include/asm/rtas.h | 10 ++-- arch/powerpc/include/asm/synch.h | 6 +- arch/powerpc/include/asm/thread_info.h | 4 +- arch/powerpc/kernel/watchdog.c | 4 +- arch/riscv/include/asm/cpuidle.h | 2 +- arch/riscv/include/asm/irqflags.h | 14 ++--- arch/riscv/include/asm/vdso/processor.h | 2 +- arch/riscv/include/asm/vector.h | 8 +-- arch/sh/include/asm/thread_info.h | 2 +- arch/x86/include/asm/cpuid/api.h | 4 +- arch/x86/include/asm/desc.h | 17 +++--- arch/x86/include/asm/gsseg.h | 4 +- arch/x86/include/asm/io.h | 2 +- arch/x86/include/asm/io_bitmap.h | 2 +- arch/x86/include/asm/local.h | 8 +-- arch/x86/include/asm/msr.h | 8 +-- arch/x86/include/asm/paravirt-spinlock.h | 2 +- arch/x86/include/asm/paravirt.h | 20 +++---- arch/x86/include/asm/pgalloc.h | 2 +- arch/x86/include/asm/pgtable_64.h | 10 ++-- arch/x86/include/asm/processor.h | 2 +- arch/x86/include/asm/segment.h | 4 +- arch/x86/include/asm/special_insns.h | 8 +-- include/asm-generic/sections.h | 4 +- include/linux/bpf.h | 8 +-- include/linux/compiler_attributes.h | 6 +- include/linux/compiler_types.h | 3 +- include/linux/context_tracking.h | 4 +- include/linux/kallsyms.h | 2 +- include/linux/ktime.h | 2 +- include/linux/llist.h | 16 ++--- include/linux/percpu-refcount.h | 12 ++-- include/linux/pgtable.h | 12 ++-- include/linux/rcupdate.h | 14 ++--- include/linux/rcupdate_trace.h | 4 +- include/linux/rcutiny.h | 2 +- include/linux/sched.h | 8 +-- include/linux/srcu.h | 10 ++-- include/linux/srcutiny.h | 5 +- include/linux/srcutree.h | 2 +- include/linux/thread_info.h | 12 ++-- include/linux/trace_events.h | 6 +- include/linux/tracepoint.h | 4 +- include/linux/u64_stats_sync.h | 30 +++++----- include/linux/uaccess.h | 4 +- kernel/bpf/helpers.c | 12 ++-- 68 files changed, 300 insertions(+), 292 deletions(-) base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244 -- 2.53.1-Meta