drop safemap code
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
all: requestor grantor 1fifo 2fifo
|
||||
chmod +x down run
|
||||
|
||||
requestor: requestor.c inc.h
|
||||
cc -static -o $@ $< -lsys -lminlib -lcompat_minix
|
||||
|
||||
grantor: grantor.c inc.h
|
||||
cc -static -o $@ $< -lsys -lminlib -lcompat_minix
|
||||
|
||||
1fifo 2fifo:
|
||||
mkfifo $@
|
||||
|
||||
run: all
|
||||
sh run
|
||||
|
||||
kill:
|
||||
sh down
|
||||
|
||||
clean:
|
||||
rm -f grantor requestor 1fifo 2fifo
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
Test Program for Safemap
|
||||
|
||||
How to run
|
||||
==========
|
||||
|
||||
1. Type `make run` to prepare and run test.
|
||||
2. When done testing, type `make clean` to clean up.
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
service down grantor
|
||||
service down requestor
|
||||
@@ -1,129 +0,0 @@
|
||||
#include "inc.h"
|
||||
|
||||
char buf_buf[BUF_SIZE + CLICK_SIZE];
|
||||
|
||||
int fid_send, fid_get;
|
||||
|
||||
/* SEF functions and variables. */
|
||||
static void sef_local_startup(void);
|
||||
|
||||
/*===========================================================================*
|
||||
* main *
|
||||
*===========================================================================*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
endpoint_t ep_self, ep_requestor, ep_child;
|
||||
cp_grant_id_t gid;
|
||||
int i, r, pid;
|
||||
char *buf;
|
||||
int status;
|
||||
|
||||
/* SEF local startup. */
|
||||
env_setargs(argc, argv);
|
||||
sef_local_startup();
|
||||
|
||||
/* Prepare work. */
|
||||
buf = (char*) CLICK_CEIL(buf_buf);
|
||||
fid_send = open(FIFO_GRANTOR, O_WRONLY);
|
||||
fid_get = open(FIFO_REQUESTOR, O_RDONLY);
|
||||
if(fid_get < 0 || fid_send < 0) {
|
||||
printf("GRANTOR: can't open fifo files.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Get the requestor's endpoint. */
|
||||
read(fid_get, &ep_requestor, sizeof(ep_requestor));
|
||||
dprint("GRANTOR: getting requestor's endpoint: %d\n", ep_requestor);
|
||||
|
||||
/* Grant. */
|
||||
gid = cpf_grant_direct(ep_requestor, (long)buf, BUF_SIZE,
|
||||
CPF_READ | CPF_WRITE | CPF_MAP);
|
||||
ep_self = getprocnr();
|
||||
dprint("GRANTOR: sending my endpoint %d and gid %d\n", ep_self, gid);
|
||||
write(fid_send, &ep_self, sizeof(ep_self));
|
||||
write(fid_send, &gid, sizeof(gid));
|
||||
|
||||
/* Test MAP. */
|
||||
buf[0] = BUF_START_GRANTOR;
|
||||
FIFO_NOTIFY(fid_send);
|
||||
FIFO_WAIT(fid_get);
|
||||
CHECK_TEST("GRANTOR", buf[0], BUF_START_REQUESTOR, "MAP");
|
||||
|
||||
/* Test UNMAP. */
|
||||
buf[0] = BUF_START_GRANTOR;
|
||||
FIFO_NOTIFY(fid_send);
|
||||
FIFO_WAIT(fid_get);
|
||||
CHECK_TEST("GRANTOR", buf[0], BUF_START_GRANTOR, "UNMAP");
|
||||
|
||||
/* Test REVOKE. */
|
||||
r = sys_saferevmap_gid(gid);
|
||||
if(r != OK) {
|
||||
printf("GRANTOR: error in sys_saferevmap_gid: %d\n", r);
|
||||
return 1;
|
||||
}
|
||||
buf[0] = BUF_START_GRANTOR+1;
|
||||
FIFO_NOTIFY(fid_send);
|
||||
FIFO_WAIT(fid_get);
|
||||
CHECK_TEST("GRANTOR", buf[0], BUF_START_GRANTOR+1, "REVOKE");
|
||||
|
||||
/* Test SMAP_COW. */
|
||||
FIFO_NOTIFY(fid_send);
|
||||
FIFO_WAIT(fid_get);
|
||||
buf[0] = BUF_START_GRANTOR;
|
||||
FIFO_NOTIFY(fid_send);
|
||||
FIFO_WAIT(fid_get);
|
||||
CHECK_TEST("GRANTOR", buf[0], BUF_START_GRANTOR, "SMAP_COW");
|
||||
|
||||
/* Test COW_SMAP. */
|
||||
r = sys_saferevmap_gid(gid);
|
||||
if(r != OK) {
|
||||
printf("GRANTOR: error in sys_saferevmap_gid: %d\n", r);
|
||||
return 1;
|
||||
}
|
||||
buf[0] = BUF_START_GRANTOR+1;
|
||||
pid = fork();
|
||||
if(pid < 0) {
|
||||
printf("GRANTOR: error in fork.\n");
|
||||
return 1;
|
||||
}
|
||||
if(pid == 0) {
|
||||
buf[0] = BUF_START_GRANTOR+2;
|
||||
exit(0);
|
||||
}
|
||||
FIFO_NOTIFY(fid_send);
|
||||
FIFO_WAIT(fid_get);
|
||||
ep_child = getnprocnr(pid);
|
||||
if ((r = sys_privctl(ep_child, SYS_PRIV_SET_USER, NULL)) != OK) {
|
||||
printf("GRANTOR: unable to set privileges: %d\n", r);
|
||||
return 1;
|
||||
}
|
||||
if ((r = sys_privctl(ep_child, SYS_PRIV_ALLOW, NULL)) != OK) {
|
||||
printf("GRANTOR: child process can't run: %d\n", r);
|
||||
return 1;
|
||||
}
|
||||
wait(&status);
|
||||
FIFO_NOTIFY(fid_send);
|
||||
CHECK_TEST("GRANTOR", buf[0], BUF_START_GRANTOR+1, "COW_SMAP");
|
||||
|
||||
/* Test COW_SMAP2 (with COW safecopy). */
|
||||
r = sys_saferevmap_gid(gid);
|
||||
if(r != OK) {
|
||||
printf("GRANTOR: error in sys_saferevmap_gid: %d\n", r);
|
||||
return 1;
|
||||
}
|
||||
FIFO_NOTIFY(fid_send);
|
||||
FIFO_WAIT(fid_get);
|
||||
CHECK_TEST("GRANTOR", buf[0], BUF_START_REQUESTOR, "COW_SMAP2");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* sef_local_startup *
|
||||
*===========================================================================*/
|
||||
static void sef_local_startup()
|
||||
{
|
||||
/* Let SEF perform startup. */
|
||||
sef_startup();
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
#define _SYSTEM
|
||||
#define _MINIX
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <minix/config.h>
|
||||
#include <minix/com.h>
|
||||
#include <minix/type.h>
|
||||
#include <minix/const.h>
|
||||
#include <minix/endpoint.h>
|
||||
#include <minix/safecopies.h>
|
||||
#include <minix/syslib.h>
|
||||
#include <minix/sysutil.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define TEST_PAGE_NUM 4
|
||||
#define BUF_SIZE (TEST_PAGE_NUM * CLICK_SIZE)
|
||||
#define BUF_START_REQUESTOR 10
|
||||
#define BUF_START_GRANTOR 20
|
||||
|
||||
#define FIFO_REQUESTOR "/usr/src/test/safemap/1fifo"
|
||||
#define FIFO_GRANTOR "/usr/src/test/safemap/2fifo"
|
||||
|
||||
#define FIFO_WAIT(fid) { \
|
||||
int a; \
|
||||
if(read(fid, &a, sizeof(a)) != sizeof(a)) \
|
||||
panic( "FIFO_WAIT failed"); \
|
||||
}
|
||||
#define FIFO_NOTIFY(fid) { \
|
||||
int a = 1; \
|
||||
if(write(fid, &a, sizeof(a)) != sizeof(a)) \
|
||||
panic( "FIFO_NOTIFY failed"); \
|
||||
}
|
||||
|
||||
#define CHECK_TEST(who, result, expected, test_name) { \
|
||||
printf("%-9s: test %s %s\n", who, test_name, \
|
||||
(expected == result ? "succeeded" : "failed")); \
|
||||
if(expected != result) { \
|
||||
exit(1); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define DEBUG 0
|
||||
#if DEBUG
|
||||
# define dprint printf
|
||||
#else
|
||||
# define dprint (void)
|
||||
#endif
|
||||
|
||||
@@ -1,153 +0,0 @@
|
||||
#include "inc.h"
|
||||
|
||||
char buf_buf[BUF_SIZE + CLICK_SIZE];
|
||||
|
||||
endpoint_t ep_granter;
|
||||
cp_grant_id_t gid;
|
||||
char *buf;
|
||||
int fid_send, fid_get;
|
||||
|
||||
/* SEF functions and variables. */
|
||||
static void sef_local_startup(void);
|
||||
|
||||
/*===========================================================================*
|
||||
* main *
|
||||
*===========================================================================*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
endpoint_t ep_self, ep_child;
|
||||
size_t size = BUF_SIZE;
|
||||
int i, r, pid;
|
||||
int status;
|
||||
|
||||
/* SEF local startup. */
|
||||
env_setargs(argc, argv);
|
||||
sef_local_startup();
|
||||
|
||||
/* Prepare work. */
|
||||
buf = (char*) CLICK_CEIL(buf_buf);
|
||||
fid_get = open(FIFO_GRANTOR, O_RDONLY);
|
||||
fid_send = open(FIFO_REQUESTOR, O_WRONLY);
|
||||
if(fid_get < 0 || fid_send < 0) {
|
||||
printf("REQUESTOR: can't open fifo files.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Send the endpoint to the granter, in order to let him to
|
||||
* create the grant.
|
||||
*/
|
||||
ep_self = getprocnr();
|
||||
write(fid_send, &ep_self, sizeof(ep_self));
|
||||
dprint("REQUESTOR: sending my endpoint: %d\n", ep_self);
|
||||
|
||||
/* Get the granter's endpoint and gid. */
|
||||
read(fid_get, &ep_granter, sizeof(ep_granter));
|
||||
read(fid_get, &gid, sizeof(gid));
|
||||
dprint("REQUESTOR: getting granter's endpoint %d and gid %d\n",
|
||||
ep_granter, gid);
|
||||
|
||||
/* Test MAP. */
|
||||
FIFO_WAIT(fid_get);
|
||||
r = sys_safemap(ep_granter, gid, 0, (long)buf, size, 1);
|
||||
if(r != OK) {
|
||||
printf("REQUESTOR: error in sys_safemap: %d\n", r);
|
||||
return 1;
|
||||
}
|
||||
CHECK_TEST("REQUESTOR", buf[0], BUF_START_GRANTOR, "MAP");
|
||||
buf[0] = BUF_START_REQUESTOR;
|
||||
r = sys_safeunmap((long)buf);
|
||||
if(r != OK) {
|
||||
printf("REQUESTOR: error in sys_safeunmap: %d\n", r);
|
||||
return 1;
|
||||
}
|
||||
FIFO_NOTIFY(fid_send);
|
||||
|
||||
/* Test UNMAP. */
|
||||
FIFO_WAIT(fid_get);
|
||||
CHECK_TEST("REQUESTOR", buf[0], BUF_START_REQUESTOR, "UNMAP");
|
||||
r = sys_safemap(ep_granter, gid, 0, (long)buf, size, 1);
|
||||
if(r != 0) {
|
||||
printf("REQUESTOR: error in sys_safemap: %d\n", r);
|
||||
return 1;
|
||||
}
|
||||
FIFO_NOTIFY(fid_send);
|
||||
|
||||
/* Test REVOKE. */
|
||||
FIFO_WAIT(fid_get);
|
||||
CHECK_TEST("REQUESTOR", buf[0], BUF_START_GRANTOR, "REVOKE");
|
||||
buf[0] = BUF_START_REQUESTOR;
|
||||
FIFO_NOTIFY(fid_send);
|
||||
|
||||
/* Test SMAP_COW. */
|
||||
FIFO_WAIT(fid_get);
|
||||
r = sys_safemap(ep_granter, gid, 0, (long)buf, size, 1);
|
||||
if(r != OK) {
|
||||
printf("REQUESTOR: error in sys_safemap: %d\n", r);
|
||||
return 1;
|
||||
}
|
||||
buf[0] = BUF_START_REQUESTOR;
|
||||
pid = fork();
|
||||
if(pid < 0) {
|
||||
printf("REQUESTOR: error in fork\n");
|
||||
return 1;
|
||||
}
|
||||
if(pid == 0) {
|
||||
exit(buf[0] != BUF_START_REQUESTOR);
|
||||
}
|
||||
FIFO_NOTIFY(fid_send);
|
||||
FIFO_WAIT(fid_get);
|
||||
ep_child = getnprocnr(pid);
|
||||
if ((r = sys_privctl(ep_child, SYS_PRIV_SET_USER, NULL)) != OK) {
|
||||
printf("REQUESTOR: unable to set privileges: %d\n", r);
|
||||
return 1;
|
||||
}
|
||||
if ((r = sys_privctl(ep_child, SYS_PRIV_ALLOW, NULL)) != OK) {
|
||||
printf("REQUESTOR: child process can't run: %d\n", r);
|
||||
return 1;
|
||||
}
|
||||
wait(&status);
|
||||
FIFO_NOTIFY(fid_send);
|
||||
CHECK_TEST("REQUESTOR", buf[0], BUF_START_GRANTOR, "SMAP_COW");
|
||||
CHECK_TEST("REQUESTOR", 1, WIFEXITED(status)
|
||||
&& (WEXITSTATUS(status) == 0), "SMAP_COW child");
|
||||
|
||||
/* Test COW_SMAP. */
|
||||
FIFO_WAIT(fid_get);
|
||||
buf[0] = BUF_START_REQUESTOR;
|
||||
r = sys_safemap(ep_granter, gid, 0, (long)buf, size, 1);
|
||||
if(r != OK) {
|
||||
printf("REQUESTOR: error in sys_safemap: %d\n", r);
|
||||
return 1;
|
||||
}
|
||||
FIFO_NOTIFY(fid_send);
|
||||
FIFO_WAIT(fid_get);
|
||||
CHECK_TEST("REQUESTOR", buf[0], BUF_START_GRANTOR+1, "COW_SMAP");
|
||||
|
||||
/* Test COW_SMAP2 (with COW safecopy). */
|
||||
FIFO_WAIT(fid_get);
|
||||
buf[0] = BUF_START_REQUESTOR;
|
||||
r = sys_safecopyto(ep_granter, gid, 0, (long)buf, size);
|
||||
if(r != OK) {
|
||||
printf("REQUESTOR: error in sys_safecopyto: %d\n", r);
|
||||
return 1;
|
||||
}
|
||||
r = sys_safemap(ep_granter, gid, 0, (long)buf, size, 1);
|
||||
if(r != OK) {
|
||||
printf("REQUESTOR: error in sys_safemap: %d\n", r);
|
||||
return 1;
|
||||
}
|
||||
FIFO_NOTIFY(fid_send);
|
||||
CHECK_TEST("REQUESTOR", buf[0], BUF_START_REQUESTOR, "COW_SMAP2");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* sef_local_startup *
|
||||
*===========================================================================*/
|
||||
static void sef_local_startup()
|
||||
{
|
||||
/* Let SEF perform startup. */
|
||||
sef_startup();
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
PWD=`pwd`
|
||||
|
||||
service up ${PWD}/grantor -config ${PWD}/system.conf -script ${PWD}/down
|
||||
service up ${PWD}/requestor -config ${PWD}/system.conf -script ${PWD}/down
|
||||
@@ -1,18 +0,0 @@
|
||||
|
||||
service requestor
|
||||
{
|
||||
system
|
||||
PRIVCTL # 4
|
||||
UMAP # 14
|
||||
;
|
||||
uid 0;
|
||||
};
|
||||
|
||||
service grantor
|
||||
{
|
||||
system
|
||||
PRIVCTL # 4
|
||||
UMAP # 14
|
||||
;
|
||||
uid 0;
|
||||
};
|
||||
@@ -1,21 +0,0 @@
|
||||
all: requestor grantor 1fifo 2fifo
|
||||
chmod +x down run
|
||||
|
||||
requestor: requestor.c inc.h
|
||||
cc -o $@ $< -lsys
|
||||
|
||||
grantor: grantor.c inc.h
|
||||
cc -o $@ $< -lsys
|
||||
|
||||
1fifo 2fifo:
|
||||
mkfifo $@
|
||||
|
||||
run: all
|
||||
sh run
|
||||
|
||||
kill:
|
||||
sh down
|
||||
|
||||
clean:
|
||||
rm -f grantor requestor 1fifo 2fifo
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
Performance Test Program for Safecopy and Safemap
|
||||
|
||||
How to run
|
||||
==========
|
||||
|
||||
1. Set USE_COW_SAFECOPY to 1 or 0 in kernel/system/do_safecopy.c
|
||||
to run safecopy tests with or without COW optimization.
|
||||
2. Type `make run` to prepare and run tests. Configuration parameters
|
||||
for performance tests are in ./run.
|
||||
3. When done testing, type `make clean` to clean up.
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
service down grantor
|
||||
service down requestor
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
#include "inc.h"
|
||||
|
||||
char buf_buf[BUF_SIZE + CLICK_SIZE];
|
||||
|
||||
int fid_send, fid_get;
|
||||
|
||||
/* SEF functions and variables. */
|
||||
static void sef_local_startup(void);
|
||||
|
||||
/*===========================================================================*
|
||||
* main *
|
||||
*===========================================================================*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
endpoint_t ep_self, ep_requestor, ep_child;
|
||||
cp_grant_id_t gid;
|
||||
int i, r, pid;
|
||||
char *buf;
|
||||
int status;
|
||||
|
||||
/* SEF local startup. */
|
||||
env_setargs(argc, argv);
|
||||
sef_local_startup();
|
||||
|
||||
/* Prepare work. */
|
||||
buf = (char*) CLICK_CEIL(buf_buf);
|
||||
fid_send = open(FIFO_GRANTOR, O_WRONLY);
|
||||
fid_get = open(FIFO_REQUESTOR, O_RDONLY);
|
||||
if(fid_get < 0 || fid_send < 0) {
|
||||
printf("GRANTOR: can't open fifo files.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Get the requestor's endpoint. */
|
||||
read(fid_get, &ep_requestor, sizeof(ep_requestor));
|
||||
dprint("GRANTOR: getting requestor's endpoint: %d\n", ep_requestor);
|
||||
|
||||
/* Grant. */
|
||||
gid = cpf_grant_direct(ep_requestor, (long)buf, BUF_SIZE,
|
||||
CPF_READ | CPF_WRITE | CPF_MAP);
|
||||
ep_self = getprocnr();
|
||||
dprint("GRANTOR: sending my endpoint %d and gid %d\n", ep_self, gid);
|
||||
write(fid_send, &ep_self, sizeof(ep_self));
|
||||
write(fid_send, &gid, sizeof(gid));
|
||||
|
||||
/* Test safemap. */
|
||||
buf[0] = 0;
|
||||
FIFO_NOTIFY(fid_send);
|
||||
FIFO_WAIT(fid_get);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* sef_local_startup *
|
||||
*===========================================================================*/
|
||||
static void sef_local_startup()
|
||||
{
|
||||
/* Let SEF perform startup. */
|
||||
sef_startup();
|
||||
}
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
#define _SYSTEM
|
||||
#define _MINIX
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <minix/config.h>
|
||||
#include <minix/com.h>
|
||||
#include <minix/type.h>
|
||||
#include <minix/const.h>
|
||||
#include <minix/endpoint.h>
|
||||
#include <minix/safecopies.h>
|
||||
#include <minix/syslib.h>
|
||||
#include <minix/sysutil.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define TEST_PAGE_NUM 50
|
||||
#define BUF_SIZE (TEST_PAGE_NUM * CLICK_SIZE)
|
||||
|
||||
#define NR_TEST_ITERATIONS 100
|
||||
|
||||
#define FIFO_REQUESTOR "/usr/src/test/safeperf/1fifo"
|
||||
#define FIFO_GRANTOR "/usr/src/test/safeperf/2fifo"
|
||||
|
||||
#define FIFO_WAIT(fid) { \
|
||||
int a; \
|
||||
if(read(fid, &a, sizeof(a)) != sizeof(a)) \
|
||||
panic( "FIFO_WAIT failed"); \
|
||||
}
|
||||
#define FIFO_NOTIFY(fid) { \
|
||||
int a = 1; \
|
||||
if(write(fid, &a, sizeof(a)) != sizeof(a)) \
|
||||
panic( "FIFO_NOTIFY failed"); \
|
||||
}
|
||||
|
||||
#define REPORT_TEST(who, test_name, diff) { \
|
||||
printf("%-9s: test %s took an average of %d.%dus per page\n", \
|
||||
who, test_name, (int)diff, ((int)(diff*1000))%1000); \
|
||||
}
|
||||
|
||||
#define DEBUG 0
|
||||
#if DEBUG
|
||||
# define dprint printf
|
||||
#else
|
||||
# define dprint (void)
|
||||
#endif
|
||||
|
||||
@@ -1,166 +0,0 @@
|
||||
#include "inc.h"
|
||||
|
||||
char buf_buf[BUF_SIZE + CLICK_SIZE];
|
||||
|
||||
endpoint_t ep_granter;
|
||||
cp_grant_id_t gid;
|
||||
char *buf;
|
||||
int fid_send, fid_get;
|
||||
|
||||
/* SEF functions and variables. */
|
||||
static void sef_local_startup(void);
|
||||
|
||||
/*===========================================================================*
|
||||
* read_write_buff *
|
||||
*===========================================================================*/
|
||||
void read_write_buff(char* buff, int size, int is_write)
|
||||
{
|
||||
int i;
|
||||
char c;
|
||||
|
||||
if(size % CLICK_SIZE != 0) {
|
||||
panic("buff_size not page aligned");
|
||||
}
|
||||
if(is_write) {
|
||||
for(i=0;i<size;i+=CLICK_SIZE) buff[i] = 1;
|
||||
}
|
||||
else {
|
||||
for(i=0;i<size;i+=CLICK_SIZE) c = buff[i];
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* exit_usage *
|
||||
*===========================================================================*/
|
||||
void exit_usage(void)
|
||||
{
|
||||
printf("Usage: requestor pages=<nr_pages> map=<0|1> write=<0|1>\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* main *
|
||||
*===========================================================================*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
endpoint_t ep_self, ep_child;
|
||||
size_t size = BUF_SIZE;
|
||||
int i, r, pid;
|
||||
int status;
|
||||
u64_t start, end, diff;
|
||||
double micros;
|
||||
char nr_pages_str[10], is_map_str[2], is_write_str[2];
|
||||
int nr_pages, is_map, is_write;
|
||||
|
||||
/* SEF local startup. */
|
||||
env_setargs(argc, argv);
|
||||
sef_local_startup();
|
||||
|
||||
/* Parse the command line. */
|
||||
r = env_get_param("pages", nr_pages_str, sizeof(nr_pages_str));
|
||||
errno = 0;
|
||||
nr_pages = atoi(nr_pages_str);
|
||||
if (r != OK || errno || nr_pages <=0) {
|
||||
exit_usage();
|
||||
}
|
||||
if(nr_pages > TEST_PAGE_NUM) {
|
||||
printf("REQUESTOR: too many pages. Max allowed: %d\n",
|
||||
TEST_PAGE_NUM);
|
||||
exit_usage();
|
||||
}
|
||||
r = env_get_param("map", is_map_str, sizeof(is_map_str));
|
||||
errno = 0;
|
||||
is_map = atoi(is_map_str);
|
||||
if (r != OK || errno || (is_map!=0 && is_map!=1)) {
|
||||
exit_usage();
|
||||
}
|
||||
r = env_get_param("write", is_write_str, sizeof(is_write_str));
|
||||
errno = 0;
|
||||
is_write = atoi(is_write_str);
|
||||
if (r != OK || errno || (is_write!=0 && is_write!=1)) {
|
||||
exit_usage();
|
||||
}
|
||||
printf("REQUESTOR: Running tests with pages=%d map=%d write=%d...\n",
|
||||
nr_pages, is_map, is_write);
|
||||
|
||||
/* Prepare work. */
|
||||
buf = (char*) CLICK_CEIL(buf_buf);
|
||||
fid_get = open(FIFO_GRANTOR, O_RDONLY);
|
||||
fid_send = open(FIFO_REQUESTOR, O_WRONLY);
|
||||
if(fid_get < 0 || fid_send < 0) {
|
||||
printf("REQUESTOR: can't open fifo files.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Send the endpoint to the granter, in order to let him to
|
||||
* create the grant.
|
||||
*/
|
||||
ep_self = getprocnr();
|
||||
write(fid_send, &ep_self, sizeof(ep_self));
|
||||
dprint("REQUESTOR: sending my endpoint: %d\n", ep_self);
|
||||
|
||||
/* Get the granter's endpoint and gid. */
|
||||
read(fid_get, &ep_granter, sizeof(ep_granter));
|
||||
read(fid_get, &gid, sizeof(gid));
|
||||
dprint("REQUESTOR: getting granter's endpoint %d and gid %d\n",
|
||||
ep_granter, gid);
|
||||
|
||||
FIFO_WAIT(fid_get);
|
||||
diff = make64(0, 0);
|
||||
|
||||
if(is_map) {
|
||||
/* Test safemap. */
|
||||
for(i=0;i<NR_TEST_ITERATIONS;i++) {
|
||||
read_tsc_64(&start);
|
||||
r = sys_safemap(ep_granter, gid, 0, (long)buf,
|
||||
nr_pages*CLICK_SIZE, D, 1);
|
||||
if(r != OK) {
|
||||
printf("REQUESTOR: safemap error: %d\n", r);
|
||||
return 1;
|
||||
}
|
||||
read_write_buff(buf, nr_pages*CLICK_SIZE, is_write);
|
||||
read_tsc_64(&end);
|
||||
diff = add64(diff, (sub64(end, start)));
|
||||
r = sys_safeunmap(D, (long)buf);
|
||||
if(r != OK) {
|
||||
printf("REQUESTOR: safeunmap error: %d\n", r);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
micros = ((double)tsc_64_to_micros(diff))
|
||||
/ (NR_TEST_ITERATIONS*nr_pages);
|
||||
REPORT_TEST("REQUESTOR", "SAFEMAP", micros);
|
||||
}
|
||||
else {
|
||||
/* Test safecopy. */
|
||||
for(i=0;i<NR_TEST_ITERATIONS;i++) {
|
||||
read_tsc_64(&start);
|
||||
r = sys_safecopyfrom(ep_granter, gid, 0, (long)buf,
|
||||
nr_pages*CLICK_SIZE);
|
||||
if(r != OK) {
|
||||
printf("REQUESTOR: safecopy error: %d\n", r);
|
||||
return 1;
|
||||
}
|
||||
read_write_buff(buf, nr_pages*CLICK_SIZE, is_write);
|
||||
read_tsc_64(&end);
|
||||
diff = add64(diff, (sub64(end, start)));
|
||||
}
|
||||
micros = ((double)tsc_64_to_micros(diff))
|
||||
/ (NR_TEST_ITERATIONS*nr_pages);
|
||||
REPORT_TEST("REQUESTOR", "SAFECOPY", micros);
|
||||
}
|
||||
|
||||
FIFO_NOTIFY(fid_send);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* sef_local_startup *
|
||||
*===========================================================================*/
|
||||
static void sef_local_startup()
|
||||
{
|
||||
/* Let SEF perform startup. */
|
||||
sef_startup();
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
PAGES="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50"
|
||||
MAP=0
|
||||
WRITE=1
|
||||
|
||||
PWD=`pwd`
|
||||
|
||||
for P in `echo $PAGES`
|
||||
do
|
||||
service up ${PWD}/grantor -config ${PWD}/system.conf -script ${PWD}/down
|
||||
service up ${PWD}/requestor -config ${PWD}/system.conf -script ${PWD}/down \
|
||||
-args pages=${P}\ map=${MAP}\ write=${WRITE}
|
||||
sleep 2
|
||||
done
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
|
||||
service requestor
|
||||
{
|
||||
system
|
||||
PRIVCTL # 4
|
||||
UMAP # 14
|
||||
;
|
||||
uid 0;
|
||||
};
|
||||
|
||||
service grantor
|
||||
{
|
||||
system
|
||||
PRIVCTL # 4
|
||||
UMAP # 14
|
||||
;
|
||||
uid 0;
|
||||
};
|
||||
Reference in New Issue
Block a user