From: Steven Rostedt <rostedt@goodmis.org>
To: "Zhang, Yanmin" <yanmin_zhang@linux.intel.com>
Cc: "Qiu, PeiyangX" <peiyangx.qiu@intel.com>,
linux-kernel@vger.kernel.org, mingo@redhat.com,
Rusty Russell <rusty@rustcorp.com.au>
Subject: Re: [PATCH] ftrace: fix race between ftrace and insmod
Date: Wed, 16 Dec 2015 09:28:12 -0500 [thread overview]
Message-ID: <20151216092812.34711e3b@grimm.local.home> (raw)
In-Reply-To: <56713CD3.80006@linux.intel.com>
On Wed, 16 Dec 2015 18:28:35 +0800
"Zhang, Yanmin" <yanmin_zhang@linux.intel.com> wrote:
> > + /*
> > + * If the tracing is enabled, go ahead and enable the record.
> > + *
> > + * The reason not to enable the record immediatelly is the
> > + * inherent check of ftrace_make_nop/ftrace_make_call for
> > + * correct previous instructions. Making first the NOP
> > + * conversion puts the module to the correct state, thus
> > + * passing the ftrace_make_call check.
> > + *
> > + * We also delay this to after the module code already set the
> > + * text to read-only, as we now need to set it back to read-write
> > + * so that we can modify the text.
> > + */
> > + if (ftrace_start_up)
> > + ftrace_arch_code_modify_prepare();
> > +
> > + do_for_each_ftrace_rec(pg, rec) {
> > + int cnt;
> > + /*
> > + * do_for_each_ftrace_rec() is a double loop.
> > + * module text shares the pg. If a record is
> > + * not part of this module, then skip this pg,
> > + * which the "break" will do.
> > + */
> > + if (!within_module_core(rec->ip, mod))
> > + break;
> > +
> > + cnt = 0;
> > +
> > + /*
> > + * When adding a module, we need to check if tracers are
> > + * currently enabled and if they are, and can trace this record,
> > + * we need to enable the module functions as well as update the
> > + * reference counts for those function records.
> > + */
> > + if (ftrace_start_up)
> > + cnt += referenced_filters(rec);
> > +
> > + /* This clears FTRACE_FL_DISABLED */
> > + rec->flags = cnt;
> > +
> > + if (ftrace_start_up && cnt) {
> > + int failed = __ftrace_replace_code(rec, 1);
>
> If we choose to call ftrace_module_enable when receiving module notification
> MODULE_STATE_COMING, TEXT section of the module is already changed to RO.
And that's why we call ftrace_arch_code_modify_prepare(). That should
change all text to RW.
-- Steve
next prev parent reply other threads:[~2015-12-16 14:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <S1751824AbbLNCkP/20151214024015Z+230@vger.kernel.org>
2015-12-14 2:59 ` Qiu, PeiyangX
2015-12-14 3:16 ` Qiu, PeiyangX
2015-12-14 15:51 ` Steven Rostedt
2015-12-15 1:05 ` Zhang, Yanmin
2015-12-15 3:26 ` Zhang, Yanmin
2015-12-15 17:37 ` Steven Rostedt
2015-12-16 0:54 ` Zhang, Yanmin
2015-12-16 10:28 ` Zhang, Yanmin
2015-12-16 14:28 ` Steven Rostedt [this message]
2015-12-17 6:48 ` Zhang, Yanmin
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=20151216092812.34711e3b@grimm.local.home \
--to=rostedt@goodmis.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peiyangx.qiu@intel.com \
--cc=rusty@rustcorp.com.au \
--cc=yanmin_zhang@linux.intel.com \
/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®