From 8ca0ca9cfb1e5081c5ff488f9c74d6306f50ddb1 Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Fri, 1 May 2009 14:52:06 +0300 Subject: [PATCH] UTCBs are mmap'ed only when needed. In case of cloned threads, UTCBs may or may not need to be mmapped. This is now checked before the do_mmap call via find_vma(). --- tasks/mm0/src/utcb.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tasks/mm0/src/utcb.c b/tasks/mm0/src/utcb.c index c5ab58e..041130f 100644 --- a/tasks/mm0/src/utcb.c +++ b/tasks/mm0/src/utcb.c @@ -9,6 +9,7 @@ #include #include #include +#include /* * UTCB management in Codezero @@ -108,13 +109,17 @@ int task_setup_utcb(struct tcb *task) slot = task_new_utcb_desc(task); out: - /* Map this region as private to current task */ - if (IS_ERR(err = do_mmap(0, 0, task, slot, - VMA_ANONYMOUS | VMA_PRIVATE | VMA_FIXED | - VM_READ | VM_WRITE, 1))) { - printf("UTCB: mmapping failed with %d\n", err); - return (int)err; - } + /* Check if utcb is already mapped (in case of multiple threads) */ + if (!find_vma(slot, &task->vm_area_head->list)) { + /* Map this region as private to current task */ + if (IS_ERR(err = do_mmap(0, 0, task, slot, + VMA_ANONYMOUS | VMA_PRIVATE | + VMA_FIXED | VM_READ | VM_WRITE, 1))) { + printf("UTCB: mmapping failed with %d\n", err); + return (int)err; + } + } else + printf("UTCB at 0x%x already mapped.\n", slot); /* Assign task's utcb address */ task->utcb_address = slot;