public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Jessica Yu <jeyu@kernel.org>,
	Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write
Date: Fri, 11 Oct 2019 13:09:33 +0200	[thread overview]
Message-ID: <20191011110933.GX2328@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20191010132013.7f3388bc@gandalf.local.home>

On Thu, Oct 10, 2019 at 01:20:13PM -0400, Steven Rostedt wrote:
> Hmm, I'm lost at what the below is trying to do with respect to the
> above.

The below is an alternative approach for the module load issue. It
accepts we patch 'late' and then uses text_poke_bp().

It works. We can then look at moving all that patching to
ftrace_module_init() later when we figure out how to do it across
architectures.

> > --- a/arch/x86/kernel/ftrace.c
> > +++ b/arch/x86/kernel/ftrace.c
> > @@ -34,6 +34,8 @@
> >  
> >  #ifdef CONFIG_DYNAMIC_FTRACE
> >  
> > +static int ftrace_poke_late = 0;
> > +
> >  int ftrace_arch_code_modify_prepare(void)
> >      __acquires(&text_mutex)
> >  {
> > @@ -43,12 +45,15 @@ int ftrace_arch_code_modify_prepare(void
> >  	 * ftrace has it set to "read/write".
> >  	 */
> >  	mutex_lock(&text_mutex);
> > +	ftrace_poke_late = 1;
> >  	return 0;
> >  }
> >  
> >  int ftrace_arch_code_modify_post_process(void)
> >      __releases(&text_mutex)
> >  {
> > +	text_poke_finish();
> > +	ftrace_poke_late = 0;
> >  	mutex_unlock(&text_mutex);
> >  	return 0;
> >  }
> > @@ -116,7 +121,10 @@ ftrace_modify_code_direct(unsigned long
> >  		return ret;
> >  
> >  	/* replace the text with the new text */
> > -	text_poke_early((void *)ip, new_code, MCOUNT_INSN_SIZE);
> > +	if (ftrace_poke_late)
> > +		text_poke_queue((void *)ip, new_code, MCOUNT_INSN_SIZE, NULL);
> > +	else
> > +		text_poke_early((void *)ip, new_code, MCOUNT_INSN_SIZE);
> >  	return 0;
> >  }
> >  
> 

  reply	other threads:[~2019-10-11 11:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-10  2:36 [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write Steven Rostedt
2019-10-10  7:31 ` Peter Zijlstra
2019-10-10  9:26   ` Peter Zijlstra
2019-10-10  9:33   ` Peter Zijlstra
2019-10-10  9:36     ` Peter Zijlstra
2019-10-10 12:29       ` Peter Zijlstra
2019-10-10 14:55         ` Steven Rostedt
2019-10-10 15:03           ` Steven Rostedt
2019-10-10 16:59           ` Steven Rostedt
2019-10-10 17:01           ` Peter Zijlstra
2019-10-10 17:20             ` Steven Rostedt
2019-10-11 11:09               ` Peter Zijlstra [this message]
2019-10-10 12:50       ` Steven Rostedt
2019-10-10 14:11         ` Peter Zijlstra
2019-10-10 12:58 ` Steven Rostedt
2019-10-14 12:31   ` 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=20191011110933.GX2328@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=jeyu@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --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