linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
To: linux-kernel@vger.kernel.org
Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
	Andi Kleen <ak@linux.intel.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	"Naveen N. Rao" <naveen.n.rao@linux.ibm.com>,
	Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
	"David S. Miller" <davem@davemloft.net>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ingo Molnar <mingo@redhat.com>
Subject: [PATCH v4 2/7] kprobes: Use lock_modules() and unlock_modules()
Date: Fri, 17 Jul 2020 06:04:16 +0300	[thread overview]
Message-ID: <20200717030422.679972-3-jarkko.sakkinen@linux.intel.com> (raw)
In-Reply-To: <20200717030422.679972-1-jarkko.sakkinen@linux.intel.com>

Use lock_modules() and unlock_modules() in order to remove compile time
dependency to the module subsystem.

Cc: Andi Kleen <ak@linux.intel.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
 kernel/kprobes.c            | 4 ++--
 kernel/trace/trace_kprobe.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 2e97febeef77..4e46d96d4e16 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -564,7 +564,7 @@ static void kprobe_optimizer(struct work_struct *work)
 	cpus_read_lock();
 	mutex_lock(&text_mutex);
 	/* Lock modules while optimizing kprobes */
-	mutex_lock(&module_mutex);
+	lock_modules();
 
 	/*
 	 * Step 1: Unoptimize kprobes and collect cleaned (unused and disarmed)
@@ -589,7 +589,7 @@ static void kprobe_optimizer(struct work_struct *work)
 	/* Step 4: Free cleaned kprobes after quiesence period */
 	do_free_cleaned_kprobes();
 
-	mutex_unlock(&module_mutex);
+	unlock_modules();
 	mutex_unlock(&text_mutex);
 	cpus_read_unlock();
 
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index aefb6065b508..710ec6a6aa8f 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -122,9 +122,9 @@ static nokprobe_inline bool trace_kprobe_module_exist(struct trace_kprobe *tk)
 	if (!p)
 		return true;
 	*p = '\0';
-	mutex_lock(&module_mutex);
+	lock_modules();
 	ret = !!find_module(tk->symbol);
-	mutex_unlock(&module_mutex);
+	unlock_modules();
 	*p = ':';
 
 	return ret;
-- 
2.25.1


  parent reply	other threads:[~2020-07-17  3:04 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-17  3:04 [PATCH v4 0/7] arch/x86: kprobes: Remove MODULES dependency Jarkko Sakkinen
2020-07-17  3:04 ` [PATCH v4 1/7] module: Add lock_modules() and unlock_modules() Jarkko Sakkinen
2020-07-17  3:04 ` Jarkko Sakkinen [this message]
2020-07-17  3:04 ` [PATCH v4 3/7] vmalloc: Add text_alloc() and text_free() Jarkko Sakkinen
2020-07-17  5:33   ` kernel test robot
2020-07-17  5:33   ` kernel test robot
2020-07-17  8:52   ` Masami Hiramatsu
2020-07-23 22:24     ` Jarkko Sakkinen
2020-07-18 16:23   ` Mike Rapoport
2020-07-20 12:01     ` Masami Hiramatsu
2020-07-23 22:28     ` Jarkko Sakkinen
2020-07-24 10:13       ` Mike Rapoport
2020-07-24 23:31         ` Jarkko Sakkinen
2020-07-24 23:40           ` Jarkko Sakkinen
2020-07-17  3:04 ` [PATCH v4 4/7] arch/x86: Implement " Jarkko Sakkinen
2020-07-17  3:04 ` [PATCH v4 5/7] arch/x86: kprobes: Use text_alloc() in alloc_insn_page() Jarkko Sakkinen
2020-07-23 22:16   ` Jarkko Sakkinen
2020-07-17  3:04 ` [PATCH v4 6/7] kprobes: Use text_alloc() and text_free() Jarkko Sakkinen
2020-07-17  3:04 ` [PATCH v4 7/7] kprobes: Flag out CONFIG_MODULES dependent code Jarkko Sakkinen

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=20200717030422.679972-3-jarkko.sakkinen@linux.intel.com \
    --to=jarkko.sakkinen@linux.intel.com \
    --cc=ak@linux.intel.com \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=naveen.n.rao@linux.ibm.com \
    --cc=rostedt@goodmis.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).