[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v17 3/9] Add cache handling functions
From: |
Orit Wasserman |
Subject: |
[Qemu-devel] [PATCH v17 3/9] Add cache handling functions |
Date: |
Tue, 10 Jul 2012 12:37:11 +0300 |
Add LRU page cache mechanism.
The page are accessed by their address.
Signed-off-by: Benoit Hudzia <address@hidden>
Signed-off-by: Petter Svard <address@hidden>
Signed-off-by: Aidan Shribman <address@hidden>
Signed-off-by: Orit Wasserman <address@hidden>
---
Makefile.objs | 1 +
cutils.c | 9 +++++++++
qemu-common.h | 13 +++++++++++++
3 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/Makefile.objs b/Makefile.objs
index 5ebbcfa..e0fb69b 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -77,6 +77,7 @@ common-obj-y += qemu-char.o #aio.o
common-obj-y += block-migration.o iohandler.o
common-obj-y += pflib.o
common-obj-y += bitmap.o bitops.o
+common-obj-y += page_cache.o
common-obj-$(CONFIG_POSIX) += migration-exec.o migration-unix.o migration-fd.o
common-obj-$(CONFIG_WIN32) += version.o
diff --git a/cutils.c b/cutils.c
index e2bc1b8..b0bdd4b 100644
--- a/cutils.c
+++ b/cutils.c
@@ -375,3 +375,12 @@ int qemu_parse_fd(const char *param)
}
return fd;
}
+
+/* round down to the nearest power of 2*/
+int64_t pow2floor(int64_t value)
+{
+ if (!is_power_of_2(value)) {
+ value = 0x8000000000000000ULL >> clz64(value);
+ }
+ return value;
+}
diff --git a/qemu-common.h b/qemu-common.h
index 09676f5..195bab5 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -1,3 +1,4 @@
+
/* Common header file that is included by all of qemu. */
#ifndef QEMU_COMMON_H
#define QEMU_COMMON_H
@@ -411,6 +412,18 @@ static inline uint64_t muldiv64(uint64_t a, uint32_t b,
uint32_t c)
/* Round number up to multiple */
#define QEMU_ALIGN_UP(n, m) QEMU_ALIGN_DOWN((n) + (m) - 1, (m))
+static inline bool is_power_of_2(int64_t value)
+{
+ if (!value) {
+ return 0;
+ }
+
+ return !(value & (value - 1));
+}
+
+/* round down to the nearest power of 2*/
+int64_t pow2floor(int64_t value);
+
#include "module.h"
#endif
--
1.7.7.6
- [Qemu-devel] [PATCH v17 0/9] XBZRLE delta for live migration of large memory app, Orit Wasserman, 2012/07/10
- [Qemu-devel] [PATCH v17 1/9] Add migration capabilities, Orit Wasserman, 2012/07/10
- [Qemu-devel] [PATCH v17 2/9] Add XBZRLE documentation, Orit Wasserman, 2012/07/10
- [Qemu-devel] [PATCH v17 4/9] Add uleb encoding/decoding functions, Orit Wasserman, 2012/07/10
- [Qemu-devel] [PATCH v17 5/9] Change ram_save_block to return -1 if there are no more changes, Orit Wasserman, 2012/07/10
- [Qemu-devel] [PATCH v17 3/9] Add cache handling functions,
Orit Wasserman <=
- [Qemu-devel] [PATCH v17 6/9] Add xbzrle_encode_buffer and xbzrle_decode_buffer functions, Orit Wasserman, 2012/07/10
- [Qemu-devel] [PATCH v17 7/9] Add XBZRLE to ram_save_block and ram_save_live, Orit Wasserman, 2012/07/10
- [Qemu-devel] [PATCH v17 8/9] Add migrate_set_cachesize command, Orit Wasserman, 2012/07/10
- [Qemu-devel] [PATCH v17 9/9] Add XBZRLE statistics, Orit Wasserman, 2012/07/10