Commit 7c2d6a781cb806fdb99837015c773398f582caf1
1 parent
f1510b2c
faster task switch
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@270 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
14 additions
and
4 deletions
exec.c
| ... | ... | @@ -585,22 +585,32 @@ void page_unmap(void) |
| 585 | 585 | { |
| 586 | 586 | PageDesc *p, *pmap; |
| 587 | 587 | unsigned long addr; |
| 588 | - int i, j, ret; | |
| 588 | + int i, j, ret, j1; | |
| 589 | 589 | |
| 590 | 590 | for(i = 0; i < L1_SIZE; i++) { |
| 591 | 591 | pmap = l1_map[i]; |
| 592 | 592 | if (pmap) { |
| 593 | 593 | p = pmap; |
| 594 | - for(j = 0;j < L2_SIZE; j++) { | |
| 594 | + for(j = 0;j < L2_SIZE;) { | |
| 595 | 595 | if (p->flags & PAGE_VALID) { |
| 596 | 596 | addr = (i << (32 - L1_BITS)) | (j << TARGET_PAGE_BITS); |
| 597 | - ret = munmap((void *)addr, TARGET_PAGE_SIZE); | |
| 597 | + /* we try to find a range to make less syscalls */ | |
| 598 | + j1 = j; | |
| 599 | + p++; | |
| 600 | + j++; | |
| 601 | + while (j < L2_SIZE && (p->flags & PAGE_VALID)) { | |
| 602 | + p++; | |
| 603 | + j++; | |
| 604 | + } | |
| 605 | + ret = munmap((void *)addr, (j - j1) << TARGET_PAGE_BITS); | |
| 598 | 606 | if (ret != 0) { |
| 599 | 607 | fprintf(stderr, "Could not unmap page 0x%08lx\n", addr); |
| 600 | 608 | exit(1); |
| 601 | 609 | } |
| 610 | + } else { | |
| 611 | + p++; | |
| 612 | + j++; | |
| 602 | 613 | } |
| 603 | - p++; | |
| 604 | 614 | } |
| 605 | 615 | free(pmap); |
| 606 | 616 | l1_map[i] = NULL; | ... | ... |