diff options
-rw-r--r-- | debian/patches/0001-include-add-lock-less-reference-counting-primitives.patch | 167 | ||||
-rw-r--r-- | debian/patches/0002-libports-lock-less-reference-counting-for-port_info-.patch | 298 | ||||
-rw-r--r-- | debian/patches/0003-libdiskfs-lock-less-reference-counting-for-peropen-o.patch | 143 | ||||
-rw-r--r-- | debian/patches/0004-libtrivfs-lock-less-reference-counting-for-trivfs_pr.patch | 176 | ||||
-rw-r--r-- | debian/patches/libpager-drop-seqnos.patch | 270 | ||||
-rw-r--r-- | debian/patches/libpager-singlethreaded.patch | 566 | ||||
-rw-r--r-- | debian/patches/libports-a-single-hashtable.patch | 550 | ||||
-rw-r--r-- | debian/patches/libports-current_rpcs_lock.patch | 196 | ||||
-rw-r--r-- | debian/patches/libports-lockless-refcounting.patch | 351 | ||||
-rw-r--r-- | debian/patches/libports-per-bucket-hashtable.patch | 1067 | ||||
-rw-r--r-- | debian/patches/series | 10 |
11 files changed, 0 insertions, 3794 deletions
diff --git a/debian/patches/0001-include-add-lock-less-reference-counting-primitives.patch b/debian/patches/0001-include-add-lock-less-reference-counting-primitives.patch deleted file mode 100644 index 0ee3897e..00000000 --- a/debian/patches/0001-include-add-lock-less-reference-counting-primitives.patch +++ /dev/null @@ -1,167 +0,0 @@ -From 6c60761119510bd019c2214eb80fd7fd244e29cd Mon Sep 17 00:00:00 2001 -From: Justus Winter <4winter@informatik.uni-hamburg.de> -Date: Tue, 6 May 2014 19:52:04 +0200 -Subject: [PATCH 1/4] include: add lock-less reference counting primitives - -* include/refcount.h: New file. ---- - include/refcount.h | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 147 insertions(+) - create mode 100644 include/refcount.h - -diff --git a/include/refcount.h b/include/refcount.h -new file mode 100644 -index 0000000..b90cc5b ---- /dev/null -+++ b/include/refcount.h -@@ -0,0 +1,147 @@ -+/* Lock-less reference counting primitives -+ -+ Copyright (C) 2014 Free Software Foundation, Inc. -+ -+ Written by Justus Winter <4winter@informatik.uni-hamburg.de> -+ -+ This file is part of the GNU Hurd. -+ -+ The GNU Hurd is free software; you can redistribute it and/or -+ modify it under the terms of the GNU General Public License as -+ published by the Free Software Foundation; either version 2, or (at -+ your option) any later version. -+ -+ The GNU Hurd is distributed in the hope that it will be useful, but -+ WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>. */ -+ -+#ifndef _HURD_REFCOUNT_H_ -+#define _HURD_REFCOUNT_H_ -+ -+#include <stdint.h> -+ -+/* Simple reference counting. */ -+ -+/* An opaque type. You must not access these values directly. */ -+typedef uint32_t refcount_t; -+ -+/* Initialize REF with REFERENCES. */ -+static inline void -+refcount_init (refcount_t *ref, uint32_t references) -+{ -+ *ref = references; -+} -+ -+/* Increment REF. Return the result of the operation. */ -+static inline uint32_t -+refcount_ref (refcount_t *ref) -+{ -+ return __atomic_add_fetch (ref, 1, __ATOMIC_RELAXED); -+} -+ -+/* Decrement REF. Return the result of the operation. */ -+static inline uint32_t -+refcount_deref (refcount_t *ref) -+{ -+ return __atomic_sub_fetch (ref, 1, __ATOMIC_RELAXED); -+} -+ -+/* Return REF. */ -+static inline uint32_t -+refcount_references (refcount_t *ref) -+{ -+ return __atomic_load_n (ref, __ATOMIC_RELAXED); -+} -+ -+/* Reference counting with weak references. */ -+ -+/* An opaque type. You must not access these values directly. */ -+typedef uint64_t refcounts_t; -+ -+/* Instead, the functions manipulating refcounts_t values write the -+ results into this kind of objects. */ -+struct references { -+ uint32_t hard; -+ uint32_t weak; -+}; -+ -+union _references { -+ struct references refs; -+ refcounts_t rc; -+}; -+ -+/* Initialize REF with HARD and WEAK references. */ -+static inline void -+refcounts_init (refcounts_t *ref, uint32_t hard, uint32_t weak) -+{ -+ ((union _references *) ref)->refs = -+ (struct references) { .hard = hard, .weak = weak }; -+} -+ -+/* Increment the hard reference count of REF. If RESULT is not NULL, -+ the result of the operation is written there. */ -+static inline void -+refcounts_ref (refcounts_t *ref, struct references *result) -+{ -+ const union _references op = { .refs = { .hard = 1 } }; -+ refcounts_t r = __atomic_add_fetch (ref, op.rc, __ATOMIC_RELAXED); -+ if (result) -+ ((union _references *) result)->rc = r; -+} -+ -+/* Decrement the hard reference count of REF. If RESULT is not NULL, -+ the result of the operation is written there. */ -+static inline void -+refcounts_deref (refcounts_t *ref, struct references *result) -+{ -+ const union _references op = { .refs = { .hard = 1 } }; -+ refcounts_t r = __atomic_sub_fetch (ref, op.rc, __ATOMIC_RELAXED); -+ if (result) -+ ((union _references *) result)->rc = r; -+} -+ -+/* Increment the weak reference count of REF. If RESULT is not NULL, -+ the result of the operation is written there. */ -+static inline void -+refcounts_ref_weak (refcounts_t *ref, struct references *result) -+{ -+ const union _references op = { .refs = { .weak = 1 } }; -+ refcounts_t r = __atomic_add_fetch (ref, op.rc, __ATOMIC_RELAXED); -+ if (result) -+ ((union _references *) result)->rc = r; -+} -+ -+/* Decrement the weak reference count of REF. If RESULT is not NULL, -+ the result of the operation is written there. */ -+static inline void -+refcounts_deref_weak (refcounts_t *ref, struct references *result) -+{ -+ const union _references op = { .refs = { .weak = 1 } }; -+ refcounts_t r = __atomic_sub_fetch (ref, op.rc, __ATOMIC_RELAXED); -+ if (result) -+ ((union _references *) result)->rc = r; -+} -+ -+/* Return the hard reference count of REF. */ -+static inline uint32_t -+refcounts_hard_references (refcounts_t *ref) -+{ -+ union _references result; -+ result.rc = __atomic_load_n (ref, __ATOMIC_RELAXED); -+ return result.refs.hard; -+} -+ -+/* Return the weak reference count of REF. */ -+static inline uint32_t -+refcounts_weak_references (refcounts_t *ref) -+{ -+ union _references result; -+ result.rc = __atomic_load_n (ref, __ATOMIC_RELAXED); -+ return result.refs.weak; -+} -+ -+#endif /* _HURD_REFCOUNT_H_ */ --- -2.0.0.rc0 - diff --git a/debian/patches/0002-libports-lock-less-reference-counting-for-port_info-.patch b/debian/patches/0002-libports-lock-less-reference-counting-for-port_info-.patch deleted file mode 100644 index 7aadc343..00000000 --- a/debian/patches/0002-libports-lock-less-reference-counting-for-port_info-.patch +++ /dev/null @@ -1,298 +0,0 @@ -From acb8bb67d9c9f287a60fc61a9e5f95112697ebd8 Mon Sep 17 00:00:00 2001 -From: Justus Winter <4winter@informatik.uni-hamburg.de> -Date: Sat, 3 May 2014 01:02:35 +0200 -Subject: [PATCH 2/4] libports: lock-less reference counting for port_info - objects - -* libports/refcount.h: New file with reference counting primitives. -* libports/ports.h (struct port_info): Use the new type. -* libports/bucket-iterate.c: Adjust accordingly. -* libports/complete-deallocate.c: Likewise. -* libports/create-internal.c: Likewise. -* libports/get-right.c: Likewise. -* libports/import-port.c: Likewise. -* libports/lookup-port.c: Likewise. -* libports/port-deref-weak.c: Likewise. -* libports/port-deref.c: Likewise. -* libports/port-ref-weak.c: Likewise. -* libports/port-ref.c: Likewise. -* libports/reallocate-from-external.c: Likewise. -* libports/transfer-right.c: Likewise. -* utils/rpctrace.c: Likewise. ---- - libports/bucket-iterate.c | 2 +- - libports/complete-deallocate.c | 2 ++ - libports/create-internal.c | 3 +-- - libports/get-right.c | 2 +- - libports/import-port.c | 3 +-- - libports/lookup-port.c | 2 +- - libports/port-deref-weak.c | 10 +++------- - libports/port-deref.c | 34 ++++++++++++++++------------------ - libports/port-ref-weak.c | 8 +++----- - libports/port-ref.c | 8 +++----- - libports/ports.h | 4 ++-- - libports/reallocate-from-external.c | 2 +- - libports/transfer-right.c | 2 +- - utils/rpctrace.c | 10 ++++++++-- - 14 files changed, 44 insertions(+), 48 deletions(-) - -diff --git a/libports/bucket-iterate.c b/libports/bucket-iterate.c -index babc204..9230b1f 100644 ---- a/libports/bucket-iterate.c -+++ b/libports/bucket-iterate.c -@@ -58,7 +58,7 @@ _ports_bucket_class_iterate (struct port_bucket *bucket, - - if (class == 0 || pi->class == class) - { -- pi->refcnt++; -+ ports_port_ref (pi); - p[n] = pi; - n++; - } -diff --git a/libports/complete-deallocate.c b/libports/complete-deallocate.c -index 8ce095b..7e7d467 100644 ---- a/libports/complete-deallocate.c -+++ b/libports/complete-deallocate.c -@@ -35,6 +35,8 @@ _ports_complete_deallocate (struct port_info *pi) - pi->port_right = MACH_PORT_NULL; - } - -+ pthread_mutex_lock (&_ports_lock); -+ - *pi->prevp = pi->next; - if (pi->next) - pi->next->prevp = pi->prevp; -diff --git a/libports/create-internal.c b/libports/create-internal.c -index 8551297..9b1a5db 100644 ---- a/libports/create-internal.c -+++ b/libports/create-internal.c -@@ -54,8 +54,7 @@ _ports_create_port_internal (struct port_class *class, - } - - pi->class = class; -- pi->refcnt = 1; -- pi->weakrefcnt = 0; -+ refcounts_init (&pi->refcounts, 1, 0); - pi->cancel_threshold = 0; - pi->mscount = 0; - pi->flags = 0; -diff --git a/libports/get-right.c b/libports/get-right.c -index 89050c6..42bfa2b 100644 ---- a/libports/get-right.c -+++ b/libports/get-right.c -@@ -41,7 +41,7 @@ ports_get_right (void *port) - if ((pi->flags & PORT_HAS_SENDRIGHTS) == 0) - { - pi->flags |= PORT_HAS_SENDRIGHTS; -- pi->refcnt++; -+ ports_port_ref (pi); - err = mach_port_request_notification (mach_task_self (), - pi->port_right, - MACH_NOTIFY_NO_SENDERS, -diff --git a/libports/import-port.c b/libports/import-port.c -index 226f47e..dd4a2f2 100644 ---- a/libports/import-port.c -+++ b/libports/import-port.c -@@ -48,8 +48,7 @@ ports_import_port (struct port_class *class, struct port_bucket *bucket, - return ENOMEM; - - pi->class = class; -- pi->refcnt = 1 + !!stat.mps_srights; -- pi->weakrefcnt = 0; -+ refcounts_init (&pi->refcounts, 1 + !!stat.mps_srights, 0); - pi->cancel_threshold = 0; - pi->mscount = stat.mps_mscount; - pi->flags = stat.mps_srights ? PORT_HAS_SENDRIGHTS : 0; -diff --git a/libports/lookup-port.c b/libports/lookup-port.c -index f79f6f0..289369f 100644 ---- a/libports/lookup-port.c -+++ b/libports/lookup-port.c -@@ -44,7 +44,7 @@ ports_lookup_port (struct port_bucket *bucket, - pi = 0; - - if (pi) -- pi->refcnt++; -+ ports_port_ref (pi); - - pthread_mutex_unlock (&_ports_lock); - -diff --git a/libports/port-deref-weak.c b/libports/port-deref-weak.c -index beb4842..8432660 100644 ---- a/libports/port-deref-weak.c -+++ b/libports/port-deref-weak.c -@@ -25,12 +25,8 @@ void - ports_port_deref_weak (void *portstruct) - { - struct port_info *pi = portstruct; -- -- pthread_mutex_lock (&_ports_lock); -- assert (pi->weakrefcnt); -- pi->weakrefcnt--; -- if (pi->refcnt == 0 && pi->weakrefcnt == 0) -+ struct references result; -+ refcounts_deref_weak (&pi->refcounts, &result); -+ if (result.hard == 0 && result.weak == 0) - _ports_complete_deallocate (pi); -- else -- pthread_mutex_unlock (&_ports_lock); - } -diff --git a/libports/port-deref.c b/libports/port-deref.c -index cf9b238..dd38f55 100644 ---- a/libports/port-deref.c -+++ b/libports/port-deref.c -@@ -25,26 +25,24 @@ void - ports_port_deref (void *portstruct) - { - struct port_info *pi = portstruct; -- int trieddroppingweakrefs = 0; -- -- retry: -- -- pthread_mutex_lock (&_ports_lock); -- -- if (pi->refcnt == 1 && pi->weakrefcnt -- && pi->class->dropweak_routine && !trieddroppingweakrefs) -+ struct references result; -+ -+ /* If we need to call the dropweak routine, we need to hold one -+ reference while doing so. We use a weak reference for this -+ purpose, which we acquire before we release our hard reference. -+ The order is important here to prevent a race. */ -+ if (pi->class->dropweak_routine) -+ refcounts_ref_weak (&pi->refcounts, NULL); -+ -+ refcounts_deref (&pi->refcounts, &result); -+ -+ if (pi->class->dropweak_routine) - { -- pthread_mutex_unlock (&_ports_lock); -- (*pi->class->dropweak_routine) (pi); -- trieddroppingweakrefs = 1; -- goto retry; -+ if (result.hard == 0 && result.weak > 1) -+ (*pi->class->dropweak_routine) (pi); -+ refcounts_deref_weak (&pi->refcounts, &result); - } -- -- assert (pi->refcnt); - -- pi->refcnt--; -- if (pi->refcnt == 0 && pi->weakrefcnt == 0) -+ if (result.hard == 0 && result.weak == 0) - _ports_complete_deallocate (pi); -- else -- pthread_mutex_unlock (&_ports_lock); - } -diff --git a/libports/port-ref-weak.c b/libports/port-ref-weak.c -index c7d3c69..e4b7fc8 100644 ---- a/libports/port-ref-weak.c -+++ b/libports/port-ref-weak.c -@@ -25,9 +25,7 @@ void - ports_port_ref_weak (void *portstruct) - { - struct port_info *pi = portstruct; -- -- pthread_mutex_lock (&_ports_lock); -- assert (pi->refcnt || pi->weakrefcnt); -- pi->weakrefcnt++; -- pthread_mutex_unlock (&_ports_lock); -+ struct references result; -+ refcounts_ref_weak (&pi->refcounts, &result); -+ assert (result.hard > 0 || result.weak > 1); - } -diff --git a/libports/port-ref.c b/libports/port-ref.c -index 92b7118..761c50f 100644 ---- a/libports/port-ref.c -+++ b/libports/port-ref.c -@@ -25,9 +25,7 @@ void - ports_port_ref (void *portstruct) - { - struct port_info *pi = portstruct; -- -- pthread_mutex_lock (&_ports_lock); -- assert (pi->refcnt || pi->weakrefcnt); -- pi->refcnt++; -- pthread_mutex_unlock (&_ports_lock); -+ struct references result; -+ refcounts_ref (&pi->refcounts, &result); -+ assert (result.hard > 1 || result.weak > 0); - } -diff --git a/libports/ports.h b/libports/ports.h -index 7f13124..957ee32 100644 ---- a/libports/ports.h -+++ b/libports/ports.h -@@ -27,6 +27,7 @@ - #include <hurd/ihash.h> - #include <mach/notify.h> - #include <pthread.h> -+#include <refcount.h> - - /* These are global values for common flags used in the various structures. - Not all of these are meaningful in all flag fields. */ -@@ -39,8 +40,7 @@ - struct port_info - { - struct port_class *class; -- int refcnt; -- int weakrefcnt; -+ refcounts_t refcounts; - mach_port_mscount_t mscount; - mach_msg_seqno_t cancel_threshold; - int flags; -diff --git a/libports/reallocate-from-external.c b/libports/reallocate-from-external.c -index 8cccb2a..4dfc59c 100644 ---- a/libports/reallocate-from-external.c -+++ b/libports/reallocate-from-external.c -@@ -53,7 +53,7 @@ ports_reallocate_from_external (void *portstruct, mach_port_t receive) - else if (((pi->flags & PORT_HAS_SENDRIGHTS) == 0) && stat.mps_srights) - { - pi->flags |= PORT_HAS_SENDRIGHTS; -- pi->refcnt++; -+ ports_port_ref (pi); - } - - pi->port_right = receive; -diff --git a/libports/transfer-right.c b/libports/transfer-right.c -index 72488a9..f4e0c86 100644 ---- a/libports/transfer-right.c -+++ b/libports/transfer-right.c -@@ -66,7 +66,7 @@ ports_transfer_right (void *tostruct, - else if (((topi->flags & PORT_HAS_SENDRIGHTS) == 0) && hassendrights) - { - topi->flags |= PORT_HAS_SENDRIGHTS; -- topi->refcnt++; -+ ports_port_ref (topi); - } - } - -diff --git a/utils/rpctrace.c b/utils/rpctrace.c -index fc913e3..b11fea4 100644 ---- a/utils/rpctrace.c -+++ b/utils/rpctrace.c -@@ -431,7 +431,9 @@ destroy_receiver_info (struct receiver_info *info) - while (send_wrapper) - { - struct sender_info *next = send_wrapper->next; -- assert (TRACED_INFO (send_wrapper)->pi.refcnt == 1); -+ assert ( -+ refcounts_hard_references (&TRACED_INFO (send_wrapper)->pi.refcounts) -+ == 1); - /* Reset the receive_right of the send wrapper in advance to avoid - * destroy_receiver_info is called when the port info is destroyed. */ - send_wrapper->receive_right = NULL; -@@ -848,7 +850,11 @@ rewrite_right (mach_port_t *right, mach_msg_type_name_t *type, - hurd_ihash_locp_remove (&traced_names, receiver_info->locp); - - send_wrapper2 = get_send_wrapper (receiver_info, dest, &rr); -- assert (TRACED_INFO (send_wrapper2)->pi.refcnt == 1); -+ assert ( -+ refcounts_hard_references ( -+ &TRACED_INFO (send_wrapper2)->pi.refcounts) -+ == 1); -+ - name = TRACED_INFO (send_wrapper2)->name; - TRACED_INFO (send_wrapper2)->name = NULL; - /* send_wrapper2 isn't destroyed normally, so we need to unlink --- -2.0.0.rc0 - diff --git a/debian/patches/0003-libdiskfs-lock-less-reference-counting-for-peropen-o.patch b/debian/patches/0003-libdiskfs-lock-less-reference-counting-for-peropen-o.patch deleted file mode 100644 index fac34440..00000000 --- a/debian/patches/0003-libdiskfs-lock-less-reference-counting-for-peropen-o.patch +++ /dev/null @@ -1,143 +0,0 @@ -From b3c7364a46a4be0871d49b3ba04bc2c7f8d2a717 Mon Sep 17 00:00:00 2001 -From: Justus Winter <4winter@informatik.uni-hamburg.de> -Date: Tue, 6 May 2014 18:58:10 +0200 -Subject: [PATCH 3/4] libdiskfs: lock-less reference counting for peropen - objects - -* libdiskfs/diskfs.h (struct peropen): Use refcount_t for field refcnt. -* libdiskfs/peropen-make.c (diskfs_make_peropen): Initialize refcnt. -* libdiskfs/peropen-rele.c (diskfs_release_peropen): Adjust accordingly. -* libdiskfs/protid-make.c (diskfs_start_protid): Likewise. Also, the -node must no longer be locked, adjust comment accordingly. -(diskfs_create_protid): Likewise. ---- - libdiskfs/diskfs.h | 7 ++++--- - libdiskfs/peropen-make.c | 2 +- - libdiskfs/peropen-rele.c | 21 ++++++++++----------- - libdiskfs/protid-make.c | 8 ++++---- - 4 files changed, 19 insertions(+), 19 deletions(-) - -diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h -index 8151ddc..ae1a150 100644 ---- a/libdiskfs/diskfs.h -+++ b/libdiskfs/diskfs.h -@@ -28,6 +28,7 @@ - #include <hurd/iohelp.h> - #include <idvec.h> - #include <features.h> -+#include <refcount.h> - - #ifdef DISKFS_DEFINE_EXTERN_INLINE - #define DISKFS_EXTERN_INLINE -@@ -57,7 +58,7 @@ struct peropen - { - int filepointer; - int lock_status; -- int refcnt; -+ refcount_t refcnt; - int openstat; - - struct node *np; -@@ -792,12 +793,12 @@ diskfs_create_node (struct node *dir, const char *name, mode_t mode, - struct dirstat *ds); - - /* Create and return a protid for an existing peropen PO in CRED, -- referring to user USER. The node PO->np must be locked. */ -+ referring to user USER. */ - error_t diskfs_create_protid (struct peropen *po, struct iouser *user, - struct protid **cred); - - /* Build and return in CRED a protid which has no user identification, for -- peropen PO. The node PO->np must be locked. */ -+ peropen PO. */ - error_t diskfs_start_protid (struct peropen *po, struct protid **cred); - - /* Finish building protid CRED started with diskfs_start_protid; -diff --git a/libdiskfs/peropen-make.c b/libdiskfs/peropen-make.c -index eba037f..6d5ca01 100644 ---- a/libdiskfs/peropen-make.c -+++ b/libdiskfs/peropen-make.c -@@ -31,7 +31,7 @@ diskfs_make_peropen (struct node *np, int flags, struct peropen *context, - - po->filepointer = 0; - po->lock_status = LOCK_UN; -- po->refcnt = 0; -+ refcount_init (&po->refcnt, 0); - po->openstat = flags; - po->np = np; - po->path = NULL; -diff --git a/libdiskfs/peropen-rele.c b/libdiskfs/peropen-rele.c -index d3f7492..877137b 100644 ---- a/libdiskfs/peropen-rele.c -+++ b/libdiskfs/peropen-rele.c -@@ -22,13 +22,8 @@ - void - diskfs_release_peropen (struct peropen *po) - { -- pthread_mutex_lock (&po->np->lock); -- -- if (--po->refcnt) -- { -- pthread_mutex_unlock (&po->np->lock); -- return; -- } -+ if (refcount_deref (&po->refcnt) > 0) -+ return; - - if (po->root_parent) - mach_port_deallocate (mach_task_self (), po->root_parent); -@@ -40,10 +35,14 @@ diskfs_release_peropen (struct peropen *po) - mach_port_deallocate (mach_task_self (), po->shadow_root_parent); - - if (po->lock_status != LOCK_UN) -- fshelp_acquire_lock (&po->np->userlock, &po->lock_status, -- &po->np->lock, LOCK_UN); -- -- diskfs_nput (po->np); -+ { -+ pthread_mutex_lock (&po->np->lock); -+ fshelp_acquire_lock (&po->np->userlock, &po->lock_status, -+ &po->np->lock, LOCK_UN); -+ diskfs_nput (po->np); -+ } -+ else -+ diskfs_nrele (po->np); - - free (po->path); - free (po); -diff --git a/libdiskfs/protid-make.c b/libdiskfs/protid-make.c -index b39b92a..22aaa2e 100644 ---- a/libdiskfs/protid-make.c -+++ b/libdiskfs/protid-make.c -@@ -20,7 +20,7 @@ - #include <assert.h> - - /* Build and return in CRED a protid which has no user identification, for -- peropen PO. The node PO->np must be locked. */ -+ peropen PO. */ - error_t - diskfs_start_protid (struct peropen *po, struct protid **cred) - { -@@ -29,7 +29,7 @@ diskfs_start_protid (struct peropen *po, struct protid **cred) - sizeof (struct protid), cred); - if (! err) - { -- po->refcnt++; -+ refcount_ref (&po->refcnt); - (*cred)->po = po; - (*cred)->shared_object = MACH_PORT_NULL; - (*cred)->mapped = 0; -@@ -55,8 +55,8 @@ diskfs_finish_protid (struct protid *cred, struct iouser *user) - assert_perror (err); - } - --/* Create and return a protid for an existing peropen PO in CRED for USER. -- The node PO->np must be locked. */ -+/* Create and return a protid for an existing peropen PO in CRED for -+ USER. */ - error_t - diskfs_create_protid (struct peropen *po, struct iouser *user, - struct protid **cred) --- -2.0.0.rc0 - diff --git a/debian/patches/0004-libtrivfs-lock-less-reference-counting-for-trivfs_pr.patch b/debian/patches/0004-libtrivfs-lock-less-reference-counting-for-trivfs_pr.patch deleted file mode 100644 index 40755616..00000000 --- a/debian/patches/0004-libtrivfs-lock-less-reference-counting-for-trivfs_pr.patch +++ /dev/null @@ -1,176 +0,0 @@ -From d814cbdc92bd9e3c41bfc459ebf783a33133dcce Mon Sep 17 00:00:00 2001 -From: Justus Winter <4winter@informatik.uni-hamburg.de> -Date: Tue, 6 May 2014 19:07:13 +0200 -Subject: [PATCH 4/4] libtrivfs: lock-less reference counting for trivfs_protid - objects - -* libtrivfs/trivfs.h (struct trivfs_protid): Use refcount_t for field -refcnt. -(struct trivfs_control): Remove unused field lock. -* libtrivfs/open.c (trivfs_open): Initialize refcnt. -* libtrivfs/io-reauthenticate.c (trivfs_S_io_reauthenticate): Adjust -accordingly. -* libtrivfs/io-restrict-auth.c (trivfs_S_io_restrict_auth): Likewise. -* libtrivfs/protid-clean.c (trivfs_clean_protid): Likewise. -* libtrivfs/protid-dup.c (trivfs_protid_dup): Likewise. -* libtrivfs/cntl-create.c (trivfs_create_control): Drop the mutex -initialization. -* libtrivfs/peropen-make.c (trivfs_make_peropen): Initialize refcnt. -* libtrivfs/peropen-rele.c (trivfs_release_peropen): Adjust accordingly. -* libtrivfs/protid-make.c (trivfs_start_protid): Likewise. Also, the -node must no longer be locked, adjust comment accordingly. -(trivfs_create_protid): Likewise. ---- - libtrivfs/cntl-create.c | 1 - - libtrivfs/io-reauthenticate.c | 5 +---- - libtrivfs/io-restrict-auth.c | 4 +--- - libtrivfs/open.c | 2 +- - libtrivfs/protid-clean.c | 25 ++++++++++++++----------- - libtrivfs/protid-dup.c | 5 +---- - libtrivfs/trivfs.h | 4 ++-- - 7 files changed, 20 insertions(+), 26 deletions(-) - -diff --git a/libtrivfs/cntl-create.c b/libtrivfs/cntl-create.c -index 910daf3..eb9a834 100644 ---- a/libtrivfs/cntl-create.c -+++ b/libtrivfs/cntl-create.c -@@ -85,7 +85,6 @@ trivfs_create_control (mach_port_t underlying, - } - - (*control)->hook = 0; -- pthread_mutex_init (&(*control)->lock, NULL); - } - - out: -diff --git a/libtrivfs/io-reauthenticate.c b/libtrivfs/io-reauthenticate.c -index 7677697..df0ed2e 100644 ---- a/libtrivfs/io-reauthenticate.c -+++ b/libtrivfs/io-reauthenticate.c -@@ -62,11 +62,8 @@ trivfs_S_io_reauthenticate (struct trivfs_protid *cred, - newcred->isroot = 1; - - newcred->hook = cred->hook; -- -- pthread_mutex_lock (&cred->po->cntl->lock); - newcred->po = cred->po; -- newcred->po->refcnt++; -- pthread_mutex_unlock (&cred->po->cntl->lock); -+ refcount_ref (&newcred->po->refcnt); - - do - err = io_restrict_auth (newcred->po->cntl->underlying, &newcred->realnode, -diff --git a/libtrivfs/io-restrict-auth.c b/libtrivfs/io-restrict-auth.c -index 65b4fd6..39670fe 100644 ---- a/libtrivfs/io-restrict-auth.c -+++ b/libtrivfs/io-restrict-auth.c -@@ -110,10 +110,8 @@ trivfs_S_io_restrict_auth (struct trivfs_protid *cred, - } - - newcred->isroot = 0; -- pthread_mutex_lock (&cred->po->cntl->lock); - newcred->po = cred->po; -- newcred->po->refcnt++; -- pthread_mutex_unlock (&cred->po->cntl->lock); -+ refcount_ref (&newcred->po->refcnt); - if (cred->isroot && idvec_contains (user->uids, 0)) - newcred->isroot = 1; - newcred->user = user; -diff --git a/libtrivfs/open.c b/libtrivfs/open.c -index f64d2ff..97e70a1 100644 ---- a/libtrivfs/open.c -+++ b/libtrivfs/open.c -@@ -40,7 +40,7 @@ trivfs_open (struct trivfs_control *cntl, - - ports_port_ref (cntl); - -- po->refcnt = 1; -+ refcount_init (&po->refcnt, 1); - po->cntl = cntl; - po->openmodes = flags; - po->hook = 0; -diff --git a/libtrivfs/protid-clean.c b/libtrivfs/protid-clean.c -index f98da6a..815e731 100644 ---- a/libtrivfs/protid-clean.c -+++ b/libtrivfs/protid-clean.c -@@ -31,19 +31,22 @@ trivfs_clean_protid (void *arg) - (*trivfs_protid_destroy_hook) (cred); - - /* If we hold the only reference to the peropen, try to get rid of it. */ -- pthread_mutex_lock (&cntl->lock); -- if (cred->po->refcnt == 1 && trivfs_peropen_destroy_hook) -+ if (refcount_deref (&cred->po->refcnt) == 0) - { -- pthread_mutex_unlock (&cntl->lock); -- (*trivfs_peropen_destroy_hook) (cred->po); -- pthread_mutex_lock (&cntl->lock); -+ if (trivfs_protid_destroy_hook) -+ { -+ refcount_ref (&cred->po->refcnt); -+ (*trivfs_peropen_destroy_hook) (cred->po); -+ if (refcount_deref (&cred->po->refcnt) == 0) -+ goto free_po; -+ } -+ else -+ { -+ free_po: -+ ports_port_deref (cntl); -+ free (cred->po); -+ } - } -- if (--cred->po->refcnt == 0) -- { -- ports_port_deref (cntl); -- free (cred->po); -- } -- pthread_mutex_unlock (&cntl->lock); - - iohelp_free_iouser (cred->user); - -diff --git a/libtrivfs/protid-dup.c b/libtrivfs/protid-dup.c -index 6169603..75f3ca8 100644 ---- a/libtrivfs/protid-dup.c -+++ b/libtrivfs/protid-dup.c -@@ -35,11 +35,8 @@ trivfs_protid_dup (struct trivfs_protid *cred, struct trivfs_protid **dup) - - if (! err) - { -- pthread_mutex_lock (&cred->po->cntl->lock); - new->po = cred->po; -- new->po->refcnt++; -- pthread_mutex_unlock (&cred->po->cntl->lock); -- -+ refcount_ref (&new->po->refcnt); - new->isroot = cred->isroot; - - err = iohelp_dup_iouser (&new->user, cred->user); -diff --git a/libtrivfs/trivfs.h b/libtrivfs/trivfs.h -index bb456ff..8902338 100644 ---- a/libtrivfs/trivfs.h -+++ b/libtrivfs/trivfs.h -@@ -24,6 +24,7 @@ - #include <mach/mach.h> - #include <hurd/ports.h> - #include <hurd/iohelp.h> -+#include <refcount.h> - - struct trivfs_protid - { -@@ -41,14 +42,13 @@ struct trivfs_peropen - { - void *hook; /* for user use */ - int openmodes; -- int refcnt; -+ refcount_t refcnt; - struct trivfs_control *cntl; - }; - - struct trivfs_control - { - struct port_info pi; -- pthread_mutex_t lock; - struct port_class *protid_class; - struct port_bucket *protid_bucket; - mach_port_t filesys_id; --- -2.0.0.rc0 - diff --git a/debian/patches/libpager-drop-seqnos.patch b/debian/patches/libpager-drop-seqnos.patch deleted file mode 100644 index c4d5be5f..00000000 --- a/debian/patches/libpager-drop-seqnos.patch +++ /dev/null @@ -1,270 +0,0 @@ -commit c41025fb44a31c26cb056af9d9ed001ae352485f -Author: Justus Winter <4winter@informatik.uni-hamburg.de> -Date: Sun Apr 27 12:42:34 2014 +0200 - - libpager: remove all the unused seqno parameters - - * libpager/Makefile (MIGSFLAGS): Drop -DSEQNOS. - * libpager/chg-compl.c: Adjust accordingly. - * libpager/data-request.c: Likewise. - * libpager/data-return.c: Likewise. - * libpager/data-unlock.c: Likewise. - * libpager/demuxer.c: Likewise. - * libpager/lock-completed.c: Likewise. - * libpager/no-senders.c: Likewise. - * libpager/notify-stubs.c: Likewise. - * libpager/object-init.c: Likewise. - * libpager/object-terminate.c: Likewise. - * libpager/stubs.c: Likewise. - -diff --git a/libpager/Makefile b/libpager/Makefile -index a15a899..2bfd845 100644 ---- a/libpager/Makefile -+++ b/libpager/Makefile -@@ -31,7 +31,7 @@ HURDLIBS= ports - LDLIBS += -lpthread - OBJS = $(SRCS:.c=.o) memory_objectServer.o notifyServer.o - --MIGSFLAGS = -DSEQNOS -imacros $(srcdir)/mig-mutate.h -+MIGSFLAGS = -imacros $(srcdir)/mig-mutate.h - MIGCOMSFLAGS = -prefix _pager_ - - include ../Makeconf -diff --git a/libpager/chg-compl.c b/libpager/chg-compl.c -index 89ccfc8..3ffe60a 100644 ---- a/libpager/chg-compl.c -+++ b/libpager/chg-compl.c -@@ -22,8 +22,7 @@ - when a memory_object_change_attributes call has completed. Read this - in combination with pager-attr.c. */ - kern_return_t --_pager_seqnos_memory_object_change_completed (struct pager *p, -- mach_port_seqno_t seq, -+_pager_S_memory_object_change_completed (struct pager *p, - boolean_t maycache, - memory_object_copy_strategy_t strat) - { -diff --git a/libpager/data-request.c b/libpager/data-request.c -index 18f3de6..7069fc8 100644 ---- a/libpager/data-request.c -+++ b/libpager/data-request.c -@@ -22,8 +22,7 @@ - - /* Implement pagein callback as described in <mach/memory_object.defs>. */ - kern_return_t --_pager_seqnos_memory_object_data_request (struct pager *p, -- mach_port_seqno_t seqno, -+_pager_S_memory_object_data_request (struct pager *p, - mach_port_t control, - vm_offset_t offset, - vm_size_t length, -diff --git a/libpager/data-return.c b/libpager/data-return.c -index f16f323..9244eca 100644 ---- a/libpager/data-return.c -+++ b/libpager/data-return.c -@@ -21,13 +21,12 @@ - #include <string.h> - #include <assert.h> - --/* Worker function used by _pager_seqnos_memory_object_data_return -- and _pager_seqnos_memory_object_data_initialize. All args are -- as for _pager_seqnos_memory_object_data_return; the additional -+/* Worker function used by _pager_S_memory_object_data_return -+ and _pager_S_memory_object_data_initialize. All args are -+ as for _pager_S_memory_object_data_return; the additional - INITIALIZING arg identifies which function is calling us. */ - kern_return_t - _pager_do_write_request (struct pager *p, -- mach_port_seqno_t seqno, - mach_port_t control, - vm_offset_t offset, - pointer_t data, -@@ -254,8 +253,7 @@ _pager_do_write_request (struct pager *p, - - /* Implement pageout call back as described by <mach/memory_object.defs>. */ - kern_return_t --_pager_seqnos_memory_object_data_return (struct pager *p, -- mach_port_seqno_t seqno, -+_pager_S_memory_object_data_return (struct pager *p, - mach_port_t control, - vm_offset_t offset, - pointer_t data, -@@ -263,6 +261,6 @@ _pager_seqnos_memory_object_data_return (struct pager *p, - int dirty, - int kcopy) - { -- return _pager_do_write_request (p, seqno, control, offset, data, -+ return _pager_do_write_request (p, control, offset, data, - length, dirty, kcopy, 0); - } -diff --git a/libpager/data-unlock.c b/libpager/data-unlock.c -index 8c7c776..8c9680c 100644 ---- a/libpager/data-unlock.c -+++ b/libpager/data-unlock.c -@@ -22,8 +22,7 @@ - /* Implement kernel requests for access as described in - <mach/memory_object.defs>. */ - kern_return_t --_pager_seqnos_memory_object_data_unlock (struct pager *p, -- mach_port_seqno_t seqno, -+_pager_S_memory_object_data_unlock (struct pager *p, - mach_port_t control, - vm_offset_t offset, - vm_size_t length, -diff --git a/libpager/demuxer.c b/libpager/demuxer.c -index 90edf1d..91e305a 100644 ---- a/libpager/demuxer.c -+++ b/libpager/demuxer.c -@@ -26,8 +26,8 @@ pager_demuxer (mach_msg_header_t *inp, - mach_msg_header_t *outp) - { - mig_routine_t routine; -- if ((routine = _pager_seqnos_memory_object_server_routine (inp)) || -- (routine = _pager_seqnos_notify_server_routine (inp))) -+ if ((routine = _pager_memory_object_server_routine (inp)) || -+ (routine = _pager_notify_server_routine (inp))) - { - (*routine) (inp, outp); - return TRUE; -diff --git a/libpager/lock-completed.c b/libpager/lock-completed.c -index 30b1dd3..4b0d87a 100644 ---- a/libpager/lock-completed.c -+++ b/libpager/lock-completed.c -@@ -23,8 +23,7 @@ - when a memory_object_lock_request call has completed. Read this - in combination with lock-object.c. */ - kern_return_t --_pager_seqnos_memory_object_lock_completed (struct pager *p, -- mach_port_seqno_t seqno, -+_pager_S_memory_object_lock_completed (struct pager *p, - mach_port_t control, - vm_offset_t offset, - vm_size_t length) -diff --git a/libpager/no-senders.c b/libpager/no-senders.c -index d0bbe27..b750101 100644 ---- a/libpager/no-senders.c -+++ b/libpager/no-senders.c -@@ -21,8 +21,7 @@ - #include "notify_S.h" - - error_t --_pager_do_seqnos_mach_notify_no_senders (struct port_info *pi, -- mach_port_seqno_t seqno, -+_pager_do_mach_notify_no_senders (struct port_info *pi, - mach_port_mscount_t mscount) - { - if (!pi || -diff --git a/libpager/notify-stubs.c b/libpager/notify-stubs.c -index a826420..6440815 100644 ---- a/libpager/notify-stubs.c -+++ b/libpager/notify-stubs.c -@@ -23,8 +23,7 @@ - #include <errno.h> - - error_t --_pager_do_seqnos_mach_notify_port_deleted (struct port_info *pi, -- mach_port_seqno_t seqno, -+_pager_do_mach_notify_port_deleted (struct port_info *pi, - mach_port_t name - __attribute__ ((unused))) - { -@@ -32,8 +31,7 @@ _pager_do_seqnos_mach_notify_port_deleted (struct port_info *pi, - } - - error_t --_pager_do_seqnos_mach_notify_msg_accepted (struct port_info *pi, -- mach_port_seqno_t seqno, -+_pager_do_mach_notify_msg_accepted (struct port_info *pi, - mach_port_t name - __attribute__ ((unused))) - { -@@ -41,8 +39,7 @@ _pager_do_seqnos_mach_notify_msg_accepted (struct port_info *pi, - } - - error_t --_pager_do_seqnos_mach_notify_port_destroyed (struct port_info *pi, -- mach_port_seqno_t seqno, -+_pager_do_mach_notify_port_destroyed (struct port_info *pi, - mach_port_t name - __attribute__ ((unused))) - { -@@ -50,15 +47,13 @@ _pager_do_seqnos_mach_notify_port_destroyed (struct port_info *pi, - } - - error_t --_pager_do_seqnos_mach_notify_send_once (struct port_info *pi, -- mach_port_seqno_t seqno) -+_pager_do_mach_notify_send_once (struct port_info *pi) - { - return 0; - } - - error_t --_pager_do_seqnos_mach_notify_dead_name (struct port_info *pi, -- mach_port_seqno_t seqno, -+_pager_do_mach_notify_dead_name (struct port_info *pi, - mach_port_t name - __attribute__ ((unused))) - { -diff --git a/libpager/object-init.c b/libpager/object-init.c -index eb62c44..619d28f 100644 ---- a/libpager/object-init.c -+++ b/libpager/object-init.c -@@ -22,8 +22,7 @@ - /* Implement the object initialiation call as described in - <mach/memory_object.defs>. */ - kern_return_t --_pager_seqnos_memory_object_init (struct pager *p, -- mach_port_seqno_t seqno, -+_pager_S_memory_object_init (struct pager *p, - mach_port_t control, - mach_port_t name, - vm_size_t pagesize) -diff --git a/libpager/object-terminate.c b/libpager/object-terminate.c -index 3f0482f..3374d10 100644 ---- a/libpager/object-terminate.c -+++ b/libpager/object-terminate.c -@@ -22,8 +22,7 @@ - /* Implement the object termination call from the kernel as described - in <mach/memory_object.defs>. */ - kern_return_t --_pager_seqnos_memory_object_terminate (struct pager *p, -- mach_port_seqno_t seqno, -+_pager_S_memory_object_terminate (struct pager *p, - mach_port_t control, - mach_port_t name) - { -diff --git a/libpager/stubs.c b/libpager/stubs.c -index c7f1a5a..9a766ec 100644 ---- a/libpager/stubs.c -+++ b/libpager/stubs.c -@@ -21,8 +21,7 @@ - #include <stdio.h> - - kern_return_t --_pager_seqnos_memory_object_copy (struct pager *p, -- mach_port_seqno_t seq, -+_pager_S_memory_object_copy (struct pager *p, - memory_object_control_t obj_ctl, - vm_offset_t off, - vm_size_t len, -@@ -33,8 +32,7 @@ _pager_seqnos_memory_object_copy (struct pager *p, - } - - kern_return_t --_pager_seqnos_memory_object_data_write (struct pager *p, -- mach_port_seqno_t seq, -+_pager_S_memory_object_data_write (struct pager *p, - mach_port_t ctl, - vm_offset_t off, - pointer_t data, -@@ -45,8 +43,7 @@ _pager_seqnos_memory_object_data_write (struct pager *p, - } - - kern_return_t --_pager_seqnos_memory_object_supply_completed (struct pager *p, -- mach_port_seqno_t seq, -+_pager_S_memory_object_supply_completed (struct pager *p, - mach_port_t ctl, - vm_offset_t off, - vm_size_t len, diff --git a/debian/patches/libpager-singlethreaded.patch b/debian/patches/libpager-singlethreaded.patch deleted file mode 100644 index f03ba024..00000000 --- a/debian/patches/libpager-singlethreaded.patch +++ /dev/null @@ -1,566 +0,0 @@ -commit 18fa27d294185abc9db774f02008f484280ddb33 -Author: Justus Winter <4winter@informatik.uni-hamburg.de> -Date: Sun Apr 27 09:16:40 2014 +0200 - - XXX libpager: make libpager single-threaded - - Previously, libpager used multiple threads to service requests to - memory objects. This has proven to be problematic, as paging requests - often arrive in batches, resulting in the creation of many hundred - threads. - - Furthermore, the semantic of paging requests requires that the - requests to an object processed in the order the messages were - delivered. This was implemented using sequence barriers in - _pager_wait_for_seqno, _pager_release_seqno, and - _pager_update_seqno{,_p}. - - Unfortunately, this means that not only do we create too many threads, - but worse, all but one thread processing requests to an object are - asleep most of the time. - - Previous attempts to introduce a fixed upper bound on the number of - threads failed because ext2fs (fatfs) used two kinds of pagers managed - by the same thread pool. This has been fixed in XXX (YYY). - - Use a single thread to service paging requests. This removes the need - for the sequence barriers, remove that code. - - This prevents paging-related thread-storms. It also seems to actually - increase the performance of the whole system, as indicated by slightly - faster Hurd package builds. - - * console/pager.c (service_paging_requests): Use a single thread. - * ext2fs/pager.c (service_paging_requests): Likewise. - * fatfs/pager.c (service_paging_requests): Likewise. - * libdiskfs/disk-pager.c (service_paging_requests): Likewise. - * storeio/pager.c (service_paging_requests): Likewise. - * libpager/chg-compl.c: Remove calls to _pager_wait_for_seqno, - _pager_release_seqno, _pager_update_seqno, and _pager_update_seqno_p. - * libpager/data-request.c: Likewise. - * libpager/data-return.c: Likewise. - * libpager/data-unlock.c: Likewise. - * libpager/demuxer.c: Likewise. - * libpager/lock-completed.c: Likewise. - * libpager/no-senders.c: Likewise. - * libpager/notify-stubs.c: Likewise. - * libpager/object-init.c: Likewise. - * libpager/object-terminate.c: Likewise. - * libpager/pager-create.c: Likewise. - * libpager/stubs.c: Likewise. - * libpager/priv.h (struct pager): Drop fields seqno and waitingforseqno. - * libpager/seqnos.c: Remove unused file. - * libpager/Makefile (SRCS): Drop seqnos.c. - -diff --git a/console/pager.c b/console/pager.c -index 87c36f0..e40ae45 100644 ---- a/console/pager.c -+++ b/console/pager.c -@@ -127,11 +127,10 @@ static void * - service_paging_requests (void *arg) - { - struct port_bucket *pager_bucket = arg; -- for (;;) -- ports_manage_port_operations_multithread (pager_bucket, -- pager_demuxer, -- 1000 * 60 * 2, -- 1000 * 60 * 10, 0); -+ ports_manage_port_operations_one_thread (pager_bucket, -+ pager_demuxer, -+ 0); -+ /* Not reached. */ - return NULL; - } - -diff --git a/ext2fs/pager.c b/ext2fs/pager.c -index 017efcc..92e9178 100644 ---- a/ext2fs/pager.c -+++ b/ext2fs/pager.c -@@ -1198,11 +1198,9 @@ static void * - service_paging_requests (void *arg) - { - struct port_bucket *pager_bucket = arg; -- ports_manage_port_operations_multithread (pager_bucket, -- pager_demuxer, -- 1000, -- 0, -- NULL); -+ ports_manage_port_operations_one_thread (pager_bucket, -+ pager_demuxer, -+ 0); - /* Not reached. */ - return NULL; - } -diff --git a/fatfs/pager.c b/fatfs/pager.c -index f855ecf..623b8d4 100644 ---- a/fatfs/pager.c -+++ b/fatfs/pager.c -@@ -762,11 +762,9 @@ static void * - service_paging_requests (void *arg) - { - struct port_bucket *pager_bucket = arg; -- ports_manage_port_operations_multithread (pager_bucket, -- pager_demuxer, -- 1000, -- 0, -- NULL); -+ ports_manage_port_operations_one_thread (pager_bucket, -+ pager_demuxer, -+ 0); - /* Not reached. */ - return NULL; - } -diff --git a/libdiskfs/disk-pager.c b/libdiskfs/disk-pager.c -index 9a0d9d8..6746d4c 100644 ---- a/libdiskfs/disk-pager.c -+++ b/libdiskfs/disk-pager.c -@@ -39,11 +39,10 @@ static void * - service_paging_requests (void *arg) - { - struct port_bucket *pager_bucket = arg; -- for (;;) -- ports_manage_port_operations_multithread (pager_bucket, -- pager_demuxer, -- 1000 * 60 * 2, -- 1000 * 60 * 10, 0); -+ ports_manage_port_operations_one_thread (pager_bucket, -+ pager_demuxer, -+ 0); -+ /* Not reached. */ - return NULL; - } - -diff --git a/libpager/Makefile b/libpager/Makefile -index b622295..a15a899 100644 ---- a/libpager/Makefile -+++ b/libpager/Makefile -@@ -22,7 +22,7 @@ SRCS = data-request.c data-return.c data-unlock.c pager-port.c \ - inhibit-term.c lock-completed.c lock-object.c mark-error.c \ - no-senders.c object-init.c object-terminate.c pagemap.c \ - pager-create.c pager-flush.c pager-shutdown.c pager-sync.c \ -- stubs.c seqnos.c demuxer.c chg-compl.c pager-attr.c clean.c \ -+ stubs.c demuxer.c chg-compl.c pager-attr.c clean.c \ - dropweak.c notify-stubs.c get-upi.c pager-memcpy.c pager-return.c \ - offer-page.c - installhdrs = pager.h -diff --git a/libpager/chg-compl.c b/libpager/chg-compl.c -index d77c46c..89ccfc8 100644 ---- a/libpager/chg-compl.c -+++ b/libpager/chg-compl.c -@@ -37,7 +37,6 @@ _pager_seqnos_memory_object_change_completed (struct pager *p, - } - - pthread_mutex_lock (&p->interlock); -- _pager_wait_for_seqno (p, seq); - - for (ar = p->attribute_requests; ar; ar = ar->next) - if (ar->may_cache == maycache && ar->copy_strategy == strat) -@@ -46,8 +45,7 @@ _pager_seqnos_memory_object_change_completed (struct pager *p, - pthread_cond_broadcast (&p->wakeup); - break; - } -- -- _pager_release_seqno (p, seq); -+ - pthread_mutex_unlock (&p->interlock); - return 0; - } -diff --git a/libpager/data-request.c b/libpager/data-request.c -index 82ce904..18f3de6 100644 ---- a/libpager/data-request.c -+++ b/libpager/data-request.c -@@ -41,7 +41,6 @@ _pager_seqnos_memory_object_data_request (struct pager *p, - - /* Acquire the right to meddle with the pagemap */ - pthread_mutex_lock (&p->interlock); -- _pager_wait_for_seqno (p, seqno); - - /* sanity checks -- we don't do multi-page requests yet. */ - if (control != p->memobjcntl) -@@ -105,7 +104,6 @@ _pager_seqnos_memory_object_data_request (struct pager *p, - } - - /* Let someone else in. */ -- _pager_release_seqno (p, seqno); - pthread_mutex_unlock (&p->interlock); - - if (!doread) -@@ -139,7 +137,6 @@ _pager_seqnos_memory_object_data_request (struct pager *p, - allow_release_out: - _pager_allow_termination (p); - release_out: -- _pager_release_seqno (p, seqno); - pthread_mutex_unlock (&p->interlock); - return 0; - } -diff --git a/libpager/data-return.c b/libpager/data-return.c -index ee6c6e8..f16f323 100644 ---- a/libpager/data-return.c -+++ b/libpager/data-return.c -@@ -52,7 +52,6 @@ _pager_do_write_request (struct pager *p, - - /* Acquire the right to meddle with the pagemap */ - pthread_mutex_lock (&p->interlock); -- _pager_wait_for_seqno (p, seqno); - - /* sanity checks -- we don't do multi-page requests yet. */ - if (control != p->memobjcntl) -@@ -101,7 +100,6 @@ _pager_do_write_request (struct pager *p, - notified[i] = (p->notify_on_evict - && ! (pm_entries[i] & PM_PAGEINWAIT)); - -- _pager_release_seqno (p, seqno); - goto notify; - } - else { -@@ -158,7 +156,6 @@ _pager_do_write_request (struct pager *p, - } - - /* Let someone else in. */ -- _pager_release_seqno (p, seqno); - pthread_mutex_unlock (&p->interlock); - - /* This is inefficient; we should send all the pages to the device at once -@@ -251,7 +248,6 @@ _pager_do_write_request (struct pager *p, - return 0; - - release_out: -- _pager_release_seqno (p, seqno); - pthread_mutex_unlock (&p->interlock); - return 0; - } -diff --git a/libpager/data-unlock.c b/libpager/data-unlock.c -index 599237c..8c7c776 100644 ---- a/libpager/data-unlock.c -+++ b/libpager/data-unlock.c -@@ -35,11 +35,6 @@ _pager_seqnos_memory_object_data_unlock (struct pager *p, - || p->port.class != _pager_class) - return EOPNOTSUPP; - -- pthread_mutex_lock (&p->interlock); -- _pager_wait_for_seqno (p, seqno); -- _pager_release_seqno (p, seqno); -- pthread_mutex_unlock (&p->interlock); -- - if (p->pager_state != NORMAL) - { - printf ("pager in wrong state for unlock\n"); -diff --git a/libpager/demuxer.c b/libpager/demuxer.c -index b4d4054..90edf1d 100644 ---- a/libpager/demuxer.c -+++ b/libpager/demuxer.c -@@ -33,8 +33,5 @@ pager_demuxer (mach_msg_header_t *inp, - return TRUE; - } - -- /* Synchronize our bookkeeping of the port's seqno with the one -- consumed by this bogus message. */ -- _pager_update_seqno (inp->msgh_local_port, inp->msgh_seqno); - return FALSE; - } -diff --git a/libpager/lock-completed.c b/libpager/lock-completed.c -index a3f3f16..30b1dd3 100644 ---- a/libpager/lock-completed.c -+++ b/libpager/lock-completed.c -@@ -37,7 +37,6 @@ _pager_seqnos_memory_object_lock_completed (struct pager *p, - return EOPNOTSUPP; - - pthread_mutex_lock (&p->interlock); -- _pager_wait_for_seqno (p, seqno); - - if (control != p->memobjcntl) - { -@@ -59,7 +58,6 @@ _pager_seqnos_memory_object_lock_completed (struct pager *p, - } - - out: -- _pager_release_seqno (p, seqno); - pthread_mutex_unlock (&p->interlock); - - return err; -diff --git a/libpager/no-senders.c b/libpager/no-senders.c -index c21dfc2..d0bbe27 100644 ---- a/libpager/no-senders.c -+++ b/libpager/no-senders.c -@@ -29,7 +29,6 @@ _pager_do_seqnos_mach_notify_no_senders (struct port_info *pi, - pi->class != _pager_class) - return EOPNOTSUPP; - -- _pager_update_seqno_p ((struct pager *) pi, seqno); - ports_no_senders (pi, mscount); - - return 0; -diff --git a/libpager/notify-stubs.c b/libpager/notify-stubs.c -index ba13882..a826420 100644 ---- a/libpager/notify-stubs.c -+++ b/libpager/notify-stubs.c -@@ -28,8 +28,6 @@ _pager_do_seqnos_mach_notify_port_deleted (struct port_info *pi, - mach_port_t name - __attribute__ ((unused))) - { -- _pager_update_seqno_p ((struct pager *) pi, seqno); -- - return 0; - } - -@@ -39,8 +37,6 @@ _pager_do_seqnos_mach_notify_msg_accepted (struct port_info *pi, - mach_port_t name - __attribute__ ((unused))) - { -- _pager_update_seqno_p ((struct pager *) pi, seqno); -- - return 0; - } - -@@ -50,8 +46,6 @@ _pager_do_seqnos_mach_notify_port_destroyed (struct port_info *pi, - mach_port_t name - __attribute__ ((unused))) - { -- _pager_update_seqno_p ((struct pager *) pi, seqno); -- - return 0; - } - -@@ -59,8 +53,6 @@ error_t - _pager_do_seqnos_mach_notify_send_once (struct port_info *pi, - mach_port_seqno_t seqno) - { -- _pager_update_seqno_p ((struct pager *) pi, seqno); -- - return 0; - } - -@@ -70,7 +62,5 @@ _pager_do_seqnos_mach_notify_dead_name (struct port_info *pi, - mach_port_t name - __attribute__ ((unused))) - { -- _pager_update_seqno_p ((struct pager *) pi, seqno); -- - return 0; - } -diff --git a/libpager/object-init.c b/libpager/object-init.c -index 6683e24..eb62c44 100644 ---- a/libpager/object-init.c -+++ b/libpager/object-init.c -@@ -33,7 +33,6 @@ _pager_seqnos_memory_object_init (struct pager *p, - return EOPNOTSUPP; - - pthread_mutex_lock (&p->interlock); -- _pager_wait_for_seqno (p, seqno); - - if (pagesize != __vm_page_size) - { -@@ -69,7 +68,6 @@ _pager_seqnos_memory_object_init (struct pager *p, - p->pager_state = NORMAL; - - out: -- _pager_release_seqno (p, seqno); - pthread_mutex_unlock (&p->interlock); - - return 0; -diff --git a/libpager/object-terminate.c b/libpager/object-terminate.c -index 365ba27..3f0482f 100644 ---- a/libpager/object-terminate.c -+++ b/libpager/object-terminate.c -@@ -32,8 +32,7 @@ _pager_seqnos_memory_object_terminate (struct pager *p, - return EOPNOTSUPP; - - pthread_mutex_lock (&p->interlock); -- _pager_wait_for_seqno (p, seqno); -- -+ - if (control != p->memobjcntl) - { - printf ("incg terminate: wrong control port"); -@@ -75,7 +74,6 @@ _pager_seqnos_memory_object_terminate (struct pager *p, - #endif - - out: -- _pager_release_seqno (p, seqno); - pthread_mutex_unlock (&p->interlock); - - return 0; -diff --git a/libpager/pager-create.c b/libpager/pager-create.c -index 1fc15b8..b583f02 100644 ---- a/libpager/pager-create.c -+++ b/libpager/pager-create.c -@@ -42,10 +42,8 @@ pager_create (struct user_pager_info *upi, - p->notify_on_evict = notify_on_evict; - p->memobjcntl = MACH_PORT_NULL; - p->memobjname = MACH_PORT_NULL; -- p->seqno = -1; - p->noterm = 0; - p->termwaiting = 0; -- p->waitingforseqno = 0; - p->pagemap = 0; - p->pagemapsize = 0; - -diff --git a/libpager/priv.h b/libpager/priv.h -index d49cbb9..dc2f908 100644 ---- a/libpager/priv.h -+++ b/libpager/priv.h -@@ -55,14 +55,11 @@ struct pager - memory_object_control_t memobjcntl; - memory_object_name_t memobjname; - -- mach_port_seqno_t seqno; -- - int noterm; /* number of threads blocking termination */ - - struct pager *next, **pprev; - - int termwaiting:1; -- int waitingforseqno:1; - - #ifdef KERNEL_INIT_RACE - /* Out of sequence object_init calls waiting for -@@ -136,10 +133,6 @@ extern int _pager_page_errors[]; - struct port_class *_pager_class; - - --void _pager_wait_for_seqno (struct pager *, mach_port_seqno_t); --void _pager_release_seqno (struct pager *, mach_port_seqno_t); --void _pager_update_seqno (mach_port_t, mach_port_seqno_t); --void _pager_update_seqno_p (struct pager *, mach_port_seqno_t); - void _pager_block_termination (struct pager *); - void _pager_allow_termination (struct pager *); - error_t _pager_pagemap_resize (struct pager *, vm_address_t); -diff --git a/libpager/seqnos.c b/libpager/seqnos.c -deleted file mode 100644 -index cab2f33..0000000 ---- a/libpager/seqnos.c -+++ /dev/null -@@ -1,79 +0,0 @@ --/* Sequence number synchronization routines for pager library -- Copyright (C) 1994, 2011 Free Software Foundation -- -- This program is free software; you can redistribute it and/or -- modify it under the terms of the GNU General Public License as -- published by the Free Software Foundation; either version 2, or (at -- your option) any later version. -- -- This program is distributed in the hope that it will be useful, but -- WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -- --#include "priv.h" --#include <assert.h> -- --/* The message with seqno SEQNO has just been dequeued for pager P; -- wait until all preceding messages have had a chance and then -- return. */ --void --_pager_wait_for_seqno (struct pager *p, -- mach_port_seqno_t seqno) --{ -- while (seqno != p->seqno + 1) -- { -- p->waitingforseqno = 1; -- pthread_cond_wait (&p->wakeup, &p->interlock); -- } --} -- -- --/* Allow the next message for pager P (potentially blocked in -- _pager_wait_for_seqno) to be handled. */ --void --_pager_release_seqno (struct pager *p, -- mach_port_seqno_t seqno) --{ -- assert (seqno == p->seqno + 1); -- p->seqno = seqno; -- if (p->waitingforseqno) -- { -- p->waitingforseqno = 0; -- pthread_cond_broadcast (&p->wakeup); -- } --} -- -- --/* Just update the seqno. */ --void --_pager_update_seqno (mach_port_t object, -- mach_port_seqno_t seqno) --{ -- struct pager *p; -- -- p = ports_lookup_port (0, object, _pager_class); -- _pager_update_seqno_p (p, seqno); -- if (p) -- ports_port_deref (p); --} -- -- --/* Just update the seqno, pointer version. */ --void --_pager_update_seqno_p (struct pager *p, -- mach_port_seqno_t seqno) --{ -- if (p -- && p->port.class == _pager_class) -- { -- pthread_mutex_lock (&p->interlock); -- _pager_wait_for_seqno (p, seqno); -- _pager_release_seqno (p, seqno); -- pthread_mutex_unlock (&p->interlock); -- } --} -diff --git a/libpager/stubs.c b/libpager/stubs.c -index 411f483..c7f1a5a 100644 ---- a/libpager/stubs.c -+++ b/libpager/stubs.c -@@ -29,9 +29,6 @@ _pager_seqnos_memory_object_copy (struct pager *p, - mach_port_t new) - { - printf ("m_o_copy called\n"); -- -- _pager_update_seqno_p (p, seq); -- - return EOPNOTSUPP; - } - -@@ -44,9 +41,6 @@ _pager_seqnos_memory_object_data_write (struct pager *p, - vm_size_t data_cnt) - { - printf ("m_o_data_write called\n"); -- -- _pager_update_seqno_p (p, seq); -- - return EOPNOTSUPP; - } - -@@ -60,8 +54,5 @@ _pager_seqnos_memory_object_supply_completed (struct pager *p, - vm_offset_t err_off) - { - printf ("m_o_supply_completed called\n"); -- -- _pager_update_seqno_p (p, seq); -- - return EOPNOTSUPP; - } -diff --git a/storeio/pager.c b/storeio/pager.c -index 7d78711..4f86407 100644 ---- a/storeio/pager.c -+++ b/storeio/pager.c -@@ -148,12 +148,10 @@ static void * - service_paging_requests (void *arg) - { - (void) arg; -- -- for (;;) -- ports_manage_port_operations_multithread (pager_port_bucket, -- pager_demuxer, -- 1000 * 30, 1000 * 60 * 5, 0); -- -+ ports_manage_port_operations_one_thread (pager_port_bucket, -+ pager_demuxer, -+ 0); -+ /* Not reached. */ - return NULL; - } - diff --git a/debian/patches/libports-a-single-hashtable.patch b/debian/patches/libports-a-single-hashtable.patch deleted file mode 100644 index c0d475ae..00000000 --- a/debian/patches/libports-a-single-hashtable.patch +++ /dev/null @@ -1,550 +0,0 @@ -commit eadebf08f11f1801d086d3878d583fd92855c765 -Author: Justus Winter <4winter@informatik.uni-hamburg.de> -Date: Sun May 4 10:28:41 2014 +0200 - - libports: use a single hash table - -diff --git a/libports/bucket-iterate.c b/libports/bucket-iterate.c -index 5a6a56b..bf9f957 100644 ---- a/libports/bucket-iterate.c -+++ b/libports/bucket-iterate.c -@@ -35,35 +35,42 @@ _ports_bucket_class_iterate (struct port_bucket *bucket, - size_t i, n, nr_items; - error_t err; - -- pthread_mutex_lock (&bucket->lock); -+ pthread_mutex_lock (&_ports_htable_lock); - -- if (bucket->htable.nr_items == 0) -+ if (_ports_htable.nr_items == 0) - { -- pthread_mutex_unlock (&bucket->lock); -+ pthread_mutex_unlock (&_ports_htable_lock); - return 0; - } - -- nr_items = bucket->htable.nr_items; -+ nr_items = _ports_htable.nr_items; - p = malloc (nr_items * sizeof *p); - if (p == NULL) - { -- pthread_mutex_unlock (&bucket->lock); -+ pthread_mutex_unlock (&_ports_htable_lock); - return ENOMEM; - } - - n = 0; -- HURD_IHASH_ITERATE (&bucket->htable, arg) -+ HURD_IHASH_ITERATE (&_ports_htable, arg) - { - struct port_info *const pi = arg; - -- if (class == 0 || pi->class == class) -+ if ((bucket == NULL || pi->bucket == bucket) -+ && (class == NULL || pi->class == class)) - { - ports_port_ref (pi); - p[n] = pi; - n++; - } - } -- pthread_mutex_unlock (&bucket->lock); -+ pthread_mutex_unlock (&_ports_htable_lock); -+ -+ if (n == 0) -+ { -+ free (p); -+ return 0; -+ } - - if (n != nr_items) - { -diff --git a/libports/claim-right.c b/libports/claim-right.c -index 73e383a..2953310 100644 ---- a/libports/claim-right.c -+++ b/libports/claim-right.c -@@ -34,9 +34,9 @@ ports_claim_right (void *portstruct) - if (ret == MACH_PORT_NULL) - return ret; - -- pthread_mutex_lock (&pi->bucket->lock); -- hurd_ihash_locp_remove (&pi->bucket->htable, pi->hentry); -- pthread_mutex_unlock (&pi->bucket->lock); -+ pthread_mutex_lock (&_ports_htable_lock); -+ hurd_ihash_locp_remove (&_ports_htable, pi->hentry); -+ pthread_mutex_unlock (&_ports_htable_lock); - err = mach_port_move_member (mach_task_self (), ret, MACH_PORT_NULL); - assert_perror (err); - pthread_mutex_lock (&_ports_global_lock); -diff --git a/libports/class-iterate.c b/libports/class-iterate.c -index 638dd45..5cfcfc8 100644 ---- a/libports/class-iterate.c -+++ b/libports/class-iterate.c -@@ -23,13 +23,5 @@ error_t - ports_class_iterate (struct port_class *class, - error_t (*fun)(void *)) - { -- pthread_mutex_lock (&_ports_global_lock); -- if (class->ports != 0) -- { -- struct port_bucket *bucket = class->ports->bucket; -- pthread_mutex_unlock (&_ports_global_lock); -- return _ports_bucket_class_iterate (bucket, class, fun); -- } -- pthread_mutex_unlock (&_ports_global_lock); -- return 0; -+ return _ports_bucket_class_iterate (NULL, class, fun); - } -diff --git a/libports/complete-deallocate.c b/libports/complete-deallocate.c -index c08d0ce..f3b7134 100644 ---- a/libports/complete-deallocate.c -+++ b/libports/complete-deallocate.c -@@ -29,9 +29,9 @@ _ports_complete_deallocate (struct port_info *pi) - - if (pi->port_right) - { -- pthread_mutex_lock (&pi->bucket->lock); -- hurd_ihash_locp_remove (&pi->bucket->htable, pi->hentry); -- pthread_mutex_unlock (&pi->bucket->lock); -+ pthread_mutex_lock (&_ports_htable_lock); -+ hurd_ihash_locp_remove (&_ports_htable, pi->hentry); -+ pthread_mutex_unlock (&_ports_htable_lock); - mach_port_mod_refs (mach_task_self (), pi->port_right, - MACH_PORT_RIGHT_RECEIVE, -1); - pi->port_right = MACH_PORT_NULL; -@@ -39,10 +39,6 @@ _ports_complete_deallocate (struct port_info *pi) - - pthread_mutex_lock (&_ports_global_lock); - -- *pi->prevp = pi->next; -- if (pi->next) -- pi->next->prevp = pi->prevp; -- - pi->bucket->count--; - pi->class->count--; - -diff --git a/libports/create-bucket.c b/libports/create-bucket.c -index f8a0996..9f6821d 100644 ---- a/libports/create-bucket.c -+++ b/libports/create-bucket.c -@@ -46,14 +46,6 @@ ports_create_bucket () - return NULL; - } - -- pthread_mutex_init (&ret->lock, NULL); -- hurd_ihash_init (&ret->htable, offsetof (struct port_info, hentry)); - ret->rpcs = ret->flags = ret->count = 0; -- -- pthread_mutex_lock (&_ports_global_lock); -- ret->next = _ports_all_buckets; -- _ports_all_buckets = ret; -- pthread_mutex_unlock (&_ports_global_lock); -- - return ret; - } -diff --git a/libports/create-class.c b/libports/create-class.c -index 12c8add..782f52b 100644 ---- a/libports/create-class.c -+++ b/libports/create-class.c -@@ -39,7 +39,6 @@ ports_create_class (void (*clean_routine)(void *), - cl->dropweak_routine = dropweak_routine; - cl->flags = 0; - cl->rpcs = 0; -- cl->ports = NULL; - cl->count = 0; - cl->uninhibitable_rpcs = ports_default_uninhibitable_rpcs; - -diff --git a/libports/create-internal.c b/libports/create-internal.c -index 33ee1e1..2c62ca6 100644 ---- a/libports/create-internal.c -+++ b/libports/create-internal.c -@@ -80,17 +80,12 @@ _ports_create_port_internal (struct port_class *class, - goto loop; - } - -- pthread_mutex_lock (&bucket->lock); -- err = hurd_ihash_add (&bucket->htable, port, pi); -- pthread_mutex_unlock (&bucket->lock); -+ pthread_mutex_lock (&_ports_htable_lock); -+ err = hurd_ihash_add (&_ports_htable, port, pi); -+ pthread_mutex_unlock (&_ports_htable_lock); - if (err) - goto lose; - -- pi->next = class->ports; -- pi->prevp = &class->ports; -- if (class->ports) -- class->ports->prevp = &pi->next; -- class->ports = pi; - bucket->count++; - class->count++; - pthread_mutex_unlock (&_ports_global_lock); -diff --git a/libports/destroy-right.c b/libports/destroy-right.c -index b12dec9..6ba7302 100644 ---- a/libports/destroy-right.c -+++ b/libports/destroy-right.c -@@ -30,12 +30,12 @@ ports_destroy_right (void *portstruct) - - if (pi->port_right != MACH_PORT_NULL) - { -- pthread_mutex_lock (&pi->bucket->lock); -- hurd_ihash_locp_remove (&pi->bucket->htable, pi->hentry); -+ pthread_mutex_lock (&_ports_htable_lock); -+ hurd_ihash_locp_remove (&_ports_htable, pi->hentry); -+ pthread_mutex_unlock (&_ports_htable_lock); - err = mach_port_mod_refs (mach_task_self (), pi->port_right, - MACH_PORT_RIGHT_RECEIVE, -1); - assert_perror (err); -- pthread_mutex_unlock (&pi->bucket->lock); - - pi->port_right = MACH_PORT_NULL; - -diff --git a/libports/import-port.c b/libports/import-port.c -index 1aa422a..7bd331d 100644 ---- a/libports/import-port.c -+++ b/libports/import-port.c -@@ -74,17 +74,12 @@ ports_import_port (struct port_class *class, struct port_bucket *bucket, - goto loop; - } - -- pthread_mutex_lock (&bucket->lock); -- err = hurd_ihash_add (&bucket->htable, port, pi); -- pthread_mutex_unlock (&bucket->lock); -+ pthread_mutex_lock (&_ports_htable_lock); -+ err = hurd_ihash_add (&_ports_htable, port, pi); -+ pthread_mutex_unlock (&_ports_htable_lock); - if (err) - goto lose; - -- pi->next = class->ports; -- pi->prevp = &class->ports; -- if (class->ports) -- class->ports->prevp = &pi->next; -- class->ports = pi; - bucket->count++; - class->count++; - pthread_mutex_unlock (&_ports_global_lock); -diff --git a/libports/inhibit-all-rpcs.c b/libports/inhibit-all-rpcs.c -index 337d068..421dc4a 100644 ---- a/libports/inhibit-all-rpcs.c -+++ b/libports/inhibit-all-rpcs.c -@@ -36,26 +36,23 @@ ports_inhibit_all_rpcs () - struct port_bucket *bucket; - int this_one = 0; - -- for (bucket = _ports_all_buckets; bucket; bucket = bucket->next) -+ pthread_mutex_lock (&_ports_htable_lock); -+ HURD_IHASH_ITERATE (&_ports_htable, portstruct) - { -- pthread_mutex_lock (&bucket->lock); -- HURD_IHASH_ITERATE (&bucket->htable, portstruct) -+ struct rpc_info *rpc; -+ struct port_info *pi = portstruct; -+ -+ for (rpc = pi->current_rpcs; rpc; rpc = rpc->next) - { -- struct rpc_info *rpc; -- struct port_info *pi = portstruct; -- -- for (rpc = pi->current_rpcs; rpc; rpc = rpc->next) -- { -- /* Avoid cancelling the calling thread if it's currently -- handling a RPC. */ -- if (rpc->thread == hurd_thread_self ()) -- this_one = 1; -- else -- hurd_thread_cancel (rpc->thread); -- } -+ /* Avoid cancelling the calling thread if it's currently -+ handling a RPC. */ -+ if (rpc->thread == hurd_thread_self ()) -+ this_one = 1; -+ else -+ hurd_thread_cancel (rpc->thread); - } -- pthread_mutex_unlock (&bucket->lock); - } -+ pthread_mutex_unlock (&_ports_htable_lock); - - while (_ports_total_rpcs > this_one) - { -diff --git a/libports/inhibit-bucket-rpcs.c b/libports/inhibit-bucket-rpcs.c -index d55798e..ee6000e 100644 ---- a/libports/inhibit-bucket-rpcs.c -+++ b/libports/inhibit-bucket-rpcs.c -@@ -35,11 +35,13 @@ ports_inhibit_bucket_rpcs (struct port_bucket *bucket) - { - int this_one = 0; - -- pthread_mutex_lock (&bucket->lock); -- HURD_IHASH_ITERATE (&bucket->htable, portstruct) -+ pthread_mutex_lock (&_ports_htable_lock); -+ HURD_IHASH_ITERATE (&_ports_htable, portstruct) - { - struct rpc_info *rpc; - struct port_info *pi = portstruct; -+ if (pi->bucket != bucket) -+ continue; - - for (rpc = pi->current_rpcs; rpc; rpc = rpc->next) - { -@@ -50,7 +52,7 @@ ports_inhibit_bucket_rpcs (struct port_bucket *bucket) - hurd_thread_cancel (rpc->thread); - } - } -- pthread_mutex_unlock (&bucket->lock); -+ pthread_mutex_unlock (&_ports_htable_lock); - - while (bucket->rpcs > this_one) - { -diff --git a/libports/inhibit-class-rpcs.c b/libports/inhibit-class-rpcs.c -index fe26f27..0019b37 100644 ---- a/libports/inhibit-class-rpcs.c -+++ b/libports/inhibit-class-rpcs.c -@@ -36,15 +36,24 @@ ports_inhibit_class_rpcs (struct port_class *class) - struct rpc_info *rpc; - int this_one = 0; - -- for (pi = class->ports; pi; pi = pi->next) -- for (rpc = pi->current_rpcs; rpc; rpc = rpc->next) -- { -- /* Avoid cancelling the calling thread. */ -- if (rpc->thread == hurd_thread_self ()) -- this_one = 1; -- else -- hurd_thread_cancel (rpc->thread); -- } -+ pthread_mutex_lock (&_ports_htable_lock); -+ HURD_IHASH_ITERATE (&_ports_htable, portstruct) -+ { -+ struct rpc_info *rpc; -+ struct port_info *pi = portstruct; -+ if (pi->class != class) -+ continue; -+ -+ for (rpc = pi->current_rpcs; rpc; rpc = rpc->next) -+ { -+ /* Avoid cancelling the calling thread. */ -+ if (rpc->thread == hurd_thread_self ()) -+ this_one = 1; -+ else -+ hurd_thread_cancel (rpc->thread); -+ } -+ } -+ pthread_mutex_unlock (&_ports_htable_lock); - - while (class->rpcs > this_one) - { -diff --git a/libports/init.c b/libports/init.c -index 36e42a0..bab4884 100644 ---- a/libports/init.c -+++ b/libports/init.c -@@ -19,9 +19,14 @@ - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - #include "ports.h" -+#include <stddef.h> - - pthread_mutex_t _ports_global_lock = PTHREAD_MUTEX_INITIALIZER; - pthread_cond_t _ports_block = PTHREAD_COND_INITIALIZER; --struct port_bucket *_ports_all_buckets; -+ -+struct hurd_ihash _ports_htable = -+ HURD_IHASH_INITIALIZER (offsetof (struct port_info, hentry)); -+pthread_mutex_t _ports_htable_lock = PTHREAD_MUTEX_INITIALIZER; -+ - int _ports_total_rpcs; - int _ports_flags; -diff --git a/libports/lookup-port.c b/libports/lookup-port.c -index c919266..c488667 100644 ---- a/libports/lookup-port.c -+++ b/libports/lookup-port.c -@@ -26,29 +26,14 @@ ports_lookup_port (struct port_bucket *bucket, - mach_port_t port, - struct port_class *class) - { -- struct port_info *pi = 0; -- -- if (bucket) -- { -- pthread_mutex_lock (&bucket->lock); -- pi = hurd_ihash_find (&bucket->htable, port); -- pthread_mutex_unlock (&bucket->lock); -- } -- else -- { -- pthread_mutex_lock (&_ports_global_lock); -- for (bucket = _ports_all_buckets; bucket; bucket = bucket->next) -- { -- pthread_mutex_lock (&bucket->lock); -- pi = hurd_ihash_find (&bucket->htable, port); -- pthread_mutex_unlock (&bucket->lock); -- if (pi) -- break; -- } -- pthread_mutex_unlock (&_ports_global_lock); -- } -- -- if (pi && class && pi->class != class) -+ struct port_info *pi; -+ pthread_mutex_lock (&_ports_htable_lock); -+ pi = hurd_ihash_find (&_ports_htable, port); -+ pthread_mutex_unlock (&_ports_htable_lock); -+ -+ if (pi -+ && ((class && pi->class != class) -+ || (bucket && pi->bucket != bucket))) - pi = 0; - - if (pi) -diff --git a/libports/ports.h b/libports/ports.h -index c5bf8eb..ea99a7f 100644 ---- a/libports/ports.h -+++ b/libports/ports.h -@@ -50,7 +50,6 @@ struct port_info - struct rpc_info *current_rpcs; - struct port_bucket *bucket; - hurd_ihash_locp_t hentry; -- struct port_info *next, **prevp; /* links on port_class list */ - }; - typedef struct port_info *port_info_t; - -@@ -63,13 +62,9 @@ typedef struct port_info *port_info_t; - struct port_bucket - { - mach_port_t portset; -- struct hurd_ihash htable; - int rpcs; - int flags; - int count; -- pthread_mutex_t lock; -- -- struct port_bucket *next; - }; - /* FLAGS above are the following: */ - #define PORT_BUCKET_INHIBITED PORTS_INHIBITED -@@ -82,7 +77,6 @@ struct port_class - { - int flags; - int rpcs; -- struct port_info *ports; - int count; - void (*clean_routine) (void *); - void (*dropweak_routine) (void *); -@@ -406,7 +400,12 @@ extern kern_return_t - /* Private data */ - extern pthread_mutex_t _ports_global_lock; - extern pthread_cond_t _ports_block; --extern struct port_bucket *_ports_all_buckets; -+ -+/* A hash table mapping port names to port_info objects. */ -+extern struct hurd_ihash _ports_htable; -+/* Access to the hash table is protected by this lock. */ -+extern pthread_mutex_t _ports_htable_lock; -+ - extern int _ports_total_rpcs; - extern int _ports_flags; - #define _PORTS_INHIBITED PORTS_INHIBITED -diff --git a/libports/reallocate-from-external.c b/libports/reallocate-from-external.c -index 84fecc9..3a01d69 100644 ---- a/libports/reallocate-from-external.c -+++ b/libports/reallocate-from-external.c -@@ -43,9 +43,9 @@ ports_reallocate_from_external (void *portstruct, mach_port_t receive) - MACH_PORT_RIGHT_RECEIVE, -1); - assert_perror (err); - -- pthread_mutex_lock (&pi->bucket->lock); -- hurd_ihash_locp_remove (&pi->bucket->htable, pi->hentry); -- pthread_mutex_unlock (&pi->bucket->lock); -+ pthread_mutex_lock (&_ports_htable_lock); -+ hurd_ihash_locp_remove (&_ports_htable, pi->hentry); -+ pthread_mutex_unlock (&_ports_htable_lock); - - if ((pi->flags & PORT_HAS_SENDRIGHTS) && !stat.mps_srights) - { -@@ -63,9 +63,9 @@ ports_reallocate_from_external (void *portstruct, mach_port_t receive) - pi->cancel_threshold = 0; - pi->mscount = stat.mps_mscount; - -- pthread_mutex_lock (&pi->bucket->lock); -- err = hurd_ihash_add (&pi->bucket->htable, receive, pi); -- pthread_mutex_unlock (&pi->bucket->lock); -+ pthread_mutex_lock (&_ports_htable_lock); -+ err = hurd_ihash_add (&_ports_htable, receive, pi); -+ pthread_mutex_unlock (&_ports_htable_lock); - assert_perror (err); - - mach_port_move_member (mach_task_self (), receive, pi->bucket->portset); -diff --git a/libports/reallocate-port.c b/libports/reallocate-port.c -index f68865e..461ca72 100644 ---- a/libports/reallocate-port.c -+++ b/libports/reallocate-port.c -@@ -36,9 +36,9 @@ ports_reallocate_port (void *portstruct) - MACH_PORT_RIGHT_RECEIVE, -1); - assert_perror (err); - -- pthread_mutex_lock (&pi->bucket->lock); -- hurd_ihash_locp_remove (&pi->bucket->htable, pi->hentry); -- pthread_mutex_unlock (&pi->bucket->lock); -+ pthread_mutex_lock (&_ports_htable_lock); -+ hurd_ihash_locp_remove (&_ports_htable, pi->hentry); -+ pthread_mutex_unlock (&_ports_htable_lock); - - err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, - &pi->port_right); -@@ -52,9 +52,9 @@ ports_reallocate_port (void *portstruct) - - pi->cancel_threshold = 0; - pi->mscount = 0; -- pthread_mutex_lock (&pi->bucket->lock); -- err = hurd_ihash_add (&pi->bucket->htable, pi->port_right, pi); -- pthread_mutex_unlock (&pi->bucket->lock); -+ pthread_mutex_lock (&_ports_htable_lock); -+ err = hurd_ihash_add (&_ports_htable, pi->port_right, pi); -+ pthread_mutex_unlock (&_ports_htable_lock); - assert_perror (err); - - err = mach_port_move_member (mach_task_self (), pi->port_right, -diff --git a/libports/transfer-right.c b/libports/transfer-right.c -index 01c08e9..04d896f 100644 ---- a/libports/transfer-right.c -+++ b/libports/transfer-right.c -@@ -41,9 +41,9 @@ ports_transfer_right (void *tostruct, - port = frompi->port_right; - if (port != MACH_PORT_NULL) - { -- pthread_mutex_lock (&frompi->bucket->lock); -- hurd_ihash_locp_remove (&frompi->bucket->htable, frompi->hentry); -- pthread_mutex_unlock (&frompi->bucket->lock); -+ pthread_mutex_lock (&_ports_htable_lock); -+ hurd_ihash_locp_remove (&_ports_htable, frompi->hentry); -+ pthread_mutex_unlock (&_ports_htable_lock); - frompi->port_right = MACH_PORT_NULL; - if (frompi->flags & PORT_HAS_SENDRIGHTS) - { -@@ -56,9 +56,9 @@ ports_transfer_right (void *tostruct, - /* Destroy the existing right in TOPI. */ - if (topi->port_right != MACH_PORT_NULL) - { -- pthread_mutex_lock (&topi->bucket->lock); -- hurd_ihash_locp_remove (&topi->bucket->htable, topi->hentry); -- pthread_mutex_unlock (&topi->bucket->lock); -+ pthread_mutex_lock (&_ports_htable_lock); -+ hurd_ihash_locp_remove (&_ports_htable, topi->hentry); -+ pthread_mutex_unlock (&_ports_htable_lock); - err = mach_port_mod_refs (mach_task_self (), topi->port_right, - MACH_PORT_RIGHT_RECEIVE, -1); - assert_perror (err); -@@ -83,9 +83,9 @@ ports_transfer_right (void *tostruct, - - if (port) - { -- pthread_mutex_lock (&topi->bucket->lock); -- err = hurd_ihash_add (&topi->bucket->htable, port, topi); -- pthread_mutex_unlock (&topi->bucket->lock); -+ pthread_mutex_lock (&_ports_htable_lock); -+ err = hurd_ihash_add (&_ports_htable, port, topi); -+ pthread_mutex_unlock (&_ports_htable_lock); - assert_perror (err); - if (topi->bucket != frompi->bucket) - { diff --git a/debian/patches/libports-current_rpcs_lock.patch b/debian/patches/libports-current_rpcs_lock.patch deleted file mode 100644 index c3b71102..00000000 --- a/debian/patches/libports-current_rpcs_lock.patch +++ /dev/null @@ -1,196 +0,0 @@ -commit 7ad61adbc08e3dabb9d36b2464324edaeb02f936 -Author: Justus Winter <4winter@informatik.uni-hamburg.de> -Date: Sun May 4 16:09:28 2014 +0200 - - libports: more awesome - - XXX Richard thinks it's a gnumach bug. - - * libports/ports.h (struct port_info): Add current_rpcs_lock. - * libports/create-internal.c (_ports_create_port_internal): - Initialize current_rpcs_lock. - * libports/import-port.c: Likewise. - * libports/begin-rpc.c: Protect access to the list using the lock. - * libports/inhibit-all-rpcs.c: Likewise. - * libports/inhibit-bucket-rpcs.c: Likewise. - * libports/inhibit-class-rpcs.c: Likewise. - * libports/inhibit-port-rpcs.c: Likewise. - * libports/interrupt-on-notify.c: Likewise. - * libports/interrupt-rpcs.c: Likewise. - -diff --git a/libports/begin-rpc.c b/libports/begin-rpc.c -index de58b06..8140ce5 100644 ---- a/libports/begin-rpc.c -+++ b/libports/begin-rpc.c -@@ -91,12 +91,14 @@ ports_begin_rpc (void *portstruct, mach_msg_id_t msg_id, struct rpc_info *info) - - /* Record that that an RPC is in progress */ - info->thread = hurd_thread_self (); -+ pthread_mutex_lock (&pi->current_rpcs_lock); - info->next = pi->current_rpcs; - info->notifies = 0; - if (pi->current_rpcs) - pi->current_rpcs->prevp = &info->next; - info->prevp = &pi->current_rpcs; - pi->current_rpcs = info; -+ pthread_mutex_unlock (&pi->current_rpcs_lock); - - pi->class->rpcs++; - pi->bucket->rpcs++; -diff --git a/libports/create-internal.c b/libports/create-internal.c -index 2c62ca6..361b453 100644 ---- a/libports/create-internal.c -+++ b/libports/create-internal.c -@@ -60,6 +60,7 @@ _ports_create_port_internal (struct port_class *class, - pi->flags = 0; - pi->port_right = port; - pi->current_rpcs = 0; -+ pthread_mutex_init (&pi->current_rpcs_lock, NULL); - pi->bucket = bucket; - - pthread_mutex_lock (&_ports_global_lock); -diff --git a/libports/import-port.c b/libports/import-port.c -index 7bd331d..4847516 100644 ---- a/libports/import-port.c -+++ b/libports/import-port.c -@@ -54,6 +54,7 @@ ports_import_port (struct port_class *class, struct port_bucket *bucket, - pi->flags = stat.mps_srights ? PORT_HAS_SENDRIGHTS : 0; - pi->port_right = port; - pi->current_rpcs = 0; -+ pthread_mutex_init (&pi->current_rpcs_lock, NULL); - pi->bucket = bucket; - - pthread_mutex_lock (&_ports_global_lock); -diff --git a/libports/inhibit-all-rpcs.c b/libports/inhibit-all-rpcs.c -index 421dc4a..4d43023 100644 ---- a/libports/inhibit-all-rpcs.c -+++ b/libports/inhibit-all-rpcs.c -@@ -42,6 +42,7 @@ ports_inhibit_all_rpcs () - struct rpc_info *rpc; - struct port_info *pi = portstruct; - -+ pthread_mutex_lock (&pi->current_rpcs_lock); - for (rpc = pi->current_rpcs; rpc; rpc = rpc->next) - { - /* Avoid cancelling the calling thread if it's currently -@@ -51,6 +52,7 @@ ports_inhibit_all_rpcs () - else - hurd_thread_cancel (rpc->thread); - } -+ pthread_mutex_unlock (&pi->current_rpcs_lock); - } - pthread_mutex_unlock (&_ports_htable_lock); - -diff --git a/libports/inhibit-bucket-rpcs.c b/libports/inhibit-bucket-rpcs.c -index ee6000e..d7ffdc2 100644 ---- a/libports/inhibit-bucket-rpcs.c -+++ b/libports/inhibit-bucket-rpcs.c -@@ -43,6 +43,7 @@ ports_inhibit_bucket_rpcs (struct port_bucket *bucket) - if (pi->bucket != bucket) - continue; - -+ pthread_mutex_lock (&pi->current_rpcs_lock); - for (rpc = pi->current_rpcs; rpc; rpc = rpc->next) - { - /* Avoid cancelling the calling thread. */ -@@ -51,6 +52,7 @@ ports_inhibit_bucket_rpcs (struct port_bucket *bucket) - else - hurd_thread_cancel (rpc->thread); - } -+ pthread_mutex_unlock (&pi->current_rpcs_lock); - } - pthread_mutex_unlock (&_ports_htable_lock); - -diff --git a/libports/inhibit-class-rpcs.c b/libports/inhibit-class-rpcs.c -index 0019b37..5243a2b 100644 ---- a/libports/inhibit-class-rpcs.c -+++ b/libports/inhibit-class-rpcs.c -@@ -44,6 +44,7 @@ ports_inhibit_class_rpcs (struct port_class *class) - if (pi->class != class) - continue; - -+ pthread_mutex_lock (&pi->current_rpcs_lock); - for (rpc = pi->current_rpcs; rpc; rpc = rpc->next) - { - /* Avoid cancelling the calling thread. */ -@@ -52,6 +53,7 @@ ports_inhibit_class_rpcs (struct port_class *class) - else - hurd_thread_cancel (rpc->thread); - } -+ pthread_mutex_unlock (&pi->current_rpcs_lock); - } - pthread_mutex_unlock (&_ports_htable_lock); - -diff --git a/libports/inhibit-port-rpcs.c b/libports/inhibit-port-rpcs.c -index f712ca9..7479a50 100644 ---- a/libports/inhibit-port-rpcs.c -+++ b/libports/inhibit-port-rpcs.c -@@ -35,7 +35,8 @@ ports_inhibit_port_rpcs (void *portstruct) - { - struct rpc_info *rpc; - struct rpc_info *this_rpc = 0; -- -+ -+ pthread_mutex_lock (&pi->current_rpcs_lock); - for (rpc = pi->current_rpcs; rpc; rpc = rpc->next) - { - /* Avoid cancelling the calling thread. */ -@@ -57,6 +58,7 @@ ports_inhibit_port_rpcs (void *portstruct) - break; - } - } -+ pthread_mutex_unlock (&pi->current_rpcs_lock); - - pi->flags &= ~PORT_INHIBIT_WAIT; - if (! err) -diff --git a/libports/interrupt-on-notify.c b/libports/interrupt-on-notify.c -index 7b93429..2118e4b 100644 ---- a/libports/interrupt-on-notify.c -+++ b/libports/interrupt-on-notify.c -@@ -170,11 +170,11 @@ ports_interrupt_self_on_notification (void *object, - struct port_info *pi = object; - thread_t thread = hurd_thread_self (); - -- pthread_mutex_lock (&_ports_global_lock); -+ pthread_mutex_lock (&pi->current_rpcs_lock); - for (rpc = pi->current_rpcs; rpc; rpc = rpc->next) - if (rpc->thread == thread) - break; -- pthread_mutex_unlock (&_ports_global_lock); -+ pthread_mutex_unlock (&pi->current_rpcs_lock); - - assert (rpc); - -diff --git a/libports/interrupt-rpcs.c b/libports/interrupt-rpcs.c -index 3dc3777..bc6e8f7 100644 ---- a/libports/interrupt-rpcs.c -+++ b/libports/interrupt-rpcs.c -@@ -27,13 +27,13 @@ ports_interrupt_rpcs (void *portstruct) - struct port_info *pi = portstruct; - struct rpc_info *rpc; - -- pthread_mutex_lock (&_ports_global_lock); -- -+ pthread_mutex_lock (&pi->current_rpcs_lock); -+ - for (rpc = pi->current_rpcs; rpc; rpc = rpc->next) - { - hurd_thread_cancel (rpc->thread); - _ports_record_interruption (rpc); - } - -- pthread_mutex_unlock (&_ports_global_lock); -+ pthread_mutex_unlock (&pi->current_rpcs_lock); - } -diff --git a/libports/ports.h b/libports/ports.h -index ea99a7f..d26df42 100644 ---- a/libports/ports.h -+++ b/libports/ports.h -@@ -48,6 +48,7 @@ struct port_info - int flags; - mach_port_t port_right; - struct rpc_info *current_rpcs; -+ pthread_mutex_t current_rpcs_lock; - struct port_bucket *bucket; - hurd_ihash_locp_t hentry; - }; diff --git a/debian/patches/libports-lockless-refcounting.patch b/debian/patches/libports-lockless-refcounting.patch deleted file mode 100644 index dbfe0314..00000000 --- a/debian/patches/libports-lockless-refcounting.patch +++ /dev/null @@ -1,351 +0,0 @@ -commit f5d4ef14bb47294046d98c06478b0b58c97cf521 -Author: Justus Winter <4winter@informatik.uni-hamburg.de> -Date: Sat May 3 01:02:35 2014 +0200 - - libports: implement lockless reference counting - - * libports/refcount.h: New file with reference counting primitives. - * libports/ports.h (struct port_info): Use the new type. - * libports/bucket-iterate.c: Adjust accordingly. - * libports/complete-deallocate.c: Likewise. - * libports/create-internal.c: Likewise. - * libports/get-right.c: Likewise. - * libports/import-port.c: Likewise. - * libports/lookup-port.c: Likewise. - * libports/port-deref-weak.c: Likewise. - * libports/port-deref.c: Likewise. - * libports/port-ref-weak.c: Likewise. - * libports/port-ref.c: Likewise. - * libports/reallocate-from-external.c: Likewise. - * libports/transfer-right.c: Likewise. - * utils/rpctrace.c: Likewise. - -diff --git a/libports/bucket-iterate.c b/libports/bucket-iterate.c -index 498cf13..38a9f7a 100644 ---- a/libports/bucket-iterate.c -+++ b/libports/bucket-iterate.c -@@ -55,7 +55,7 @@ _ports_bucket_class_iterate (struct port_bucket *bucket, - - if (class == 0 || pi->class == class) - { -- pi->refcnt++; -+ ports_port_ref (pi); - p[n] = pi; - n++; - } -diff --git a/libports/complete-deallocate.c b/libports/complete-deallocate.c -index 8ce095b..7e7d467 100644 ---- a/libports/complete-deallocate.c -+++ b/libports/complete-deallocate.c -@@ -35,6 +35,8 @@ _ports_complete_deallocate (struct port_info *pi) - pi->port_right = MACH_PORT_NULL; - } - -+ pthread_mutex_lock (&_ports_lock); -+ - *pi->prevp = pi->next; - if (pi->next) - pi->next->prevp = pi->prevp; -diff --git a/libports/create-internal.c b/libports/create-internal.c -index 8551297..d56637c 100644 ---- a/libports/create-internal.c -+++ b/libports/create-internal.c -@@ -54,8 +54,7 @@ _ports_create_port_internal (struct port_class *class, - } - - pi->class = class; -- pi->refcnt = 1; -- pi->weakrefcnt = 0; -+ refcount_init (&pi->refcounts, 1, 0); - pi->cancel_threshold = 0; - pi->mscount = 0; - pi->flags = 0; -diff --git a/libports/get-right.c b/libports/get-right.c -index 89050c6..42bfa2b 100644 ---- a/libports/get-right.c -+++ b/libports/get-right.c -@@ -41,7 +41,7 @@ ports_get_right (void *port) - if ((pi->flags & PORT_HAS_SENDRIGHTS) == 0) - { - pi->flags |= PORT_HAS_SENDRIGHTS; -- pi->refcnt++; -+ ports_port_ref (pi); - err = mach_port_request_notification (mach_task_self (), - pi->port_right, - MACH_NOTIFY_NO_SENDERS, -diff --git a/libports/import-port.c b/libports/import-port.c -index 226f47e..5c66685 100644 ---- a/libports/import-port.c -+++ b/libports/import-port.c -@@ -48,8 +48,7 @@ ports_import_port (struct port_class *class, struct port_bucket *bucket, - return ENOMEM; - - pi->class = class; -- pi->refcnt = 1 + !!stat.mps_srights; -- pi->weakrefcnt = 0; -+ refcount_init (&pi->refcounts, 1 + !!stat.mps_srights, 0); - pi->cancel_threshold = 0; - pi->mscount = stat.mps_mscount; - pi->flags = stat.mps_srights ? PORT_HAS_SENDRIGHTS : 0; -diff --git a/libports/lookup-port.c b/libports/lookup-port.c -index f79f6f0..289369f 100644 ---- a/libports/lookup-port.c -+++ b/libports/lookup-port.c -@@ -44,7 +44,7 @@ ports_lookup_port (struct port_bucket *bucket, - pi = 0; - - if (pi) -- pi->refcnt++; -+ ports_port_ref (pi); - - pthread_mutex_unlock (&_ports_lock); - -diff --git a/libports/port-deref-weak.c b/libports/port-deref-weak.c -index beb4842..48e5354 100644 ---- a/libports/port-deref-weak.c -+++ b/libports/port-deref-weak.c -@@ -25,12 +25,8 @@ void - ports_port_deref_weak (void *portstruct) - { - struct port_info *pi = portstruct; -- -- pthread_mutex_lock (&_ports_lock); -- assert (pi->weakrefcnt); -- pi->weakrefcnt--; -- if (pi->refcnt == 0 && pi->weakrefcnt == 0) -+ struct refs result; -+ refcount_deref_weak (&pi->refcounts, &result); -+ if (result.hard == 0 && result.weak == 0) - _ports_complete_deallocate (pi); -- else -- pthread_mutex_unlock (&_ports_lock); - } -diff --git a/libports/port-deref.c b/libports/port-deref.c -index cf9b238..056159c 100644 ---- a/libports/port-deref.c -+++ b/libports/port-deref.c -@@ -26,25 +26,19 @@ ports_port_deref (void *portstruct) - { - struct port_info *pi = portstruct; - int trieddroppingweakrefs = 0; -+ struct refs result; - - retry: -- -- pthread_mutex_lock (&_ports_lock); -- -- if (pi->refcnt == 1 && pi->weakrefcnt -+ refcount_deref (&pi->refcounts, &result); -+ if (result.hard == 0 && result.weak > 1 - && pi->class->dropweak_routine && !trieddroppingweakrefs) - { -- pthread_mutex_unlock (&_ports_lock); -+ refcount_ref (&pi->refcounts, NULL); - (*pi->class->dropweak_routine) (pi); - trieddroppingweakrefs = 1; - goto retry; - } -- -- assert (pi->refcnt); - -- pi->refcnt--; -- if (pi->refcnt == 0 && pi->weakrefcnt == 0) -+ if (result.hard == 0 && result.weak == 0) - _ports_complete_deallocate (pi); -- else -- pthread_mutex_unlock (&_ports_lock); - } -diff --git a/libports/port-ref-weak.c b/libports/port-ref-weak.c -index c7d3c69..8b75005 100644 ---- a/libports/port-ref-weak.c -+++ b/libports/port-ref-weak.c -@@ -25,9 +25,7 @@ void - ports_port_ref_weak (void *portstruct) - { - struct port_info *pi = portstruct; -- -- pthread_mutex_lock (&_ports_lock); -- assert (pi->refcnt || pi->weakrefcnt); -- pi->weakrefcnt++; -- pthread_mutex_unlock (&_ports_lock); -+ struct refs result; -+ refcount_ref_weak (&pi->refcounts, &result); -+ assert (result.hard > 0 || result.weak > 1); - } -diff --git a/libports/port-ref.c b/libports/port-ref.c -index 92b7118..6310902 100644 ---- a/libports/port-ref.c -+++ b/libports/port-ref.c -@@ -25,9 +25,7 @@ void - ports_port_ref (void *portstruct) - { - struct port_info *pi = portstruct; -- -- pthread_mutex_lock (&_ports_lock); -- assert (pi->refcnt || pi->weakrefcnt); -- pi->refcnt++; -- pthread_mutex_unlock (&_ports_lock); -+ struct refs result; -+ refcount_ref (&pi->refcounts, &result); -+ assert (result.hard > 1 || result.weak > 0); - } -diff --git a/libports/ports.h b/libports/ports.h -index 7f13124..7088b2d 100644 ---- a/libports/ports.h -+++ b/libports/ports.h -@@ -22,12 +22,15 @@ - #define _HURD_PORTS_ - - #include <mach.h> -+#include <stdint.h> - #include <stdlib.h> - #include <hurd.h> - #include <hurd/ihash.h> - #include <mach/notify.h> - #include <pthread.h> - -+#include "refcount.h" -+ - /* These are global values for common flags used in the various structures. - Not all of these are meaningful in all flag fields. */ - #define PORTS_INHIBITED 0x0100 /* block RPC's */ -@@ -39,8 +42,7 @@ - struct port_info - { - struct port_class *class; -- int refcnt; -- int weakrefcnt; -+ reference_counts refcounts; - mach_port_mscount_t mscount; - mach_msg_seqno_t cancel_threshold; - int flags; -diff --git a/libports/reallocate-from-external.c b/libports/reallocate-from-external.c -index 8cccb2a..4dfc59c 100644 ---- a/libports/reallocate-from-external.c -+++ b/libports/reallocate-from-external.c -@@ -53,7 +53,7 @@ ports_reallocate_from_external (void *portstruct, mach_port_t receive) - else if (((pi->flags & PORT_HAS_SENDRIGHTS) == 0) && stat.mps_srights) - { - pi->flags |= PORT_HAS_SENDRIGHTS; -- pi->refcnt++; -+ ports_port_ref (pi); - } - - pi->port_right = receive; -diff --git a/libports/refcount.h b/libports/refcount.h -new file mode 100644 -index 0000000..43da5b4 ---- /dev/null -+++ b/libports/refcount.h -@@ -0,0 +1,72 @@ -+#ifndef _PORTS_REFCOUNT_H_ -+#define _PORTS_REFCOUNT_H_ -+ -+typedef uint64_t reference_counts; -+ -+struct refs { -+ uint32_t hard; -+ uint32_t weak; -+}; -+ -+union _refs { -+ struct refs refs; -+ reference_counts rc; -+}; -+ -+extern inline void -+refcount_init (reference_counts *ref, uint32_t hard, uint32_t weak) -+{ -+ ((union _refs *) ref)->refs = -+ (struct refs) { .hard = hard, .weak = weak }; -+} -+ -+extern inline void -+refcount_ref (reference_counts *ref, struct refs *result) -+{ -+ const union _refs op = { .refs = { .hard = 1 } }; -+ reference_counts r = __atomic_add_fetch (ref, op.rc, __ATOMIC_RELAXED); -+ if (result) -+ ((union _refs *) result)->rc = r; -+} -+ -+extern inline void -+refcount_deref (reference_counts *ref, struct refs *result) -+{ -+ const union _refs op = { .refs = { .hard = 1 } }; -+ ((union _refs *) result)->rc = -+ __atomic_sub_fetch (ref, op.rc, __ATOMIC_RELAXED); -+} -+ -+extern inline void -+refcount_ref_weak (reference_counts *ref, struct refs *result) -+{ -+ const union _refs op = { .refs = { .weak = 1 } }; -+ ((union _refs *) result)->rc = -+ __atomic_add_fetch (ref, op.rc, __ATOMIC_RELAXED); -+} -+ -+extern inline void -+refcount_deref_weak (reference_counts *ref, struct refs *result) -+{ -+ const union _refs op = { .refs = { .weak = 1 } }; -+ ((union _refs *) result)->rc = -+ __atomic_sub_fetch (ref, op.rc, __ATOMIC_RELAXED); -+} -+ -+extern inline uint32_t -+refcount_hard_refs (reference_counts *ref) -+{ -+ union _refs result; -+ result.rc = __atomic_load_n (ref, __ATOMIC_RELAXED); -+ return result.refs.hard; -+} -+ -+extern inline uint32_t -+refcount_weak_refs (reference_counts *ref) -+{ -+ union _refs result; -+ result.rc = __atomic_load_n (ref, __ATOMIC_RELAXED); -+ return result.refs.weak; -+} -+ -+#endif /* _PORTS_REFCOUNT_H_ */ -diff --git a/libports/transfer-right.c b/libports/transfer-right.c -index 72488a9..f4e0c86 100644 ---- a/libports/transfer-right.c -+++ b/libports/transfer-right.c -@@ -66,7 +66,7 @@ ports_transfer_right (void *tostruct, - else if (((topi->flags & PORT_HAS_SENDRIGHTS) == 0) && hassendrights) - { - topi->flags |= PORT_HAS_SENDRIGHTS; -- topi->refcnt++; -+ ports_port_ref (topi); - } - } - -diff --git a/utils/rpctrace.c b/utils/rpctrace.c -index fc913e3..248d4e2 100644 ---- a/utils/rpctrace.c -+++ b/utils/rpctrace.c -@@ -431,7 +431,8 @@ destroy_receiver_info (struct receiver_info *info) - while (send_wrapper) - { - struct sender_info *next = send_wrapper->next; -- assert (TRACED_INFO (send_wrapper)->pi.refcnt == 1); -+ assert (refcount_hard_refs (&TRACED_INFO (send_wrapper)->pi.refcounts) -+ == 1); - /* Reset the receive_right of the send wrapper in advance to avoid - * destroy_receiver_info is called when the port info is destroyed. */ - send_wrapper->receive_right = NULL; -@@ -848,7 +849,10 @@ rewrite_right (mach_port_t *right, mach_msg_type_name_t *type, - hurd_ihash_locp_remove (&traced_names, receiver_info->locp); - - send_wrapper2 = get_send_wrapper (receiver_info, dest, &rr); -- assert (TRACED_INFO (send_wrapper2)->pi.refcnt == 1); -+ assert ( -+ refcount_hard_refs (&TRACED_INFO (send_wrapper2)->pi.refcounts) -+ == 1); -+ - name = TRACED_INFO (send_wrapper2)->name; - TRACED_INFO (send_wrapper2)->name = NULL; - /* send_wrapper2 isn't destroyed normally, so we need to unlink diff --git a/debian/patches/libports-per-bucket-hashtable.patch b/debian/patches/libports-per-bucket-hashtable.patch deleted file mode 100644 index 98d3f31d..00000000 --- a/debian/patches/libports-per-bucket-hashtable.patch +++ /dev/null @@ -1,1067 +0,0 @@ -commit 60e4ccf4cfd4e67fa7b0a51d95d87a1791e34788 -Author: Justus Winter <4winter@informatik.uni-hamburg.de> -Date: Sat May 3 03:53:41 2014 +0200 - - libports: per-bucket lock for the hash tables - -diff --git a/libports/begin-rpc.c b/libports/begin-rpc.c -index 142af98..de58b06 100644 ---- a/libports/begin-rpc.c -+++ b/libports/begin-rpc.c -@@ -29,14 +29,14 @@ ports_begin_rpc (void *portstruct, mach_msg_id_t msg_id, struct rpc_info *info) - - struct port_info *pi = portstruct; - -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - - do - { - /* If our receive right is gone, then abandon the RPC. */ - if (pi->port_right == MACH_PORT_NULL) - { -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - return EOPNOTSUPP; - } - -@@ -75,13 +75,13 @@ ports_begin_rpc (void *portstruct, mach_msg_id_t msg_id, struct rpc_info *info) - if (block_flags) - { - *block_flags |= PORTS_BLOCKED; -- if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_lock)) -+ if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_global_lock)) - /* We've been cancelled, just return EINTR. If we were the - only one blocking, PORTS_BLOCKED will still be turned on, - but that's ok, it will just cause a (harmless) extra - pthread_cond_broadcast(). */ - { -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - return EINTR; - } - } -@@ -102,7 +102,7 @@ ports_begin_rpc (void *portstruct, mach_msg_id_t msg_id, struct rpc_info *info) - pi->bucket->rpcs++; - _ports_total_rpcs++; - -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - - return 0; - } -diff --git a/libports/bucket-iterate.c b/libports/bucket-iterate.c -index 9230b1f..5a6a56b 100644 ---- a/libports/bucket-iterate.c -+++ b/libports/bucket-iterate.c -@@ -35,11 +35,11 @@ _ports_bucket_class_iterate (struct port_bucket *bucket, - size_t i, n, nr_items; - error_t err; - -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&bucket->lock); - - if (bucket->htable.nr_items == 0) - { -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&bucket->lock); - return 0; - } - -@@ -47,7 +47,7 @@ _ports_bucket_class_iterate (struct port_bucket *bucket, - p = malloc (nr_items * sizeof *p); - if (p == NULL) - { -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&bucket->lock); - return ENOMEM; - } - -@@ -63,7 +63,7 @@ _ports_bucket_class_iterate (struct port_bucket *bucket, - n++; - } - } -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&bucket->lock); - - if (n != nr_items) - { -diff --git a/libports/claim-right.c b/libports/claim-right.c -index 4851ea3..73e383a 100644 ---- a/libports/claim-right.c -+++ b/libports/claim-right.c -@@ -34,19 +34,21 @@ ports_claim_right (void *portstruct) - if (ret == MACH_PORT_NULL) - return ret; - -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&pi->bucket->lock); - hurd_ihash_locp_remove (&pi->bucket->htable, pi->hentry); -+ pthread_mutex_unlock (&pi->bucket->lock); - err = mach_port_move_member (mach_task_self (), ret, MACH_PORT_NULL); - assert_perror (err); -+ pthread_mutex_lock (&_ports_global_lock); - pi->port_right = MACH_PORT_NULL; - if (pi->flags & PORT_HAS_SENDRIGHTS) - { - pi->flags &= ~PORT_HAS_SENDRIGHTS; -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - ports_port_deref (pi); - } - else -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - - return ret; - } -diff --git a/libports/class-iterate.c b/libports/class-iterate.c -index 1f8878a..638dd45 100644 ---- a/libports/class-iterate.c -+++ b/libports/class-iterate.c -@@ -23,13 +23,13 @@ error_t - ports_class_iterate (struct port_class *class, - error_t (*fun)(void *)) - { -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - if (class->ports != 0) - { - struct port_bucket *bucket = class->ports->bucket; -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - return _ports_bucket_class_iterate (bucket, class, fun); - } -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - return 0; - } -diff --git a/libports/complete-deallocate.c b/libports/complete-deallocate.c -index 7e7d467..c08d0ce 100644 ---- a/libports/complete-deallocate.c -+++ b/libports/complete-deallocate.c -@@ -29,13 +29,15 @@ _ports_complete_deallocate (struct port_info *pi) - - if (pi->port_right) - { -+ pthread_mutex_lock (&pi->bucket->lock); - hurd_ihash_locp_remove (&pi->bucket->htable, pi->hentry); -+ pthread_mutex_unlock (&pi->bucket->lock); - mach_port_mod_refs (mach_task_self (), pi->port_right, - MACH_PORT_RIGHT_RECEIVE, -1); - pi->port_right = MACH_PORT_NULL; - } - -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - - *pi->prevp = pi->next; - if (pi->next) -@@ -44,7 +46,7 @@ _ports_complete_deallocate (struct port_info *pi) - pi->bucket->count--; - pi->class->count--; - -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - - if (pi->class->clean_routine) - (*pi->class->clean_routine)(pi); -diff --git a/libports/count-bucket.c b/libports/count-bucket.c -index 63feb6b..8e6eadb 100644 ---- a/libports/count-bucket.c -+++ b/libports/count-bucket.c -@@ -25,10 +25,10 @@ ports_count_bucket (struct port_bucket *bucket) - { - int ret; - -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - ret = bucket->count; - bucket->flags |= PORT_BUCKET_NO_ALLOC; -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - - return ret; - } -diff --git a/libports/count-class.c b/libports/count-class.c -index 0c48b46..5f5dc73 100644 ---- a/libports/count-class.c -+++ b/libports/count-class.c -@@ -25,9 +25,9 @@ ports_count_class (struct port_class *class) - { - int ret; - -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - ret = class->count; - class->flags |= PORT_CLASS_NO_ALLOC; -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - return ret; - } -diff --git a/libports/create-bucket.c b/libports/create-bucket.c -index 52d50c3..f8a0996 100644 ---- a/libports/create-bucket.c -+++ b/libports/create-bucket.c -@@ -46,13 +46,14 @@ ports_create_bucket () - return NULL; - } - -+ pthread_mutex_init (&ret->lock, NULL); - hurd_ihash_init (&ret->htable, offsetof (struct port_info, hentry)); - ret->rpcs = ret->flags = ret->count = 0; - -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - ret->next = _ports_all_buckets; - _ports_all_buckets = ret; -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - - return ret; - } -diff --git a/libports/create-internal.c b/libports/create-internal.c -index d56637c..33ee1e1 100644 ---- a/libports/create-internal.c -+++ b/libports/create-internal.c -@@ -62,25 +62,27 @@ _ports_create_port_internal (struct port_class *class, - pi->current_rpcs = 0; - pi->bucket = bucket; - -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - - loop: - if (class->flags & PORT_CLASS_NO_ALLOC) - { - class->flags |= PORT_CLASS_ALLOC_WAIT; -- if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_lock)) -+ if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_global_lock)) - goto cancelled; - goto loop; - } - if (bucket->flags & PORT_BUCKET_NO_ALLOC) - { - bucket->flags |= PORT_BUCKET_ALLOC_WAIT; -- if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_lock)) -+ if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_global_lock)) - goto cancelled; - goto loop; - } - -+ pthread_mutex_lock (&bucket->lock); - err = hurd_ihash_add (&bucket->htable, port, pi); -+ pthread_mutex_unlock (&bucket->lock); - if (err) - goto lose; - -@@ -91,7 +93,7 @@ _ports_create_port_internal (struct port_class *class, - class->ports = pi; - bucket->count++; - class->count++; -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - - if (install) - { -@@ -107,7 +109,7 @@ _ports_create_port_internal (struct port_class *class, - cancelled: - err = EINTR; - lose: -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - lose_unlocked:; - error_t e; - e = mach_port_mod_refs (mach_task_self (), port, -diff --git a/libports/destroy-right.c b/libports/destroy-right.c -index 65e19c7..b12dec9 100644 ---- a/libports/destroy-right.c -+++ b/libports/destroy-right.c -@@ -30,12 +30,12 @@ ports_destroy_right (void *portstruct) - - if (pi->port_right != MACH_PORT_NULL) - { -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&pi->bucket->lock); - hurd_ihash_locp_remove (&pi->bucket->htable, pi->hentry); - err = mach_port_mod_refs (mach_task_self (), pi->port_right, - MACH_PORT_RIGHT_RECEIVE, -1); - assert_perror (err); -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&pi->bucket->lock); - - pi->port_right = MACH_PORT_NULL; - -diff --git a/libports/enable-bucket.c b/libports/enable-bucket.c -index f9c7b85..bf33cf8 100644 ---- a/libports/enable-bucket.c -+++ b/libports/enable-bucket.c -@@ -23,12 +23,12 @@ - void - ports_enable_bucket (struct port_bucket *bucket) - { -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - bucket->flags &= ~PORT_BUCKET_NO_ALLOC; - if (bucket->flags & PORT_BUCKET_ALLOC_WAIT) - { - bucket->flags &= ~PORT_BUCKET_ALLOC_WAIT; - pthread_cond_broadcast (&_ports_block); - } -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - } -diff --git a/libports/enable-class.c b/libports/enable-class.c -index b3894eb..cbddc1a 100644 ---- a/libports/enable-class.c -+++ b/libports/enable-class.c -@@ -23,12 +23,12 @@ - void - ports_enable_class (struct port_class *class) - { -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - class->flags &= ~PORT_CLASS_NO_ALLOC; - if (class->flags & PORT_CLASS_ALLOC_WAIT) - { - class->flags &= ~PORT_CLASS_ALLOC_WAIT; - pthread_cond_broadcast (&_ports_block); - } -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - } -diff --git a/libports/end-rpc.c b/libports/end-rpc.c -index b5dcb3a..9134822 100644 ---- a/libports/end-rpc.c -+++ b/libports/end-rpc.c -@@ -25,7 +25,7 @@ ports_end_rpc (void *port, struct rpc_info *info) - { - struct port_info *pi = port; - -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - - if (info->notifies) - _ports_remove_notified_rpc (info); -@@ -51,5 +51,5 @@ ports_end_rpc (void *port, struct rpc_info *info) - RPC is now finished anwhow. */ - hurd_check_cancel (); - -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - } -diff --git a/libports/get-right.c b/libports/get-right.c -index 42bfa2b..6fe68f5 100644 ---- a/libports/get-right.c -+++ b/libports/get-right.c -@@ -29,11 +29,11 @@ ports_get_right (void *port) - mach_port_t foo; - error_t err; - -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - - if (pi->port_right == MACH_PORT_NULL) - { -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - return MACH_PORT_NULL; - } - -@@ -53,6 +53,6 @@ ports_get_right (void *port) - if (foo != MACH_PORT_NULL) - mach_port_deallocate (mach_task_self (), foo); - } -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - return pi->port_right; - } -diff --git a/libports/import-port.c b/libports/import-port.c -index 5c66685..1aa422a 100644 ---- a/libports/import-port.c -+++ b/libports/import-port.c -@@ -56,25 +56,27 @@ ports_import_port (struct port_class *class, struct port_bucket *bucket, - pi->current_rpcs = 0; - pi->bucket = bucket; - -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - - loop: - if (class->flags & PORT_CLASS_NO_ALLOC) - { - class->flags |= PORT_CLASS_ALLOC_WAIT; -- if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_lock)) -+ if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_global_lock)) - goto cancelled; - goto loop; - } - if (bucket->flags & PORT_BUCKET_NO_ALLOC) - { - bucket->flags |= PORT_BUCKET_ALLOC_WAIT; -- if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_lock)) -+ if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_global_lock)) - goto cancelled; - goto loop; - } - -+ pthread_mutex_lock (&bucket->lock); - err = hurd_ihash_add (&bucket->htable, port, pi); -+ pthread_mutex_unlock (&bucket->lock); - if (err) - goto lose; - -@@ -85,7 +87,7 @@ ports_import_port (struct port_class *class, struct port_bucket *bucket, - class->ports = pi; - bucket->count++; - class->count++; -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - - mach_port_move_member (mach_task_self (), port, bucket->portset); - -@@ -107,7 +109,7 @@ ports_import_port (struct port_class *class, struct port_bucket *bucket, - cancelled: - err = EINTR; - lose: -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - free (pi); - - return err; -diff --git a/libports/inhibit-all-rpcs.c b/libports/inhibit-all-rpcs.c -index d4a54ba..337d068 100644 ---- a/libports/inhibit-all-rpcs.c -+++ b/libports/inhibit-all-rpcs.c -@@ -27,7 +27,7 @@ ports_inhibit_all_rpcs () - { - error_t err = 0; - -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - - if (_ports_flags & (_PORTS_INHIBITED | _PORTS_INHIBIT_WAIT)) - err = EBUSY; -@@ -38,6 +38,7 @@ ports_inhibit_all_rpcs () - - for (bucket = _ports_all_buckets; bucket; bucket = bucket->next) - { -+ pthread_mutex_lock (&bucket->lock); - HURD_IHASH_ITERATE (&bucket->htable, portstruct) - { - struct rpc_info *rpc; -@@ -53,12 +54,13 @@ ports_inhibit_all_rpcs () - hurd_thread_cancel (rpc->thread); - } - } -+ pthread_mutex_unlock (&bucket->lock); - } - - while (_ports_total_rpcs > this_one) - { - _ports_flags |= _PORTS_INHIBIT_WAIT; -- if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_lock)) -+ if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_global_lock)) - /* We got cancelled. */ - { - err = EINTR; -@@ -71,7 +73,7 @@ ports_inhibit_all_rpcs () - _ports_flags |= _PORTS_INHIBITED; - } - -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - - return err; - } -diff --git a/libports/inhibit-bucket-rpcs.c b/libports/inhibit-bucket-rpcs.c -index 965aa03..d55798e 100644 ---- a/libports/inhibit-bucket-rpcs.c -+++ b/libports/inhibit-bucket-rpcs.c -@@ -27,7 +27,7 @@ ports_inhibit_bucket_rpcs (struct port_bucket *bucket) - { - error_t err = 0; - -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - - if (bucket->flags & (PORT_BUCKET_INHIBITED | PORT_BUCKET_INHIBIT_WAIT)) - err = EBUSY; -@@ -35,6 +35,7 @@ ports_inhibit_bucket_rpcs (struct port_bucket *bucket) - { - int this_one = 0; - -+ pthread_mutex_lock (&bucket->lock); - HURD_IHASH_ITERATE (&bucket->htable, portstruct) - { - struct rpc_info *rpc; -@@ -49,12 +50,12 @@ ports_inhibit_bucket_rpcs (struct port_bucket *bucket) - hurd_thread_cancel (rpc->thread); - } - } -- -+ pthread_mutex_unlock (&bucket->lock); - - while (bucket->rpcs > this_one) - { - bucket->flags |= PORT_BUCKET_INHIBIT_WAIT; -- if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_lock)) -+ if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_global_lock)) - /* We got cancelled. */ - { - err = EINTR; -@@ -67,7 +68,7 @@ ports_inhibit_bucket_rpcs (struct port_bucket *bucket) - bucket->flags |= PORT_BUCKET_INHIBITED; - } - -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - - return err; - } -diff --git a/libports/inhibit-class-rpcs.c b/libports/inhibit-class-rpcs.c -index 7ee8653..fe26f27 100644 ---- a/libports/inhibit-class-rpcs.c -+++ b/libports/inhibit-class-rpcs.c -@@ -26,7 +26,7 @@ ports_inhibit_class_rpcs (struct port_class *class) - { - error_t err = 0; - -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - - if (class->flags & (PORT_CLASS_INHIBITED | PORT_CLASS_INHIBIT_WAIT)) - err = EBUSY; -@@ -49,7 +49,7 @@ ports_inhibit_class_rpcs (struct port_class *class) - while (class->rpcs > this_one) - { - class->flags |= PORT_CLASS_INHIBIT_WAIT; -- if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_lock)) -+ if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_global_lock)) - /* We got cancelled. */ - { - err = EINTR; -@@ -62,7 +62,7 @@ ports_inhibit_class_rpcs (struct port_class *class) - class->flags |= PORT_CLASS_INHIBITED; - } - -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - - return err; - } -diff --git a/libports/inhibit-port-rpcs.c b/libports/inhibit-port-rpcs.c -index b741eeb..f712ca9 100644 ---- a/libports/inhibit-port-rpcs.c -+++ b/libports/inhibit-port-rpcs.c -@@ -27,7 +27,7 @@ ports_inhibit_port_rpcs (void *portstruct) - error_t err = 0; - struct port_info *pi = portstruct; - -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - - if (pi->flags & (PORT_INHIBITED | PORT_INHIBIT_WAIT)) - err = EBUSY; -@@ -50,7 +50,7 @@ ports_inhibit_port_rpcs (void *portstruct) - && !(pi->current_rpcs == this_rpc && ! this_rpc->next)) - { - pi->flags |= PORT_INHIBIT_WAIT; -- if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_lock)) -+ if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_global_lock)) - /* We got cancelled. */ - { - err = EINTR; -@@ -63,7 +63,7 @@ ports_inhibit_port_rpcs (void *portstruct) - pi->flags |= PORT_INHIBITED; - } - -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - - return err; - } -diff --git a/libports/init.c b/libports/init.c -index 3ef5388..36e42a0 100644 ---- a/libports/init.c -+++ b/libports/init.c -@@ -20,7 +20,7 @@ - - #include "ports.h" - --pthread_mutex_t _ports_lock = PTHREAD_MUTEX_INITIALIZER; -+pthread_mutex_t _ports_global_lock = PTHREAD_MUTEX_INITIALIZER; - pthread_cond_t _ports_block = PTHREAD_COND_INITIALIZER; - struct port_bucket *_ports_all_buckets; - int _ports_total_rpcs; -diff --git a/libports/interrupt-notified-rpcs.c b/libports/interrupt-notified-rpcs.c -index 49a15d0..06f1c1f 100644 ---- a/libports/interrupt-notified-rpcs.c -+++ b/libports/interrupt-notified-rpcs.c -@@ -36,7 +36,7 @@ ports_interrupt_notified_rpcs (void *object, - { - struct ports_notify *np; - -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - for (np = _ports_notifications; np; np = np->next) - if (np->port == port && np->what == what) - { -@@ -49,7 +49,7 @@ ports_interrupt_notified_rpcs (void *object, - } - break; - } -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - } - } - -diff --git a/libports/interrupt-on-notify.c b/libports/interrupt-on-notify.c -index b358e84..7b93429 100644 ---- a/libports/interrupt-on-notify.c -+++ b/libports/interrupt-on-notify.c -@@ -34,13 +34,13 @@ ports_interrupt_rpc_on_notification (void *object, - struct rpc_notify *new_req, *req; - struct port_info *pi = object; - -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - - if (! MACH_PORT_VALID (port)) - /* PORT is already dead or bogus, so interrupt the rpc immediately. */ - { - hurd_thread_cancel (rpc->thread); -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - return 0; - } - -@@ -53,11 +53,11 @@ ports_interrupt_rpc_on_notification (void *object, - time we'll add a new structure, so we malloc while we don't have the - lock, and free it if we're wrong. */ - { -- pthread_mutex_unlock (&_ports_lock); /* Don't hold the lock during malloc. */ -+ pthread_mutex_unlock (&_ports_global_lock); /* Don't hold the lock during malloc. */ - new_req = malloc (sizeof (struct rpc_notify)); - if (! new_req) - return ENOMEM; -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - } - - /* Find any existing entry for PORT/WHAT. */ -@@ -80,7 +80,7 @@ ports_interrupt_rpc_on_notification (void *object, - { - new_req->next = _ports_free_rpc_notifies; - _ports_free_rpc_notifies = new_req; -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - return ENOMEM; - } - } -@@ -138,7 +138,7 @@ ports_interrupt_rpc_on_notification (void *object, - if (req_notify) - pthread_mutex_lock (&pn->lock); - -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - - if (req_notify) - { -@@ -170,11 +170,11 @@ ports_interrupt_self_on_notification (void *object, - struct port_info *pi = object; - thread_t thread = hurd_thread_self (); - -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - for (rpc = pi->current_rpcs; rpc; rpc = rpc->next) - if (rpc->thread == thread) - break; -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - - assert (rpc); - -diff --git a/libports/interrupt-operation.c b/libports/interrupt-operation.c -index 943bd4f..940ae27 100644 ---- a/libports/interrupt-operation.c -+++ b/libports/interrupt-operation.c -@@ -29,10 +29,10 @@ ports_S_interrupt_operation (struct port_info *pi, - { - if (!pi) - return EOPNOTSUPP; -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - if (pi->cancel_threshold < seqno) - pi->cancel_threshold = seqno; -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - ports_interrupt_rpcs (pi); - return 0; - } -diff --git a/libports/interrupt-rpcs.c b/libports/interrupt-rpcs.c -index 42f51a5..3dc3777 100644 ---- a/libports/interrupt-rpcs.c -+++ b/libports/interrupt-rpcs.c -@@ -27,7 +27,7 @@ ports_interrupt_rpcs (void *portstruct) - struct port_info *pi = portstruct; - struct rpc_info *rpc; - -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - - for (rpc = pi->current_rpcs; rpc; rpc = rpc->next) - { -@@ -35,5 +35,5 @@ ports_interrupt_rpcs (void *portstruct) - _ports_record_interruption (rpc); - } - -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - } -diff --git a/libports/lookup-port.c b/libports/lookup-port.c -index 289369f..c919266 100644 ---- a/libports/lookup-port.c -+++ b/libports/lookup-port.c -@@ -27,26 +27,32 @@ ports_lookup_port (struct port_bucket *bucket, - struct port_class *class) - { - struct port_info *pi = 0; -- -- pthread_mutex_lock (&_ports_lock); - - if (bucket) -- pi = hurd_ihash_find (&bucket->htable, port); -+ { -+ pthread_mutex_lock (&bucket->lock); -+ pi = hurd_ihash_find (&bucket->htable, port); -+ pthread_mutex_unlock (&bucket->lock); -+ } - else -- for (bucket = _ports_all_buckets; bucket; bucket = bucket->next) -- { -- pi = hurd_ihash_find (&bucket->htable, port); -- if (pi) -- break; -- } -- -+ { -+ pthread_mutex_lock (&_ports_global_lock); -+ for (bucket = _ports_all_buckets; bucket; bucket = bucket->next) -+ { -+ pthread_mutex_lock (&bucket->lock); -+ pi = hurd_ihash_find (&bucket->htable, port); -+ pthread_mutex_unlock (&bucket->lock); -+ if (pi) -+ break; -+ } -+ pthread_mutex_unlock (&_ports_global_lock); -+ } -+ - if (pi && class && pi->class != class) - pi = 0; - - if (pi) - ports_port_ref (pi); - -- pthread_mutex_unlock (&_ports_lock); -- - return pi; - } -diff --git a/libports/manage-multithread.c b/libports/manage-multithread.c -index 2067cba..3ef4f4e 100644 ---- a/libports/manage-multithread.c -+++ b/libports/manage-multithread.c -@@ -173,10 +173,10 @@ ports_manage_port_operations_multithread (struct port_bucket *bucket, - } - else - { -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - if (inp->msgh_seqno < pi->cancel_threshold) - hurd_thread_cancel (link.thread); -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - status = demuxer (inp, outheadp); - ports_end_rpc (pi, &link); - } -diff --git a/libports/no-senders.c b/libports/no-senders.c -index 1a6084b..77d033f 100644 ---- a/libports/no-senders.c -+++ b/libports/no-senders.c -@@ -29,10 +29,10 @@ ports_no_senders (void *portstruct, - int dealloc; - mach_port_t old; - -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - if ((pi->flags & PORT_HAS_SENDRIGHTS) == 0) - { -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - return; - } - if (mscount >= pi->mscount) -@@ -53,8 +53,8 @@ ports_no_senders (void *portstruct, - mach_port_deallocate (mach_task_self (), old); - dealloc = 0; - } -- pthread_mutex_unlock (&_ports_lock); -- -+ pthread_mutex_unlock (&_ports_global_lock); -+ - if (dealloc) - { - ports_interrupt_notified_rpcs (portstruct, pi->port_right, -diff --git a/libports/ports.h b/libports/ports.h -index 7088b2d..c5bf8eb 100644 ---- a/libports/ports.h -+++ b/libports/ports.h -@@ -67,6 +67,8 @@ struct port_bucket - int rpcs; - int flags; - int count; -+ pthread_mutex_t lock; -+ - struct port_bucket *next; - }; - /* FLAGS above are the following: */ -@@ -402,7 +404,7 @@ extern kern_return_t - ports_do_mach_notify_send_once (struct port_info *pi); - - /* Private data */ --extern pthread_mutex_t _ports_lock; -+extern pthread_mutex_t _ports_global_lock; - extern pthread_cond_t _ports_block; - extern struct port_bucket *_ports_all_buckets; - extern int _ports_total_rpcs; -diff --git a/libports/reallocate-from-external.c b/libports/reallocate-from-external.c -index 4dfc59c..84fecc9 100644 ---- a/libports/reallocate-from-external.c -+++ b/libports/reallocate-from-external.c -@@ -34,17 +34,19 @@ ports_reallocate_from_external (void *portstruct, mach_port_t receive) - - err = mach_port_get_receive_status (mach_task_self (), receive, &stat); - assert_perror (err); -- -- pthread_mutex_lock (&_ports_lock); -- -+ -+ pthread_mutex_lock (&_ports_global_lock); -+ - assert (pi->port_right); - - err = mach_port_mod_refs (mach_task_self (), pi->port_right, - MACH_PORT_RIGHT_RECEIVE, -1); - assert_perror (err); - -+ pthread_mutex_lock (&pi->bucket->lock); - hurd_ihash_locp_remove (&pi->bucket->htable, pi->hentry); -- -+ pthread_mutex_unlock (&pi->bucket->lock); -+ - if ((pi->flags & PORT_HAS_SENDRIGHTS) && !stat.mps_srights) - { - dropref = 1; -@@ -55,15 +57,17 @@ ports_reallocate_from_external (void *portstruct, mach_port_t receive) - pi->flags |= PORT_HAS_SENDRIGHTS; - ports_port_ref (pi); - } -- -+ pthread_mutex_unlock (&_ports_global_lock); -+ - pi->port_right = receive; - pi->cancel_threshold = 0; - pi->mscount = stat.mps_mscount; -- -+ -+ pthread_mutex_lock (&pi->bucket->lock); - err = hurd_ihash_add (&pi->bucket->htable, receive, pi); -+ pthread_mutex_unlock (&pi->bucket->lock); - assert_perror (err); -- pthread_mutex_unlock (&_ports_lock); -- -+ - mach_port_move_member (mach_task_self (), receive, pi->bucket->portset); - - if (stat.mps_srights) -diff --git a/libports/reallocate-port.c b/libports/reallocate-port.c -index d2adaeb..f68865e 100644 ---- a/libports/reallocate-port.c -+++ b/libports/reallocate-port.c -@@ -29,14 +29,16 @@ ports_reallocate_port (void *portstruct) - error_t err; - int dropref = 0; - -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - assert (pi->port_right); - - err = mach_port_mod_refs (mach_task_self (), pi->port_right, - MACH_PORT_RIGHT_RECEIVE, -1); - assert_perror (err); - -+ pthread_mutex_lock (&pi->bucket->lock); - hurd_ihash_locp_remove (&pi->bucket->htable, pi->hentry); -+ pthread_mutex_unlock (&pi->bucket->lock); - - err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, - &pi->port_right); -@@ -46,11 +48,14 @@ ports_reallocate_port (void *portstruct) - pi->flags &= ~PORT_HAS_SENDRIGHTS; - dropref = 1; - } -+ pthread_mutex_unlock (&_ports_global_lock); -+ - pi->cancel_threshold = 0; - pi->mscount = 0; -+ pthread_mutex_lock (&pi->bucket->lock); - err = hurd_ihash_add (&pi->bucket->htable, pi->port_right, pi); -+ pthread_mutex_unlock (&pi->bucket->lock); - assert_perror (err); -- pthread_mutex_unlock (&_ports_lock); - - err = mach_port_move_member (mach_task_self (), pi->port_right, - pi->bucket->portset); -diff --git a/libports/resume-all-rpcs.c b/libports/resume-all-rpcs.c -index e4befff..e7766a1 100644 ---- a/libports/resume-all-rpcs.c -+++ b/libports/resume-all-rpcs.c -@@ -24,7 +24,7 @@ - void - ports_resume_all_rpcs () - { -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - assert (_ports_flags & _PORTS_INHIBITED); - _ports_flags &= ~_PORTS_INHIBITED; - if (_ports_flags & _PORTS_BLOCKED) -@@ -32,5 +32,5 @@ ports_resume_all_rpcs () - _ports_flags &= ~_PORTS_BLOCKED; - pthread_cond_broadcast (&_ports_block); - } -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - } -diff --git a/libports/resume-bucket-rpcs.c b/libports/resume-bucket-rpcs.c -index cf4db91..1078dac 100644 ---- a/libports/resume-bucket-rpcs.c -+++ b/libports/resume-bucket-rpcs.c -@@ -24,7 +24,7 @@ - void - ports_resume_bucket_rpcs (struct port_bucket *bucket) - { -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - assert (bucket->flags & PORT_BUCKET_INHIBITED); - bucket->flags &= ~PORT_BUCKET_INHIBITED; - if (bucket->flags & PORT_BUCKET_BLOCKED) -@@ -32,5 +32,5 @@ ports_resume_bucket_rpcs (struct port_bucket *bucket) - bucket->flags &= ~PORT_BUCKET_BLOCKED; - pthread_cond_broadcast (&_ports_block); - } -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - } -diff --git a/libports/resume-class-rpcs.c b/libports/resume-class-rpcs.c -index 60a2b12..00ec7de 100644 ---- a/libports/resume-class-rpcs.c -+++ b/libports/resume-class-rpcs.c -@@ -24,7 +24,7 @@ - void - ports_resume_class_rpcs (struct port_class *class) - { -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - assert (class->flags & PORT_CLASS_INHIBITED); - class->flags &= ~PORT_CLASS_INHIBITED; - if (class->flags & PORT_CLASS_BLOCKED) -@@ -32,5 +32,5 @@ ports_resume_class_rpcs (struct port_class *class) - class->flags &= ~PORT_CLASS_BLOCKED; - pthread_cond_broadcast (&_ports_block); - } -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - } -diff --git a/libports/resume-port-rpcs.c b/libports/resume-port-rpcs.c -index 6d71ab5..845c6f1 100644 ---- a/libports/resume-port-rpcs.c -+++ b/libports/resume-port-rpcs.c -@@ -25,9 +25,9 @@ void - ports_resume_port_rpcs (void *portstruct) - { - struct port_info *pi = portstruct; -- -- pthread_mutex_lock (&_ports_lock); -- -+ -+ pthread_mutex_lock (&_ports_global_lock); -+ - assert (pi->flags & PORT_INHIBITED); - pi->flags &= ~PORT_INHIBITED; - if (pi->flags & PORT_BLOCKED) -@@ -35,5 +35,5 @@ ports_resume_port_rpcs (void *portstruct) - pi->flags &= ~PORT_BLOCKED; - pthread_cond_broadcast (&_ports_block); - } -- pthread_mutex_unlock (&_ports_lock); -+ pthread_mutex_unlock (&_ports_global_lock); - } -diff --git a/libports/transfer-right.c b/libports/transfer-right.c -index f4e0c86..01c08e9 100644 ---- a/libports/transfer-right.c -+++ b/libports/transfer-right.c -@@ -35,13 +35,15 @@ ports_transfer_right (void *tostruct, - int hassendrights = 0; - error_t err; - -- pthread_mutex_lock (&_ports_lock); -+ pthread_mutex_lock (&_ports_global_lock); - - /* Fetch the port in FROMPI and clear its use */ - port = frompi->port_right; - if (port != MACH_PORT_NULL) - { -+ pthread_mutex_lock (&frompi->bucket->lock); - hurd_ihash_locp_remove (&frompi->bucket->htable, frompi->hentry); -+ pthread_mutex_unlock (&frompi->bucket->lock); - frompi->port_right = MACH_PORT_NULL; - if (frompi->flags & PORT_HAS_SENDRIGHTS) - { -@@ -54,7 +56,9 @@ ports_transfer_right (void *tostruct, - /* Destroy the existing right in TOPI. */ - if (topi->port_right != MACH_PORT_NULL) - { -+ pthread_mutex_lock (&topi->bucket->lock); - hurd_ihash_locp_remove (&topi->bucket->htable, topi->hentry); -+ pthread_mutex_unlock (&topi->bucket->lock); - err = mach_port_mod_refs (mach_task_self (), topi->port_right, - MACH_PORT_RIGHT_RECEIVE, -1); - assert_perror (err); -@@ -74,10 +78,14 @@ ports_transfer_right (void *tostruct, - topi->port_right = port; - topi->cancel_threshold = frompi->cancel_threshold; - topi->mscount = frompi->mscount; -- -+ -+ pthread_mutex_unlock (&_ports_global_lock); -+ - if (port) - { -+ pthread_mutex_lock (&topi->bucket->lock); - err = hurd_ihash_add (&topi->bucket->htable, port, topi); -+ pthread_mutex_unlock (&topi->bucket->lock); - assert_perror (err); - if (topi->bucket != frompi->bucket) - { -@@ -86,9 +94,7 @@ ports_transfer_right (void *tostruct, - assert_perror (err); - } - } -- -- pthread_mutex_unlock (&_ports_lock); -- -+ - /* Take care of any lowered reference counts. */ - if (dereffrompi) - ports_port_deref (frompi); diff --git a/debian/patches/series b/debian/patches/series index d959b7e1..7462b249 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -41,13 +41,3 @@ xkb-compat.patch mach-defpager-protected-payload.patch #ext2fs-cache-superblock.patch -#libports-lockless-refcounting.patch -#libports-per-bucket-hashtable.patch -#libports-a-single-hashtable.patch -#libports-current_rpcs_lock.patch -#libpager-singlethreaded.patch -#libpager-drop-seqnos.patch -0001-include-add-lock-less-reference-counting-primitives.patch -0002-libports-lock-less-reference-counting-for-port_info-.patch -#0003-libdiskfs-lock-less-reference-counting-for-peropen-o.patch -0004-libtrivfs-lock-less-reference-counting-for-trivfs_pr.patch |