# HG changeset patch # User Paul Boddie # Date 1613345543 -3600 # Node ID beb4817970ed3d7fe3723c845ee7e7d33dd5f731 # Parent 8b3eb741f05a94aba3054a12c4f0858171c94a13 Removed dataspace concurrency testing operations: it is now assumed that measures around capability allocation in libipc, enabled using the ipc_cap_alloc_init function, will prevent repeated association of the same address with multiple dataspaces. Introduced an inner loop to test repeated traversal of open file regions. diff -r 8b3eb741f05a -r beb4817970ed dstest_test_client.cc --- a/dstest_test_client.cc Sun Feb 14 23:11:41 2021 +0100 +++ b/dstest_test_client.cc Mon Feb 15 00:32:23 2021 +0100 @@ -26,8 +26,6 @@ #include #include -#include -#include #include #include @@ -41,44 +39,20 @@ -const unsigned int ACTIVITY_ITERATIONS = 100; +/* Test parameters affected by capability limits. */ + const unsigned long NUMBER_OF_FILES = 10; const unsigned int START_LIMIT = 10; +const unsigned int ACTIVITY_ITERATIONS = 20; + +/* Test parameters unaffected by any capability limits. */ + const unsigned int MAP_PAGES = 20; +const unsigned int REGION_ITERATIONS = 10; -static std::mutex _lock; -static std::set _memory; - -static long attach_dataspace(l4_cap_idx_t cap, unsigned long size, void **memory) -{ - std::lock_guard guard(_lock); - - long err = ipc_attach_dataspace(cap, size, memory); - - if (err) - return err; - - if (_memory.find(*memory) != _memory.end()) - { - printf("Memory assigned again: %p\n", *memory); - return -L4_EINVAL; - } - - _memory.insert(*memory); - return L4_EOK; -} - -static long detach_dataspace(void *memory) -{ - std::lock_guard guard(_lock); - - _memory.erase(memory); - return ipc_detach_dataspace(memory); -} - - +/* An activity opening and reading from a file. */ static long activity(l4_cap_idx_t context_ref, unsigned long fileid, unsigned int start_page) { @@ -118,16 +92,11 @@ return err; } - //printf("Mapped region from %ld to %ld with content %ld.\n", - // start_pos, end_pos, data_end); - size = end_pos - start_pos; - //printf("Attach region of size %ld...\n", size); - char *memory; - err = attach_dataspace(file_ref, size, (void **) &memory); + err = ipc_attach_dataspace(file_ref, size, (void **) &memory); if (err) { @@ -136,40 +105,39 @@ return err; } - //printf("Mapped memory from %lx / %ld at %p\n", file_ref, page(start_page), memory); - if (data_end < size) size = data_end; - for (unsigned long offset = 0; offset < size; offset += step) - { - unsigned long remaining = size - offset; - unsigned long sample_remaining = remaining < sample ? remaining : sample; + /* Read the region a number of times. */ - strncpy(buf, (memory + offset), sample_remaining); - buf[sample_remaining] = '\0'; - //printf("%p: %s\n", (memory + offset), buf); + for (unsigned int read_counter = 0; read_counter < REGION_ITERATIONS; read_counter++) + { + for (unsigned long offset = 0; offset < size; offset += step) + { + unsigned long remaining = size - offset; + unsigned long sample_remaining = remaining < sample ? remaining : sample; - /* Test the data obtained. */ + strncpy(buf, (memory + offset), sample_remaining); + buf[sample_remaining] = '\0'; + + /* Test the data obtained. */ - unsigned long filepos = start_pos + offset; - unsigned long _fileid = 0, _filepos = 0; - char *sep = strchr(buf, ':'); + unsigned long filepos = start_pos + offset; + unsigned long _fileid = 0, _filepos = 0; + char *sep = strchr(buf, ':'); - if (sep != NULL) - { - *sep = '\0'; sep++; - _fileid = atol(buf); _filepos = atol(sep); + if (sep != NULL) + { + *sep = '\0'; sep++; + _fileid = atol(buf); _filepos = atol(sep); + } + + if ((fileid != _fileid) || (filepos != _filepos)) + printf("! %ld:%ld is not %ld:%ld\n", _fileid, _filepos, fileid, filepos); } - - if ((fileid != _fileid) || (filepos != _filepos)) - printf("! %ld:%ld is not %ld:%ld\n", _fileid, _filepos, fileid, filepos); } - detach_dataspace(memory); - - //printf("Unmapped memory from %ld at %p\n", page(start_page), memory); - + ipc_detach_dataspace(memory); ipc_cap_free_um(file_ref); return L4_EOK; @@ -190,7 +158,6 @@ break; } - //printf("Ending: %ld @ %d\n", fileid, start_page); return err; } @@ -225,7 +192,7 @@ /* Map context memory to write the filename. */ - err = attach_dataspace(*context_ref, size, (void **) filename); + err = ipc_attach_dataspace(*context_ref, size, (void **) filename); if (err) { @@ -273,7 +240,7 @@ /* Discard the context. */ - detach_dataspace(filename); + ipc_detach_dataspace(filename); ipc_cap_free_um(context_ref); printf("End: %ld\n", fileid);