Commit 2e9f42ee authored by Vikram Narayanan's avatar Vikram Narayanan
Browse files

Merge branch 'dummy_one_slot' of gitlab.flux.utah.edu:xcap/xcap-async-module into dummy_one_slot

parents 3b1b4e2d ad82feb5
Pipeline #2857 failed with stages
in 13 seconds
*.sw*
*.o
*.ko
*.cmd
......@@ -6,6 +7,7 @@
*.symvers
*.mod.c
*Makefile.in
*.patch
aclocal.m4
autom4te.cache
config.h.in
......
......@@ -37,6 +37,30 @@
#define EXPORT_SYMBOL(x)
#endif
/* Linux kernel only provides ffs variant, which operates on 32-bit registers.
* For promoting the bsf instruction to 64-bit, intel manual suggests to use
* REX.W prefix to the instruction. However, when the operands are 64-bits, gcc
* already promotes bsf to 64-bit.
*/
static __always_inline int ffsll(long long x)
{
long long r;
/*
* AMD64 says BSFL won't clobber the dest reg if x==0; Intel64 says the
* dest reg is undefined if x==0, but their CPU architect says its
* value is written to set it to the same as before, except that the
* top 32 bits will be cleared.
*
* We cannot do this on 32 bits because at the very least some
* 486 CPUs did not behave this way.
*/
asm("bsf %1,%0"
: "=r" (r)
: "rm" (x), "0" (-1));
return r + 1;
}
/*
* Initilaizes awe mapper.
*/
......@@ -57,8 +81,11 @@ awe_mapper_init(void)
printf("No space left for awe_map_ptr\n");
return;
}
awe_map->awe_bitmap |= ~0;
#ifdef LINUX_KERNEL
awe_map->awe_bitmap = ~0UL;
#else
awe_map->awe_bitmap = ~0LL;
#endif
set_awe_map((awe_table_t*) awe_map);
current->ptstate = PTS();
}
......@@ -93,12 +120,18 @@ _awe_mapper_create_id(awe_table_t *awe_map)
{
int id;
#ifdef LINUX_KERNEL
id = ffs(awe_map->awe_bitmap);
id = ffsll(awe_map->awe_bitmap);
#elif defined(linux)
id = __builtin_ffsll(awe_map->awe_bitmap);
#endif
awe_map->awe_bitmap &= ~(1 << (id - 1));
return id;
awe_map->awe_bitmap &= ~(1LL << (id - 1));
assert(id != 0);
#ifndef NDEBUG
if (!id)
printk("%s, id %d, bitmap %016llx\n", __func__, id, awe_map->awe_bitmap);
#endif
return id;
}
/*
......
......@@ -21,7 +21,7 @@
struct awe_table
{
awe_t awe_list[AWE_TABLE_COUNT];
unsigned long long awe_bitmap;
long long awe_bitmap;
// uint32_t used_slots;
// uint32_t next_id;
......@@ -65,7 +65,7 @@ static inline void set_awe_map(awe_table_t * map_ptr)
static inline void
_awe_mapper_remove_id(awe_table_t *awe_map, uint32_t id)
{
assert(id < AWE_TABLE_COUNT);
assert(id <= AWE_TABLE_COUNT);
assert(!(awe_map->awe_bitmap & (1 << (id - 1))));
awe_map->awe_bitmap |= (1 << (id - 1));
}
......@@ -111,8 +111,9 @@ static inline int is_slot_allocated(uint32_t id)
static inline awe_t *
_awe_mapper_get_awe(awe_table_t *awe_map, uint32_t id)
{
//assert(id >= AWE_TABLE_COUNT);
if (id >= AWE_TABLE_COUNT) {
if (id > AWE_TABLE_COUNT) {
printk("%s, id(%u) > table count(%u)\n", __func__, id, AWE_TABLE_COUNT);
}
if (!awe_map) {
......@@ -124,6 +125,7 @@ _awe_mapper_get_awe(awe_table_t *awe_map, uint32_t id)
}
if (!_is_slot_allocated(awe_map, id))
return NULL;
assert(id <= AWE_TABLE_COUNT);
return &(awe_map->awe_list[id]);
}
......
......@@ -23,7 +23,7 @@ static void abort_example_init(void)
}
printk(KERN_ERR "ASYNC 0 signaling all awe's\n");
THCStopAllAwes();
// THCStopAllAwes();
printk(KERN_ERR "ASYNC 0 aborting\n");
THCAbort();
......
......@@ -17,9 +17,12 @@
#include <linux/module.h>
#include "../test_helpers.h"
#define NUM_SWITCH_MEASUREMENTS 1000000
#define NUM_AWES 64
#include "./test.c"
MODULE_LICENSE("GPL");
#define NUM_SWITCH_MEASUREMENTS 100000
#define CPU_NUM 1
static unsigned long ctx_measurements_arr[NUM_SWITCH_MEASUREMENTS];
......@@ -27,12 +30,38 @@ static unsigned long thd_measurements_arr[NUM_SWITCH_MEASUREMENTS];
static int test_ctx_switch_and_thd_creation(void)
{
#if 0
unsigned long t1, t2, t3;
uint32_t msg_id;
int i;
int ret;
#endif
thc_init();
test_async();
test_async_yield();
test_basic_do_finish_create();
test_basic_nonblocking_async_create();
test_basic_N_nonblocking_asyncs_create();
test_basic_N_blocking_asyncs_create();
test_basic_N_blocking_asyncs_create_pts();
test_basic_N_blocking_id_asyncs();
test_basic_N_blocking_id_asyncs_pts();
test_basic_N_blocking_id_asyncs_and_N_yields_back();
test_basic_N_blocking_id_asyncs_and_N_yields_back_extrnl_ids();
test_do_finish_yield();
test_do_finish_yield_no_dispatch();
// test_create_and_ctx_switch_to_awe();
test_ctx_switch_no_dispatch();
test_ctx_switch_no_dispatch_direct();
test_ctx_switch_no_dispatch_direct_trusted();
test_ctx_switch_to_awe();
test_create_awe();
#if 0
for( i = 0; i < NUM_SWITCH_MEASUREMENTS; i++ )
{
DO_FINISH_(ctx_switch,{
......@@ -55,6 +84,7 @@ static int test_ctx_switch_and_thd_creation(void)
});
ctx_measurements_arr[i] = t3 - t2;
}
#endif
thc_done();
return 0;
......
This diff is collapsed.
/*
* test_helpers.h
*
* Some common utilities for setting up threads, pinning them
* to cores, setting up message buffers, etc.
*
* Copyright: University of Utah
*/
#ifndef FIPC_KERNEL_TEST_HELPERS_H
#define FIPC_KERNEL_TEST_HELPERS_H
static inline unsigned long test_fipc_start_stopwatch(void)
{
unsigned long stamp;
/*
* Assumes x86
*
* rdtsc returns current cycle counter on cpu;
* low 32 bits in %rax, high 32 bits in %rdx.
*
* Note: We use rdtsc to start the stopwatch because it won't
* wait for prior instructions to complete (that we don't care
* about). It is not exact - meaning that instructions after
* it in program order may start executing before the read
* is completed (so we may slightly underestimate the time to
* execute the intervening instructions). But also note that
* the two subsequent move instructions are also counted against
* us (overestimate).
*/
asm volatile(
"rdtsc\n\t"
"shl $32, %%rdx\n\t"
"or %%rdx, %%rax\n\t"
: "=a" (stamp)
:
: "rdx");
return stamp;
}
static inline unsigned long test_fipc_stop_stopwatch(void)
{
unsigned long stamp;
/*
* Assumes x86
*
* Unlike start_stopwatch, we want to wait until all prior
* instructions are done, so we use rdtscp. (We don't care
* about the tsc aux value.)
*/
asm volatile(
"rdtscp\n\t"
"shl $32, %%rdx\n\t"
"or %%rdx, %%rax\n\t"
: "=a" (stamp)
:
: "rdx", "rcx");
return stamp;
}
#endif
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