linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jim Cromie <jim.cromie@gmail.com>
To: jbaron@akamai.com, linux-kernel@vger.kernel.org
Cc: Jim Cromie <jim.cromie@gmail.com>
Subject: [PATCH 8/8] dyndbg: add locking around zpool-add loop in zpool-init
Date: Fri,  7 Aug 2020 14:09:56 -0600	[thread overview]
Message-ID: <20200807200957.1269454-10-jim.cromie@gmail.com> (raw)
In-Reply-To: <20200807200957.1269454-1-jim.cromie@gmail.com>

summary: no fix here.

Locking review:

ddebug_zpool_init(), like other *_init() routines, does not run under
a lock (that we control).  Unlike them, it runs later, at late_init.
I dont know whether this is pertinent to the kernel panic.

ddebug_callsite_get/put() are called as a pair under mutex-lock for
all 3 callsite users; dynamic_emit_prefix() does its own ABBA-ish LGPU
(Lock-Get-Put-Unlock), as does ddebug_change().

ddebug_proc_show() does GP, ddebug_proc_start|stop() wrap it with LU.

ddebug_add_module() does LU to protect list_add(), HEAD~x added
ddebug_zpool_add() inside that protection.

This commit adds locking to ddebug_zpool_init(), around the loop of
ddebug_zpool_add(), to match the locking in ddebug_add_module().

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 lib/dynamic_debug.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 9c51f24a9c66..716231a98910 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -1187,8 +1187,10 @@ static void __init ddebug_zpool_init(void)
 	}
 
 	/* add-module normally does this, but not in time for builtins */
+	mutex_lock(&ddebug_lock);
 	for (iter = __start___dyndbg; iter < __stop___dyndbg; iter++)
 		ddebug_zpool_add(iter);
+	mutex_unlock(&ddebug_lock);
 
 	v2pr_info("total pages: %lu compaction: %lu\n",
 		  zs_get_total_pages(dd_callsite_zpool),
@@ -1285,4 +1287,3 @@ early_initcall(dynamic_debug_init);
 
 /* Debugfs setup must be done later */
 fs_initcall(dynamic_debug_init_control);
-
-- 
2.26.2


      parent reply	other threads:[~2020-08-07 20:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-07 20:09 [PATCH 0/7] dyndbg: WIP diet plan Jim Cromie
2020-08-07 20:09 ` [PATCH 1/7] dyndbg: give %3u width in pr-format, cosmetic only Jim Cromie
2020-08-07 20:09 ` [PATCH 2/7] dyndbg: motivate a diet plan Jim Cromie
2020-08-07 20:09 ` [PATCH 3/7] dyndbg: select ZPOOL in Kconfig.debug Jim Cromie
2020-08-09  5:05   ` Randy Dunlap
2020-08-09 15:09     ` jim.cromie
2020-08-07 20:09 ` [PATCH 4/7] dyndbg: split struct _ddebug in 2, creating _ddebug_callsite Jim Cromie
2020-08-07 20:09 ` [PATCH 5/7] dyndbg: WIP replace __dyndbg_callsite section with a zs-pool copy Jim Cromie
2020-08-07 23:50   ` kernel test robot
2020-08-07 20:09 ` [PATCH 6/7] dyndbg: add locking around zpool-add loop in zpool-init Jim Cromie
2020-08-07 20:09 ` [PATCH 6/8] dyndbg: ddebug_zpool_remove Jim Cromie
2020-08-07 20:09 ` [PATCH 7/7] dyndbg: enable 'cache' of active pr_debug callsites Jim Cromie
2020-08-09  4:35   ` [dyndbg] 4397a3e7bf: BUG:sleeping_function_called_from_invalid_context_at_mm/slab.h kernel test robot
2020-08-12 15:11     ` jim.cromie
2020-08-07 20:09 ` Jim Cromie [this message]

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=20200807200957.1269454-10-jim.cromie@gmail.com \
    --to=jim.cromie@gmail.com \
    --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;
as well as URLs for NNTP newsgroup(s).