From: Ralf Baechle <ralf@linux-mips.org>
To: "Maciej W. Rozycki" <macro@linux-mips.org>
Cc: James Hogan <james.hogan@imgtec.com>, linux-mips@linux-mips.org
Subject: Re: [PATCH v2 02/10] MIPS: hazards: Add hazard macros for tlb read
Date: Tue, 26 May 2015 15:32:12 +0200 [thread overview]
Message-ID: <20150526133211.GE13022@linux-mips.org> (raw)
In-Reply-To: <alpine.LFD.2.11.1505261401040.11225@eddie.linux-mips.org>
On Tue, May 26, 2015 at 02:25:52PM +0100, Maciej W. Rozycki wrote:
> > > > - tlb_read_hazard
> > > > Between tlbr and mfc0 (various TLB registers). This is copied from
> > > > tlbw_use_hazard in all cases on the assumption that tlbr has similar
> > > > data writer characteristics to tlbw, and mfc0 has similar data user
> > > > characteristics to loads and stores.
> > >
> > > Be careful with this assumption, it does not stand for R4600/R4700 and
> > > R5000 processors (4 vs 3 intervening instructions), you need an extra NOP
> > > for them. Likewise there is a difference with the 5K (1 vs 0 intervening
> > > instructions), but it's already buried in our pessimistic barrier that
> > > assumes 4 intervening instructions.
> >
> > The TLB write hazard is 4 cycles on the 8 stage R4000 pipeline but 2 cycles
> > on the R4600 pipeline.
>
> I misinterpreted the numbers in the table for the R4600/R4700/R5000,
> sorry. It gives pipeline stage numbers rather than instruction counts,
> unlike the 5K and some other tables.
>
> The difference is still there however: for TLBW_/use it's (3 - 2 - 1) =>
> 0 and for TLBR/MFC0 it's (4 - 2 - 1) => 1 (there's a one-cycle slip for
> TLBW_ instructions causing it). We use 3 NOPs for this variant, so it'll
> be covered.
>
> > We handle this in a particularly non-obvious but
> > optimized way by exploiting the fact that the R4000 pipeline kills two
> > instructions following the branch delay slot like:
> >
> > .set noreorder
> > MTC0 $reg, c0_sometlbregister
> > B 1f
> > 1: NOP
> > TLBW
> >
> > where the branch-nop sequence will cost 4 cycles on the R4000's eight-stage
> > pipeline but only two on the R4600 pipeline.
>
> And this code is where? ISTR seeing it before, but now all I can see in
> <asm/hazards.h> for the R4k and friends is:
>
> #define __tlbw_use_hazard \
> nop; \
> nop; \
> nop
>
> It does not cover the 4-instruction hazard of the original R4000 even, so
> it looks like it has to be fixed, perhaps by using code like you quoted.
Sorry for reciting kernel code from memory :-) I haven't checked a current
kernel before posting. If it's been removed then this there might be a
bug or at least something that can be optimized for the R4000/R4000.
Ralf
next prev parent reply other threads:[~2015-05-26 13:32 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-19 8:50 [PATCH v2 00/10] MIPS: dump_tlb improvements James Hogan
2015-05-19 8:50 ` James Hogan
2015-05-19 8:50 ` [PATCH RFC v2 01/10] MIPS: Add SysRq operation to dump TLBs on all CPUs James Hogan
2015-05-19 8:50 ` James Hogan
2015-05-24 21:21 ` Joshua Kinard
2015-05-26 11:58 ` Maciej W. Rozycki
2015-05-27 13:09 ` Maciej W. Rozycki
2015-07-14 9:27 ` James Hogan
2015-07-14 9:27 ` James Hogan
2015-05-19 8:50 ` [PATCH v2 02/10] MIPS: hazards: Add hazard macros for tlb read James Hogan
2015-05-19 8:50 ` James Hogan
2015-05-26 12:36 ` Maciej W. Rozycki
2015-05-26 12:53 ` Ralf Baechle
2015-05-26 13:25 ` Maciej W. Rozycki
2015-05-26 13:32 ` Ralf Baechle [this message]
2015-05-19 8:50 ` [PATCH v2 03/10] MIPS: mipsregs.h: Add EntryLo bit definitions James Hogan
2015-05-19 8:50 ` James Hogan
2015-05-28 23:47 ` Maciej W. Rozycki
2015-05-19 8:50 ` [PATCH v2 04/10] MIPS: dump_tlb: Use tlbr hazard macros James Hogan
2015-05-19 8:50 ` James Hogan
2015-05-19 8:50 ` [PATCH v2 05/10] MIPS: dump_tlb: Refactor TLB matching James Hogan
2015-05-19 8:50 ` James Hogan
2015-05-19 8:50 ` [PATCH v2 06/10] MIPS: dump_tlb: Make use of EntryLo bit definitions James Hogan
2015-05-19 8:50 ` James Hogan
2015-05-19 8:50 ` [PATCH v2 07/10] MIPS: dump_tlb: Take global bit into account James Hogan
2015-05-19 8:50 ` James Hogan
2015-05-19 8:50 ` [PATCH v2 08/10] MIPS: dump_tlb: Take EHINV " James Hogan
2015-05-19 8:50 ` James Hogan
2015-05-19 8:50 ` [PATCH v2 09/10] MIPS: dump_tlb: Take RI/XI bits " James Hogan
2015-05-19 8:50 ` James Hogan
2015-05-19 8:50 ` [PATCH v2 10/10] MIPS: dump_tlb: Take XPA " James Hogan
2015-05-19 8:50 ` James Hogan
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=20150526133211.GE13022@linux-mips.org \
--to=ralf@linux-mips.org \
--cc=james.hogan@imgtec.com \
--cc=linux-mips@linux-mips.org \
--cc=macro@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 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.