Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1293646
| From | "Zhang, Yanmin" <yanmin_zhang@linux.intel.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] ftrace: fix race between ftrace and insmod |
| Date | 2015-12-17 07:50 +0100 |
| Message-ID | <qGAxX-4aR-3@gated-at.bofh.it> (permalink) |
| References | (4 earlier) <qFMhP-5wn-5@gated-at.bofh.it> <qFOtj-6Va-9@gated-at.bofh.it> <qG1JU-7j0-7@gated-at.bofh.it> <qGhvk-wX-21@gated-at.bofh.it> <qGlfz-2SD-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 2015/12/16 22:28, Steven Rostedt wrote:
> 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.
Thanks for the kind pointer.
We would add codes into your patch based on notifier and send patch to you by
private email.
Yanmin
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH] ftrace: fix race between ftrace and insmod "Qiu, PeiyangX" <peiyangx.qiu@intel.com> - 2015-12-14 04:00 +0100
[PATCH] ftrace: fix race between ftrace and insmod "Qiu, PeiyangX" <peiyangx.qiu@intel.com> - 2015-12-14 04:20 +0100
Re: [PATCH] ftrace: fix race between ftrace and insmod Steven Rostedt <rostedt@goodmis.org> - 2015-12-14 17:00 +0100
Re: [PATCH] ftrace: fix race between ftrace and insmod "Zhang, Yanmin" <yanmin_zhang@linux.intel.com> - 2015-12-15 02:10 +0100
Re: [PATCH] ftrace: fix race between ftrace and insmod "Zhang, Yanmin" <yanmin_zhang@linux.intel.com> - 2015-12-15 04:30 +0100
Re: [PATCH] ftrace: fix race between ftrace and insmod Steven Rostedt <rostedt@goodmis.org> - 2015-12-15 18:40 +0100
Re: [PATCH] ftrace: fix race between ftrace and insmod "Zhang, Yanmin" <yanmin_zhang@linux.intel.com> - 2015-12-16 02:00 +0100
Re: [PATCH] ftrace: fix race between ftrace and insmod "Zhang, Yanmin" <yanmin_zhang@linux.intel.com> - 2015-12-16 11:30 +0100
Re: [PATCH] ftrace: fix race between ftrace and insmod Steven Rostedt <rostedt@goodmis.org> - 2015-12-16 15:30 +0100
Re: [PATCH] ftrace: fix race between ftrace and insmod "Zhang, Yanmin" <yanmin_zhang@linux.intel.com> - 2015-12-17 07:50 +0100
csiph-web