• Lorenzo Pieralisi's avatar
    ARM: 7919/1: mm: refactor v7 cache cleaning ops to use way/index sequence · 70f665fe
    Lorenzo Pieralisi authored
    Set-associative caches on all v7 implementations map the index bits
    to physical addresses LSBs and tag bits to MSBs. As the last level
    of cache on current and upcoming ARM systems grows in size,
    this means that under normal DRAM controller configurations, the
    current v7 cache flush routine using set/way operations triggers a
    DRAM memory controller precharge/activate for every cache line
    writeback since the cache routine cleans lines by first fixing the
    index and then looping through ways (index bits are mapped to lower
    physical addresses on all v7 cache implementations; this means that,
    with last level cache sizes in the order of MBytes, lines belonging
    to the same set but different ways map to different DRAM pages).
    
    Given the random content of cache tags, swapping the order between
    indexes and ways loops do not prevent DRAM pages precharge and
    activate cycles but at least, on average, improves the chances that
    either multiple lines hit the same page or multiple lines belong to
    different DRAM banks, improving throughput significantly.
    
    This patch swaps the inner loops in the v7 cache flushing routine
    to carry out the clean operations first on all sets belonging to
    a given way (looping through sets) and then decrementing the way.
    
    Benchmarks showed that by swapping the ordering in which sets and
    ways are decremented in the v7 cache flushing routine, that uses
    set/way operations, time required to flush caches is reduced
    significantly, owing to improved writebacks throughput to the DRAM
    controller.
    
    Benchmarks results vary and depend heavily on the last level of
    cache tag RAM content when cache is cleaned and invalidated, ranging
    from 2x throughput when all tag RAM entries contain dirty lines
    mapping to sequential pages of RAM to 1x (ie no improvement) when
    all tag RAM accesses trigger a DRAM precharge/activate cycle, as the
    current code implies on most DRAM controller configurations.
    Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
    Acked-by: default avatarNicolas Pitre <nico@linaro.org>
    Acked-by: default avatarSantosh Shilimkar <santosh.shilimkar@ti.com>
    Reviewed-by: default avatarDave Martin <Dave.Martin@arm.com>
    Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
    Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
    70f665fe
cache-v7.S 12.1 KB