From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8138B446849 for ; Tue, 11 Aug 2026 14:16:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786457783; cv=none; b=BiaNYxm5a4hoOEkobGaI69jQmZc7SHzx/Y7u600hLuzD0XZIuC5nPZsUyGrR09HdlaZmYU2NRV+BXwJlLx/CS/fRc5Mm15AMjQyLyBns0q5YGMv+6Mab7q6KrEsFWMMTcFPvKxcOO8Ep5lOKa7ItkVuMClTupVHk2K6OZOlhYwY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786457783; c=relaxed/simple; bh=d0NfhccDDvqk0Pmef2u84FrjHkpt6nwimvqyjjG3WFA=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=iCbNAk0EKlP0j/48tZucgB8sb6JdZsRtho/35I5xrq1Q+tlS/AFUHcNn7cgNlBpcItqsvdvL5T0Rpu5bBYKN9BCw9zU/5WBkLjxQnRIwD+Vjkxoz4TkVW3JfsxIYi7nVt0dFf6W5G/dOgv3d2zOcngHnHrbc5YYI76L5H3zVbn0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oXbAhpeN; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oXbAhpeN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 231141F00A3A; Tue, 11 Aug 2026 14:16:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786457782; bh=qTJE+DqTEnM2QBjWqbIP+90bGXPufMDyv0LUT5P6ifo=; h=Date:From:To:Cc:Subject:References; b=oXbAhpeNkRs00NdibWY6LSmYKKX5WVTlJhyukqZ4pBw2++L3Bz5gXknvyy1//3VOy rhZ+VZuQnxFiUdTYxpiBx4ljMuXr1/QJ5Ym4X+L2vDAc9T1KEwmQHjG10OFmD8k4FW 5AGAeeSPq3KonNeg4FAxfIo8yefxQrVvegxy6RqXZcngFkndei0Qd04z757lC2rB0L SCdY3O65zODJBJXK7KXydu0cZ7Cj786INnfJseA1jy71vXSUGXC+Q04gTxePy/OUGq 0tU1sHFlsgTXwWlnpL0N7LXDXsu0ctx2NHs4HGa40eF34gOl2ZvMUVTUjMb3mZ0uKt bW2Wd1Yt7pmYg== Received: from rostedt by gandalf with local (Exim 4.99.4) (envelope-from ) id 1wtnHO-00000002XX8-09ih; Tue, 11 Aug 2026 10:16:34 -0400 Message-ID: <20260811141633.889458733@kernel.org> User-Agent: quilt/0.69 Date: Tue, 11 Aug 2026 10:15:39 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Andrey Grodzovsky , Song Liu Subject: [for-next][PATCH 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl References: <20260811141538.174498661@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 From: Andrey Grodzovsky Writing 0 to kernel.ftrace_enabled has not reliably disabled ftrace for years (FTRACE_OPS_FL_PERMANENT users already block it, and more callers rely on ftrace always being on). Refuse the write instead of leaving it in an inconsistent "disables some, not all" state: return -EOPNOTSUPP and log a message. Reads and enabling (writing 1) are unaffected. Update the docs to note the deprecation up front. Link: https://patch.msgid.link/20260806153000.4184871-2-andrey.grodzovsky@crowdstrike.com Suggested-by: Steven Rostedt Signed-off-by: Andrey Grodzovsky Acked-by: Song Liu Signed-off-by: Steven Rostedt --- Documentation/trace/ftrace.rst | 5 ++++ kernel/trace/ftrace.c | 43 +++++----------------------------- 2 files changed, 11 insertions(+), 37 deletions(-) diff --git a/Documentation/trace/ftrace.rst b/Documentation/trace/ftrace.rst index 84f06bf0da9b..7261f25f8b4b 100644 --- a/Documentation/trace/ftrace.rst +++ b/Documentation/trace/ftrace.rst @@ -3313,6 +3313,11 @@ this special filter via:: ftrace_enabled -------------- +.. note:: + Disabling ftrace via this switch is deprecated. Writing 0 is refused + with -EOPNOTSUPP and logs a warning; writing 1 and reading the value + are unaffected. + Note, the proc sysctl ftrace_enable is a big on/off switch for the function tracer. By default it is enabled (when function tracing is enabled in the kernel). If it is disabled, all function tracing is diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 6c47a94f5924..d1989958d6b2 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -9370,38 +9370,10 @@ static void ftrace_startup_sysctl(void) } } -static void ftrace_shutdown_sysctl(void) -{ - int command; - - if (unlikely(ftrace_disabled)) - return; - - /* ftrace_start_up is true if ftrace is running */ - if (ftrace_start_up) { - command = FTRACE_DISABLE_CALLS; - if (ftrace_graph_active) - command |= FTRACE_STOP_FUNC_RET; - ftrace_run_update_code(command); - } -} #else # define ftrace_startup_sysctl() do { } while (0) -# define ftrace_shutdown_sysctl() do { } while (0) #endif /* CONFIG_DYNAMIC_FTRACE */ -static bool is_permanent_ops_registered(void) -{ - struct ftrace_ops *op; - - do_for_each_ftrace_op(op, ftrace_ops_list) { - if (op->flags & FTRACE_OPS_FL_PERMANENT) - return true; - } while_for_each_ftrace_op(op); - - return false; -} - static int ftrace_enable_sysctl(const struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) @@ -9428,15 +9400,12 @@ ftrace_enable_sysctl(const struct ctl_table *table, int write, ftrace_startup_sysctl(); } else { - if (is_permanent_ops_registered()) { - ftrace_enabled = true; - return -EBUSY; - } - - /* stopping ftrace calls (just send to ftrace_stub) */ - ftrace_trace_function = ftrace_stub; - - ftrace_shutdown_sysctl(); + /* + * Disabling ftrace at runtime via this knob is deprecated. + */ + ftrace_enabled = true; + pr_warn_once("The ftrace_enabled file is deprecated and no longer disables ftrace\n"); + return -EOPNOTSUPP; } last_ftrace_enabled = !!ftrace_enabled; -- 2.53.0