diff options
Diffstat (limited to 'debian')
-rw-r--r-- | debian/patches/pager-alloc0001-libpager-provide-pager_create_alloc.patch | 183 | ||||
-rw-r--r-- | debian/patches/pager-alloc0002-more.patch | 169 | ||||
-rw-r--r-- | debian/patches/series | 2 |
3 files changed, 354 insertions, 0 deletions
diff --git a/debian/patches/pager-alloc0001-libpager-provide-pager_create_alloc.patch b/debian/patches/pager-alloc0001-libpager-provide-pager_create_alloc.patch new file mode 100644 index 00000000..b56aaa91 --- /dev/null +++ b/debian/patches/pager-alloc0001-libpager-provide-pager_create_alloc.patch @@ -0,0 +1,183 @@ +From 0994ce18f6c09b7c5c6e47e0d0468109aef0e2c4 Mon Sep 17 00:00:00 2001 +From: Justus Winter <justus@gnupg.org> +Date: Sun, 22 May 2016 19:35:10 +0200 +Subject: [PATCH hurd 1/2] libpager: provide 'pager_create_alloc' + +Add a variant to 'pager_create' that allocates memory for the user +hook next to the pager data increasing locality. + +* doc/hurd.texi: Document new function. +* ext2fs/pager.c (pager_clear_user_data): Don't free 'upi'. +(diskfs_get_filemap): Use the new function. +* libpager/pager-create.c (_pager_create): New generic allocation +function. +(pager_create): Use the new generic function. +(pager_create_alloc): New function. +* libpager/pager.h (pager_create_alloc): New prototype. +--- + doc/hurd.texi | 5 +++++ + ext2fs/pager.c | 25 +++++++++++-------------- + libpager/pager-create.c | 50 ++++++++++++++++++++++++++++++++++++++++--------- + libpager/pager.h | 8 ++++++++ + 4 files changed, 65 insertions(+), 23 deletions(-) + +diff --git a/doc/hurd.texi b/doc/hurd.texi +index 2bcf561..8428a77 100644 +--- a/doc/hurd.texi ++++ b/doc/hurd.texi +@@ -1410,6 +1410,11 @@ create references to pagers by use of the relevant ports library + functions. On errors, return null and set @code{errno}. + @end deftypefun + ++@deftypefun {struct pager *} pager_create_alloc (@w{size_t @var{u_pager_size}}, @w{struct port_bucket *@var{bucket}}, @w{boolean_t @var{may_cache}}, @w{memory_object_copy_strategy_t @var{copy_strategy}}) ++Likewise, but allocate space for the user hook adjacent to the pager ++data. ++@end deftypefun ++ + Once you are ready to turn over control to the pager library, you should + call @code{ports_manage_port_operations_multithread} on the + @var{bucket}, using @code{pager_demuxer} as the ports @var{demuxer}. +diff --git a/ext2fs/pager.c b/ext2fs/pager.c +index 485f69c..2ddce68 100644 +--- a/ext2fs/pager.c ++++ b/ext2fs/pager.c +@@ -822,8 +822,6 @@ pager_clear_user_data (struct user_pager_info *upi) + + diskfs_nrele_light (upi->node); + } +- +- free (upi); + } + + /* This will be called when the ports library wants to drop weak references. +@@ -1316,23 +1314,22 @@ diskfs_get_filemap (struct node *node, vm_prot_t prot) + } + else + { +- struct user_pager_info *upi = +- malloc (sizeof (struct user_pager_info)); +- upi->type = FILE_DATA; +- upi->node = node; +- upi->max_prot = prot; +- diskfs_nref_light (node); +- diskfs_node_disknode (node)->pager = +- pager_create (upi, file_pager_bucket, MAY_CACHE, +- MEMORY_OBJECT_COPY_DELAY, 0); +- if (diskfs_node_disknode (node)->pager == 0) ++ struct user_pager_info *upi; ++ pager = pager_create_alloc (sizeof *upi, file_pager_bucket, ++ MAY_CACHE, MEMORY_OBJECT_COPY_DELAY, 0); ++ if (pager == NULL) + { +- diskfs_nrele_light (node); +- free (upi); + pthread_spin_unlock (&node_to_page_lock); + return MACH_PORT_NULL; + } + ++ upi = pager->upi; ++ upi->type = FILE_DATA; ++ upi->node = node; ++ upi->max_prot = prot; ++ diskfs_nref_light (node); ++ diskfs_node_disknode (node)->pager = pager; ++ + /* A weak reference for being part of the node. */ + ports_port_ref_weak (diskfs_node_disknode (node)->pager); + +diff --git a/libpager/pager-create.c b/libpager/pager-create.c +index b583f02..b3b7c8f 100644 +--- a/libpager/pager-create.c ++++ b/libpager/pager-create.c +@@ -17,21 +17,19 @@ + + #include "priv.h" + +-/* Create and return a new pager with user info UPI. */ +-struct pager * +-pager_create (struct user_pager_info *upi, +- struct port_bucket *bucket, +- boolean_t may_cache, +- memory_object_copy_strategy_t copy_strategy, +- boolean_t notify_on_evict) ++static struct pager * ++_pager_create (size_t size, ++ struct port_bucket *bucket, ++ boolean_t may_cache, ++ memory_object_copy_strategy_t copy_strategy, ++ boolean_t notify_on_evict) + { + struct pager *p; + +- errno = ports_create_port (_pager_class, bucket, sizeof (struct pager), &p); ++ errno = ports_create_port (_pager_class, bucket, sizeof *p + size, &p); + if (errno) + return 0; + +- p->upi = upi; + p->pager_state = NOTINIT; + pthread_mutex_init (&p->interlock, NULL); + pthread_cond_init (&p->wakeup, NULL); +@@ -50,6 +48,40 @@ pager_create (struct user_pager_info *upi, + return p; + } + ++/* Create and return a new pager with user info UPI. */ ++struct pager * ++pager_create (struct user_pager_info *upi, ++ struct port_bucket *bucket, ++ boolean_t may_cache, ++ memory_object_copy_strategy_t copy_strategy, ++ boolean_t notify_on_evict) ++{ ++ struct pager *p; ++ ++ p = _pager_create (0, bucket, may_cache, copy_strategy, notify_on_evict); ++ if (p) ++ p->upi = upi; ++ ++ return p; ++} ++ ++struct pager * ++pager_create_alloc (size_t u_pager_size, ++ struct port_bucket *bucket, ++ boolean_t may_cache, ++ memory_object_copy_strategy_t copy_strategy, ++ boolean_t notify_on_evict) ++{ ++ struct pager *p; ++ ++ p = _pager_create (u_pager_size, bucket, may_cache, copy_strategy, ++ notify_on_evict); ++ if (p) ++ p->upi = (struct user_pager_info *) ((char *) p + sizeof *p); ++ ++ return p; ++} ++ + + /* This causes the function to be run at startup by compiler magic. */ + static void create_class (void) __attribute__ ((constructor)); +diff --git a/libpager/pager.h b/libpager/pager.h +index df4db68..d2a8d39 100644 +--- a/libpager/pager.h ++++ b/libpager/pager.h +@@ -69,6 +69,14 @@ pager_create (struct user_pager_info *u_pager, + memory_object_copy_strategy_t copy_strategy, + boolean_t notify_on_evict); + ++/* Likewise, but also allocate space for the user hook. */ ++struct pager * ++pager_create_alloc (size_t u_pager_size, ++ struct port_bucket *bucket, ++ boolean_t may_cache, ++ memory_object_copy_strategy_t copy_strategy, ++ boolean_t notify_on_evict); ++ + /* Return the user_pager_info struct associated with a pager. */ + struct user_pager_info * + pager_get_upi (struct pager *p); +-- +2.8.1 + diff --git a/debian/patches/pager-alloc0002-more.patch b/debian/patches/pager-alloc0002-more.patch new file mode 100644 index 00000000..2427acf5 --- /dev/null +++ b/debian/patches/pager-alloc0002-more.patch @@ -0,0 +1,169 @@ +From 51782897a736fbbc271b1c924e653ec508310971 Mon Sep 17 00:00:00 2001 +From: Justus Winter <justus@gnupg.org> +Date: Sun, 24 Jul 2016 16:35:29 +0200 +Subject: [PATCH hurd 2/2] more + +--- + console/pager.c | 22 ++++++++-------------- + ext2fs/pager.c | 2 +- + fatfs/pager.c | 21 +++++++++------------ + isofs/pager.c | 18 +++++++++--------- + 4 files changed, 27 insertions(+), 36 deletions(-) + +diff --git a/console/pager.c b/console/pager.c +index 05074a7..d60935a 100644 +--- a/console/pager.c ++++ b/console/pager.c +@@ -49,12 +49,11 @@ static struct pager_requests *pager_requests; + void + pager_clear_user_data (struct user_pager_info *upi) + { +- int idx; ++ size_t idx; + + for (idx = 0; idx < upi->memobj_npages; idx++) + if (upi->memobj_pages[idx]) + vm_deallocate (mach_task_self (), upi->memobj_pages[idx], vm_page_size); +- free (upi); + } + + +@@ -148,21 +147,17 @@ user_pager_create (struct user_pager *user_pager, unsigned int npages, + error_t err; + struct user_pager_info *upi; + +- upi = calloc (1, sizeof (struct user_pager_info) +- + sizeof (vm_address_t) * npages); +- if (!upi) ++ /* XXX Are the values 1 and MEMORY_OBJECT_COPY_DELAY correct? */ ++ user_pager->pager = \ ++ pager_create_alloc (sizeof *upi + sizeof (vm_address_t) * npages, ++ pager_bucket, 1, MEMORY_OBJECT_COPY_DELAY, 0); ++ if (!user_pager->pager) + return errno; + ++ upi = pager_get_upi (user_pager->pager); + upi->memobj_npages = npages; ++ memset (upi->memobj_pages, 0, sizeof (vm_address_t) * npages); + +- /* XXX Are the values 1 and MEMORY_OBJECT_COPY_DELAY correct? */ +- user_pager->pager = pager_create (upi, pager_bucket, +- 1, MEMORY_OBJECT_COPY_DELAY, 0); +- if (!user_pager->pager) +- { +- free (upi); +- return errno; +- } + user_pager->memobj = pager_get_port (user_pager->pager); + ports_port_deref (user_pager->pager); + +@@ -182,7 +177,6 @@ user_pager_create (struct user_pager *user_pager, unsigned int npages, + VM_INHERIT_NONE); + if (err) + { +- /* UPI will be cleaned up by libpager. */ + mach_port_deallocate (mach_task_self (), user_pager->memobj); + return err; + } +diff --git a/ext2fs/pager.c b/ext2fs/pager.c +index 2ddce68..456b582 100644 +--- a/ext2fs/pager.c ++++ b/ext2fs/pager.c +@@ -1323,7 +1323,7 @@ diskfs_get_filemap (struct node *node, vm_prot_t prot) + return MACH_PORT_NULL; + } + +- upi = pager->upi; ++ upi = pager_get_upi (pager); + upi->type = FILE_DATA; + upi->node = node; + upi->max_prot = prot; +diff --git a/fatfs/pager.c b/fatfs/pager.c +index 84376bd..bef8dbe 100644 +--- a/fatfs/pager.c ++++ b/fatfs/pager.c +@@ -747,8 +747,6 @@ pager_clear_user_data (struct user_pager_info *upi) + + diskfs_nrele_light (upi->node); + } +- +- free (upi); + } + + /* This will be called when the ports library wants to drop weak +@@ -839,22 +837,21 @@ diskfs_get_filemap (struct node *node, vm_prot_t prot) + } + else + { +- struct user_pager_info *upi = +- malloc (sizeof (struct user_pager_info)); +- upi->type = FILE_DATA; +- upi->node = node; +- upi->max_prot = prot; +- diskfs_nref_light (node); ++ struct user_pager_info *upi; + node->dn->pager = +- pager_create (upi, file_pager_bucket, MAY_CACHE, +- MEMORY_OBJECT_COPY_DELAY, 0); +- if (node->dn->pager == 0) ++ pager_create_alloc (sizeof *upi, file_pager_bucket, MAY_CACHE, ++ MEMORY_OBJECT_COPY_DELAY, 0); ++ if (node->dn->pager == NULL) + { + diskfs_nrele_light (node); +- free (upi); + pthread_spin_unlock (&node_to_page_lock); + return MACH_PORT_NULL; + } ++ upi = pager_get_upi (node->dn->pager); ++ upi->type = FILE_DATA; ++ upi->node = node; ++ upi->max_prot = prot; ++ diskfs_nref_light (node); + + right = pager_get_port (node->dn->pager); + ports_port_deref (node->dn->pager); +diff --git a/isofs/pager.c b/isofs/pager.c +index b4be4e2..42cad8d 100644 +--- a/isofs/pager.c ++++ b/isofs/pager.c +@@ -128,7 +128,6 @@ pager_clear_user_data (struct user_pager_info *upi) + pthread_spin_unlock (&node2pagelock); + diskfs_nrele_light (upi->np); + } +- free (upi); + } + + void +@@ -176,19 +175,20 @@ diskfs_get_filemap (struct node *np, vm_prot_t prot) + do + if (!np->dn->fileinfo) + { +- upi = malloc (sizeof (struct user_pager_info)); +- upi->type = FILE_DATA; +- upi->np = np; +- diskfs_nref_light (np); +- upi->p = pager_create (upi, pager_bucket, 1, +- MEMORY_OBJECT_COPY_DELAY, 0); +- if (upi->p == 0) ++ struct pager *p; ++ p = pager_create_alloc (sizeof *upi, pager_bucket, 1, ++ MEMORY_OBJECT_COPY_DELAY, 0); ++ if (p == NULL) + { + diskfs_nrele_light (np); +- free (upi); + pthread_spin_unlock (&node2pagelock); + return MACH_PORT_NULL; + } ++ upi = pager_get_upi (p); ++ upi->type = FILE_DATA; ++ upi->np = np; ++ diskfs_nref_light (np); ++ upi->p = p; + np->dn->fileinfo = upi; + right = pager_get_port (np->dn->fileinfo->p); + ports_port_deref (np->dn->fileinfo->p); +-- +2.8.1 + diff --git a/debian/patches/series b/debian/patches/series index 0b41ab85..fcf808ce 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -42,3 +42,5 @@ nfs0001-nfs-fix-memory-leak.patch corefiles0001-trans-crash-xxx-core-file-templates.patch leaks0001-xxx-print-fail.patch +pager-alloc0001-libpager-provide-pager_create_alloc.patch +pager-alloc0002-more.patch |