diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2014-05-26 12:32:22 +0200 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2014-05-26 12:32:22 +0200 |
commit | e8a1d099b2ec7fa6843978597c617f6f703dd135 (patch) | |
tree | 74119a3f893d7c94ff0cade4e3a04e69ec1000fd /debian | |
parent | 4ee28b5fca1f61f7446352ee7332e8b2599d0644 (diff) |
add patch series
Diffstat (limited to 'debian')
9 files changed, 463 insertions, 0 deletions
diff --git a/debian/patches/0001-libstore-provide-function-declaration-until-availabl.patch b/debian/patches/0001-libstore-provide-function-declaration-until-availabl.patch new file mode 100644 index 00000000..f16712c1 --- /dev/null +++ b/debian/patches/0001-libstore-provide-function-declaration-until-availabl.patch @@ -0,0 +1,38 @@ +From cf0a11322f70824107ae3ac7a45c21c8a6cac558 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Wed, 21 May 2014 13:30:24 +0200 +Subject: [PATCH 1/8] libstore: provide function declaration until available + upstream + +Until the Hurd specific header is available, provide a local +declaration of ped_device_new_from_store. + +* libstore/part.c (ped_device_new_from_store): New declaration. +--- + libstore/part.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/libstore/part.c b/libstore/part.c +index 56e904e..fb7f07e 100644 +--- a/libstore/part.c ++++ b/libstore/part.c +@@ -26,6 +26,16 @@ + + #include <parted/parted.h> + /*#include <parted/device_gnu.h>*/ ++ ++/* XXX Until the Hurd specific header is available, provide the ++ declaration of ped_device_new_from_store here. */ ++ ++/* Initialize a PedDevice using SOURCE. The SOURCE will NOT be destroyed; ++ the caller created it, it is the caller's responsilbility to free it ++ after it calls ped_device_destory. SOURCE is not registered in Parted's ++ list of devices. */ ++PedDevice* ped_device_new_from_store (struct store *source); ++ + #include <string.h> + #include <error.h> + +-- +2.0.0.rc2 + diff --git a/debian/patches/0002-term-fix-memory-leak.patch b/debian/patches/0002-term-fix-memory-leak.patch new file mode 100644 index 00000000..c25695d0 --- /dev/null +++ b/debian/patches/0002-term-fix-memory-leak.patch @@ -0,0 +1,30 @@ +From 3f55bd402025bb8c21686086c0721b049472c3b4 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Tue, 20 May 2014 16:17:17 +0200 +Subject: [PATCH 2/8] term: fix memory leak + +I hope someone fixed that bug. + +* term/users.c (pi_destroy_hook): Fix memory leak. +--- + term/users.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/term/users.c b/term/users.c +index 97bc22c..9bd51d0 100644 +--- a/term/users.c ++++ b/term/users.c +@@ -259,9 +259,7 @@ pi_destroy_hook (struct trivfs_protid *cred) + { + assert (((struct protid_hook *)cred->hook)->refcnt > 0); + if (--((struct protid_hook *)cred->hook)->refcnt == 0) +- /* XXX don't free for now, so we can try and catch a multiple-freeing +- bug. */ +- /* free (cred->hook) */; ++ free (cred->hook); + } + pthread_mutex_unlock (&global_lock); + } +-- +2.0.0.rc2 + diff --git a/debian/patches/0003-libpager-drop-unused-fields-from-struct-pager.patch b/debian/patches/0003-libpager-drop-unused-fields-from-struct-pager.patch new file mode 100644 index 00000000..e84741c5 --- /dev/null +++ b/debian/patches/0003-libpager-drop-unused-fields-from-struct-pager.patch @@ -0,0 +1,26 @@ +From 31a897520d73e7be2453428fde4557b68b74b90f Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Sun, 25 May 2014 14:37:55 +0200 +Subject: [PATCH 3/8] libpager: drop unused fields from struct pager + +* libpager/priv.h (struct pager): Drop fields next, pprev. +--- + libpager/priv.h | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/libpager/priv.h b/libpager/priv.h +index d49cbb9..1f8405a 100644 +--- a/libpager/priv.h ++++ b/libpager/priv.h +@@ -59,8 +59,6 @@ struct pager + + int noterm; /* number of threads blocking termination */ + +- struct pager *next, **pprev; +- + int termwaiting:1; + int waitingforseqno:1; + +-- +2.0.0.rc2 + diff --git a/debian/patches/0004-ext2fs-fix-diskfs_pager_users.patch b/debian/patches/0004-ext2fs-fix-diskfs_pager_users.patch new file mode 100644 index 00000000..349c8cbb --- /dev/null +++ b/debian/patches/0004-ext2fs-fix-diskfs_pager_users.patch @@ -0,0 +1,29 @@ +From f834b1f76f22f301daf9759973244838fecae56b Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Sun, 25 May 2014 14:18:35 +0200 +Subject: [PATCH 4/8] ext2fs: fix diskfs_pager_users + +This fixes a bug introduced in 86122789. + +* ext2fs/pager.c (diskfs_pager_users): We count file_pager_bucket, +which does not include the disk pagers. Fix condition accordingly. +--- + ext2fs/pager.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/ext2fs/pager.c b/ext2fs/pager.c +index 017efcc..ce5bc6d 100644 +--- a/ext2fs/pager.c ++++ b/ext2fs/pager.c +@@ -1449,7 +1449,7 @@ diskfs_pager_users () + { + int npagers = ports_count_bucket (file_pager_bucket); + +- if (npagers <= 1) ++ if (npagers == 0) + return 0; + + if (MAY_CACHE) +-- +2.0.0.rc2 + diff --git a/debian/patches/0005-trans-mtab-fix-initialization.patch b/debian/patches/0005-trans-mtab-fix-initialization.patch new file mode 100644 index 00000000..fafe35c9 --- /dev/null +++ b/debian/patches/0005-trans-mtab-fix-initialization.patch @@ -0,0 +1,26 @@ +From cab118a3d0142b5585ba5c8a2fc4ab163f835b31 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Fri, 23 May 2014 09:54:10 +0200 +Subject: [PATCH 5/8] trans/mtab: fix initialization + +* trans/mtab.c (main): Fix initialization of mtab in one-shot mode. +--- + trans/mtab.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/trans/mtab.c b/trans/mtab.c +index 8c9f8d3..df03b1d 100644 +--- a/trans/mtab.c ++++ b/trans/mtab.c +@@ -255,7 +255,7 @@ main (int argc, char *argv[]) + else + { + /* One-shot mode. */ +- struct mtab mtab = { NULL, 0, 0 }; ++ struct mtab mtab = { .lock = PTHREAD_MUTEX_INITIALIZER }; + err = mtab_populate (&mtab, target_path, insecure); + if (err) + error (5, err, "%s", target_path); +-- +2.0.0.rc2 + diff --git a/debian/patches/0006-libdiskfs-fix-node-leak-in-the-name-cache.patch b/debian/patches/0006-libdiskfs-fix-node-leak-in-the-name-cache.patch new file mode 100644 index 00000000..5fb81f15 --- /dev/null +++ b/debian/patches/0006-libdiskfs-fix-node-leak-in-the-name-cache.patch @@ -0,0 +1,26 @@ +From d20ab223f4fdf2b8bcc44a9fdbd664df154a850e Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Sat, 24 May 2014 20:29:23 +0200 +Subject: [PATCH 6/8] libdiskfs: fix node leak in the name cache + +* libdiskfs/name-cache.c (diskfs_check_lookup_cache): Release node +reference in a special case of lookup failure. +--- + libdiskfs/name-cache.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libdiskfs/name-cache.c b/libdiskfs/name-cache.c +index c113692..a212a6d 100644 +--- a/libdiskfs/name-cache.c ++++ b/libdiskfs/name-cache.c +@@ -249,6 +249,7 @@ diskfs_check_lookup_cache (struct node *dir, const char *name) + { + /* Lose */ + pthread_mutex_unlock (&np->lock); ++ diskfs_nrele (np); + return 0; + } + } +-- +2.0.0.rc2 + diff --git a/debian/patches/0007-libihash-do-not-use-an-integer-hash-function-by-defa.patch b/debian/patches/0007-libihash-do-not-use-an-integer-hash-function-by-defa.patch new file mode 100644 index 00000000..3c213ec8 --- /dev/null +++ b/debian/patches/0007-libihash-do-not-use-an-integer-hash-function-by-defa.patch @@ -0,0 +1,105 @@ +From 9b872cb28f17974832691477ad95c1cb12991266 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Mon, 26 May 2014 12:18:08 +0200 +Subject: [PATCH 7/8] libihash: do not use an integer hash function by default + +Recently libihash was changed to use an integer hash function on the +keys in an attempt to reduce the rate of collisions (2d898893), which +has long been assumed to be high. + +Richard Braun was kind enough to run some benchmarks. He observed: + +"1/ Using an extremely simple microbenchmark [1] that merely inserts +keys, either random integers or sequential ones to match the way port +names are managed, it seems that the previous code, despite its +apparent flaws, did quite well. + +[1] http://darnassus.sceen.net/gitweb/rbraun/ihtest.git + +Using an integer hashing function actually reduces performance on the +sequential integer test case. It makes sense because, considering a +set of consecutive integers starting from 0, and a hash table that +always has more slots than items, a modulo is a perfect hash +function. Even when taking into account that only names for receive +rights are normally managed with libihash, i.e. that keys aren't +actually sequential, they are almost all equally distributed, leading +to very few collisions. + +Therefore, as a third option, I've removed the hashing function, +leaving only a fast modulo (an AND) and this variant provided the best +raw results. + +2/ I've also built hurd packages multiple times and got average build +times with each variant (previous, new, new without hash function) and +here are the results I obtained respectively : 52m59s, 52m31s, 52m22s." + +Do not use the integer hash function on the keys by default. + +* libihash/ihash.c (murmur3_mix32): Remove now unused function. +(find_index): Use the fast division method to derive the index. +(add_one): Likewise. Also, update the comment to reflect the current +hashing method. +--- + libihash/ihash.c | 22 ++++------------------ + 1 file changed, 4 insertions(+), 18 deletions(-) + +diff --git a/libihash/ihash.c b/libihash/ihash.c +index 4d9cc18..fa29257 100644 +--- a/libihash/ihash.c ++++ b/libihash/ihash.c +@@ -32,19 +32,6 @@ + + #include "ihash.h" + +-/* This is the integer finalizer from MurmurHash3. */ +-static inline uint32_t +-murmur3_mix32 (uint32_t h, unsigned int bits) +-{ +- h ^= h >> 16; +- h *= 0x85ebca6b; +- h ^= h >> 13; +- h *= 0xc2b2ae35; +- h ^= h >> 16; +- +- return h >> (32 - bits); +-} +- + /* Return 1 if the slot with the index IDX in the hash table HT is + empty, and 0 otherwise. */ + static inline int +@@ -74,7 +61,7 @@ find_index (hurd_ihash_t ht, hurd_ihash_key_t key) + unsigned int up_idx; + unsigned int mask = ht->size - 1; + +- idx = murmur3_mix32 (key, __builtin_ctzl (ht->size)); ++ idx = key & mask; + + if (ht->items[idx].value == _HURD_IHASH_EMPTY || ht->items[idx].key == key) + return idx; +@@ -205,20 +192,19 @@ hurd_ihash_set_max_load (hurd_ihash_t ht, unsigned int max_load) + found. The arguments are identical to hurd_ihash_add. + + We are using open address hashing. As the hash function we use the +- division method with quadratic probe. This is guaranteed to try +- all slots in the hash table if the prime number is 3 mod 4. */ ++ division method with linear probe. */ + static inline int + add_one (hurd_ihash_t ht, hurd_ihash_key_t key, hurd_ihash_value_t value) + { + unsigned int idx; + unsigned int first_free; ++ unsigned int mask = ht->size - 1; + +- idx = murmur3_mix32 (key, __builtin_ctzl (ht->size)); ++ idx = key & mask; + first_free = idx; + + if (ht->items[idx].value != _HURD_IHASH_EMPTY && ht->items[idx].key != key) + { +- unsigned int mask = ht->size - 1; + unsigned int up_idx = idx; + + do +-- +2.0.0.rc2 + diff --git a/debian/patches/0008-libtrivfs-lock-less-reference-counting-for-trivfs_pe.patch b/debian/patches/0008-libtrivfs-lock-less-reference-counting-for-trivfs_pe.patch new file mode 100644 index 00000000..7622dae9 --- /dev/null +++ b/debian/patches/0008-libtrivfs-lock-less-reference-counting-for-trivfs_pe.patch @@ -0,0 +1,175 @@ +From fb401e6350457d26648348fa3b16abc9cb2cfe43 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 8/8] libtrivfs: lock-less reference counting for + trivfs_peropen objects + +* libtrivfs/trivfs.h (struct trivfs_peropen): Use refcount_t for field +refcnt. +(struct trivfs_control): Remove unused field lock. +* libtrivfs/cntl-create.c (trivfs_create_control): Drop the mutex +initialization. +* libtrivfs/io-reauthenticate.c (trivfs_S_io_reauthenticate): Adjust +accordingly. +* libtrivfs/io-restrict-auth.c (trivfs_S_io_restrict_auth): Likewise. +* libtrivfs/open.c (trivfs_open): Initialize refcnt. +* libtrivfs/protid-clean.c (trivfs_clean_protid): Likewise. +* libtrivfs/protid-dup.c (trivfs_protid_dup): 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 | 29 ++++++++++++++++++----------- + libtrivfs/protid-dup.c | 5 +---- + libtrivfs/trivfs.h | 4 ++-- + 7 files changed, 24 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..86fbc19 100644 +--- a/libtrivfs/protid-clean.c ++++ b/libtrivfs/protid-clean.c +@@ -31,19 +31,26 @@ 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 (trivfs_peropen_destroy_hook) + { +- pthread_mutex_unlock (&cntl->lock); +- (*trivfs_peropen_destroy_hook) (cred->po); +- pthread_mutex_lock (&cntl->lock); ++ if (refcount_deref (&cred->po->refcnt) == 0) ++ { ++ /* Reaquire a reference while we call the hook. */ ++ refcount_ref (&cred->po->refcnt); ++ (*trivfs_peropen_destroy_hook) (cred->po); ++ if (refcount_deref (&cred->po->refcnt) == 0) ++ { ++ ports_port_deref (cntl); ++ free (cred->po); ++ } ++ } + } +- if (--cred->po->refcnt == 0) +- { +- ports_port_deref (cntl); +- free (cred->po); +- } +- pthread_mutex_unlock (&cntl->lock); ++ else ++ if (refcount_deref (&cred->po->refcnt) == 0) ++ { ++ ports_port_deref (cntl); ++ free (cred->po); ++ } + + 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.rc2 + diff --git a/debian/patches/series b/debian/patches/series index c08b0f99..e7fd39f0 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -40,3 +40,11 @@ xkb-compat.patch mach-defpager-protected-payload.patch +0001-libstore-provide-function-declaration-until-availabl.patch +0002-term-fix-memory-leak.patch +0003-libpager-drop-unused-fields-from-struct-pager.patch +0004-ext2fs-fix-diskfs_pager_users.patch +0005-trans-mtab-fix-initialization.patch +0006-libdiskfs-fix-node-leak-in-the-name-cache.patch +0007-libihash-do-not-use-an-integer-hash-function-by-defa.patch +0008-libtrivfs-lock-less-reference-counting-for-trivfs_pe.patch |