Date: Wed, 16 Aug 2006 12:48:50 GMT From: Roman Divacky <rdivacky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 104214 for review Message-ID: <200608161248.k7GCmod7065948@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <sys/queue.h> #include <sys/lock.h> #include <sys/mutex.h> +#include <sys/sx.h> #include <sys/malloc.h> #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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200608161248.k7GCmod7065948>