From: Yeongkyoon Lee <yeongkyoon.lee@samsung.com>
To: Aurelien Jarno <aurelien@aurel32.net>
Cc: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v5 0/3] tcg: enhance code generation quality for qemu_ld/st IRs
Date: Wed, 10 Oct 2012 23:09:12 +0900 [thread overview]
Message-ID: <50758188.3000904@samsung.com> (raw)
In-Reply-To: <50754F3A.5030602@samsung.com>
On 2012년 10월 10일 19:34, Yeongkyoon Lee wrote:
> On 2012년 10월 10일 15:45, Aurelien Jarno wrote:
>> On Wed, Oct 10, 2012 at 01:17:36PM +0900, Yeongkyoon Lee wrote:
>>> On 2012년 10월 10일 02:09, Aurelien Jarno wrote:
>>>> On Tue, Oct 09, 2012 at 06:55:58PM +0200, Paolo Bonzini wrote:
>>>>> Il 09/10/2012 18:19, Aurelien Jarno ha scritto:
>>>>>>>> Instead of calling the MMU helper with an additional argument
>>>>>>>> (7), and
>>>>>>>> then jump back (8) to the next code (4), what about pushing the
>>>>>>>> address
>>>>>>>> of the next code (4) on the stack and use a jmp instead of the
>>>>>>>> call. In
>>>>>>>> that case you don't need the extra argument to the helpers.
>>>>>>>>
>>>>>> Maybe it wasn't very clear. This is based on the fact that call is
>>>>>> basically push %rip + jmp. Therefore we can fake the return
>>>>>> address by
>>>>>> putting the value we want, here the address of the next code.
>>>>>> This mean
>>>>>> that we don't need to pass the extra argument to the helper for the
>>>>>> return address, as GET_PC() would work correctly (it basically
>>>>>> reads the
>>>>>> return address on the stack).
>>>>>>
>>>>>> For other architectures, it might not be a push, but rather a
>>>>>> move to
>>>>>> link register, basically put the return address where the calling
>>>>>> convention asks for.
>>>>>>
>>>>>> OTOH I just realized it only works if the end of the slow path
>>>>>> (moving
>>>>>> the value from the return address to the correct register). It
>>>>>> might be
>>>>>> something doable.
>>>>> Branch predictors will not oldschool tricks like this one. :)
>>>>>
>>>> Given it is only used in the slow path (ie the exception more than the
>>>> rule), branch prediction isn't that important there.
>>>>
>>> I had already considered the approach of using jmp and removing
>>> extra argument for helper call.
>>> However, the problem is that the helper needs the gen code addr used
>>> by tb_find_pc() and cpu_restore_state().
>>> That means the code addr in the helper can be actually said the addr
>>> corresponding to QEMU_ld/st IR rather than the return addr.
>>> In my LDST optimization, the helper call site is not in the code of
>>> IR but in the end of TB.
>> GETPC() uses the return address to determine the call place, and as long
>> as the code at the end of the TB set a return address corresponding to
>> the one of the fast path instructions, tb_find_pc() will be able to find
>> the correct instruction.
>>
>> That implies that at least one instruction at the end of the generated
>> code is shared between the slow path and the fast path, but in the other
>> hand it avoids having to different kind of mmu helpers.
>>
>
> How about nop instruction at the end of fast path as return address of
> helper?
> That means the change of "call helper" to "push addr of nop" and "jmp
> helper".
> Although I need to check the feasibility, it is expected to avoid
> helper fragmentation and to make performance degradation to be minimum.
>
>
I've done some tests about performance degradation when nop instruction
is inserted to qemu_ld/st fast path.
The result is ok because I did not find any notable performance degradation.
I'll patch new version without the change of MMU helper's description soon.
prev parent reply other threads:[~2012-10-10 14:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-09 12:37 [Qemu-devel] [PATCH v5 0/3] tcg: enhance code generation quality for qemu_ld/st IRs Yeongkyoon Lee
2012-10-09 12:37 ` [Qemu-devel] [PATCH v5 1/3] configure: Add CONFIG_QEMU_LDST_OPTIMIZATION for TCG qemu_ld/st optimization Yeongkyoon Lee
2012-10-09 12:37 ` [Qemu-devel] [PATCH v5 2/3] tcg: Add declarations and templates of extended MMU helpers Yeongkyoon Lee
2012-10-09 18:36 ` Richard Henderson
2012-10-10 11:04 ` Yeongkyoon Lee
2012-10-09 12:37 ` [Qemu-devel] [PATCH v5 3/3] tcg: Optimize qemu_ld/st by generating slow paths at the end of a block Yeongkyoon Lee
2012-10-09 18:49 ` Richard Henderson
2012-10-10 4:41 ` Yeongkyoon Lee
2012-10-09 14:26 ` [Qemu-devel] [PATCH v5 0/3] tcg: enhance code generation quality for qemu_ld/st IRs Aurelien Jarno
2012-10-09 16:19 ` Aurelien Jarno
2012-10-09 16:55 ` Paolo Bonzini
2012-10-09 17:09 ` Aurelien Jarno
2012-10-10 4:17 ` Yeongkyoon Lee
2012-10-10 6:45 ` Aurelien Jarno
2012-10-10 10:34 ` Yeongkyoon Lee
2012-10-10 14:09 ` Yeongkyoon Lee [this message]
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=50758188.3000904@samsung.com \
--to=yeongkyoon.lee@samsung.com \
--cc=aurelien@aurel32.net \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.