From: Orit Wasserman <owasserm@redhat.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, aliguori@us.ibm.com,
quintela@redhat.com, Petter Svard <petters@cs.umu.se>,
stefanha@gmail.com, mdroth@linux.vnet.ibm.com,
Benoit Hudzia <benoit.hudzia@sap.com>,
blauwirbel@gmail.com, Orit Wasserman <owasserm@redhat.com>,
chegu_vinod@hp.com, avi@redhat.com,
Aidan Shribman <aidan.shribman@sap.com>,
pbonzini@redhat.com, eblake@redhat.com
Subject: [Qemu-devel] [PATCH v17 3/9] Add cache handling functions
Date: Tue, 10 Jul 2012 12:37:11 +0300 [thread overview]
Message-ID: <1341913037-8579-4-git-send-email-owasserm@redhat.com> (raw)
In-Reply-To: <1341913037-8579-1-git-send-email-owasserm@redhat.com>
Add LRU page cache mechanism.
The page are accessed by their address.
Signed-off-by: Benoit Hudzia <benoit.hudzia@sap.com>
Signed-off-by: Petter Svard <petters@cs.umu.se>
Signed-off-by: Aidan Shribman <aidan.shribman@sap.com>
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
---
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
next prev parent reply other threads:[~2012-07-10 9:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-10 9:37 [Qemu-devel] [PATCH v17 0/9] XBZRLE delta for live migration of large memory app Orit Wasserman
2012-07-10 9:37 ` [Qemu-devel] [PATCH v17 1/9] Add migration capabilities Orit Wasserman
2012-07-10 9:37 ` [Qemu-devel] [PATCH v17 2/9] Add XBZRLE documentation Orit Wasserman
2012-07-10 9:37 ` Orit Wasserman [this message]
2012-07-10 19:16 ` [Qemu-devel] [PATCH v17 3/9] Add cache handling functions Orit Wasserman
2012-07-10 9:37 ` [Qemu-devel] [PATCH v17 4/9] Add uleb encoding/decoding functions Orit Wasserman
2012-07-10 9:37 ` [Qemu-devel] [PATCH v17 5/9] Change ram_save_block to return -1 if there are no more changes Orit Wasserman
2012-07-10 9:37 ` [Qemu-devel] [PATCH v17 6/9] Add xbzrle_encode_buffer and xbzrle_decode_buffer functions Orit Wasserman
2012-07-10 9:37 ` [Qemu-devel] [PATCH v17 7/9] Add XBZRLE to ram_save_block and ram_save_live Orit Wasserman
2012-07-10 9:37 ` [Qemu-devel] [PATCH v17 8/9] Add migrate_set_cachesize command Orit Wasserman
2012-07-10 9:37 ` [Qemu-devel] [PATCH v17 9/9] Add XBZRLE statistics Orit Wasserman
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=1341913037-8579-4-git-send-email-owasserm@redhat.com \
--to=owasserm@redhat.com \
--cc=aidan.shribman@sap.com \
--cc=aliguori@us.ibm.com \
--cc=avi@redhat.com \
--cc=benoit.hudzia@sap.com \
--cc=blauwirbel@gmail.com \
--cc=chegu_vinod@hp.com \
--cc=eblake@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=petters@cs.umu.se \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=stefanha@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).