[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 41/42] block: Give always priority to unused entries
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 41/42] block: Give always priority to unused entries in the qcow2 L2 cache |
Date: |
Fri, 6 Feb 2015 17:40:48 +0100 |
From: Alberto Garcia <address@hidden>
The current algorithm to replace entries from the L2 cache gives
priority to newer hits by dividing the hit count of all existing
entries by two everytime there is a cache miss.
However, if there are several cache misses the hit count of the
existing entries can easily go down to 0. This will result in those
entries being replaced even when there are others that have never been
used.
This problem is more noticeable with larger disk images and cache
sizes, since the chances of having several misses before the cache is
full are higher.
If we make sure that the hit count can never go down to 0 again,
unused entries will always have priority.
Signed-off-by: Alberto Garcia <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2-cache.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
index 904f6b1..b115549 100644
--- a/block/qcow2-cache.c
+++ b/block/qcow2-cache.c
@@ -253,7 +253,9 @@ static int qcow2_cache_find_entry_to_replace(Qcow2Cache *c)
/* Give newer hits priority */
/* TODO Check how to optimize the replacement strategy */
- c->entries[i].cache_hits /= 2;
+ if (c->entries[i].cache_hits > 1) {
+ c->entries[i].cache_hits /= 2;
+ }
}
if (min_index == -1) {
--
1.8.3.1
- [Qemu-devel] [PULL 32/42] qed: check for header size overflow, (continued)
- [Qemu-devel] [PULL 32/42] qed: check for header size overflow, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 34/42] block: fix off-by-one error in qcow and qcow2, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 37/42] iotests: Fix 104 for NBD, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 30/42] block/dmg: support bzip2 block entry types, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 33/42] qemu-iotests: add 116 invalid QED input file tests, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 38/42] nbd: Improve error messages, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 40/42] nbd: fix max_discard/max_transfer_length, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 35/42] iotests: Fix 083, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 36/42] iotests: Fix 100 for nbd, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 39/42] block: introduce BDRV_REQUEST_MAX_SECTORS, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 41/42] block: Give always priority to unused entries in the qcow2 L2 cache,
Kevin Wolf <=
- [Qemu-devel] [PULL 42/42] qcow2: Rewrite qcow2_alloc_bytes(), Kevin Wolf, 2015/02/06