All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthias Rosenfelder <rosenfelder.lkml@googlemail.com>
To: sparclinux@vger.kernel.org
Subject: Re: [RFC/PATCH] sparc32/LEON: Cache flush during context switch
Date: Tue, 10 May 2011 22:31:03 +0000	[thread overview]
Message-ID: <4DC9BCA7.5090709@googlemail.com> (raw)
In-Reply-To: <4DC89ECB.6030309@googlemail.com>

On 10.05.2011 13:26, Kristoffer Glembo wrote:
>
> The cache can generate a hit after a context switch if there exists cache lines
> belonging to the newly switched in process.

Is this really possible? You mean that the cache line has "survived" 
during the execution of the last timeslice of another (i.e. different) 
task AND that the last and the new task have shared a memory region AND 
this shared memory region is susceptible to virtual aliasing in the data 
cache AND the last task has actually written to one of these virtual 
addresses AND the new task actually reads from exactly this virtual 
alias address that the last task wrote to?

This seems very unlikely to me but I must admit that you have a point 
here. It is possible in theory, though very unlikely.

But then what is the context number stored for every cache line for?
Only for the case when you have a tiny cache with the lowest possible 
associativity that you can save a few cycle on a context switch? People 
want _big_ caches with _high_ associativity in order to improve the hit 
rate. Having a bigger cache even if you have to flush it on a context 
switch is much better for performance than having a tiny one without a 
flush. Why do you waste so much hardware on a feature that has so little 
benefit?



> You could avoid this if you always make shared memory regions non-cacheable. I don't know
> enough to say whether this is currently possible.

I don't think this is a good idea. It is propably better to still use 
caches and flush the caches on a context switch than making these 
regions uncacheable at all. This will propably slow down access to these 
regions too much.


>
> I think Daniel meant a solution to the cache coherency problem. It is possible to
> fully avoid aliases in hardware.

Ah yes, of course.

>
> What terminology do you have a problem with in the Linux kernel? That it is written
> "set size" instead of "way size" in some comments? I don't think "set size" is an uncommon
> alias for "way size" ...

But I do. A cache set consists of all cache lines in a cache that can 
store data belonging to addresses that have the same index (i.e. the 
"middle" part of the cache address is the same for all cache lines in a 
cache set). The way size is the sum of all cache lines that belong to a 
certain way, i.e. the n-th possiblity within a cache set to store and 
retrieve a cache line. Way zero is the first possibility in each set; 
Way one is the second and so on...
Cache lines belonging to the same way don't necessarily have any address 
bits in common. Whereas the cache lines belonging to a cache set do...

By the way: If it is correct what you say then why was this changed for 
the Leon4 manual? Leon2 and 3 manuals use the wrong terminology while 
the Leon4 manual uses the correct one. Obviously, there must be at least 
one person at Gaisler who believes that the previous terminology was not 
correct. Leon2 and 3 manual mention "multi-set caches" while 
Leon4-manual mentions "multi-way caches". Look at the GRLIB ipcore 
user's manual.

One thing in addition: Please don't get me wrong. I don't want to blame 
anybody too much. I just would like to see consistent terminology in the 
code so it is easier for everybody to understand. That's all I am aiming 
for.


Thanks,

      Matthias

  parent reply	other threads:[~2011-05-10 22:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-10  2:11 [RFC/PATCH] sparc32/LEON: Cache flush during context switch Matthias Rosenfelder
2011-05-10  7:19 ` Daniel Hellstrom
2011-05-10 10:36 ` Matthias Rosenfelder
2011-05-10 11:26 ` Kristoffer Glembo
2011-05-10 22:31 ` Matthias Rosenfelder [this message]
2011-05-11  9:46 ` Kristoffer Glembo
2011-05-11 12:33 ` Daniel Hellstrom

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=4DC9BCA7.5090709@googlemail.com \
    --to=rosenfelder.lkml@googlemail.com \
    --cc=sparclinux@vger.kernel.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.