mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Namit Gupta <gupta.namit@samsung.com>
To: rostedt@goodmis.org, mingo@redhat.com, linux-kernel@vger.kernel.org
Cc: a.sahrawat@samsung.com, pankaj.m@samsung.com,
	Namit Gupta <gupta.namit@samsung.com>
Subject: ftrace/module: Move ftrace_release_mod() to ddebug_cleanup label
Date: Wed, 15 Nov 2017 15:18:54 +0530	[thread overview]
Message-ID: <1510739334-11334-1-git-send-email-gupta.namit@samsung.com> (raw)
In-Reply-To: <CGME20171115095144epcas5p38455d1efc3aab5d80caa640583c9587c@epcas5p3.samsung.com>

ftrace_module_init happen after dynamic_debug_setup, it is desired that
cleanup should be called after this label however in current implementation
it is called in free module label,ie:even though ftrace in not initialized,
from so many fail case ftrace_release_mod() will be called and unnecessary
traverse the whole list.
In below patch we moved ftrace_release_mod() from free_module label to
ddebug_cleanup label. that is the best possible location, other solution
is to make new label to ftrace_release_mod() but since ftrace_module_init()
is not return with minimum changes it should be in ddebug_cleanup label.


Signed-off-by: Namit Gupta <gupta.namit@samsung.com>
Reviewed-by: Amit Sahrawat <a.sahrawat@samsung.com>
---
 kernel/module.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index 0d1cb8d..3498d62 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -3523,6 +3523,12 @@ static int load_module(struct load_info *info, const char __user *uargs,
 	unset_module_core_ro_nx(mod);
 
  ddebug_cleanup:
+	/*
+	 * Ftrace needs to clean up what it initialized.
+	 * This does nothing if ftrace_module_init() wasn't called,
+	 * but it must be called outside of module_mutex.
+	 */
+	ftrace_release_mod(mod);
 	dynamic_debug_remove(info->debug);
 	synchronize_sched();
 	kfree(mod->args);
@@ -3541,12 +3547,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
 	synchronize_rcu();
 	mutex_unlock(&module_mutex);
  free_module:
-	/*
-	 * Ftrace needs to clean up what it initialized.
-	 * This does nothing if ftrace_module_init() wasn't called,
-	 * but it must be called outside of module_mutex.
-	 */
-	ftrace_release_mod(mod);
 	/* Free lock-classes; relies on the preceding sync_rcu() */
 	lockdep_free_key_range(mod->module_core, mod->core_size);
 
-- 
1.9.1

       reply	other threads:[~2017-11-15  9:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20171115095144epcas5p38455d1efc3aab5d80caa640583c9587c@epcas5p3.samsung.com>
2017-11-15  9:48 ` Namit Gupta [this message]
2017-12-11 14:42   ` Steven Rostedt
     [not found]   ` <CGME20171115095144epcas5p38455d1efc3aab5d80caa640583c9587c@epcms5p4>
     [not found]     ` <20171129053635epcms5p46340b7d7c82cc90ff9b31fa26ac40878@epcms5p4>
2017-11-29 12:14       ` Steven Rostedt
     [not found]       ` <CGME20171115095144epcas5p38455d1efc3aab5d80caa640583c9587c@epcms5p1>
     [not found]         ` <20171206031707epcms5p1e0848a6672f4b7848046c0cae538f3ad@epcms5p1>
2017-12-06 12:10           ` Steven Rostedt
2017-12-12  3:49     ` AMIT SAHRAWAT
     [not found] <CGME20171212115859epcas5p1c80cacda05c36d4ef2607df2450d4aa3@epcas5p1.samsung.com>
2017-12-12 11:54 ` [PATCH v2] ftrace/module: Move ftrace_release_mod " Namit Gupta
2017-12-28 16:32   ` Steven Rostedt
2017-12-29  0:36     ` Jessica Yu
2017-12-29  0:57       ` Steven Rostedt
2017-12-29  1:02         ` Jessica Yu

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=1510739334-11334-1-git-send-email-gupta.namit@samsung.com \
    --to=gupta.namit@samsung.com \
    --cc=a.sahrawat@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pankaj.m@samsung.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

all inboxes | Powered by JetHome®