From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Andi Kleen <andi@firstfloor.org>,
linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Arjan van de Ven <arjan@infradead.org>,
Rusty Russell <rusty@rustcorp.com.au>,
"H. Peter Anvin" <hpa@zytor.com>,
Steven Rostedt <srostedt@redhat.com>
Subject: Re: [PATCH 4/6] ftrace, x86: make kernel text writable only for conversions
Date: Mon, 23 Feb 2009 13:34:14 -0500 [thread overview]
Message-ID: <20090223183414.GA3962@Krystal> (raw)
In-Reply-To: <alpine.DEB.2.00.0902231236340.18221@gandalf.stny.rr.com>
* Steven Rostedt (rostedt@goodmis.org) wrote:
>
> On Mon, 23 Feb 2009, Mathieu Desnoyers wrote:
> > >
> > > Hmm, lets see. I simply set a bit in the PTE mappings. There's not many,
> > > since a lot are 2M pages, for x86_64. Call stop_machine, and now I can
> > > modify 1 or 20,000 locations. Set the PTE bit back. Note, the changing of
> > > the bits are only done when CONFIG_DEBUG_RODATA is set.
> > >
> > > text_poke requires allocating a page. Map the page into memory. Set up a
> > > break point.
> >
> > text_poke does not _require_ a break point. text_poke can work with
> > stop_machine.
>
> It can? Doesn't text_poke require allocating pages? The code called by
> stop_machine is all atomic. vmap does not give an option to allocate with
> GFP_ATOMIC.
>
>
> > There are two different problems here :
>
> I agree that they are two different problems. The reason I relate them is
> because text_poke can not be called from a stop_machine call.
>
> >
> > - How you deal with concurrency
> > - you use stop machine
> > - I use breakpoints
> > - How you deal with RO page mappings
> > - you change the kernel page flags
> > - i use text_poke
> >
> > Please don't mix those separate concerns.
>
> So you have two different concerns. One is that I use stop_machine,
> instead of break points, the other is that I modify all kernel text to
> make the change.
>
> Lets look at them separately.
>
> The stop_machine vs. break points.
>
> breakpoints is a cool trick, but is not implemented on all the archs that
> dynamic ftrace is.
>
> break points are performed on a running system. This may be lower in
> latency tracing when the tracer is started, but can create a large number
> of variables that can not all be understood.
>
> stop_machine is quite simple. No need to take traps, no need to handle
> what to do when another process runs the code being changed.
>
> When making the hooks, stop_machine can add a bit of a interrupt latency.
> But this is only when the hooks are added or removed. Why is this such a
> big deal?
On a live system, adding interrupt latency even when tracing is not
active yet _is_ a big deal.
> It is much easier to add the hooks with tracing disabled (via
> a simple toggle bit). Then start and stop your tracing by using the toggle
> bit. After you are all done, then remove the hooks. Or just keep them
> on since they are low overhead anyway (only a few hooks right?)
>
>
> CONFIG_DEBUG_RODATA (only an x86 issue at the moment)
>
> text_poke vs changing all pages:
>
> You said this is a separate issue than stop_machine. But that is not the
> case. text_poke can not be done in an atomic section. This removes it from
> being used by stop_machine.
>
Hrm, I wonder if we could create a variant of vmap_ram that would be
atomic ? That would clearly fix our problems.
> As you said, text_poke only handles the RO/RW issue, not the modifying of
> code on the fly. Thus, keeping stop_machine around, we must also not use
> text_poke.
Not if we modify vmap_ram...
>
> I guess this takes the text_poke vs changing all pages out of the
> question. While stop_machine is still being used, we can not use
> text_poke (without rewriting it).
Where is the problem ? Let's improve it if needed.
>
> Also when we want to trace all functions, is it really necessary to vmap
> each one at a time? Andi suggested that we could optimise by mapping
> larger pages, and finding the ones that share the page. This too would
> require a rewrite of text_poke.
>
This is an optimization, we should see the performance penality first
before we start optimizing things too early.
Mathieu
>
>
> > > >
> > > > If, in the end, your argument is "the function tracer works as-is now,
> > > > and I have no time to change it given it represents too much work" or "I
> > > > don't care about your use-cases", I'm OK with that. But please then don't
> > > > argue that it's because it's the best technical solution when it isn't.
> > >
> > > No, I have yet to hear a valuable argument against stop_machine. You are
> > > pushing the burden of proof on me, when we have something that does work,
> > > on several archs. You want me to redesign the system to be x86 only, and
> > > then say, hey, my original code works better.
> > >
> >
> > stop_machine involves high interrupt latency. This is the argument I've
> > been repeating for 1-2 emails already. And I have to disagree with you :
> > we can do this code generically given the right abstractions
> > (BREAKPOINT_INSN* macros I proposed earlier). Is having something that
> > "works" your only argument to stop improving it ?
>
> The high interrupt latency only happens at the time we need to hook the
> functions. This does not mean it is the time to start the tracing. That
> can be done separately.
>
> Your only concern is the stop_machine latency? Then you might as well also
> prevent modules, since that uses stop machine too. Again, this happens
> only when the tracer hooks are added or removed. This is done at a time
> the sys-admin will activate it. It is not a random latency that is
> occurred by some timer or other asynchronous event.
>
> >
> > > I do not see text_poke being theoretically better. The only reason you
> > > given me to use it is because you dislike stop_machine.
> > >
> >
> > There is absolutely no link between stop_machine and text_poke. I argue
> > against stop_machine saying that the breakpoint approach is less
> > intrusive because it does not involve disabling interrupts for so long,
> > and I argue against modifying the kernel page flags because that
> > modifies the access rights of the core kernel and modules to RO
> > mappings, which is IMO a side-effect that we should eliminate _if we
> > can_. Please keep those two concerns separate.
>
> text_poke can not be executed from stop_machine. There's the link. The two
> concerns are not separate.
>
> Your concern with stop_machine is that it will cause an interrupt latency
> when the sysadmin enables or disables the functions. There exists other
> interrupt latencies that can be worst that are asynchronous. Run hackbench
> with the irqs off tracer and see for yourself.
>
> -- Steve
>
--
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
next prev parent reply other threads:[~2009-02-23 18:34 UTC|newest]
Thread overview: 89+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-20 1:13 [git pull] changes for tip, and a nasty x86 page table bug Steven Rostedt
2009-02-20 1:13 ` [PATCH 1/6] x86: check PMD in spurious_fault handler Steven Rostedt
2009-02-20 1:13 ` [PATCH 2/6] x86: keep pmd rw bit set when creating 4K level pages Steven Rostedt
2009-02-20 1:13 ` [PATCH 3/6] ftrace: allow archs to preform pre and post process for code modification Steven Rostedt
2009-02-20 1:13 ` [PATCH 4/6] ftrace, x86: make kernel text writable only for conversions Steven Rostedt
2009-02-20 1:32 ` Andrew Morton
2009-02-20 1:44 ` Steven Rostedt
2009-02-20 2:05 ` [PATCH][git pull] update to tip/tracing/ftrace Steven Rostedt
2009-02-22 17:50 ` [PATCH 4/6] ftrace, x86: make kernel text writable only for conversions Andi Kleen
2009-02-22 22:53 ` Steven Rostedt
2009-02-23 0:29 ` Andi Kleen
2009-02-23 2:33 ` Mathieu Desnoyers
2009-02-23 4:29 ` Steven Rostedt
2009-02-23 4:53 ` Mathieu Desnoyers
2009-02-23 14:48 ` Steven Rostedt
2009-02-23 15:42 ` Mathieu Desnoyers
2009-02-23 15:51 ` Steven Rostedt
2009-02-23 15:55 ` Steven Rostedt
2009-02-23 16:13 ` Mathieu Desnoyers
2009-02-23 16:48 ` Steven Rostedt
2009-02-23 17:31 ` Mathieu Desnoyers
2009-02-23 18:17 ` Steven Rostedt
2009-02-23 18:34 ` Mathieu Desnoyers [this message]
2009-02-27 17:52 ` Masami Hiramatsu
2009-02-27 18:07 ` Mathieu Desnoyers
2009-02-27 18:34 ` Masami Hiramatsu
2009-02-27 18:53 ` Mathieu Desnoyers
2009-02-27 20:57 ` Masami Hiramatsu
2009-03-02 17:01 ` [RFC][PATCH] x86: make text_poke() atomic Masami Hiramatsu
2009-03-02 17:19 ` Mathieu Desnoyers
2009-03-02 22:15 ` Masami Hiramatsu
2009-03-02 22:22 ` Ingo Molnar
2009-03-02 22:55 ` Masami Hiramatsu
2009-03-02 23:09 ` Ingo Molnar
2009-03-02 23:38 ` Masami Hiramatsu
2009-03-02 23:49 ` Ingo Molnar
2009-03-03 0:00 ` Mathieu Desnoyers
2009-03-03 0:00 ` [PATCH] Text Edit Lock - Architecture Independent Code Mathieu Desnoyers
2009-03-03 0:32 ` Ingo Molnar
2009-03-03 0:39 ` Mathieu Desnoyers
2009-03-03 1:30 ` [PATCH] Text Edit Lock - Architecture Independent Code (v2) Mathieu Desnoyers
2009-03-03 1:31 ` [PATCH] Text Edit Lock - kprobes architecture independent support (v2) Mathieu Desnoyers
2009-03-03 9:27 ` Ingo Molnar
2009-03-03 12:06 ` Ananth N Mavinakayanahalli
2009-03-03 14:28 ` Mathieu Desnoyers
2009-03-03 14:33 ` [PATCH] Text Edit Lock - kprobes architecture independent support (v3) Mathieu Desnoyers
2009-03-03 14:53 ` [PATCH] Text Edit Lock - kprobes architecture independent support (v2) Ingo Molnar
2009-03-03 0:01 ` [PATCH] Text Edit Lock - kprobes architecture independent support Mathieu Desnoyers
2009-03-03 0:10 ` Masami Hiramatsu
2009-03-03 0:05 ` [RFC][PATCH] x86: make text_poke() atomic Masami Hiramatsu
2009-03-03 0:22 ` Ingo Molnar
2009-03-03 0:31 ` Masami Hiramatsu
2009-03-03 16:31 ` [PATCH] x86: make text_poke() atomic using fixmap Masami Hiramatsu
2009-03-03 17:08 ` Mathieu Desnoyers
2009-03-05 10:38 ` Ingo Molnar
2009-03-06 14:06 ` Ingo Molnar
2009-03-06 14:49 ` Masami Hiramatsu
2009-03-02 18:28 ` [RFC][PATCH] x86: make text_poke() atomic Arjan van de Ven
2009-03-02 18:36 ` Mathieu Desnoyers
2009-03-02 18:55 ` Arjan van de Ven
2009-03-02 19:13 ` Masami Hiramatsu
2009-03-02 19:23 ` H. Peter Anvin
2009-03-02 19:47 ` Mathieu Desnoyers
2009-03-02 18:42 ` Linus Torvalds
2009-03-03 4:54 ` Nick Piggin
2009-02-23 18:23 ` [PATCH 4/6] ftrace, x86: make kernel text writable only for conversions Steven Rostedt
2009-02-23 9:02 ` Ingo Molnar
2009-02-27 21:08 ` Pavel Machek
2009-02-28 16:56 ` Andi Kleen
2009-02-28 22:08 ` Pavel Machek
[not found] ` <87wsba1a9f.fsf@basil.nowhere.org>
2009-02-28 22:19 ` Pavel Machek
2009-02-28 23:52 ` Andi Kleen
2009-02-20 1:13 ` [PATCH 5/6] ftrace: immediately stop code modification if failure is detected Steven Rostedt
2009-02-20 1:13 ` [PATCH 6/6] ftrace: break out modify loop immediately on detection of error Steven Rostedt
2009-02-20 2:00 ` [git pull] changes for tip, and a nasty x86 page table bug Linus Torvalds
2009-02-20 2:08 ` Steven Rostedt
2009-02-20 3:44 ` Linus Torvalds
2009-02-20 4:00 ` Steven Rostedt
2009-02-20 4:17 ` Linus Torvalds
2009-02-20 4:34 ` Steven Rostedt
2009-02-20 5:02 ` Huang Ying
2009-02-20 7:29 ` [PATCH] x86: use the right protections for split-up pagetables Ingo Molnar
2009-02-20 7:39 ` [PATCH, v2] " Ingo Molnar
2009-02-20 8:02 ` Ingo Molnar
2009-02-20 10:24 ` Ingo Molnar
2009-02-20 13:57 ` [PATCH] " Steven Rostedt
2009-02-20 15:40 ` Linus Torvalds
2009-02-20 16:59 ` Ingo Molnar
2009-02-20 18:33 ` H. Peter Anvin
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=20090223183414.GA3962@Krystal \
--to=mathieu.desnoyers@polymtl.ca \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=arjan@infradead.org \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=rusty@rustcorp.com.au \
--cc=srostedt@redhat.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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