From owner-svn-src-stable-7@FreeBSD.ORG Thu Mar 3 22:09:10 2011 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 81B771065694; Thu, 3 Mar 2011 22:09:10 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6F4018FC1A; Thu, 3 Mar 2011 22:09:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p23M9Abi082193; Thu, 3 Mar 2011 22:09:10 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p23M9Amr082190; Thu, 3 Mar 2011 22:09:10 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201103032209.p23M9Amr082190@svn.freebsd.org> From: John Baldwin Date: Thu, 3 Mar 2011 22:09:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r219255 - in stable/7/sys: kern sys X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Mar 2011 22:09:10 -0000 Author: jhb Date: Thu Mar 3 22:09:10 2011 New Revision: 219255 URL: http://svn.freebsd.org/changeset/base/219255 Log: MFC 218969: Expose the umtx_key structure and API to the rest of the kernel. Modified: stable/7/sys/kern/kern_umtx.c stable/7/sys/sys/umtx.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/kern/kern_umtx.c ============================================================================== --- stable/7/sys/kern/kern_umtx.c Thu Mar 3 22:08:51 2011 (r219254) +++ stable/7/sys/kern/kern_umtx.c Thu Mar 3 22:09:10 2011 (r219255) @@ -58,38 +58,9 @@ __FBSDID("$FreeBSD$"); #include #endif -#define TYPE_SIMPLE_WAIT 0 -#define TYPE_CV 1 -#define TYPE_SIMPLE_LOCK 2 -#define TYPE_NORMAL_UMUTEX 3 -#define TYPE_PI_UMUTEX 4 -#define TYPE_PP_UMUTEX 5 -#define TYPE_RWLOCK 6 - #define _UMUTEX_TRY 1 #define _UMUTEX_WAIT 2 -/* Key to represent a unique userland synchronous object */ -struct umtx_key { - int hash; - int type; - int shared; - union { - struct { - vm_object_t object; - uintptr_t offset; - } shared; - struct { - struct vmspace *vs; - uintptr_t addr; - } private; - struct { - void *a; - uintptr_t b; - } both; - } info; -}; - /* Priority inheritance mutex info. */ struct umtx_pi { /* Owner thread */ @@ -185,10 +156,6 @@ struct umtxq_chain { #define UMTX_CHAINS 128 #define UMTX_SHIFTS (__WORD_BIT - 7) -#define THREAD_SHARE 0 -#define PROCESS_SHARE 1 -#define AUTO_SHARE 2 - #define GET_SHARE(flags) \ (((flags) & USYNC_PROCESS_SHARED) == 0 ? THREAD_SHARE : PROCESS_SHARE) @@ -214,10 +181,6 @@ static void umtxq_insert_queue(struct um static void umtxq_remove_queue(struct umtx_q *uq, int q); static int umtxq_sleep(struct umtx_q *uq, const char *wmesg, int timo); static int umtxq_count(struct umtx_key *key); -static int umtx_key_match(const struct umtx_key *k1, const struct umtx_key *k2); -static int umtx_key_get(void *addr, int type, int share, - struct umtx_key *key); -static void umtx_key_release(struct umtx_key *key); static struct umtx_pi *umtx_pi_alloc(int); static void umtx_pi_free(struct umtx_pi *pi); static void umtx_pi_adjust_locked(struct thread *td, u_char oldpri); @@ -280,14 +243,6 @@ umtxq_hash(struct umtx_key *key) key->hash = ((n * GOLDEN_RATIO_PRIME) >> UMTX_SHIFTS) % UMTX_CHAINS; } -static inline int -umtx_key_match(const struct umtx_key *k1, const struct umtx_key *k2) -{ - return (k1->type == k2->type && - k1->info.both.a == k2->info.both.a && - k1->info.both.b == k2->info.both.b); -} - static inline struct umtxq_chain * umtxq_getchain(struct umtx_key *key) { @@ -500,7 +455,7 @@ umtxq_sleep(struct umtx_q *uq, const cha /* * Convert userspace address into unique logical address. */ -static int +int umtx_key_get(void *addr, int type, int share, struct umtx_key *key) { struct thread *td = curthread; @@ -546,7 +501,7 @@ umtx_key_get(void *addr, int type, int s /* * Release key. */ -static inline void +void umtx_key_release(struct umtx_key *key) { if (key->shared) Modified: stable/7/sys/sys/umtx.h ============================================================================== --- stable/7/sys/sys/umtx.h Thu Mar 3 22:08:51 2011 (r219254) +++ stable/7/sys/sys/umtx.h Thu Mar 3 22:09:10 2011 (r219255) @@ -190,8 +190,58 @@ umtx_wake(u_long *p, int nr_wakeup) #else +/* + * The umtx_key structure is used by both the Linux futex code and the + * umtx implementation to map userland addresses to unique keys. + */ + +enum { + TYPE_SIMPLE_WAIT, + TYPE_CV, + TYPE_SIMPLE_LOCK, + TYPE_NORMAL_UMUTEX, + TYPE_PI_UMUTEX, + TYPE_PP_UMUTEX, + TYPE_RWLOCK, +}; + +/* Key to represent a unique userland synchronous object */ +struct umtx_key { + int hash; + int type; + int shared; + union { + struct { + struct vm_object *object; + uintptr_t offset; + } shared; + struct { + struct vmspace *vs; + uintptr_t addr; + } private; + struct { + void *a; + uintptr_t b; + } both; + } info; +}; + +#define THREAD_SHARE 0 +#define PROCESS_SHARE 1 +#define AUTO_SHARE 2 + struct thread; +static inline int +umtx_key_match(const struct umtx_key *k1, const struct umtx_key *k2) +{ + return (k1->type == k2->type && + k1->info.both.a == k2->info.both.a && + k1->info.both.b == k2->info.both.b); +} + +int umtx_key_get(void *, int, int, struct umtx_key *); +void umtx_key_release(struct umtx_key *); struct umtx_q *umtxq_alloc(void); void umtxq_free(struct umtx_q *); int kern_umtx_wake(struct thread *, void *, int, int);