Skip to content

Commit 421a41c

Browse files
guilhermepiccolikees
authored andcommitted
pstore/ftrace: Keep ftrace module parameter and debugfs switch in sync
Commit a5d05b0 ("pstore/ftrace: Allow immediate recording") introduced a kernel parameter to enable early-boot collection for ftrace frontend. But then, if we enable the debugfs later, the parameter remains set as N. This is not a biggie, things work fine; but at the same time, why not have both in sync if possible, right? Cc: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com> Link: https://patch.msgid.link/20260301192704.1263589-1-gpiccoli@igalia.com Signed-off-by: Kees Cook <kees@kernel.org>
1 parent 2ddb69f commit 421a41c

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

fs/pstore/ftrace.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,16 @@ static struct ftrace_ops pstore_ftrace_ops __read_mostly = {
6262
};
6363

6464
static DEFINE_MUTEX(pstore_ftrace_lock);
65-
static bool pstore_ftrace_enabled;
65+
static bool record_ftrace;
66+
module_param(record_ftrace, bool, 0400);
67+
MODULE_PARM_DESC(record_ftrace,
68+
"enable ftrace recording immediately (default: off)");
6669

6770
static int pstore_set_ftrace_enabled(bool on)
6871
{
6972
ssize_t ret;
7073

71-
if (on == pstore_ftrace_enabled)
74+
if (on == record_ftrace)
7275
return 0;
7376

7477
if (on) {
@@ -82,7 +85,7 @@ static int pstore_set_ftrace_enabled(bool on)
8285
pr_err("%s: unable to %sregister ftrace ops: %zd\n",
8386
__func__, on ? "" : "un", ret);
8487
} else {
85-
pstore_ftrace_enabled = on;
88+
record_ftrace = on;
8689
}
8790

8891
return ret;
@@ -111,7 +114,7 @@ static ssize_t pstore_ftrace_knob_write(struct file *f, const char __user *buf,
111114
static ssize_t pstore_ftrace_knob_read(struct file *f, char __user *buf,
112115
size_t count, loff_t *ppos)
113116
{
114-
char val[] = { '0' + pstore_ftrace_enabled, '\n' };
117+
char val[] = { '0' + record_ftrace, '\n' };
115118

116119
return simple_read_from_buffer(buf, count, ppos, val, sizeof(val));
117120
}
@@ -124,11 +127,6 @@ static const struct file_operations pstore_knob_fops = {
124127

125128
static struct dentry *pstore_ftrace_dir;
126129

127-
static bool record_ftrace;
128-
module_param(record_ftrace, bool, 0400);
129-
MODULE_PARM_DESC(record_ftrace,
130-
"enable ftrace recording immediately (default: off)");
131-
132130
void pstore_register_ftrace(void)
133131
{
134132
if (!psinfo->write)
@@ -145,9 +143,9 @@ void pstore_register_ftrace(void)
145143
void pstore_unregister_ftrace(void)
146144
{
147145
mutex_lock(&pstore_ftrace_lock);
148-
if (pstore_ftrace_enabled) {
146+
if (record_ftrace) {
149147
unregister_ftrace_function(&pstore_ftrace_ops);
150-
pstore_ftrace_enabled = false;
148+
record_ftrace = false;
151149
}
152150
mutex_unlock(&pstore_ftrace_lock);
153151

0 commit comments

Comments
 (0)