mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
selftests: kvm: move get_run_delay() into lib/test_util
get_run_delay() is defined static in xen_shinfo_test and steal_time test. Move it to lib and remove code duplication. Signed-off-by: Shuah Khan <skhan@linuxfoundation.org> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
@@ -102,6 +102,7 @@ const struct vm_mem_backing_src_alias *vm_mem_backing_src_alias(uint32_t i);
|
|||||||
size_t get_backing_src_pagesz(uint32_t i);
|
size_t get_backing_src_pagesz(uint32_t i);
|
||||||
void backing_src_help(void);
|
void backing_src_help(void);
|
||||||
enum vm_mem_backing_src_type parse_backing_src_type(const char *type_name);
|
enum vm_mem_backing_src_type parse_backing_src_type(const char *type_name);
|
||||||
|
long get_run_delay(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Whether or not the given source type is shared memory (as opposed to
|
* Whether or not the given source type is shared memory (as opposed to
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/syscall.h>
|
||||||
#include <linux/mman.h>
|
#include <linux/mman.h>
|
||||||
#include "linux/kernel.h"
|
#include "linux/kernel.h"
|
||||||
|
|
||||||
@@ -303,3 +304,17 @@ enum vm_mem_backing_src_type parse_backing_src_type(const char *type_name)
|
|||||||
TEST_FAIL("Unknown backing src type: %s", type_name);
|
TEST_FAIL("Unknown backing src type: %s", type_name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long get_run_delay(void)
|
||||||
|
{
|
||||||
|
char path[64];
|
||||||
|
long val[2];
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
sprintf(path, "/proc/%ld/schedstat", syscall(SYS_gettid));
|
||||||
|
fp = fopen(path, "r");
|
||||||
|
fscanf(fp, "%ld %ld ", &val[0], &val[1]);
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
return val[1];
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <sys/syscall.h>
|
|
||||||
#include <asm/kvm.h>
|
#include <asm/kvm.h>
|
||||||
#include <asm/kvm_para.h>
|
#include <asm/kvm_para.h>
|
||||||
|
|
||||||
@@ -217,20 +216,6 @@ static void steal_time_dump(struct kvm_vm *vm, uint32_t vcpuid)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static long get_run_delay(void)
|
|
||||||
{
|
|
||||||
char path[64];
|
|
||||||
long val[2];
|
|
||||||
FILE *fp;
|
|
||||||
|
|
||||||
sprintf(path, "/proc/%ld/schedstat", syscall(SYS_gettid));
|
|
||||||
fp = fopen(path, "r");
|
|
||||||
fscanf(fp, "%ld %ld ", &val[0], &val[1]);
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
return val[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *do_steal_time(void *arg)
|
static void *do_steal_time(void *arg)
|
||||||
{
|
{
|
||||||
struct timespec ts, stop;
|
struct timespec ts, stop;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <sys/syscall.h>
|
|
||||||
|
|
||||||
#define VCPU_ID 5
|
#define VCPU_ID 5
|
||||||
|
|
||||||
@@ -98,20 +97,6 @@ static void guest_code(void)
|
|||||||
GUEST_DONE();
|
GUEST_DONE();
|
||||||
}
|
}
|
||||||
|
|
||||||
static long get_run_delay(void)
|
|
||||||
{
|
|
||||||
char path[64];
|
|
||||||
long val[2];
|
|
||||||
FILE *fp;
|
|
||||||
|
|
||||||
sprintf(path, "/proc/%ld/schedstat", syscall(SYS_gettid));
|
|
||||||
fp = fopen(path, "r");
|
|
||||||
fscanf(fp, "%ld %ld ", &val[0], &val[1]);
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
return val[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
static int cmp_timespec(struct timespec *a, struct timespec *b)
|
static int cmp_timespec(struct timespec *a, struct timespec *b)
|
||||||
{
|
{
|
||||||
if (a->tv_sec > b->tv_sec)
|
if (a->tv_sec > b->tv_sec)
|
||||||
|
|||||||
Reference in New Issue
Block a user