From: Jim Cromie <jim.cromie@gmail.com>
To: jbaron@akamai.com, gregkh@linuxfoundation.org,
linux-kernel@vger.kernel.org
Cc: Jim Cromie <jim.cromie@gmail.com>
Subject: [RFC PATCH v3 02/18] dyndbg: __init iterate over __dyndbg & __dyndbg_site in parallel
Date: Mon, 15 Mar 2021 23:07:45 -0600 [thread overview]
Message-ID: <20210316050801.2446401-3-jim.cromie@gmail.com> (raw)
In-Reply-To: <20210316050801.2446401-1-jim.cromie@gmail.com>
In dynamic_debug_init(), rework for-loop; add 2nd 'site' var, and
iterate over both __dyndbg* sections in parallel. Replace uses of
iter->site with the new 'site' iter, add a BUG_ON to enforce the
invariant given by HEAD~1's DECLARE_DYNAMIC_DEBUG_METADATA base->site
initialization.
0- declare the new elf section start/stop, named in vmlinux.lds.h
I disregarded a checkpatch warning about externs in c-files, stuck
with current practice.
1- clean up use of 4 iterators for clarity:
(iter, site), and ((iter, site)_mod_start) block markers.
2- iterate over __dyndbg_sites in parallel with __dyndbg
s/iter->site/site/g;
3- add BUG_ON(iter->site != site)
DECLARE_DYNAMIC_DEBUG_METADATA + linker insure this now.
Maybe we can drop pointer, still get order.
4- var rename n to site_ct
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
lib/dynamic_debug.c | 36 +++++++++++++++++++++++-------------
1 file changed, 23 insertions(+), 13 deletions(-)
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 738c4ce28046..c3c35dcc6a59 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -41,6 +41,8 @@
extern struct _ddebug __start___dyndbg[];
extern struct _ddebug __stop___dyndbg[];
+extern struct _ddebug_site __start___dyndbg_sites[];
+extern struct _ddebug_site __stop___dyndbg_sites[];
struct ddebug_table {
struct list_head link;
@@ -118,6 +120,7 @@ do { \
#define vpr_info(fmt, ...) vnpr_info(1, fmt, ##__VA_ARGS__)
#define v2pr_info(fmt, ...) vnpr_info(2, fmt, ##__VA_ARGS__)
+#define v3pr_info(fmt, ...) vnpr_info(3, fmt, ##__VA_ARGS__)
static void vpr_info_dq(const struct ddebug_query *query, const char *msg)
{
@@ -1082,11 +1085,12 @@ static int __init dynamic_debug_init_control(void)
static int __init dynamic_debug_init(void)
{
- struct _ddebug *iter, *iter_start;
+ struct _ddebug *iter, *iter_mod_start;
+ struct _ddebug_site *site, *site_mod_start;
const char *modname = NULL;
char *cmdline;
int ret = 0;
- int n = 0, entries = 0, modct = 0;
+ int site_ct = 0, entries = 0, modct = 0;
if (&__start___dyndbg == &__stop___dyndbg) {
if (IS_ENABLED(CONFIG_DYNAMIC_DEBUG)) {
@@ -1097,23 +1101,29 @@ static int __init dynamic_debug_init(void)
ddebug_init_success = 1;
return 0;
}
- iter = __start___dyndbg;
- modname = iter->site->modname;
- iter_start = iter;
- for (; iter < __stop___dyndbg; iter++) {
+
+ iter = iter_mod_start = __start___dyndbg;
+ site = site_mod_start = __start___dyndbg_sites;
+ modname = site->modname;
+
+ for (; iter < __stop___dyndbg; iter++, site++) {
+
+ BUG_ON(site != iter->site);
entries++;
- if (strcmp(modname, iter->site->modname)) {
+
+ if (strcmp(modname, site->modname)) {
modct++;
- ret = ddebug_add_module(iter_start, n, modname);
+ ret = ddebug_add_module(iter_mod_start, site_ct, modname);
if (ret)
goto out_err;
- n = 0;
- modname = iter->site->modname;
- iter_start = iter;
+ site_ct = 0;
+ modname = site->modname;
+ iter_mod_start = iter;
+ site_mod_start = site;
}
- n++;
+ site_ct++;
}
- ret = ddebug_add_module(iter_start, n, modname);
+ ret = ddebug_add_module(iter_mod_start, site_ct, modname);
if (ret)
goto out_err;
--
2.29.2
next prev parent reply other threads:[~2021-03-16 5:09 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-16 5:07 [RFC PATCH v3 00/18] dynamic debug diet plan Jim Cromie
2021-03-16 5:07 ` [RFC PATCH v3 01/18] dyndbg: split struct _ddebug, move display fields to new _ddebug_site Jim Cromie
2021-03-16 5:07 ` Jim Cromie [this message]
2021-03-16 5:07 ` [RFC PATCH v3 03/18] dyndbg: refactor part of ddebug_change to ddebug_match_site Jim Cromie
2021-03-16 5:07 ` [RFC PATCH v3 04/18] dyndbg: accept null site in ddebug_match_site Jim Cromie
2021-03-16 5:07 ` [RFC PATCH v3 05/18] dyndbg: hoist ->site out of ddebug_match_site Jim Cromie
2021-03-16 5:07 ` [RFC PATCH v3 06/18] dyndbg: accept null site in ddebug_change Jim Cromie
2021-03-16 5:07 ` [RFC PATCH v3 07/18] dyndbg: accept null site in dynamic_emit_prefix Jim Cromie
2021-03-16 5:07 ` [RFC PATCH v3 08/18] dyndbg: accept null site in ddebug_proc_show Jim Cromie
2021-03-16 5:07 ` [RFC PATCH v3 09/18] dyndbg: optimize ddebug_emit_prefix Jim Cromie
2021-03-16 5:07 ` [RFC PATCH v3 10/18] dyndbg: avoid calling dyndbg_emit_prefix when it has no work Jim Cromie
2021-03-16 5:07 ` [RFC PATCH v3 11/18] dyndbg: refactor ddebug_alter_site out of ddebug_change Jim Cromie
2021-03-16 5:07 ` [RFC PATCH v3 12/18] dyndbg: allow deleting site info via control interface Jim Cromie
2021-03-16 5:07 ` [RFC PATCH v3 13/18] dyndbg+module: expose ddebug_sites to modules Jim Cromie
2021-03-16 5:07 ` [RFC PATCH v3 14/18] dyndbg: add ddebug_site(_get|_put) abstraction Jim Cromie
2021-03-16 5:07 ` [RFC PATCH v3 15/18] dyndbg: add _index to struct _ddebug Jim Cromie
2021-03-16 5:07 ` [RFC PATCH v3 16/18] dyndbg: prevent build bugs via -DNO_DYNAMIC_DEBUG_TABLE Jim Cromie
2021-03-16 5:08 ` [RFC PATCH v3 17/18] dyndbg: RFC - DECLARE/DEFINE_DYNAMIC_DEBUG_TABLE Jim Cromie
2021-03-16 5:08 ` [RFC PATCH v3 18/18] dyndbg: shuffle ddebug_table fields Jim Cromie
2021-03-19 4:12 ` [RFC PATCH v3 00/18] dynamic debug diet plan Andi Kleen
2021-05-02 2:16 ` jim.cromie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210316050801.2446401-3-jim.cromie@gmail.com \
--to=jim.cromie@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jbaron@akamai.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox