linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jim Cromie <jim.cromie@gmail.com>
To: linux-mm@kvack.org
Cc: gregkh@linuxfoundation.org, linux@rasmusvillemoes.dk,
	Jim Cromie <jim.cromie@gmail.com>,
	Jason Baron <jbaron@akamai.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 6/7] dyndbg: add locking around zpool-add loop in zpool-init
Date: Wed, 25 Nov 2020 12:36:25 -0700	[thread overview]
Message-ID: <20201125193626.2266995-7-jim.cromie@gmail.com> (raw)
In-Reply-To: <20201125193626.2266995-1-jim.cromie@gmail.com>

This commit doesnt improve things, last commit was working, next one
still breaks, despite this "fix".  I keep it separate to isolate it
and the reasoning for review, which now stated, will be refuted as
needed. ;-)

Locking review:

ddebug_zpool_init(), like other ddebug_*_init() routines, does no
locking itself.  Unlike them, it runs later, at late_init.  This patch
doesnt fix the kernel panic that HEAD+1 does.

ddebug_callsite_get/put() are called as a pair under mutex-lock for
all 3 callsite users.

2 of them; ddebug_change() and dynamic_emit_prefix(), do their own
ABBA-ish LGPU (Lock-Get-Put-Unlock).

ddebug_proc_show() does the GP part, and is wrapped by
ddebug_proc_start|stop() with LU.

ddebug_add_module() does LU to protect list_add(), HEAD~1 added
ddebug_zpool_add() loop 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 | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 473406b069a7..534d73e45844 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -1195,8 +1195,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),
-- 
2.28.0


  parent reply	other threads:[~2020-11-25 19:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20201125193626.2266995-1-jim.cromie@gmail.com>
2020-11-25 19:36 ` [PATCH 1/7] dyndbg: move struct _ddebug's display fields to new _ddebug_callsite Jim Cromie
2020-11-25 19:36 ` [PATCH 2/7] dyndbg: count repetition in __dyndbg_callsite fields Jim Cromie
2020-11-25 19:36 ` [PATCH 3/7] dyndbg: add some code to see alignments of linkage data Jim Cromie
2020-11-25 19:36 ` [PATCH 4/7] dyndbg: select ZPOOL,ZS_MALLOC in Kconfig.debug DYNAMIC_DEBUG_CORE Jim Cromie
2020-11-25 19:36 ` [PATCH 5/7] dyndbg: replace __dyndbg_callsite section with a zs-pool copy Jim Cromie
2020-11-25 19:36 ` Jim Cromie [this message]
2020-11-25 19:36 ` [PATCH 7/7] dyndbg: enable 'cache' of active pr_debug callsites Jim Cromie
2020-11-25 20:54   ` Jason Baron
2020-11-25 21:23     ` jim.cromie
2020-08-07 20:09 [PATCH 0/7] dyndbg: WIP diet plan Jim Cromie
2020-08-07 20:09 ` [PATCH 6/7] dyndbg: add locking around zpool-add loop in zpool-init 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=20201125193626.2266995-7-jim.cromie@gmail.com \
    --to=jim.cromie@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jbaron@akamai.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux@rasmusvillemoes.dk \
    /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).