[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240210235009.2405808-16-ukaszb@chromium.org>
Date: Sun, 11 Feb 2024 00:49:45 +0100
From: Łukasz Bartosik <ukaszb@...omium.org>
To: Jason Baron <jbaron@...mai.com>,
Jim Cromie <jim.cromie@...il.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Kees Cook <keescook@...omium.org>,
Douglas Anderson <dianders@...omium.org>
Cc: Guenter Roeck <groeck@...gle.com>,
Yaniv Tzoreff <yanivt@...gle.com>,
Benson Leung <bleung@...gle.com>,
Steven Rostedt <rostedt@...dmis.org>,
Vincent Whitchurch <vincent.whitchurch@...s.com>,
Pekka Paalanen <ppaalanen@...il.com>,
Sean Paul <seanpaul@...omium.org>,
Daniel Vetter <daniel@...ll.ch>,
Simon Ser <contact@...rsion.fr>,
John Ogness <john.ogness@...utronix.de>,
Petr Mladek <pmladek@...e.com>,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
linux-kernel@...r.kernel.org,
upstream@...ihalf.com
Subject: [PATCH v4 15/39] dyndbg: update selection of trace destination
If callsite's current trace destination is '0' and user provided T flag
without trace destination name then set callsite's trace destination to
default trace destination. If a user provided trace destination name
:trace_dest_name with or without T flag then set callsite's trace
destination to the provided name. Otherwise keep callsite's current
trace destination.
The change main purpose is to preserve trace destination names (different
from '0') set previously by a user which can be later enabled with
'label' keyword.
Signed-off-by: Łukasz Bartosik <ukaszb@...omium.org>
---
lib/dynamic_debug.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index f91c51234456..172497954e00 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -480,6 +480,27 @@ void update_tr_dst(const struct _ddebug *desc, const struct dd_ctrl *nctrl)
trc_tbl.buf[ndst].use_cnt++;
}
+
+/*
+ * Selects trace destination. If callsite's current trace destination is '0'
+ * and user provided T flag without trace destination name then set callsite's
+ * trace destination to default trace destination. If a user provided trace
+ * destination name :trace_dest_name with or without T flag then set callsite's
+ * trace destination to the provided name. Otherwise keep callsite's current
+ * trace destination.
+ */
+static int select_tr_dst(struct flag_settings *modifiers, int cur_dst)
+{
+ if (!cur_dst && modifiers->flags & _DPRINTK_FLAGS_TRACE &&
+ modifiers->trace_dst == DST_NOT_SET)
+ return trc_tbl.default_dst;
+
+ if (modifiers->trace_dst >= 0)
+ return modifiers->trace_dst;
+
+ return cur_dst;
+}
+
static int ddebug_parse_cmd(char *words[], int nwords)
{
if (nwords != 1)
@@ -590,8 +611,7 @@ static int ddebug_change(const struct ddebug_query *query,
nfound++;
nctrl.flags = (get_flags(dp) & modifiers->mask) | modifiers->flags;
- nctrl.trace_dst = modifiers->trace_dst == DST_NOT_SET ?
- get_trace_dst(dp) : modifiers->trace_dst;
+ nctrl.trace_dst = select_tr_dst(modifiers, get_trace_dst(dp));
if (!memcmp(&nctrl, get_ctrl(dp), sizeof(nctrl)))
continue;
#ifdef CONFIG_JUMP_LABEL
@@ -881,10 +901,6 @@ static int ddebug_parse_flags(const char *str, struct flag_settings *modifiers)
break;
}
- if (modifiers->flags & _DPRINTK_FLAGS_TRACE &&
- modifiers->trace_dst == DST_NOT_SET)
- modifiers->trace_dst = trc_tbl.default_dst;
-
v3pr_info("flags=0x%x mask=0x%x, trace_dest=0x%x\n",
modifiers->flags, modifiers->mask, modifiers->trace_dst);
--
2.43.0.687.g38aa6559b0-goog
Powered by blists - more mailing lists