linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@redhat.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
	Kyle Moffett <kyle@moffetthome.net>,
	Peter Zijlstra <peterz@infradead.org>,
	Fr??d??ric Weisbecker <fweisbec@gmail.com>,
	Tom Tromey <tromey@redhat.com>, Oleg Nesterov <oleg@redhat.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	"Frank Ch. Eigler" <fche@redhat.com>,
	linux-next@vger.kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	utrace-devel@redhat.com, Thomas Gleixner <tglx@linutronix.de>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: linux-next: add utrace tree
Date: Tue, 02 Feb 2010 01:47:48 -0500	[thread overview]
Message-ID: <4B67CA94.7000501@redhat.com> (raw)
In-Reply-To: <20100129074241.GG14636@elte.hu>

Ingo Molnar wrote:
> 
> * Ananth N Mavinakayanahalli <ananth@in.ibm.com> wrote:
> 
>> On Thu, Jan 28, 2010 at 09:55:02AM +0100, Ingo Molnar wrote:
>>
>> ...
>>
>>> Lets compare the two cases via a drawing. Your current uprobes submission 
>>> does:
>>>
>>>  [kernel]      do probe thing     single-step trap
>>>                ^            |     ^              |
>>>                |            v     |              v
>>>  [user]     INT3            XOL-ins              next ins-stream
>>>
>>>  ( add the need for serialization to make sure the whole single-step thing 
>>>    does not get out of sync with reality. )
>>>
>>> And emulator approach would do:
>>>
>>>  [kernel]      emul-demux-fastpath, do probe thing
>>>                ^                                 |
>>>                |                                 v
>>>  [user]     INT3                                 next ins-stream
>>>
>>> far simpler conceptually, and faster as well, because it's one kernel entry.
>>
>> Ingo,
>>
>> Yes, conceptually, emulation is simpler. In fact, it may even be the
>> right thing to do from a housekeeping POV if gdb were enabled to use
>> breakpoint assistance in the kernel. However... emulation is not
>> easy. Just quoting Peter Anvin:
>>
>>> On the more general rule of interpretation: I'm really concerned about
>>> having a bunch of partially-capable x86 interpreters all over the
>>> kernel.  x86 is *hard* to emulate, and it will only get harder as the
>>> architecture evolves.
>>>
>>>       -hpa
> 
> This is obviously true for a full emulator. Except for the fact that:
> 
>> Yes, I know you suggested we start with a small subset.
> 
> and for the fact that we already have emulators in the kernel.
> 
> Plus we _already_ need to decode instructions for safe kprobing and have the 
> code for that upstream. So it's not like we can avoid decoding the 
> instructions. (and emulating certain instruction patterns is really just a 
> natural next step of a good decoder.)
> 
>> We already have an implementation of instruction emulation in kernel for x86 
>> and powerpc, but its too KVM centric. If there is a generic emulation layer, 
>> we would use it.
> 
> So this approach, beyond being simpler, more robust and faster than the 
> current XOL code, would also trigger (much needed) cleanups in other parts of 
> the kernel and would share code with other kernel subsystems.

Hm, ok. Indeed, we have some x86 emulator-like codes in kernel(see,
arch/x86/mm/pf_in.*). I think it is basically good thing to re-implement
much-better emulator for all. But I think it'll be a long step, because
when I had tried to reuse kvm emulator for decoder, I felt that was too
specialized for kvm, vcpu, guest virtual memory access, and so on.

If we could make an emulator/evaluater/decoder which can provide
functions for those consumers, I'm not so sure it is fast enough,
because I don't think XOL code is so slower than emulating... based on my
experience of kprobe benchmarks, it will need ~500 cycles.
If the emulator can be faster than that, I agreed.

(BTW, apart from uprobes need, I think those codes should be refined
with some well-maintainable instruction maps, like x86-opcode-map.txt :))


> Dont you see the obvious advantages of that?

Hmm, my another concern is if we have to make emulators for each arch,
an XOL implementation could be much simpler than total code of that.


So, summarize my thought, in short term (and only for uprobe), XOL
is better way to go. It can be reused on other archs, generic, and
not-so-slow (and we can boost some opcodes). However, it'll not
transparent from user space(users can see which instruction is probed),
will reduce user space, and might have security issue(?).

In long term, generic x86 emulator is also another way. If we
can make it enough generic, we don't need XOL code. However, it is
hard and takes a time to make it so generic, and can be slower than
XOL on some complex instructions (and also, how many instructions
should be supported is enough for that?). Indeed, I must admit that
implementing an emulator should be exciting for kernel hackers :)

Anyway, if you think we can't avoid generalizing x86 emulators
(even without uprobes), maybe, it a good way to go.

Thank you,

-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com

  parent reply	other threads:[~2010-02-02  6:47 UTC|newest]

Thread overview: 125+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20100119211646.GF16096@redhat.com>
2010-01-20  0:12 ` linux-next: add utrace tree Stephen Rothwell
2010-01-20  5:49   ` Ingo Molnar
2010-01-20  6:15     ` Ananth N Mavinakayanahalli
2010-01-20  6:28       ` Ingo Molnar
2010-01-20  6:40         ` Ananth N Mavinakayanahalli
2010-01-20 10:43           ` Frederic Weisbecker
2010-01-20  6:59         ` Stephen Rothwell
2010-01-20 13:24           ` Frank Ch. Eigler
2010-01-20  7:29         ` Ingo Molnar
2010-01-20 14:38           ` Stephen Rothwell
2010-01-21  1:22             ` Roland McGrath
2010-01-22  0:17             ` Stephen Rothwell
2010-01-22  0:30               ` Andrew Morton
2010-01-22  0:31                 ` Andrew Morton
2010-01-22  0:51                   ` Frank Ch. Eigler
2010-01-22  1:05                     ` Andrew Morton
2010-01-22  1:25                       ` Frank Ch. Eigler
2010-01-22  1:32                         ` Linus Torvalds
2010-01-22  2:22                           ` Frank Ch. Eigler
2010-01-22  2:35                             ` Linus Torvalds
2010-01-22 20:51                               ` Oleg Nesterov
2010-01-23  6:04                               ` Ingo Molnar
2010-01-23 12:03                                 ` Frank Ch. Eigler
2010-01-24 16:36                                   ` Thomas Gleixner
2010-01-22  1:28                       ` Linus Torvalds
2010-01-22  5:21                         ` Ananth N Mavinakayanahalli
2010-01-22 13:43                           ` Valdis.Kletnieks
2010-01-22 19:39                             ` Oleg Nesterov
2010-01-26 13:58                             ` Pavel Machek
2010-01-22 18:28                         ` Oleg Nesterov
2010-01-22 20:01                           ` Frank Ch. Eigler
2010-01-22 20:16                             ` Peter Zijlstra
2010-01-22 21:44                               ` Frank Ch. Eigler
2010-01-22 21:59                             ` Linus Torvalds
2010-01-22 22:13                               ` Frank Ch. Eigler
2010-01-23  0:11                                 ` Linus Torvalds
2010-01-23  0:22                                   ` Linus Torvalds
2010-01-23  6:20                                     ` Kyle Moffett
2010-01-23 11:01                                       ` Alan Cox
2010-01-23 11:51                                         ` Frank Ch. Eigler
2010-01-23 15:57                                         ` Arnaldo Carvalho de Melo
2010-01-23 11:23                                       ` Ingo Molnar
2010-01-23 11:47                                         ` Frank Ch. Eigler
2010-01-23 19:48                                           ` tytso
2010-01-24 18:01                                             ` Frank Ch. Eigler
2010-01-25  1:42                                             ` Kyle Moffett
2010-01-25  4:55                                               ` tytso
2010-01-25 16:52                                               ` Linus Torvalds
2010-01-25 17:02                                                 ` Frank Ch. Eigler
2010-01-25 17:36                                                   ` Linus Torvalds
2010-01-25 17:45                                                     ` Linus Torvalds
2010-01-25 17:54                                                     ` Steven Rostedt
2010-01-25 18:03                                                       ` Alan Cox
2010-01-25 18:12                                                       ` Linus Torvalds
2010-01-25 18:30                                                         ` Steven Rostedt
2010-01-25 18:45                                                           ` Thomas Gleixner
2010-01-25 20:34                                                             ` Ingo Molnar
2010-01-25 20:30                                                     ` Mark Wielaard
2010-01-25 20:42                                                       ` Linus Torvalds
2010-01-26  0:02                                                         ` Renzo Davoli
2010-01-26  0:07                                                           ` Linus Torvalds
2010-01-26 16:08                                                             ` Johannes Stezenbach
2010-01-26 16:28                                                               ` Linus Torvalds
2010-01-26 16:34                                                                 ` Christoph Hellwig
2010-01-28 23:53                                                 ` Benjamin Herrenschmidt
2010-01-29  0:21                                                   ` Linus Torvalds
2010-01-25  4:59                                         ` Ananth N Mavinakayanahalli
2010-01-25 10:13                                           ` Peter Zijlstra
2010-01-24  5:04                                       ` Linus Torvalds
2010-01-24 10:25                                         ` tytso
2010-01-24 13:20                                           ` Frank Ch. Eigler
2010-01-25 21:05                                         ` Tom Tromey
2010-01-25 21:41                                           ` Linus Torvalds
2010-01-26 14:21                                             ` Ananth N Mavinakayanahalli
2010-01-26 23:20                                             ` Tom Tromey
2010-01-26 23:37                                               ` Linus Torvalds
2010-01-27  6:52                                                 ` Peter Zijlstra
2010-01-27  8:54                                                   ` Ingo Molnar
2010-01-28  1:52                                                     ` Jim Keniston
2010-01-28  8:55                                                       ` Ingo Molnar
2010-01-29  0:59                                                         ` Jim Keniston
2010-01-29  7:39                                                           ` Ingo Molnar
2010-01-29  7:52                                                             ` Ananth N Mavinakayanahalli
2010-01-29  7:55                                                               ` Ananth N Mavinakayanahalli
2010-01-29  9:16                                                                 ` Ingo Molnar
2010-01-29  9:11                                                               ` Ingo Molnar
2010-01-29  9:31                                                                 ` Ananth N Mavinakayanahalli
2010-01-29  9:51                                                                   ` Ingo Molnar
2010-01-29 18:13                                                             ` Frank Ch. Eigler
2010-01-29  4:55                                                         ` Ananth N Mavinakayanahalli
2010-01-29  7:42                                                           ` Ingo Molnar
2010-01-30 17:49                                                             ` Steven Rostedt
2010-01-30 17:59                                                               ` Linus Torvalds
2010-02-02  6:47                                                             ` Masami Hiramatsu [this message]
2010-01-27 10:43                                                   ` Linus Torvalds
2010-01-27 10:55                                                     ` Peter Zijlstra
2010-01-27 10:58                                                       ` Peter Zijlstra
2010-01-27 11:04                                                       ` Linus Torvalds
2010-01-27 16:01                                                         ` Frederic Weisbecker
2010-01-27 11:05                                                       ` Ananth N Mavinakayanahalli
2010-01-27 11:08                                                         ` Peter Zijlstra
2010-01-27 11:20                                                           ` Ananth N Mavinakayanahalli
2010-02-08 10:09                                                         ` Avi Kivity
2010-01-27 11:07                                                     ` Srikar Dronamraju
2010-01-27 13:59                                                     ` Steven Rostedt
2010-01-27 17:42                                                       ` H. Peter Anvin
2010-01-27 18:53                                                         ` Steven Rostedt
2010-02-08  6:54                                                         ` Pavel Machek
2010-02-08  9:30                                                           ` H. Peter Anvin
2010-02-08  9:53                                                           ` Arjan van de Ven
2010-01-27 19:18                                                     ` H. Peter Anvin
2010-01-27  0:38                                               ` Frank Ch. Eigler
2010-01-26 15:00                                           ` Frank Ch. Eigler
2010-01-26 17:33                                           ` Andi Kleen
2010-01-26 18:46                                             ` Linus Torvalds
2010-01-26 21:02                                               ` Andi Kleen
2010-01-26 21:53                                                 ` Oleg Nesterov
2010-01-26 22:03                                                   ` Andi Kleen
2010-01-26 23:32                                                     ` Oleg Nesterov
2010-01-26 21:30                                               ` Oleg Nesterov
2010-01-26 23:27                                             ` Tom Tromey
2010-01-23  8:05                                     ` Alexey Dobriyan
2010-01-22 17:45                       ` Oleg Nesterov
2010-01-20  8:52         ` Peter Zijlstra
2010-01-20 13:01         ` Frank Ch. Eigler

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=4B67CA94.7000501@redhat.com \
    --to=mhiramat@redhat.com \
    --cc=acme@redhat.com \
    --cc=fche@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=kyle@moffetthome.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sfr@canb.auug.org.au \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=tromey@redhat.com \
    --cc=utrace-devel@redhat.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;
as well as URLs for NNTP newsgroup(s).