rtm test
This commit is contained in:
parent
5daaace5f2
commit
3ab356a937
|
@ -0,0 +1,37 @@
|
|||
#!/bin/bash
|
||||
|
||||
source ../config.sh
|
||||
logdir=$logbasedir/rtm/
|
||||
loop=(0)
|
||||
threads=(32)
|
||||
modes=(non log rtmlog)
|
||||
size_types=(0 1)
|
||||
|
||||
mkdir -p $logdir
|
||||
|
||||
function run {
|
||||
cd $basedir
|
||||
./quick-build.sh
|
||||
for thread in ${threads[@]}
|
||||
do
|
||||
for size_type in ${size_types[@]}
|
||||
do
|
||||
# baseline
|
||||
mkdir -p $logdir/$thread/$1
|
||||
$appdir/rtm.exp $size_type 2>&1 | tee $logdir/$thread/$1/$size_type.out
|
||||
sleep 30
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
run rtmlog
|
||||
|
||||
sed -i 's/^\(#define USE_TSX\)/\/\/ \1/' $rtmconfig
|
||||
run log
|
||||
|
||||
sed -i 's/^\(#define USE_LOG\)/\/\/ \1/' $rtmconfig
|
||||
run non
|
||||
|
||||
sed -i '/^\/\/ #define USE_TSX$/s/^\/\/ //' $rtmconfig
|
||||
sed -i '/^\/\/ #define USE_LOG$/s/^\/\/ //' $rtmconfig
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/expect
|
||||
|
||||
set timeout 30
|
||||
set size_type [lindex $argv 0]
|
||||
|
||||
# start
|
||||
spawn ./build/simulate.sh
|
||||
expect "Welcome to ChCore shell!"
|
||||
# run anything you like here
|
||||
# interact
|
||||
send -- "rtm_test.bin $size_type &\r"
|
||||
|
||||
while {1} {
|
||||
expect {
|
||||
"rtm test finished" {
|
||||
puts "success\n"
|
||||
exit
|
||||
}
|
||||
timeout {
|
||||
puts "failed\n"
|
||||
exit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
expect ""
|
||||
|
||||
interact
|
||||
|
|
@ -4,8 +4,9 @@
|
|||
# test_mode="IPMI"
|
||||
test_mode="QEMU"
|
||||
|
||||
basedir="/home/xxx/treesls"
|
||||
basedir="/home/yjs/treesls"
|
||||
aedir="$basedir/artificial_evaluation"
|
||||
logbasedir="$aedir/logs/$test_mode"
|
||||
appdir="$aedir/applications"
|
||||
kconfig="$basedir/kernel/sls_config.cmake"
|
||||
rtmconfig="$basedir/kernel/include/arch/x86_64/plat/intel/immintrin.h"
|
||||
|
|
|
@ -33,5 +33,5 @@ chcore_generate_emulate_sh(
|
|||
"--enable-kvm -machine pc,nvdimm=on -m 16G,slots=2,maxmem=64G \
|
||||
-object memory-backend-file,id=mem1,share=on,mem-path=\$nvm_backend_file,size=16G \
|
||||
-device nvdimm,id=nvdimm1,memdev=mem1 \
|
||||
-cpu host -smp 20 -serial mon:stdio -nographic -cdrom \$basedir/chcore.iso"
|
||||
-cpu host -smp 64 -serial mon:stdio -nographic -cdrom \$basedir/chcore.iso"
|
||||
)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#define USE_TSX
|
||||
// #define USE_TSX
|
||||
// #define USE_LOG
|
||||
// #define PRE_TOUCH
|
||||
// #define PRINT_ABORT_COUNT
|
||||
|
||||
#ifndef __RTM__
|
||||
#pragma GCC push_options
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
/* Should be set at boot time */
|
||||
#define PLAT_CPU_NUM 10
|
||||
#define PLAT_CPU_NUM 32
|
||||
|
||||
/* MSR Registers */
|
||||
#define IA32_APIC_BASE 0x0000001b
|
||||
|
|
|
@ -198,10 +198,12 @@ struct page *buddy_get_pages(struct phys_mem_pool *pool, int order)
|
|||
if (!list_empty(free_list)) {
|
||||
/* Get a free memory chunck from the free list */
|
||||
page = list_entry(free_list->next, struct page, node);
|
||||
#ifdef USE_LOG
|
||||
prepare_latest_log(pool,
|
||||
ADD_PAGES,
|
||||
(u64)page,
|
||||
order, cur_order);
|
||||
#endif
|
||||
list_del(&page->node);
|
||||
pool->free_lists[cur_order].nr_free -= 1;
|
||||
break;
|
||||
|
@ -249,10 +251,12 @@ struct page *buddy_get_pages(struct phys_mem_pool *pool, int order)
|
|||
goto redo;
|
||||
}
|
||||
} else {
|
||||
#ifdef USE_LOG
|
||||
prepare_latest_log(pool,
|
||||
ADD_PAGES,
|
||||
(u64)page,
|
||||
order, cur_order);
|
||||
#endif
|
||||
list_del(&page->node);
|
||||
pool->free_lists[cur_order].nr_free -= 1;
|
||||
page = split_chunk(pool, order, page);
|
||||
|
@ -267,7 +271,9 @@ struct page *buddy_get_pages(struct phys_mem_pool *pool, int order)
|
|||
}
|
||||
|
||||
out:
|
||||
#ifdef USE_LOG
|
||||
commit_latest_log(pool);
|
||||
#endif
|
||||
unlock(&pool->buddy_lock);
|
||||
return page;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ struct slab_log_entry {
|
|||
int order;
|
||||
};
|
||||
|
||||
#ifdef USE_LOG
|
||||
static void prepare_slab_log(struct slab_log_entry *log, void *free_list_head, int current_free_count, void *next_slot, int order) {
|
||||
log->commited = false;
|
||||
log->free_list_head = free_list_head;
|
||||
|
@ -35,6 +36,7 @@ static void prepare_slab_log(struct slab_log_entry *log, void *free_list_head, i
|
|||
static void commit_slab_log(struct slab_log_entry *log) {
|
||||
log->commited = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
static inline int order_to_index(int order)
|
||||
|
@ -162,13 +164,17 @@ static void *alloc_in_slab_impl(int order)
|
|||
struct slab_header *current_slab;
|
||||
struct slab_slot_list* free_list;
|
||||
void* next_slot;
|
||||
#ifdef USE_LOG
|
||||
struct slab_log_entry log;
|
||||
#endif
|
||||
|
||||
lock(&slabs_locks[order]);
|
||||
|
||||
current_slab = slab_pool[order].current_slab;
|
||||
#ifdef USE_LOG
|
||||
log.from_init = false;
|
||||
log.current_slab = current_slab;
|
||||
#endif
|
||||
/* When serving the first allocation request. */
|
||||
|
||||
if (unlikely(current_slab == NULL)) {
|
||||
|
@ -177,17 +183,19 @@ static void *alloc_in_slab_impl(int order)
|
|||
unlock(&slabs_locks[order]);
|
||||
return NULL;
|
||||
}
|
||||
#ifdef USE_LOG
|
||||
log.from_init = true;
|
||||
log.current_slab = current_slab;
|
||||
#endif
|
||||
slab_pool[order].current_slab = current_slab;
|
||||
}
|
||||
|
||||
free_list = (struct slab_slot_list*)current_slab->free_list_head;
|
||||
BUG_ON(free_list == NULL);
|
||||
next_slot = free_list->next_free;
|
||||
|
||||
#ifdef USE_LOG
|
||||
prepare_slab_log(&log, current_slab->free_list_head, current_slab->current_free_cnt, next_slot, order);
|
||||
|
||||
#endif
|
||||
#ifdef USE_TSX
|
||||
if (start_rtm == true) {
|
||||
int status;
|
||||
|
@ -219,8 +227,9 @@ static void *alloc_in_slab_impl(int order)
|
|||
/* When current_slab is full, choose a new slab as the current one. */
|
||||
if (unlikely(current_slab->current_free_cnt == 0))
|
||||
choose_new_current_slab(&slab_pool[order], order);
|
||||
|
||||
#ifdef USE_LOG
|
||||
commit_slab_log(&log);
|
||||
#endif
|
||||
unlock(&slabs_locks[order]);
|
||||
|
||||
return (void *)free_list;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# SLS Basic Configruations
|
||||
set(SLS_RESTORE ON)
|
||||
set(SLS_RESTORE OFF)
|
||||
set(SLS_EXT_SYNC OFF)
|
||||
set(SLS_HYBRID_MEM ON)
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ target_compile_options(assert.bin PRIVATE -g3 -ggdb)
|
|||
add_executable(udp_echo_server.bin udp_echo_server.c)
|
||||
add_executable(tcp_echo_server.bin tcp_echo_server.c)
|
||||
|
||||
add_executable(tsx_test.bin tsx_test.c)
|
||||
add_executable(rtm_test.bin rtm_test.c)
|
||||
|
||||
# TreeSLS
|
||||
add_subdirectory(treesls)
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <chcore/pmu.h>
|
||||
#include <pthread.h>
|
||||
#include <chcore/syscall.h>
|
||||
#include <string.h>
|
||||
|
||||
#pragma GCC push_options
|
||||
#pragma GCC optimize ("O0")
|
||||
#define num_threads 32
|
||||
s64 time_list[num_threads];
|
||||
int fixed_size = 128;
|
||||
int varying_size_times_max = 12;
|
||||
int total_malloc_times = 100000;
|
||||
|
||||
enum test_size_t {
|
||||
FIXED,
|
||||
VARYING
|
||||
} test_size_type;
|
||||
// non log rtm+log
|
||||
|
||||
void *work(void *arg) {
|
||||
int i = *(int *)arg;
|
||||
usys_set_affinity(-1, i);
|
||||
usys_yield();
|
||||
s64 start = 0, end = 0, period;
|
||||
|
||||
int count = total_malloc_times / num_threads;
|
||||
int size;
|
||||
pmu_clear_cnt();
|
||||
start = pmu_read_real_cycle();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (test_size_type == FIXED) {
|
||||
size = fixed_size;
|
||||
} else {
|
||||
size = (1 << ((i % varying_size_times_max)));
|
||||
}
|
||||
void *m = malloc(size);
|
||||
(void)m;
|
||||
}
|
||||
|
||||
end = pmu_read_real_cycle();
|
||||
period = end - start;
|
||||
time_list[i] = period;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool parse_args(int argc, char *argv[]) {
|
||||
if (argc != 2) {
|
||||
return false;
|
||||
}
|
||||
if (strcmp(argv[1], "0")) {
|
||||
test_size_type = FIXED;
|
||||
} else {
|
||||
test_size_type = VARYING;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (parse_args(argc, argv) == false) {
|
||||
return -1;
|
||||
}
|
||||
pthread_t threads[num_threads];
|
||||
int thread_index[num_threads];
|
||||
for (int i = 0; i < num_threads; i++) {
|
||||
thread_index[i] = i;
|
||||
if (pthread_create(&threads[i], NULL, work, thread_index + i) != 0) {
|
||||
perror("Failed to create thread");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < num_threads; i++) {
|
||||
pthread_join(threads[i], NULL);
|
||||
}
|
||||
|
||||
s64 avg = 0;
|
||||
for (int i = 0; i < num_threads; i++) {
|
||||
avg += time_list[i] / num_threads;
|
||||
}
|
||||
|
||||
printf("result: %ld\n", avg);
|
||||
printf("rtm test finished\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
#pragma GCC pop_options
|
|
@ -1,49 +0,0 @@
|
|||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <chcore/pmu.h>
|
||||
#include <pthread.h>
|
||||
#include <chcore/syscall.h>
|
||||
|
||||
#pragma GCC push_options
|
||||
#pragma GCC optimize ("O0")
|
||||
const int num_threads = 10;
|
||||
|
||||
void *work(void *arg) {
|
||||
int i = *(int *)arg;
|
||||
usys_set_affinity(-1, i);
|
||||
usys_yield();
|
||||
s64 start = 0, end = 0;
|
||||
int size = 4096;
|
||||
int count = 1000000 / num_threads;
|
||||
pmu_clear_cnt();
|
||||
start = pmu_read_real_cycle();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
void *m = malloc(size);
|
||||
(void)m;
|
||||
}
|
||||
|
||||
end = pmu_read_real_cycle();
|
||||
printf("tsx_test total %ld\n", end - start);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
pthread_t threads[num_threads];
|
||||
int thread_index[num_threads];
|
||||
for (int i = 0; i < num_threads; i++) {
|
||||
thread_index[i] = i;
|
||||
if (pthread_create(&threads[i], NULL, work, thread_index + i) != 0) {
|
||||
perror("Failed to create thread");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < num_threads; i++) {
|
||||
pthread_join(threads[i], NULL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#pragma GCC pop_options
|
Loading…
Reference in New Issue