Commit 90316e6e authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'linux-kselftest-fixes-5.15-rc3' of...

Merge tag 'linux-kselftest-fixes-5.15-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull Kselftest fixes from Shuah Khan:

 - fix to Kselftest common framework header install to run before other
   targets for it work correctly in parallel build case.

 - fixes to kvm test to not ignore fscanf() returns which could result
   in inconsistent test behavior and failures.

* tag 'linux-kselftest-fixes-5.15-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
  selftests: kvm: fix get_run_delay() ignoring fscanf() return warn
  selftests: kvm: move get_run_delay() into lib/test_util
  selftests:kvm: fix get_trans_hugepagesz() ignoring fscanf() return warn
  selftests:kvm: fix get_warnings_count() ignoring fscanf() return warn
  selftests: be sure to make khdr before other targets
parents a5e0acea f5013d41
...@@ -95,6 +95,8 @@ struct vm_mem_backing_src_alias { ...@@ -95,6 +95,8 @@ struct vm_mem_backing_src_alias {
uint32_t flag; uint32_t flag;
}; };
#define MIN_RUN_DELAY_NS 200000UL
bool thp_configured(void); bool thp_configured(void);
size_t get_trans_hugepagesz(void); size_t get_trans_hugepagesz(void);
size_t get_def_hugetlb_pagesz(void); size_t get_def_hugetlb_pagesz(void);
...@@ -102,6 +104,7 @@ const struct vm_mem_backing_src_alias *vm_mem_backing_src_alias(uint32_t i); ...@@ -102,6 +104,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 @@ ...@@ -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"
...@@ -129,13 +130,16 @@ size_t get_trans_hugepagesz(void) ...@@ -129,13 +130,16 @@ size_t get_trans_hugepagesz(void)
{ {
size_t size; size_t size;
FILE *f; FILE *f;
int ret;
TEST_ASSERT(thp_configured(), "THP is not configured in host kernel"); TEST_ASSERT(thp_configured(), "THP is not configured in host kernel");
f = fopen("/sys/kernel/mm/transparent_hugepage/hpage_pmd_size", "r"); f = fopen("/sys/kernel/mm/transparent_hugepage/hpage_pmd_size", "r");
TEST_ASSERT(f != NULL, "Error in opening transparent_hugepage/hpage_pmd_size"); TEST_ASSERT(f != NULL, "Error in opening transparent_hugepage/hpage_pmd_size");
fscanf(f, "%ld", &size); ret = fscanf(f, "%ld", &size);
ret = fscanf(f, "%ld", &size);
TEST_ASSERT(ret < 1, "Error reading transparent_hugepage/hpage_pmd_size");
fclose(f); fclose(f);
return size; return size;
...@@ -300,3 +304,19 @@ enum vm_mem_backing_src_type parse_backing_src_type(const char *type_name) ...@@ -300,3 +304,19 @@ 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");
/* Return MIN_RUN_DELAY_NS upon failure just to be safe */
if (fscanf(fp, "%ld %ld ", &val[0], &val[1]) < 2)
val[1] = MIN_RUN_DELAY_NS;
fclose(fp);
return val[1];
}
...@@ -10,7 +10,6 @@ ...@@ -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>
...@@ -20,7 +19,6 @@ ...@@ -20,7 +19,6 @@
#define NR_VCPUS 4 #define NR_VCPUS 4
#define ST_GPA_BASE (1 << 30) #define ST_GPA_BASE (1 << 30)
#define MIN_RUN_DELAY_NS 200000UL
static void *st_gva[NR_VCPUS]; static void *st_gva[NR_VCPUS];
static uint64_t guest_stolen_time[NR_VCPUS]; static uint64_t guest_stolen_time[NR_VCPUS];
...@@ -217,20 +215,6 @@ static void steal_time_dump(struct kvm_vm *vm, uint32_t vcpuid) ...@@ -217,20 +215,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;
......
...@@ -82,7 +82,8 @@ int get_warnings_count(void) ...@@ -82,7 +82,8 @@ int get_warnings_count(void)
FILE *f; FILE *f;
f = popen("dmesg | grep \"WARNING:\" | wc -l", "r"); f = popen("dmesg | grep \"WARNING:\" | wc -l", "r");
fscanf(f, "%d", &warnings); if (fscanf(f, "%d", &warnings) < 1)
warnings = 0;
fclose(f); fclose(f);
return warnings; return warnings;
......
...@@ -14,7 +14,6 @@ ...@@ -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) ...@@ -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)
......
...@@ -48,6 +48,7 @@ ARCH ?= $(SUBARCH) ...@@ -48,6 +48,7 @@ ARCH ?= $(SUBARCH)
# When local build is done, headers are installed in the default # When local build is done, headers are installed in the default
# INSTALL_HDR_PATH usr/include. # INSTALL_HDR_PATH usr/include.
.PHONY: khdr .PHONY: khdr
.NOTPARALLEL:
khdr: khdr:
ifndef KSFT_KHDR_INSTALL_DONE ifndef KSFT_KHDR_INSTALL_DONE
ifeq (1,$(DEFAULT_INSTALL_HDR_PATH)) ifeq (1,$(DEFAULT_INSTALL_HDR_PATH))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment