Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@linux-mips.org>
To: COLin <colin@realtek.com>
Cc: "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>
Subject: Re: 24k data cache, PIPT or VIPT?
Date: Mon, 24 Jan 2011 13:47:15 +0100	[thread overview]
Message-ID: <20110124124715.GB12232@linux-mips.org> (raw)
In-Reply-To: <AB43F607AA1BE0439402E9061AC9519D011EF513EB8D@rtitmbs7.realtek.com.tw>

On Fri, Jan 21, 2011 at 04:52:54PM +0800, COLin wrote:

> Hi all,
> I found that there is this information while Linux is booting:
>     [Primary data cache 32kB, 4-way, PIPT, no aliases, linesize 32 bytes]
> I thought the latest MIPS CPUs all use VIPT. I didn't find anything about PIPT on 24k Software User's Manual, either.
> The code related to this is here:
>         case CPU_24K:
>         case CPU_34K:
>         case CPU_74K:
>         case CPU_1004K:
>                 if ((read_c0_config7() & (1 << 16))) {
>                         /* effectively physically indexed dcache,
>                            thus no virtual aliases. */ 
>                         c->dcache.flags |= MIPS_CACHE_PINDEX;
>                         break;
> 
> The 16's bit of config 7 register:
>     [Alias removed: This bit indicates that the data cache is organized to
> avoid virtual aliasing problems. This bit is only set if the data cache
> config and MMU type would normally cause aliasing - i.e., only for
> the 32KB and larger data cache and TLB-based MMU.]
> 
> Does it imply that the CPU is using PIPT?

It means the cache will behave as if it is PIPT, that is it doesn't have
cache aliases.  It doesn't say anything about the actual implementation - it
could be anything, VIPT, PIPT or even crazy stuff.

VIPT makes sense because the lookup can start early before the address
translation has been completed.  The alias removal usually works by
detecting if an operation would result in cache aliases, that is multiple
ways containing conflicting data.  If that happens all conflicting ways
will be written back to secondary cache, invalidated and the operation
will be rerun.

Another strategy was implemented in the R4000 / R4000 SC and MC versions
where the S-cache for every primary cache line contains some virtual
address bits that are needed to detect an alias.  If that ever happens
the CPU will thrown an alias and the exception handler can cleanup the
mess.  Other architectures would do that in microcode hidden from OS
software.

From a software perspective the most preferable solution is increasing
the number of cache ways.  If cache_size / nr_of_ways <= page_size a
cache will no longer suffer from aliases.  Unfortunately hardware folks
traditionally dislike this approach.

  Ralf

WARNING: multiple messages have this Message-ID (diff)
From: Ralf Baechle <ralf@linux-mips.org>
To: COLin <colin@realtek.com>
Cc: "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>
Subject: Re: 24k data cache, PIPT or VIPT?
Date: Mon, 24 Jan 2011 13:47:15 +0100	[thread overview]
Message-ID: <20110124124715.GB12232@linux-mips.org> (raw)
Message-ID: <20110124124715.WB76pNGG9ozDTJG2WrZmtp0oaUDZhTKG_g9pScqI5Bo@z> (raw)
In-Reply-To: <AB43F607AA1BE0439402E9061AC9519D011EF513EB8D@rtitmbs7.realtek.com.tw>

On Fri, Jan 21, 2011 at 04:52:54PM +0800, COLin wrote:

> Hi all,
> I found that there is this information while Linux is booting:
>     [Primary data cache 32kB, 4-way, PIPT, no aliases, linesize 32 bytes]
> I thought the latest MIPS CPUs all use VIPT. I didn't find anything about PIPT on 24k Software User's Manual, either.
> The code related to this is here:
>         case CPU_24K:
>         case CPU_34K:
>         case CPU_74K:
>         case CPU_1004K:
>                 if ((read_c0_config7() & (1 << 16))) {
>                         /* effectively physically indexed dcache,
>                            thus no virtual aliases. */ 
>                         c->dcache.flags |= MIPS_CACHE_PINDEX;
>                         break;
> 
> The 16's bit of config 7 register:
>     [Alias removed: This bit indicates that the data cache is organized to
> avoid virtual aliasing problems. This bit is only set if the data cache
> config and MMU type would normally cause aliasing - i.e., only for
> the 32KB and larger data cache and TLB-based MMU.]
> 
> Does it imply that the CPU is using PIPT?

It means the cache will behave as if it is PIPT, that is it doesn't have
cache aliases.  It doesn't say anything about the actual implementation - it
could be anything, VIPT, PIPT or even crazy stuff.

VIPT makes sense because the lookup can start early before the address
translation has been completed.  The alias removal usually works by
detecting if an operation would result in cache aliases, that is multiple
ways containing conflicting data.  If that happens all conflicting ways
will be written back to secondary cache, invalidated and the operation
will be rerun.

Another strategy was implemented in the R4000 / R4000 SC and MC versions
where the S-cache for every primary cache line contains some virtual
address bits that are needed to detect an alias.  If that ever happens
the CPU will thrown an alias and the exception handler can cleanup the
mess.  Other architectures would do that in microcode hidden from OS
software.

  parent reply	other threads:[~2011-01-24 12:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-21  8:52 24k data cache, PIPT or VIPT? COLin
2011-01-21 21:54 ` David VomLehn (dvomlehn)
2011-01-21 21:54   ` David VomLehn (dvomlehn)
2011-01-23  4:34 ` Edgar E. Iglesias
2011-01-23 18:11   ` Ralf Baechle
2011-01-24 12:47 ` Ralf Baechle [this message]
2011-01-24 12:47   ` Ralf Baechle

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=20110124124715.GB12232@linux-mips.org \
    --to=ralf@linux-mips.org \
    --cc=colin@realtek.com \
    --cc=linux-mips@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