From owner-p4-projects@FreeBSD.ORG Sun May 6 12:49:55 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id F0FDF16A404; Sun, 6 May 2007 12:49:54 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C79AA16A402 for ; Sun, 6 May 2007 12:49:54 +0000 (UTC) (envelope-from rdivacky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id B7E7F13C458 for ; Sun, 6 May 2007 12:49:54 +0000 (UTC) (envelope-from rdivacky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l46Cns4J002411 for ; Sun, 6 May 2007 12:49:54 GMT (envelope-from rdivacky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l46CnsMI002408 for perforce@freebsd.org; Sun, 6 May 2007 12:49:54 GMT (envelope-from rdivacky@FreeBSD.org) Date: Sun, 6 May 2007 12:49:54 GMT Message-Id: <200705061249.l46CnsMI002408@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to rdivacky@FreeBSD.org using -f From: Roman Divacky To: Perforce Change Reviews Cc: Subject: PERFORCE change 119328 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 May 2007 12:49:55 -0000 http://perforce.freebsd.org/chv.cgi?CH=119328 Change 119328 by rdivacky@rdivacky_witten on 2007/05/06 12:49:50 Replace Giant with our own sx lock. There is no point in using Giant. The locking might need some review but it should be safe as it is (just inefficient). Affected files ... .. //depot/projects/soc2007/rdivacky/linux_futex/sys/amd64/linux32/linux32_sysvec.c#2 edit .. //depot/projects/soc2007/rdivacky/linux_futex/sys/compat/linux/linux_futex.c#5 edit .. //depot/projects/soc2007/rdivacky/linux_futex/sys/i386/linux/linux_sysvec.c#2 edit Differences ... ==== //depot/projects/soc2007/rdivacky/linux_futex/sys/amd64/linux32/linux32_sysvec.c#2 (text+ko) ==== @@ -125,6 +125,7 @@ extern LIST_HEAD(futex_list, futex) futex_list; extern struct sx futex_sx; +extern struct sx futex_lock; static eventhandler_tag linux_exit_tag; static eventhandler_tag linux_schedtail_tag; @@ -1084,7 +1085,8 @@ mtx_init(&emul_lock, "emuldata lock", NULL, MTX_DEF); sx_init(&emul_shared_lock, "emuldata->shared lock"); LIST_INIT(&futex_list); - sx_init(&futex_sx, "futex protection lock"); + sx_init(&futex_sx, "futex list protection lock"); + sx_init(&futex_lock, "futex protection lock"); linux_exit_tag = EVENTHANDLER_REGISTER(process_exit, linux_proc_exit, NULL, 1000); linux_schedtail_tag = EVENTHANDLER_REGISTER(schedtail, linux_schedtail, @@ -1115,6 +1117,7 @@ mtx_destroy(&emul_lock); sx_destroy(&emul_shared_lock); sx_destroy(&futex_sx); + sx_destroy(&futex_lock); EVENTHANDLER_DEREGISTER(process_exit, linux_exit_tag); EVENTHANDLER_DEREGISTER(schedtail, linux_schedtail_tag); EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag); ==== //depot/projects/soc2007/rdivacky/linux_futex/sys/compat/linux/linux_futex.c#5 (text+ko) ==== @@ -75,6 +75,7 @@ LIST_HEAD(futex_list, futex) futex_list; struct sx futex_sx; /* this protects the LIST of futexes */ +struct sx futex_lock; #define FUTEX_LOCK sx_xlock(&futex_sx) #define FUTEX_UNLOCK sx_xunlock(&futex_sx) @@ -82,8 +83,8 @@ #define FUTEX_LOCKED 1 #define FUTEX_UNLOCKED 0 -#define FUTEX_SYSTEM_LOCK mtx_lock(&Giant) -#define FUTEX_SYSTEM_UNLOCK mtx_unlock(&Giant) +#define FUTEX_SYSTEM_LOCK sx_xlock(&futex_lock) +#define FUTEX_SYSTEM_UNLOCK sx_xunlock(&futex_lock) static struct futex *futex_get(void *, int); static void futex_put(struct futex *); @@ -390,7 +391,7 @@ printf("FUTEX --> %d tlseep timeout = %ld\n", td->td_proc->p_pid, timeout); #endif - ret = tsleep(wp, PCATCH | PZERO, "linuxfutex", timeout); + ret = sx_sleep(wp, &futex_lock, PCATCH | PZERO, "linuxfutex", timeout); #ifdef DEBUG if (ldebug(sys_futex)) printf("FUTEX -> %d tsleep returns %d\n", ==== //depot/projects/soc2007/rdivacky/linux_futex/sys/i386/linux/linux_sysvec.c#2 (text+ko) ==== @@ -109,6 +109,7 @@ extern LIST_HEAD(futex_list, futex) futex_list; extern struct sx futex_sx; +extern struct sx futex_lock; static eventhandler_tag linux_exit_tag; static eventhandler_tag linux_schedtail_tag; @@ -920,7 +921,8 @@ mtx_init(&emul_lock, "emuldata lock", NULL, MTX_DEF); sx_init(&emul_shared_lock, "emuldata->shared lock"); LIST_INIT(&futex_list); - sx_init(&futex_sx, "futex protection lock"); + sx_init(&futex_sx, "futex list protection lock"); + sx_init(&futex_lock, "futex protection lock"); linux_exit_tag = EVENTHANDLER_REGISTER(process_exit, linux_proc_exit, NULL, 1000); linux_schedtail_tag = EVENTHANDLER_REGISTER(schedtail, linux_schedtail, @@ -951,6 +953,7 @@ mtx_destroy(&emul_lock); sx_destroy(&emul_shared_lock); sx_destroy(&futex_sx); + sx_destroy(&futex_lock); EVENTHANDLER_DEREGISTER(process_exit, linux_exit_tag); EVENTHANDLER_DEREGISTER(schedtail, linux_schedtail_tag); EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag);