* [RFC][PATCH 5/5] example of userspace application register it memory in ksm
@ 2008-01-21 16:16 Izik Eidus
0 siblings, 0 replies; only message in thread
From: Izik Eidus @ 2008-01-21 16:16 UTC (permalink / raw)
To: kvm-devel, andrea-atKUWr5tajBWk0Htik3J/w,
avi-atKUWr5tajBWk0Htik3J/w, dor.laor-atKUWr5tajBWk0Htik3J/w,
yaniv-atKUWr5tajBWk0Htik3J/w, linux-mm-Bw31MaZKKs3YtjvyW6yDsg
[-- Attachment #1: Type: text/plain, Size: 73 bytes --]
(this is the modification for qemu to make it work with ksm)
--
woof.
[-- Attachment #2: 0005-qemu-register-the-memory-of-qemu-with-ksm.patch --]
[-- Type: text/x-patch, Size: 1778 bytes --]
>From 813266c7d59acb64c104448c255cc2c9d4f0187e Mon Sep 17 00:00:00 2001
From: Izik Eidus <izike-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Date: Mon, 21 Jan 2008 17:41:09 +0200
Subject: [PATCH] qemu: register the memory of qemu with ksm,
so it can be shared
Signed-off-by: Izik Eidus <izike-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
---
qemu/vl.c | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/qemu/vl.c b/qemu/vl.c
index 756e13d..691db36 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -21,6 +21,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
+#include "ksm.h"
#include "hw/hw.h"
#include "hw/boards.h"
#include "hw/usb.h"
@@ -8501,6 +8503,37 @@ void qemu_get_launch_info(int *argc, char ***argv, int *opt_daemonize, const cha
*opt_incoming = incoming;
}
+int ksm_register_memory(void)
+{
+ int fd;
+ int ksm_fd;
+ int r = 1;
+ struct ksm_memory_region ksm_region;
+
+ fd = open("/dev/ksm", O_RDWR | O_TRUNC, (mode_t)0600);
+ if (fd == -1)
+ goto out;
+
+ ksm_fd = ioctl(fd, KSM_CREATE_SHARED_MEMORY_AREA);
+ if (ksm_fd == -1)
+ goto out_free;
+
+ ksm_region.npages = phys_ram_size / TARGET_PAGE_SIZE;
+ ksm_region.addr = phys_ram_base;
+ r = ioctl(ksm_fd, KSM_REGISTER_MEMORY_REGION, &ksm_region);
+ if (r)
+ goto out_free1;
+
+ return r;
+
+out_free1:
+ close(ksm_fd);
+out_free:
+ close(fd);
+out:
+ return r;
+}
+
int main(int argc, char **argv)
{
#ifdef CONFIG_GDBSTUB
@@ -9353,6 +9386,8 @@ int main(int argc, char **argv)
}
#endif
+ ksm_register_memory();
+
bdrv_init();
/* we always create the cdrom drive, even if no disk is there */
--
1.5.3.6
[-- Attachment #3: Type: text/plain, Size: 228 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
[-- Attachment #4: Type: text/plain, Size: 186 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2008-01-21 16:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-21 16:16 [RFC][PATCH 5/5] example of userspace application register it memory in ksm Izik Eidus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox