Date: Wed, 23 Feb 2011 13:19:14 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r218969 - in head/sys: kern sys Message-ID: <201102231319.p1NDJEhQ060637@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Wed Feb 23 13:19:14 2011 New Revision: 218969 URL: http://svn.freebsd.org/changeset/base/218969 Log: Expose the umtx_key structure and API to the rest of the kernel. MFC after: 3 days Modified: head/sys/kern/kern_umtx.c head/sys/sys/umtx.h Modified: head/sys/kern/kern_umtx.c ============================================================================== --- head/sys/kern/kern_umtx.c Wed Feb 23 12:58:50 2011 (r218968) +++ head/sys/kern/kern_umtx.c Wed Feb 23 13:19:14 2011 (r218969) @@ -59,41 +59,9 @@ __FBSDID("$FreeBSD$"); #include <compat/freebsd32/freebsd32_proto.h> #endif -enum { - TYPE_SIMPLE_WAIT, - TYPE_CV, - TYPE_SEM, - TYPE_SIMPLE_LOCK, - TYPE_NORMAL_UMUTEX, - TYPE_PI_UMUTEX, - TYPE_PP_UMUTEX, - TYPE_RWLOCK -}; - #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 */ @@ -208,10 +176,6 @@ struct umtxq_chain { #define UMTX_CHAINS 512 #define UMTX_SHIFTS (__WORD_BIT - 9) -#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) @@ -237,10 +201,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 int do_unlock_pp(struct thread *td, struct umutex *m, uint32_t flags); @@ -307,14 +267,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) { @@ -567,7 +519,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; @@ -613,7 +565,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: head/sys/sys/umtx.h ============================================================================== --- head/sys/sys/umtx.h Wed Feb 23 12:58:50 2011 (r218968) +++ head/sys/sys/umtx.h Wed Feb 23 13:19:14 2011 (r218969) @@ -171,8 +171,59 @@ 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_SEM, + 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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201102231319.p1NDJEhQ060637>