User Space:swapout (this is a rebase commit to merge into development)

This commit is contained in:
Hitoshi Iizuka
2017-10-26 20:29:16 +09:00
parent 5a8d1f09e8
commit aebacb243e
51 changed files with 2649 additions and 38 deletions

View File

@@ -0,0 +1,180 @@
diff --git a/kernel/pager.c b/kernel/pager.c
index 2fc1a72..a5e7233 100644
--- a/kernel/pager.c
+++ b/kernel/pager.c
@@ -65,7 +65,8 @@
* the mlockcntnr structure is used.
* The mlockcntnr keeps the list of
*/
-#define MLOCKADDRS_SIZE 128
+//#define MLOCKADDRS_SIZE 128
+#define MLOCKADDRS_SIZE 8
struct addrpair {
unsigned long start;
unsigned long end;
@@ -296,6 +297,8 @@ pager_open(struct swapinfo *si, char *fname, int flag, int mode)
{
int fd;
copy_to_user(si->udata_buf, fname, strlen(fname) + 1);
+// kprintf("%s: copy_to_user si->udata_buf:%s,fname:%s\n",
+// __FUNCTION__, si->udata_buf, fname);
fd = linux_open(si->udata_buf, flag, mode);
return fd;
}
@@ -304,6 +307,8 @@ static int
pager_unlink(struct swapinfo *si, char *fname)
{
copy_to_user(si->udata_buf, fname, strlen(fname) + 1);
+// kprintf("%s: copy_to_user si->udata_buf:%s,fname:%s\n",
+// __FUNCTION__, si->udata_buf, fname);
return linux_unlink(si->udata_buf);
}
@@ -403,6 +408,9 @@ mlocklist_morereq(struct swapinfo *si, unsigned long *start)
{
struct areaent went,*ent = si->mlock_area.tail;
copy_from_user(&went, ent, sizeof(struct areaent));
+ kprintf("%s: copy_from_user went.count:%d,ent->count:%d\n",
+ __FUNCTION__, went.count, ent->count); //test case 1
+
dkprintf("mlocklist_morereq: start = %ld and = %ld\n",
went.pair[went.count].start, went.pair[went.count].end);
@@ -421,6 +429,8 @@ arealist_alloc(struct swapinfo *si, struct arealist *areap)
if (areap->head == NULL) return -ENOMEM;
memset(&went, 0, sizeof(struct areaent));
copy_to_user(areap->head, &went, sizeof(struct areaent));
+// kprintf("%s: copy_to_user went.count:%d,areap->head->count:%d\n",
+// __FUNCTION__, went.count, areap->head->count); //test case
return 0;
}
@@ -465,6 +475,8 @@ arealist_get(struct swapinfo *si, struct addrpair **pair, struct arealist *area)
memset(&wtmp, 0, sizeof(struct areaent));
copy_to_user(tmp, &wtmp, sizeof(struct areaent));
copy_to_user(&(area->tail->next), &tmp, sizeof(struct areaent *));
+// kprintf("%s: copy_to_user wtmp.count:%d,tmp->count:%d area->tail->next %x:%x\n",
+// __FUNCTION__, wtmp.count, tmp->count, area->tail->next, tmp); //test case
area->tail = tmp;
if (pair) *pair = area->tail->pair;
@@ -476,8 +488,13 @@ arealist_update(int cnt, struct arealist *area)
{
int i;
copy_from_user(&i, &(area->tail->count), sizeof(int));
+ kprintf("%s: copy_from_user i:%d, area->tail->count:%d\n",
+ __FUNCTION__, i, area->tail->count); //test case 2
+
i += cnt;
copy_to_user(&(area->tail->count), &i, sizeof(int));
+// kprintf("%s: copy_to_user i:%d, area->tail->count:%d\n",
+// __FUNCTION__, i, area->tail->count); //test case
area->count += cnt;
}
@@ -492,6 +509,8 @@ arealist_add(struct swapinfo *si, unsigned long start, unsigned long end,
if (cc < 0) return -1;
waddr.start = start; waddr.end = end; waddr.flag = flag;
copy_to_user(addr, &waddr, sizeof(struct addrpair));
+// kprintf("%s: copy_to_user addr->start:%x, waddr.strt:%x\n",
+// __FUNCTION__, addr->start, waddr.start); //test case
arealist_update(1, area);
return 0;
@@ -510,11 +529,17 @@ arealist_preparewrite(struct arealist *areap, struct swap_areainfo *info,
for (ent = areap->head; ent != NULL; ent = ent->next) {
int i;
copy_from_user(&went, ent, sizeof(struct areaent));
+ kprintf("%s: copy_from_user went.count:%d,ent->count:%d\n",
+ __FUNCTION__, went.count, ent->count); //test case 3
+
for (i = 0; i < went.count; i++, count++) {
ssize_t sz = went.pair[i].end - went.pair[i].start;
copy_to_user(&(info[count].start), &(went.pair[i].start), sizeof(unsigned long));
copy_to_user(&(info[count].end), &(went.pair[i].end), sizeof(unsigned long));
copy_to_user(&(info[count].flag), &(went.pair[i].flag), sizeof(unsigned long));
+// kprintf("%s: copy_to_user info[%d].start:%x,end:%x,flag:%x ,went.pair[%d].start:%x,end:%x,flag:%x\n",
+// __FUNCTION__, count, info[count].start, info[count].end, info[count].flag,
+// i, went.pair[i].start, went.pair[i].end, went.pair[i].flag); //test case
if (flag) { /* position in file */
pos = off + totsz;
@@ -526,6 +551,8 @@ arealist_preparewrite(struct arealist *areap, struct swap_areainfo *info,
}
}
copy_to_user(&(info[count].pos), &pos, sizeof(unsigned long));
+// kprintf("%s: copy_to_user info[%d].pos:%x,pos:%x\n",
+// __FUNCTION__, count, info[count].pos, pos);
totsz += sz;
}
}
@@ -675,8 +702,10 @@ do_pagein(int flag)
// ihk_mc_pt_print_pte(vm->address_space->page_table, (void*) si->swap_info[i].start);
}
linux_close(fd);
+#if 0
print_region("after pagin", vm);
dkprintf("do_pagein: done, currss(%lx)\n", vm->currss);
+#endif
vm->swapinfo = NULL;
kfree(si->swapfname);
kfree(si);
@@ -742,6 +771,8 @@ do_pageout(char *fname, void *buf, size_t size, int flag)
}
copy_to_user(si->udata_buf, si->swapfname, strlen(si->swapfname) + 1);
+ kprintf("%s: copy_to_user si->udata_buf:%s,si->swapfname:%s\n",
+ __FUNCTION__, si->udata_buf, si->swapfname);
fd = linux_open(si->udata_buf, O_RDWR|O_CREAT|O_TRUNC, 0600);
if (fd < 0) {
ekprintf("do_pageout: Cannot open/create file: %s\n", fname);
@@ -807,8 +838,10 @@ do_pageout(char *fname, void *buf, size_t size, int flag)
}
}
}
+#if 0
arealist_print("SWAP", &si->swap_area, si->swap_area.count);
arealist_print("MLOCK", &si->mlock_area, si->mlock_area.count);
+#endif
si->swap_info = myalloc(si, sizeof(struct swap_areainfo)* si->swap_area.count);
si->mlock_info = myalloc(si, sizeof(struct swap_areainfo)* si->mlock_area.count);
if (si->swap_info == NULL || si->mlock_info == NULL) goto nomem;
@@ -819,6 +852,8 @@ do_pageout(char *fname, void *buf, size_t size, int flag)
copy_to_user(&(si->swphdr->version), MCKERNEL_SWAP_VERSION, SWAP_HLEN);
copy_to_user(&(si->swphdr->count_sarea), &(si->swap_area.count), sizeof(unsigned int));
copy_to_user(&(si->swphdr->count_marea), &(si->mlock_area.count), sizeof(unsigned int));
+// kprintf("%s: copy_to_user si->swphdr->magic:%s,si->swphdr->version:%s,si->swphdr->count_sarea:%d,si->swphdr->count_marea:%d,si->swap_area.count:%d,si->mlock_area.count:%d\n",
+// __FUNCTION__, si->swphdr->magic, si->swphdr->version, si->swphdr->count_sarea, si->swphdr->count_marea, si->swap_area.count, si->mlock_area.count);
if ((cc = pager_write(fd, si->swphdr, sizeof(struct swap_header)))
!= sizeof(struct swap_header)) {
if (cc >= 0)
@@ -844,6 +879,9 @@ do_pageout(char *fname, void *buf, size_t size, int flag)
for (i = 0; i < si->swap_area.count; i++) {
struct swap_areainfo sw_info;
copy_from_user(&sw_info, &(si->swap_info[i]), sizeof(struct swap_areainfo));
+ kprintf("%s:1 copy_from_user %x:%x\n",
+ __FUNCTION__, sw_info.start, si->swap_info[i].start); // test case 4
+
sz = sw_info.end - sw_info.start;
if ((cc = pager_write(fd, (void*) sw_info.start, sz)) != sz) {
if (cc >= 0)
@@ -859,6 +897,9 @@ do_pageout(char *fname, void *buf, size_t size, int flag)
for (i = 0; i < si->swap_area.count; i++) {
struct swap_areainfo sw_info;
copy_from_user(&sw_info, &(si->swap_info[i]), sizeof(struct swap_areainfo));
+ kprintf("%s:2 copy_from_user %x:%x\n",
+ __FUNCTION__, sw_info.start, si->swap_info[i].start); // test case 4
+
cc = ihk_mc_pt_free_range(vm->address_space->page_table,
vm,
(void*) sw_info.start,
@@ -880,6 +921,9 @@ do_pageout(char *fname, void *buf, size_t size, int flag)
for (i = 0; i < si->swap_area.count; i++) {
struct swap_areainfo sw_info;
copy_from_user(&sw_info, &(si->swap_info[i]), sizeof(struct swap_areainfo));
+ kprintf("%s:3 copy_from_user %x:%x\n",
+ __FUNCTION__, sw_info.start, si->swap_info[i].start); // test case 4
+
sz = sw_info.end - sw_info.start;
cc = linux_munmap((void*) sw_info.start, sz, 0);
if (cc < 0) {

View File

@@ -0,0 +1,180 @@
diff --git a/kernel/pager.c b/kernel/pager.c
index 2fc1a72..bbffba7 100644
--- a/kernel/pager.c
+++ b/kernel/pager.c
@@ -65,7 +65,8 @@
* the mlockcntnr structure is used.
* The mlockcntnr keeps the list of
*/
-#define MLOCKADDRS_SIZE 128
+//#define MLOCKADDRS_SIZE 128
+#define MLOCKADDRS_SIZE 8
struct addrpair {
unsigned long start;
unsigned long end;
@@ -296,6 +297,8 @@ pager_open(struct swapinfo *si, char *fname, int flag, int mode)
{
int fd;
copy_to_user(si->udata_buf, fname, strlen(fname) + 1);
+// kprintf("%s: copy_to_user si->udata_buf:%s,fname:%s\n",
+// __FUNCTION__, si->udata_buf, fname);
fd = linux_open(si->udata_buf, flag, mode);
return fd;
}
@@ -304,6 +307,8 @@ static int
pager_unlink(struct swapinfo *si, char *fname)
{
copy_to_user(si->udata_buf, fname, strlen(fname) + 1);
+// kprintf("%s: copy_to_user si->udata_buf:%s,fname:%s\n",
+// __FUNCTION__, si->udata_buf, fname);
return linux_unlink(si->udata_buf);
}
@@ -403,6 +408,9 @@ mlocklist_morereq(struct swapinfo *si, unsigned long *start)
{
struct areaent went,*ent = si->mlock_area.tail;
copy_from_user(&went, ent, sizeof(struct areaent));
+// kprintf("%s: copy_from_user went.count:%d,ent->count:%d\n",
+// __FUNCTION__, went.count, ent->count); //test case 1
+
dkprintf("mlocklist_morereq: start = %ld and = %ld\n",
went.pair[went.count].start, went.pair[went.count].end);
@@ -421,6 +429,8 @@ arealist_alloc(struct swapinfo *si, struct arealist *areap)
if (areap->head == NULL) return -ENOMEM;
memset(&went, 0, sizeof(struct areaent));
copy_to_user(areap->head, &went, sizeof(struct areaent));
+// kprintf("%s: copy_to_user went.count:%d,areap->head->count:%d\n",
+// __FUNCTION__, went.count, areap->head->count); //test case
return 0;
}
@@ -465,6 +475,8 @@ arealist_get(struct swapinfo *si, struct addrpair **pair, struct arealist *area)
memset(&wtmp, 0, sizeof(struct areaent));
copy_to_user(tmp, &wtmp, sizeof(struct areaent));
copy_to_user(&(area->tail->next), &tmp, sizeof(struct areaent *));
+// kprintf("%s: copy_to_user wtmp.count:%d,tmp->count:%d area->tail->next %x:%x\n",
+// __FUNCTION__, wtmp.count, tmp->count, area->tail->next, tmp); //test case
area->tail = tmp;
if (pair) *pair = area->tail->pair;
@@ -476,8 +488,13 @@ arealist_update(int cnt, struct arealist *area)
{
int i;
copy_from_user(&i, &(area->tail->count), sizeof(int));
+// kprintf("%s: copy_from_user i:%d, area->tail->count:%d\n",
+// __FUNCTION__, i, area->tail->count); //test case 2
+
i += cnt;
copy_to_user(&(area->tail->count), &i, sizeof(int));
+ kprintf("%s: copy_to_user i:%d, area->tail->count:%d\n",
+ __FUNCTION__, i, area->tail->count); //test case
area->count += cnt;
}
@@ -492,6 +509,8 @@ arealist_add(struct swapinfo *si, unsigned long start, unsigned long end,
if (cc < 0) return -1;
waddr.start = start; waddr.end = end; waddr.flag = flag;
copy_to_user(addr, &waddr, sizeof(struct addrpair));
+ kprintf("%s: copy_to_user addr->start:%x, waddr.start:%x\n",
+ __FUNCTION__, addr->start, waddr.start); //test case
arealist_update(1, area);
return 0;
@@ -510,11 +529,17 @@ arealist_preparewrite(struct arealist *areap, struct swap_areainfo *info,
for (ent = areap->head; ent != NULL; ent = ent->next) {
int i;
copy_from_user(&went, ent, sizeof(struct areaent));
+// kprintf("%s: copy_from_user went.count:%d,ent->count:%d\n",
+// __FUNCTION__, went.count, ent->count); //test case 3
+
for (i = 0; i < went.count; i++, count++) {
ssize_t sz = went.pair[i].end - went.pair[i].start;
copy_to_user(&(info[count].start), &(went.pair[i].start), sizeof(unsigned long));
copy_to_user(&(info[count].end), &(went.pair[i].end), sizeof(unsigned long));
copy_to_user(&(info[count].flag), &(went.pair[i].flag), sizeof(unsigned long));
+// kprintf("%s: copy_to_user info[%d].start:%x,end:%x,flag:%x ,went.pair[%d].start:%x,end:%x,flag:%x\n",
+// __FUNCTION__, count, info[count].start, info[count].end, info[count].flag,
+// i, went.pair[i].start, went.pair[i].end, went.pair[i].flag); //test case
if (flag) { /* position in file */
pos = off + totsz;
@@ -526,6 +551,8 @@ arealist_preparewrite(struct arealist *areap, struct swap_areainfo *info,
}
}
copy_to_user(&(info[count].pos), &pos, sizeof(unsigned long));
+// kprintf("%s: copy_to_user info[%d].pos:%x,pos:%x\n",
+// __FUNCTION__, count, info[count].pos, pos);
totsz += sz;
}
}
@@ -675,8 +702,10 @@ do_pagein(int flag)
// ihk_mc_pt_print_pte(vm->address_space->page_table, (void*) si->swap_info[i].start);
}
linux_close(fd);
+#if 0
print_region("after pagin", vm);
dkprintf("do_pagein: done, currss(%lx)\n", vm->currss);
+#endif
vm->swapinfo = NULL;
kfree(si->swapfname);
kfree(si);
@@ -742,6 +771,8 @@ do_pageout(char *fname, void *buf, size_t size, int flag)
}
copy_to_user(si->udata_buf, si->swapfname, strlen(si->swapfname) + 1);
+ kprintf("%s: copy_to_user si->udata_buf:%s,si->swapfname:%s\n",
+ __FUNCTION__, si->udata_buf, si->swapfname);
fd = linux_open(si->udata_buf, O_RDWR|O_CREAT|O_TRUNC, 0600);
if (fd < 0) {
ekprintf("do_pageout: Cannot open/create file: %s\n", fname);
@@ -807,8 +838,10 @@ do_pageout(char *fname, void *buf, size_t size, int flag)
}
}
}
+#if 0
arealist_print("SWAP", &si->swap_area, si->swap_area.count);
arealist_print("MLOCK", &si->mlock_area, si->mlock_area.count);
+#endif
si->swap_info = myalloc(si, sizeof(struct swap_areainfo)* si->swap_area.count);
si->mlock_info = myalloc(si, sizeof(struct swap_areainfo)* si->mlock_area.count);
if (si->swap_info == NULL || si->mlock_info == NULL) goto nomem;
@@ -819,6 +852,8 @@ do_pageout(char *fname, void *buf, size_t size, int flag)
copy_to_user(&(si->swphdr->version), MCKERNEL_SWAP_VERSION, SWAP_HLEN);
copy_to_user(&(si->swphdr->count_sarea), &(si->swap_area.count), sizeof(unsigned int));
copy_to_user(&(si->swphdr->count_marea), &(si->mlock_area.count), sizeof(unsigned int));
+ kprintf("%s: copy_to_user si->swphdr->magic:%s,si->swphdr->version:%s,si->swphdr->count_sarea:%d,si->swphdr->count_marea:%d,si->swap_area.count:%d,si->mlock_area.count:%d\n",
+ __FUNCTION__, si->swphdr->magic, si->swphdr->version, si->swphdr->count_sarea, si->swphdr->count_marea, si->swap_area.count, si->mlock_area.count);
if ((cc = pager_write(fd, si->swphdr, sizeof(struct swap_header)))
!= sizeof(struct swap_header)) {
if (cc >= 0)
@@ -844,6 +879,9 @@ do_pageout(char *fname, void *buf, size_t size, int flag)
for (i = 0; i < si->swap_area.count; i++) {
struct swap_areainfo sw_info;
copy_from_user(&sw_info, &(si->swap_info[i]), sizeof(struct swap_areainfo));
+// kprintf("%s:1 copy_from_user %x:%x\n",
+// __FUNCTION__, sw_info.start, si->swap_info[i].start); // test case 4
+
sz = sw_info.end - sw_info.start;
if ((cc = pager_write(fd, (void*) sw_info.start, sz)) != sz) {
if (cc >= 0)
@@ -859,6 +897,9 @@ do_pageout(char *fname, void *buf, size_t size, int flag)
for (i = 0; i < si->swap_area.count; i++) {
struct swap_areainfo sw_info;
copy_from_user(&sw_info, &(si->swap_info[i]), sizeof(struct swap_areainfo));
+// kprintf("%s:2 copy_from_user %x:%x\n",
+// __FUNCTION__, sw_info.start, si->swap_info[i].start); // test case 4
+
cc = ihk_mc_pt_free_range(vm->address_space->page_table,
vm,
(void*) sw_info.start,
@@ -880,6 +921,9 @@ do_pageout(char *fname, void *buf, size_t size, int flag)
for (i = 0; i < si->swap_area.count; i++) {
struct swap_areainfo sw_info;
copy_from_user(&sw_info, &(si->swap_info[i]), sizeof(struct swap_areainfo));
+// kprintf("%s:3 copy_from_user %x:%x\n",
+// __FUNCTION__, sw_info.start, si->swap_info[i].start); // test case 4
+
sz = sw_info.end - sw_info.start;
cc = linux_munmap((void*) sw_info.start, sz, 0);
if (cc < 0) {

View File

@@ -0,0 +1,180 @@
diff --git a/kernel/pager.c b/kernel/pager.c
index 2fc1a72..b644460 100644
--- a/kernel/pager.c
+++ b/kernel/pager.c
@@ -65,7 +65,8 @@
* the mlockcntnr structure is used.
* The mlockcntnr keeps the list of
*/
-#define MLOCKADDRS_SIZE 128
+//#define MLOCKADDRS_SIZE 128
+#define MLOCKADDRS_SIZE 8
struct addrpair {
unsigned long start;
unsigned long end;
@@ -296,6 +297,8 @@ pager_open(struct swapinfo *si, char *fname, int flag, int mode)
{
int fd;
copy_to_user(si->udata_buf, fname, strlen(fname) + 1);
+ kprintf("%s: copy_to_user si->udata_buf:%s,fname:%s\n",
+ __FUNCTION__, si->udata_buf, fname);
fd = linux_open(si->udata_buf, flag, mode);
return fd;
}
@@ -304,6 +307,8 @@ static int
pager_unlink(struct swapinfo *si, char *fname)
{
copy_to_user(si->udata_buf, fname, strlen(fname) + 1);
+ kprintf("%s: copy_to_user si->udata_buf:%s,fname:%s\n",
+ __FUNCTION__, si->udata_buf, fname);
return linux_unlink(si->udata_buf);
}
@@ -403,6 +408,9 @@ mlocklist_morereq(struct swapinfo *si, unsigned long *start)
{
struct areaent went,*ent = si->mlock_area.tail;
copy_from_user(&went, ent, sizeof(struct areaent));
+// kprintf("%s: copy_from_user went.count:%d,ent->count:%d\n",
+// __FUNCTION__, went.count, ent->count); //test case 1
+
dkprintf("mlocklist_morereq: start = %ld and = %ld\n",
went.pair[went.count].start, went.pair[went.count].end);
@@ -421,6 +429,8 @@ arealist_alloc(struct swapinfo *si, struct arealist *areap)
if (areap->head == NULL) return -ENOMEM;
memset(&went, 0, sizeof(struct areaent));
copy_to_user(areap->head, &went, sizeof(struct areaent));
+ kprintf("%s: copy_to_user went.count:%d,areap->head->count:%d\n",
+ __FUNCTION__, went.count, areap->head->count); //test case
return 0;
}
@@ -465,6 +475,8 @@ arealist_get(struct swapinfo *si, struct addrpair **pair, struct arealist *area)
memset(&wtmp, 0, sizeof(struct areaent));
copy_to_user(tmp, &wtmp, sizeof(struct areaent));
copy_to_user(&(area->tail->next), &tmp, sizeof(struct areaent *));
+ kprintf("%s: copy_to_user wtmp.count:%d,tmp->count:%d area->tail->next %x:%x\n",
+ __FUNCTION__, wtmp.count, tmp->count, area->tail->next, tmp); //test case
area->tail = tmp;
if (pair) *pair = area->tail->pair;
@@ -476,8 +488,13 @@ arealist_update(int cnt, struct arealist *area)
{
int i;
copy_from_user(&i, &(area->tail->count), sizeof(int));
+// kprintf("%s: copy_from_user i:%d, area->tail->count:%d\n",
+// __FUNCTION__, i, area->tail->count); //test case 2
+
i += cnt;
copy_to_user(&(area->tail->count), &i, sizeof(int));
+// kprintf("%s: copy_to_user i:%d, area->tail->count:%d\n",
+// __FUNCTION__, i, area->tail->count); //test case
area->count += cnt;
}
@@ -492,6 +509,8 @@ arealist_add(struct swapinfo *si, unsigned long start, unsigned long end,
if (cc < 0) return -1;
waddr.start = start; waddr.end = end; waddr.flag = flag;
copy_to_user(addr, &waddr, sizeof(struct addrpair));
+// kprintf("%s: copy_to_user addr->start:%x, waddr.start:%x\n",
+// __FUNCTION__, addr->start, waddr.start); //test case
arealist_update(1, area);
return 0;
@@ -510,11 +529,17 @@ arealist_preparewrite(struct arealist *areap, struct swap_areainfo *info,
for (ent = areap->head; ent != NULL; ent = ent->next) {
int i;
copy_from_user(&went, ent, sizeof(struct areaent));
+// kprintf("%s: copy_from_user went.count:%d,ent->count:%d\n",
+// __FUNCTION__, went.count, ent->count); //test case 3
+
for (i = 0; i < went.count; i++, count++) {
ssize_t sz = went.pair[i].end - went.pair[i].start;
copy_to_user(&(info[count].start), &(went.pair[i].start), sizeof(unsigned long));
copy_to_user(&(info[count].end), &(went.pair[i].end), sizeof(unsigned long));
copy_to_user(&(info[count].flag), &(went.pair[i].flag), sizeof(unsigned long));
+ kprintf("%s: copy_to_user info[%d].start:%x,end:%x,flag:%x ,went.pair[%d].start:%x,end:%x,flag:%x\n",
+ __FUNCTION__, count, info[count].start, info[count].end, info[count].flag,
+ i, went.pair[i].start, went.pair[i].end, went.pair[i].flag); //test case
if (flag) { /* position in file */
pos = off + totsz;
@@ -526,6 +551,8 @@ arealist_preparewrite(struct arealist *areap, struct swap_areainfo *info,
}
}
copy_to_user(&(info[count].pos), &pos, sizeof(unsigned long));
+ kprintf("%s: copy_to_user info[%d].pos:%x,pos:%x\n",
+ __FUNCTION__, count, info[count].pos, pos);
totsz += sz;
}
}
@@ -675,8 +702,10 @@ do_pagein(int flag)
// ihk_mc_pt_print_pte(vm->address_space->page_table, (void*) si->swap_info[i].start);
}
linux_close(fd);
+#if 0
print_region("after pagin", vm);
dkprintf("do_pagein: done, currss(%lx)\n", vm->currss);
+#endif
vm->swapinfo = NULL;
kfree(si->swapfname);
kfree(si);
@@ -742,6 +771,8 @@ do_pageout(char *fname, void *buf, size_t size, int flag)
}
copy_to_user(si->udata_buf, si->swapfname, strlen(si->swapfname) + 1);
+// kprintf("%s: copy_to_user si->udata_buf:%s,si->swapfname:%s\n",
+// __FUNCTION__, si->udata_buf, si->swapfname);
fd = linux_open(si->udata_buf, O_RDWR|O_CREAT|O_TRUNC, 0600);
if (fd < 0) {
ekprintf("do_pageout: Cannot open/create file: %s\n", fname);
@@ -807,8 +838,10 @@ do_pageout(char *fname, void *buf, size_t size, int flag)
}
}
}
+#if 0
arealist_print("SWAP", &si->swap_area, si->swap_area.count);
arealist_print("MLOCK", &si->mlock_area, si->mlock_area.count);
+#endif
si->swap_info = myalloc(si, sizeof(struct swap_areainfo)* si->swap_area.count);
si->mlock_info = myalloc(si, sizeof(struct swap_areainfo)* si->mlock_area.count);
if (si->swap_info == NULL || si->mlock_info == NULL) goto nomem;
@@ -819,6 +852,8 @@ do_pageout(char *fname, void *buf, size_t size, int flag)
copy_to_user(&(si->swphdr->version), MCKERNEL_SWAP_VERSION, SWAP_HLEN);
copy_to_user(&(si->swphdr->count_sarea), &(si->swap_area.count), sizeof(unsigned int));
copy_to_user(&(si->swphdr->count_marea), &(si->mlock_area.count), sizeof(unsigned int));
+// kprintf("%s: copy_to_user si->swphdr->magic:%s,si->swphdr->version:%s,si->swphdr->count_sarea:%d,si->swphdr->count_marea:%d,si->swap_area.count:%d,si->mlock_area.count:%d\n",
+// __FUNCTION__, si->swphdr->magic, si->swphdr->version, si->swphdr->count_sarea, si->swphdr->count_marea, si->swap_area.count, si->mlock_area.count);
if ((cc = pager_write(fd, si->swphdr, sizeof(struct swap_header)))
!= sizeof(struct swap_header)) {
if (cc >= 0)
@@ -844,6 +879,9 @@ do_pageout(char *fname, void *buf, size_t size, int flag)
for (i = 0; i < si->swap_area.count; i++) {
struct swap_areainfo sw_info;
copy_from_user(&sw_info, &(si->swap_info[i]), sizeof(struct swap_areainfo));
+// kprintf("%s:1 copy_from_user %x:%x\n",
+// __FUNCTION__, sw_info.start, si->swap_info[i].start); // test case 4
+
sz = sw_info.end - sw_info.start;
if ((cc = pager_write(fd, (void*) sw_info.start, sz)) != sz) {
if (cc >= 0)
@@ -859,6 +897,9 @@ do_pageout(char *fname, void *buf, size_t size, int flag)
for (i = 0; i < si->swap_area.count; i++) {
struct swap_areainfo sw_info;
copy_from_user(&sw_info, &(si->swap_info[i]), sizeof(struct swap_areainfo));
+// kprintf("%s:2 copy_from_user %x:%x\n",
+// __FUNCTION__, sw_info.start, si->swap_info[i].start); // test case 4
+
cc = ihk_mc_pt_free_range(vm->address_space->page_table,
vm,
(void*) sw_info.start,
@@ -880,6 +921,9 @@ do_pageout(char *fname, void *buf, size_t size, int flag)
for (i = 0; i < si->swap_area.count; i++) {
struct swap_areainfo sw_info;
copy_from_user(&sw_info, &(si->swap_info[i]), sizeof(struct swap_areainfo));
+// kprintf("%s:3 copy_from_user %x:%x\n",
+// __FUNCTION__, sw_info.start, si->swap_info[i].start); // test case 4
+
sz = sw_info.end - sw_info.start;
cc = linux_munmap((void*) sw_info.start, sz, 0);
if (cc < 0) {

View File

@@ -0,0 +1,13 @@
diff --git a/executer/user/qlmpilib.c b/executer/user/qlmpilib.c
index 7fcbcb5..e373839 100644
--- a/executer/user/qlmpilib.c
+++ b/executer/user/qlmpilib.c
@@ -158,7 +158,7 @@ int ql_client(int *argc,char ***argv)
syscall(803);
rc = PMI_Barrier();
- rc = swapout(swap_file, buffer, BUF_SIZE, 1);
+ rc = swapout(swap_file, buffer, BUF_SIZE, 3);
#ifdef QL_DEBUG
printf(" swapout rc=%d\n",rc);

View File

@@ -0,0 +1,85 @@
diff --git a/arch/x86_64/kernel/syscall.c b/arch/x86_64/kernel/syscall.c
index 29dbd04..66f77b5 100644
--- a/arch/x86_64/kernel/syscall.c
+++ b/arch/x86_64/kernel/syscall.c
@@ -1936,6 +1936,8 @@ int do_process_vm_read_writev(int pid,
struct vm_range *range;
struct mcs_rwlock_node_irqsave lock;
struct mcs_rwlock_node update_lock;
+ kprintf("%s: arg2_addr:%x,arg4_addr:%x\n",
+ __FUNCTION__, local_iov, remote_iov); //PATCH
/* Sanity checks */
if (flags) {
@@ -2212,6 +2214,8 @@ int move_pages_smp_handler(int cpu_index, int nr_cpus, void *arg)
int count = mpsr->count;
struct page_table *save_pt;
extern struct page_table *get_init_page_table(void);
+ kprintf("%s: mpsr->user_virt_addr:%x,mpsr->user_nodes:%x,mpsr->user_status:%x\n",
+ __FUNCTION__, mpsr->user_virt_addr, mpsr->user_nodes, mpsr->user_status); //PATCH
i_s = (count / nr_cpus) * cpu_index;
i_e = i_s + (count / nr_cpus);
diff --git a/kernel/futex.c b/kernel/futex.c
index 495ee50..a7d08e2 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -749,6 +749,8 @@ static int futex_wait_setup(uint32_t __user *uaddr, uint32_t val, int fshared,
*hb = queue_lock(q);
ret = get_futex_value_locked(&uval, uaddr);
+ kprintf("get_futex_value_locked: uval:%d,*uaddr:%d,uaddr:%x\n",
+ uval, *uaddr, uaddr); //PATCH
if (ret) {
queue_unlock(q, *hb);
put_futex_key(fshared, &q->key);
diff --git a/kernel/syscall.c b/kernel/syscall.c
index e7fed5d..9c174c9 100644
--- a/kernel/syscall.c
+++ b/kernel/syscall.c
@@ -3827,6 +3827,8 @@ mc_perf_event_alloc(struct perf_event_attr *attr)
if (!attr) {
return NULL;
}
+ kprintf("%s: attr->disabled:%d,attr->exclude_kernel:%d\n",
+ __FUNCTION__, attr->disabled, attr->exclude_kernel); //PATCH
event = kmalloc(sizeof(struct mc_perf_event), IHK_MC_AP_NOWAIT);
if (!event) {
@@ -5340,6 +5342,9 @@ SYSCALL_DECLARE(futex)
struct ihk_os_cpu_monitor *monitor = cpu_local_var(monitor);
monitor->status = IHK_OS_MONITOR_KERNEL_HEAVY;
+
+ kprintf("%s:*uaddr:%d,uaddr:%x\n",
+ __FUNCTION__, *uaddr, uaddr); //PATCH
/* Cross-address space futex? */
if (op & FUTEX_PRIVATE_FLAG) {
@@ -8720,6 +8725,8 @@ SYSCALL_DECLARE(move_pages)
int ret = 0;
unsigned long t_s, t_e;
+ kprintf("%s: user_virt_addr:%x,user_nodes:%x,user_status:%x\n",
+ __FUNCTION__, user_virt_addr, user_nodes, user_status); //PATCH
t_s = rdtsc();
@@ -8905,6 +8912,8 @@ SYSCALL_DECLARE(process_vm_writev)
(const struct iovec *)ihk_mc_syscall_arg3(ctx);
unsigned long riovcnt = ihk_mc_syscall_arg4(ctx);
unsigned long flags = ihk_mc_syscall_arg5(ctx);
+ kprintf("%s: arg2_addr:%x,arg4_addr:%x\n",
+ __FUNCTION__, local_iov, remote_iov); //PATCH
return do_process_vm_read_writev(pid, local_iov, liovcnt,
remote_iov, riovcnt, flags, PROCESS_VM_WRITE);
@@ -8920,6 +8929,8 @@ SYSCALL_DECLARE(process_vm_readv)
(const struct iovec *)ihk_mc_syscall_arg3(ctx);
unsigned long riovcnt = ihk_mc_syscall_arg4(ctx);
unsigned long flags = ihk_mc_syscall_arg5(ctx);
+ kprintf("%s: arg2_addr:%x,arg4_addr:%x\n",
+ __FUNCTION__, local_iov, remote_iov); //PATCH
return do_process_vm_read_writev(pid, local_iov, liovcnt,
remote_iov, riovcnt, flags, PROCESS_VM_READ);