This is the mail archive of the
sid@sourceware.org
mailing list for the SID project.
sid-20110801 Patch to fix multiple cache line aging
- From: John Wehle <john at feith dot com>
- To: sid at sources dot redhat dot com
- Date: Sun, 16 Oct 2011 01:04:23 -0400 (EDT)
- Subject: sid-20110801 Patch to fix multiple cache line aging
Currently the SID cache component references the same lru_replacement
object each time it creates a lru cache. This causes configurations
with multiple caches (e.g. an Icache and Dcache) to use the same lru
array to track the line ages which creates problems since the array
no longer reflects the age of the lines in either cache. Each cache
needs their own (private) lru array.
Based on code inspection it appears fifo_replacement suffers the same
problem.
The enclosed patch has been tested on FreeBSD with sid configured for
tomi Borealis (a processor under development by Venray Technology).
ChangeLog:
Sun Oct 16 00:16:46 EDT 2011 John Wehle (john@feith.com)
* component/cache/cache.cxx (CacheCreate): Allocate a new
replacement object each time for the fifo and lru types.
-- John
------------------------8<------------------------------8<---------------
--- component/cache/cache.cxx.ORIGINAL 2009-04-08 16:39:34.000000000 -0400
+++ component/cache/cache.cxx 2011-10-13 00:22:20.000000000 -0400
@@ -44,8 +44,6 @@ static string replacement_algorithms[] =
// One per replacement policy
static cache_replacement_null null_replacement;
-static cache_replacement_lru lru_replacement;
-static cache_replacement_fifo fifo_replacement;
static cache_replacement_random random_replacement;
static cache_line_factory internal_line_factory;
static mep_assoc_replacement_algorithm mep_assoc_replacement;
@@ -1335,9 +1341,9 @@ CacheCreate (const string& typeName)
return new cache_component (assoc, cache_sz, line_sz, null_replacement, internal_line_factory);
if (replace_alg_string == "lru")
- return new cache_component (assoc, cache_sz, line_sz, lru_replacement, internal_line_factory);
+ return new cache_component (assoc, cache_sz, line_sz, *new cache_replacement_lru, internal_line_factory);
else if (replace_alg_string == "fifo")
- return new cache_component (assoc, cache_sz, line_sz, fifo_replacement, internal_line_factory);
+ return new cache_component (assoc, cache_sz, line_sz, *new cache_replacement_fifo, internal_line_factory);
else if (replace_alg_string == "random")
return new cache_component (assoc, cache_sz, line_sz, random_replacement, internal_line_factory);
}
@@ -1347,9 +1353,9 @@ CacheCreate (const string& typeName)
return new blocking_cache_component (assoc, cache_sz, line_sz, null_replacement, internal_line_factory);
if (replace_alg_string == "lru")
- return new blocking_cache_component (assoc, cache_sz, line_sz, lru_replacement, internal_line_factory);
+ return new blocking_cache_component (assoc, cache_sz, line_sz, *new cache_replacement_lru, internal_line_factory);
else if (replace_alg_string == "fifo")
- return new blocking_cache_component (assoc, cache_sz, line_sz, fifo_replacement, internal_line_factory);
+ return new blocking_cache_component (assoc, cache_sz, line_sz, *new cache_replacement_fifo, internal_line_factory);
else if (replace_alg_string == "random")
return new blocking_cache_component (assoc, cache_sz, line_sz, random_replacement, internal_line_factory);
}
-------------------------------------------------------------------------