From: David Daney <ddaney@caviumnetworks.com>
To: David VomLehn <dvomlehn@cisco.com>
Cc: linux-mips@linux-mips.org, ralf@linux-mips.org
Subject: Re: [PATCH] MIPS: Don't branch to eret in TLB refill.
Date: Tue, 12 May 2009 18:12:11 -0700 [thread overview]
Message-ID: <4A0A1E6B.6050908@caviumnetworks.com> (raw)
In-Reply-To: <20090513002337.GA12536@cuplxvomd02.corp.sa.net>
David VomLehn wrote:
> On Tue, May 12, 2009 at 03:45:16PM -0700, David Daney wrote:
>> If the TLB refill handler is too bit and needs to be split, there is
>> no need to branch around the split if the branch target would be an
>> eret. Since the eret returns from the handler, control flow never
>> passes it. A branch to an eret is equivalent to the eret itself.
>>
>> Signed-off-by: David Daney <ddaney@caviumnetworks.com>
>> ---
>> arch/mips/mm/tlbex.c | 50 +++++++++++++++++++++++++++++++++-----------------
>> 1 files changed, 33 insertions(+), 17 deletions(-)
>>
>> diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
>> index 4dc4f3e..ffa7104 100644
>> --- a/arch/mips/mm/tlbex.c
>> +++ b/arch/mips/mm/tlbex.c
>> @@ -723,28 +731,36 @@ static void __cpuinit build_r4000_tlb_refill_handler(void)
>> uasm_copy_handler(relocs, labels, tlb_handler, p, f);
>> final_len = p - tlb_handler;
>> } else {
>> - u32 *split = tlb_handler + 30;
>> -
>> - /*
>> - * Find the split point.
>> - */
>> - if (uasm_insn_has_bdelay(relocs, split - 1))
>> - split--;
>> + u32 *split;
>> + if (split_on_eret) {
>> + split = tlb_handler + 32;
>> + } else {
>> + split = tlb_handler + 30;
>
> It would be a shame to pass up an opportunity to eliminate some of the
> pile of magic constants we have in the MIPS tree. Given that the MIPS
> documentation describes the size of the TLB Refill handler as 0x80 bytes,
> we could add something like:
>
That would be a different patch according to the one patch per problem rule.
> /* Maximum # of instructions in exception vector for TLB Refill handler */
> #define MIPS64_TLB_REFILL_OPS (0x80 / sizeof(union mips_instruction))
>
> and could change the last few lines of the code above to, for example:
>
> if (split_on_eret) {
> split = tlb_handler + MIPS64_TLB_REFILL_OPS;
> } else {
> split = tlb_handler + MIPS64_TLB_REFILL_OPS - 2;
>
> (you'd need to include asm/inst.h to get union mips_instruction defined)
It is certainly possible to do something like that, but it isn't clear
to me that it makes it any easier to understand.
>
>> +
>> + /*
>> + * Find the split point.
>> + */
>> + if (uasm_insn_has_bdelay(relocs, split - 1))
>> + split--;
>> + }
>
> The code itself makes sense. Does this case actually happen much, or was
> this just an itch?
>
For my CPU it was happening 100% of the time when I add the soon to be
submitted hugeTLBfs support patch. Although I have not measured it,
this code is so hot that keeping the normal case fitting on a single
cache line should be a big win.
David Daney
next prev parent reply other threads:[~2009-05-13 1:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-12 22:45 [PATCH] MIPS: Don't branch to eret in TLB refill David Daney
2009-05-13 0:23 ` David VomLehn
2009-05-13 1:12 ` David Daney [this message]
2009-05-13 2:01 ` Paul Gortmaker
2009-05-16 7:28 ` Maciej W. Rozycki
2009-05-18 16:25 ` David Daney
2009-05-18 17:48 ` Maciej W. Rozycki
2009-05-18 19:32 ` [PATCH] MIPS: Fold the TLB refill at the vmalloc path if possible Maciej W. Rozycki
2009-05-18 23:26 ` David Daney
2009-05-18 23:33 ` Maciej W. Rozycki
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=4A0A1E6B.6050908@caviumnetworks.com \
--to=ddaney@caviumnetworks.com \
--cc=dvomlehn@cisco.com \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.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