From owner-p4-projects@FreeBSD.ORG Wed Aug 16 12:48:51 2006 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 AE72B16A4DF; Wed, 16 Aug 2006 12:48:51 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 56B0516A4DD for ; Wed, 16 Aug 2006 12:48:51 +0000 (UTC) (envelope-from rdivacky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1AA6A43D45 for ; Wed, 16 Aug 2006 12:48:51 +0000 (GMT) (envelope-from rdivacky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k7GCmopg065951 for ; Wed, 16 Aug 2006 12:48:50 GMT (envelope-from rdivacky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k7GCmod7065948 for perforce@freebsd.org; Wed, 16 Aug 2006 12:48:50 GMT (envelope-from rdivacky@FreeBSD.org) Date: Wed, 16 Aug 2006 12:48:50 GMT Message-Id: <200608161248.k7GCmod7065948@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 104214 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: Wed, 16 Aug 2006 12:48:51 -0000 http://perforce.freebsd.org/chv.cgi?CH=104214 Change 104214 by rdivacky@rdivacky_witten on 2006/08/16 12:48:16 Change futex lock from mutex to sx. Make futex_get atomic (protected by the futex lock). Affected files ... .. //depot/projects/soc2006/rdivacky_linuxolator/amd64/linux32/linux32_sysvec.c#8 edit .. //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_futex.c#28 edit .. //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux_sysvec.c#17 edit Differences ... ==== //depot/projects/soc2006/rdivacky_linuxolator/amd64/linux32/linux32_sysvec.c#8 (text+ko) ==== @@ -124,7 +124,7 @@ static void linux32_fixlimits(struct proc *p); extern LIST_HEAD(futex_list, futex) futex_list; -extern struct mtx futex_mtx; +extern struct sx futex_sx; static eventhandler_tag linux_exit_tag; static eventhandler_tag linux_schedtail_tag; @@ -1079,7 +1079,7 @@ linux_device_register_handler(*ldhp); sx_init(&emul_shared_lock, "emuldata->shared lock"); LIST_INIT(&futex_list); - mtx_init(&futex_mtx, "futex protection lock", NULL, MTX_DEF); + sx_init(&futex_sx, "futex protection lock"); linux_exit_tag = EVENTHANDLER_REGISTER(process_exit, linux_proc_exit, NULL, 1000); linux_schedtail_tag = EVENTHANDLER_REGISTER(schedtail, linux_schedtail, @@ -1109,7 +1109,7 @@ linux_device_unregister_handler(*ldhp); sx_destroy(&emul_lock); sx_destroy(&emul_shared_lock); - mtx_destroy(&futex_mtx); + sx_destroy(&futex_sx); EVENTHANDLER_DEREGISTER(process_exit, linux_exit_tag); EVENTHANDLER_DEREGISTER(schedtail, linux_schedtail_tag); EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag); ==== //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_futex.c#28 (text+ko) ==== @@ -47,6 +47,7 @@ #include #include #include +#include #include #ifdef COMPAT_LINUX32 @@ -73,10 +74,10 @@ }; LIST_HEAD(futex_list, futex) futex_list; -struct mtx futex_mtx; /* this protects the LIST of futexes */ +struct sx futex_sx; /* this protects the LIST of futexes */ -#define FUTEX_LOCK mtx_lock(&futex_mtx) -#define FUTEX_UNLOCK mtx_unlock(&futex_mtx) +#define FUTEX_LOCK sx_xlock(&futex_sx) +#define FUTEX_UNLOCK sx_xunlock(&futex_sx) #define FUTEX_LOCKED 1 #define FUTEX_UNLOCKED 0 @@ -339,13 +340,8 @@ return f; } } - if (locked == FUTEX_UNLOCKED) - FUTEX_UNLOCK; - /* Not found, create it */ f = malloc(sizeof(*f), M_LINUX, M_WAITOK); - if (locked == FUTEX_UNLOCKED) - FUTEX_LOCK; f->f_uaddr = uaddr; f->f_refcount = 1; TAILQ_INIT(&f->f_waiting_proc); ==== //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux_sysvec.c#17 (text+ko) ==== @@ -108,7 +108,7 @@ u_long stack, u_long ps_strings); extern LIST_HEAD(futex_list, futex) futex_list; -extern struct mtx futex_mtx; +extern struct sx futex_sx; static eventhandler_tag linux_exit_tag; static eventhandler_tag linux_schedtail_tag; @@ -920,7 +920,7 @@ sx_init(&emul_lock, "emuldata lock"); sx_init(&emul_shared_lock, "emuldata->shared lock"); LIST_INIT(&futex_list); - mtx_init(&futex_mtx, "futex protection lock", NULL, MTX_DEF); + sx_init(&futex_sx, "futex protection lock"); linux_exit_tag = EVENTHANDLER_REGISTER(process_exit, linux_proc_exit, NULL, 1000); linux_schedtail_tag = EVENTHANDLER_REGISTER(schedtail, linux_schedtail, @@ -950,7 +950,7 @@ linux_device_unregister_handler(*ldhp); sx_destroy(&emul_lock); sx_destroy(&emul_shared_lock); - mtx_destroy(&futex_mtx); + sx_destroy(&futex_sx); EVENTHANDLER_DEREGISTER(process_exit, linux_exit_tag); EVENTHANDLER_DEREGISTER(schedtail, linux_schedtail_tag); EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag);