add first version of the lazy release consistency

This commit is contained in:
Stefan Lankes 2011-08-23 14:03:34 -07:00
parent 637399c1e1
commit 499f43bfaf
4 changed files with 24 additions and 7 deletions

View file

@ -361,6 +361,9 @@ size_t map_region(size_t viraddr, size_t phyaddr, uint32_t npages, uint32_t flag
#else
pgt->entries[index] |= PG_SVM;
#endif
if (flags & MAP_SVM_LAZYRELEASE)
pgt->entries[index] |= PG_SVM_LAZYRELEASE|PG_PWT;
if (flags & MAP_NO_ACCESS)
pgt->entries[index] &= ~PG_PRESENT;

View file

@ -137,11 +137,17 @@ int svm_access_request(size_t addr)
return change_page_permissions(addr, addr+PAGE_SIZE, VMA_READ|VMA_WRITE|VMA_CACHEABLE);
}
void* svmmalloc(size_t size, uint32_t consitency)
void* svmmalloc(size_t size, uint32_t consistency)
{
size_t phyaddr, viraddr, i;
uint32_t flags;
uint32_t map_flags = MAP_KERNEL_SPACE|MAP_MPE|MAP_SVM_STRONG;
uint32_t map_flags = MAP_KERNEL_SPACE|MAP_MPE;
if (consistency & SVM_STRONG)
map_flags |= MAP_SVM_STRONG;
else if (consistency & SVM_LAZYRELEASE)
map_flags |= MAP_SVM_LAZYRELEASE;
else return 0;
// currently, we allocate memory in page size granulation
size = (size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
@ -150,7 +156,7 @@ void* svmmalloc(size_t size, uint32_t consitency)
flags = irq_nested_disable();
phyaddr = (size_t) RCCE_shmalloc(size);
if (RCCE_ue())
if (RCCE_ue() && (consistency & SVM_STRONG))
map_flags |= MAP_NO_ACCESS;
irq_nested_enable(flags);

View file

@ -49,7 +49,8 @@ extern "C" {
#define MAP_MPE (1 << 8)
#endif
#define MAP_SVM_STRONG (1 << 9)
#define MAP_NO_ACCESS (1 << 10)
#define MAP_SVM_LAZYRELEASE (1 << 10)
#define MAP_NO_ACCESS (1 << 11)
void NORETURN abort(void);

View file

@ -115,8 +115,9 @@ int mail_ping(void* arg) {
return 0;
}
//#define N 1024
#define N 514
#define N 1024
//#define N 514
#define LAZY
volatile static int* A[N];
volatile static int* B[N];
@ -132,7 +133,7 @@ static int svm_test(void *arg)
my_ue = RCCE_ue();
num_ues = RCCE_num_ues();
#if 0
#if 1
if (!my_ue) {
// allocate and initialize SVM region
A[0] = (int*) kmalloc(3*N*N*sizeof(int));
@ -173,7 +174,11 @@ static int svm_test(void *arg)
#endif
// allocate and initialize SVM region
#ifndef LAZY
A[0] = (int*) svmmalloc(3*N*N*sizeof(int), SVM_STRONG);
#else
A[0] = (int*) svmmalloc(3*N*N*sizeof(int), SVM_LAZYRELEASE);
#endif
if (!my_ue)
memset((void*) A[0], 0x00, 3*N*N*sizeof(int));
@ -199,9 +204,11 @@ static int svm_test(void *arg)
start = rdtsc();
start = rdtsc();
#ifndef LAZY
// Now, we need only read access on A and B
change_page_permissions((size_t) A[0], (size_t) (A[0]+2*N*N), VMA_CACHEABLE|VMA_READ);
RCCE_barrier(&RCCE_COMM_WORLD);
#endif
// start calculation
for(i=my_ue*(N/num_ues); i<(my_ue+1)*(N/num_ues); i++)