my state.

trying to get some memory optimisation (less pagetable reloading,
less tlb purging) features working smoothly.

to be documented when committing to trunk :)
This commit is contained in:
Ben Gras
2009-06-06 23:27:10 +00:00
parent 9d56ac3fc9
commit 4dae6c4bbc
30 changed files with 721 additions and 588 deletions

View File

@@ -63,19 +63,8 @@ register message *m_ptr; /* pointer to request message */
}
if (i >= nr_io_range)
{
static int curr= 0, limit= 100, extra= 20;
if (curr < limit+extra)
{
kprintf("do_devio: port 0x%x (size %d) not allowed\n",
m_ptr->DIO_PORT, size);
} else if (curr == limit+extra)
{
kprintf("do_devio: no debug output for a while\n");
}
else if (curr == 2*limit-1)
limit *= 2;
curr++;
return EPERM;
}
}
@@ -83,19 +72,8 @@ register message *m_ptr; /* pointer to request message */
doit:
if (m_ptr->DIO_PORT & (size-1))
{
static int curr= 0, limit= 100, extra= 20;
if (curr < limit+extra)
{
kprintf("do_devio: unaligned port 0x%x (size %d)\n",
m_ptr->DIO_PORT, size);
} else if (curr == limit+extra)
{
kprintf("do_devio: no debug output for a while\n");
}
else if (curr == 2*limit-1)
limit *= 2;
curr++;
return EPERM;
}

View File

@@ -90,7 +90,7 @@ register message *m_ptr; /* pointer to request message */
/* Calculate endpoint identifier, so caller knows what it is. */
m_ptr->PR_ENDPT = rpc->p_endpoint;
m_ptr->PR_FORK_MSGADDR = (char *) rpp->p_delivermsg_lin;
m_ptr->PR_FORK_MSGADDR = (char *) rpp->p_delivermsg_vir;
/* Install new map */
r = newmap(rpc, map_ptr);

View File

@@ -8,6 +8,7 @@
*/
#include "../system.h"
#include "../vm.h"
#if USE_MEMSET

View File

@@ -61,22 +61,11 @@ endpoint_t *e_granter; /* new granter (magic grants) */
if(!HASGRANTTABLE(granter_proc)) return EPERM;
if(priv(granter_proc)->s_grant_entries <= grant) {
static int curr= 0, limit= 100, extra= 20;
if (curr < limit+extra)
{
kprintf(
"verify_grant: grant verify failed in ep %d proc %d: "
"grant %d out of range for table size %d\n",
granter, proc_nr, grant,
priv(granter_proc)->s_grant_entries);
} else if (curr == limit+extra)
{
kprintf("verify_grant: no debug output for a while\n");
}
else if (curr == 2*limit-1)
limit *= 2;
curr++;
return(EPERM);
}
@@ -219,23 +208,9 @@ int access; /* CPF_READ for a copy from granter to grantee, CPF_WRITE
/* Verify permission exists. */
if((r=verify_grant(granter, grantee, grantid, bytes, access,
g_offset, &v_offset, &new_granter)) != OK) {
static int curr= 0, limit= 100, extra= 20;
if (curr < limit+extra)
{
#if 0
kprintf(
"grant %d verify to copy %d->%d by %d failed: err %d\n",
grantid, *src, *dst, grantee, r);
#endif
} else if (curr == limit+extra)
{
kprintf(
"do_safecopy`safecopy: no debug output for a while\n");
}
else if (curr == 2*limit-1)
limit *= 2;
curr++;
return r;
}

View File

@@ -13,6 +13,8 @@
#include <minix/type.h>
#include <minix/config.h>
extern int verifyrange;
/*===========================================================================*
* do_vmctl *
*===========================================================================*/
@@ -21,7 +23,7 @@ register message *m_ptr; /* pointer to request message */
{
int proc_nr, i;
endpoint_t ep = m_ptr->SVMCTL_WHO;
struct proc *p, *rp;
struct proc *p, *rp, *target;
if(ep == SELF) { ep = m_ptr->m_source; }
@@ -40,15 +42,25 @@ register message *m_ptr; /* pointer to request message */
/* Send VM the information about the memory request. */
if(!(rp = vmrequest))
return ESRCH;
if(!RTS_ISSET(rp, VMREQUEST))
minix_panic("do_vmctl: no VMREQUEST set", NO_NUM);
vmassert(RTS_ISSET(rp, VMREQUEST));
#if 0
printf("kernel: vm request sent by: %s / %d about %d; 0x%lx-0x%lx, wr %d\n",
printf("kernel: vm request sent by: %s / %d about %d; 0x%lx-0x%lx, wr %d, stack: %s ",
rp->p_name, rp->p_endpoint, rp->p_vmrequest.who,
rp->p_vmrequest.start,
rp->p_vmrequest.start + rp->p_vmrequest.length,
rp->p_vmrequest.writeflag);
rp->p_vmrequest.writeflag, rp->p_vmrequest.stacktrace);
printf("type %d\n", rp->p_vmrequest.type);
#endif
#if DEBUG_VMASSERT
okendpt(rp->p_vmrequest.who, &proc_nr);
target = proc_addr(proc_nr);
if(!RTS_ISSET(target, VMREQTARGET)) {
printf("set stack: %s\n", rp->p_vmrequest.stacktrace);
minix_panic("VMREQTARGET not set for target",
NO_NUM);
}
#endif
/* Reply with request fields. */
@@ -56,6 +68,7 @@ register message *m_ptr; /* pointer to request message */
m_ptr->SVMCTL_MRG_LEN = rp->p_vmrequest.length;
m_ptr->SVMCTL_MRG_WRITE = rp->p_vmrequest.writeflag;
m_ptr->SVMCTL_MRG_EP = rp->p_vmrequest.who;
m_ptr->SVMCTL_MRG_REQUESTOR = (void *) rp->p_endpoint;
rp->p_vmrequest.vmresult = VMSUSPEND;
/* Remove from request chain. */
@@ -63,41 +76,84 @@ register message *m_ptr; /* pointer to request message */
return OK;
case VMCTL_MEMREQ_REPLY:
if(!(rp = p->p_vmrequest.requestor))
minix_panic("do_vmctl: no requestor set", ep);
p->p_vmrequest.requestor = NULL;
if(!RTS_ISSET(rp, VMREQUEST))
minix_panic("do_vmctl: no VMREQUEST set", ep);
if(rp->p_vmrequest.vmresult != VMSUSPEND)
minix_panic("do_vmctl: result not VMSUSPEND set",
rp->p_vmrequest.vmresult);
rp->p_vmrequest.vmresult = m_ptr->SVMCTL_VALUE;
if(rp->p_vmrequest.vmresult == VMSUSPEND)
minix_panic("VM returned VMSUSPEND?", NO_NUM);
if(rp->p_vmrequest.vmresult != OK)
vmassert(RTS_ISSET(p, VMREQUEST));
vmassert(p->p_vmrequest.vmresult == VMSUSPEND);
okendpt(p->p_vmrequest.who, &proc_nr);
target = proc_addr(proc_nr);
p->p_vmrequest.vmresult = m_ptr->SVMCTL_VALUE;
vmassert(p->p_vmrequest.vmresult != VMSUSPEND);
if(p->p_vmrequest.vmresult != OK)
kprintf("SYSTEM: VM replied %d to mem request\n",
rp->p_vmrequest.vmresult);
p->p_vmrequest.vmresult);
/* Put on restart chain. */
rp->p_vmrequest.nextrestart = vmrestart;
vmrestart = rp;
#if 0
printf("memreq reply: vm request sent by: %s / %d about %d; 0x%lx-0x%lx, wr %d, stack: %s ",
p->p_name, p->p_endpoint, p->p_vmrequest.who,
p->p_vmrequest.start,
p->p_vmrequest.start + p->p_vmrequest.length,
p->p_vmrequest.writeflag, p->p_vmrequest.stacktrace);
printf("type %d\n", p->p_vmrequest.type);
#endif
#if DEBUG_VMASSERT
{
vmassert(target->p_rts_flags);
/* Sanity check. */
if(rp->p_vmrequest.vmresult == OK) {
if(CHECKRANGE(p,
rp->p_vmrequest.start,
rp->p_vmrequest.length,
rp->p_vmrequest.writeflag) != OK) {
kprintf("SYSTEM: request %d:0x%lx-0x%lx, wrflag %d, failed\n",
rp->p_endpoint,
rp->p_vmrequest.start, rp->p_vmrequest.start + rp->p_vmrequest.length,
rp->p_vmrequest.writeflag);
if(p->p_vmrequest.vmresult == OK) {
int r;
vmassert(!verifyrange);
verifyrange = 1;
r = CHECKRANGE(target,
p->p_vmrequest.start,
p->p_vmrequest.length,
p->p_vmrequest.writeflag);
vmassert(verifyrange);
verifyrange = 0;
if(r != OK) {
kprintf("SYSTEM: request by %d: on ep %d: 0x%lx-0x%lx, wrflag %d, stack %s, failed\n",
p->p_endpoint, target->p_endpoint,
p->p_vmrequest.start, p->p_vmrequest.start + p->p_vmrequest.length,
p->p_vmrequest.writeflag,
p->p_vmrequest.stacktrace);
printf("printing pt of %d (0x%lx)\n",
vm_print(target->p_endpoint),
target->p_seg.p_cr3
);
vm_print(target->p_seg.p_cr3);
minix_panic("SYSTEM: fail but VM said OK", NO_NUM);
}
}
}
}
}
#endif
vmassert(RTS_ISSET(target, VMREQTARGET));
RTS_LOCK_UNSET(target, VMREQTARGET);
if(p->p_vmrequest.type == VMSTYPE_KERNELCALL) {
/* Put on restart chain. */
p->p_vmrequest.nextrestart = vmrestart;
vmrestart = p;
} else if(p->p_vmrequest.type == VMSTYPE_DELIVERMSG) {
vmassert(p->p_misc_flags & MF_DELIVERMSG);
vmassert(p == target);
vmassert(RTS_ISSET(p, VMREQUEST));
vmassert(RTS_ISSET(p, VMREQTARGET));
RTS_LOCK_UNSET(p, VMREQUEST);
RTS_LOCK_UNSET(target, VMREQTARGET);
} else {
#if DEBUG_VMASSERT
printf("suspended with stack: %s\n",
p->p_vmrequest.stacktrace);
#endif
minix_panic("strange request type",
p->p_vmrequest.type);
}
return OK;
case VMCTL_ENABLE_PAGING:
if(vm_running)
@@ -105,8 +161,13 @@ kprintf("SYSTEM: request %d:0x%lx-0x%lx, wrflag %d, failed\n",
vm_init(p);
if(!vm_running)
minix_panic("do_vmctl: paging enabling failed", NO_NUM);
vmassert(p->p_delivermsg_lin ==
umap_local(p, D, p->p_delivermsg_vir, sizeof(message)));
if(newmap(p, m_ptr->SVMCTL_VALUE) != OK)
minix_panic("do_vmctl: newmap failed", NO_NUM);
p->p_delivermsg_lin =
umap_local(p, D, p->p_delivermsg_vir, sizeof(message));
vmassert(p->p_delivermsg_lin);
return OK;
}