Required tools for playing around with memory:
hexdumpobjdumpreadelfxxdgcore
| // Sample custom iterator. | |
| // By perfectly.insane (http://www.dreamincode.net/forums/index.php?showuser=76558) | |
| // From: http://www.dreamincode.net/forums/index.php?showtopic=58468 | |
| #include <iostream> | |
| #include <vector> | |
| #include <algorithm> | |
| #include <iterator> | |
| #include <cassert> |
| #include <sys/mman.h> | |
| #include <fcntl.h> | |
| #include <unistd.h> | |
| #include <cuda_runtime.h> | |
| #include <cerrno> | |
| #include <cstring> | |
| #include <memory> | |
| #include <stdexcept> |
| # Assuming an Ubuntu Docker image | |
| $ docker run -it <image> /bin/bash |
| /* please refer better example: https://github.com/dvdhrm/docs/tree/master/drm-howto/ */ | |
| #define _XOPEN_SOURCE 600 | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <sys/mman.h> | |
| #include <fcntl.h> | |
| #include <unistd.h> | |
| #include <xf86drm.h> |
| #include <stdio.h> | |
| #include <cuda_runtime.h> | |
| #include "helper_cuda.h" | |
| /* A very simple kernel function */ | |
| __global__ void kernel(int *d_var) { d_var[threadIdx.x] += 10; } | |
| int * host_p; | |
| int * host_result; | |
| int * dev_p; |
| adb -s [device] shell input keyevent 4 |
| #include<linux/module.h> | |
| #include<linux/kernel.h> | |
| #include<linux/string.h> | |
| #include<linux/vmalloc.h> | |
| #include<linux/mm.h> | |
| #include<linux/init.h> | |
| #include<linux/proc_fs.h> | |
| #include<linux/sched.h> | |
| #include<linux/uaccess.h> | |
| #include<linux/fs.h> |
| #include <linux/module.h> | |
| #include <linux/kernel.h> | |
| #include <linux/device.h> | |
| #include <linux/init.h> | |
| #include <linux/fs.h> | |
| #include <linux/mm.h> | |
| #include <asm/uaccess.h> | |
| #define MAX_SIZE (PAGE_SIZE * 2) /* max size mmaped to userspace */ | |
| #define DEVICE_NAME "mchar" |
But default in linux you can figure out how many times and for what reasons there is a VM Exit from a VM into the kvm kernel module. However given the ubiquity of vhost and the ability of kvm to emulate most device models directly in the kernel, most of those VM exits do not result in a transition from host kernel into the QEMU. The transitions from VM -> kvm -> QEMU are typically the most expensive.
Here we try to figure out how many of the VM Exits result in the invocation of QEMU.
This can be done very simply with perf