aboutsummaryrefslogtreecommitdiff
path: root/libpager
Commit message (Collapse)AuthorAgeFilesLines
* Style tweaksSergey Bugaev2023-05-101-4/+4
| | | | Message-Id: <20230508213136.608575-42-bugaevc@gmail.com>
* Use designated initializers when building mach_msg_type_tFlavio Cruz2023-05-041-8/+8
| | | | Message-Id: <ZFLcIs0iwiC9kQDf@jupiter.tail36e24.ts.net>
* Use uintptr_t for message payloads.Flavio Cruz2023-05-021-1/+1
| | | | | A follow up to 92fad38a043b75ed6b435b3efa574ede91dbe9ee in gnumach. Message-Id: <ZFCNasf9bJ9qj+CG@jupiter.tail36e24.ts.net>
* Modernize code by removing use of old style definitions.Flavio Cruz2023-04-031-1/+1
| | | | | Also add -Werror=old-style-definition to enforce new code. Message-Id: <ZBZ+8xf7GHy2RT/h@jupiter.tail36e24.ts.net>
* Avoid undefined-behaviorSamuel Thibault2023-02-021-5/+5
| | | | | 1 << 31 is undefined behavior, 1 needs to be made unsigned for << 31 to be defined behavior.
* Fix some compiler warningsSvante Signell2023-01-193-3/+3
|
* libpager: Fix memleak on errorSamuel Thibault2023-01-011-1/+4
|
* Fix *printf specifier for user space mach ports.Flavio Cruz2022-12-063-3/+3
| | | | | mach_port_t are mach_port_name_t and thus require %u instead of %lu. Message-Id: <Y42RELMbulK4xaKM@reue>
* Fix types of read write and readables methodsEtienne Brateau2022-08-291-1/+1
| | | | Message-Id: <20220829193617.13481-1-etienne.brateau@gmail.com>
* Update to the improved memory_object_create proxy RPCSamuel Thibault2022-08-101-4/+2
| | | | Thus avoiding two RPCs.
* Do not cache the R/O proxySamuel Thibault2022-08-105-32/+14
| | | | | We cannot properly detect when to release the ro_proxy, so let's just not cache it.
* libpager: Add pager_get_ro_port ()Sergey Bugaev2022-08-106-1/+73
| | | | | A pager will now maintain a port to a read-only memory object proxy for itself, and let the users access it with pager_get_ro_port ().
* libpager: Make it a bit parallelSamuel Thibault2022-03-011-1/+1
| | | | | | | | Making libpager use several workers allows it to queue several requests to the disk (e.g. for different processes faulting data) rather than waiting for them sequentially. * libpager/demuxer.c (WORKER_COUNT): Set to 10.
* libpager: fix assertion unsigned against 0Etienne Brateau2022-01-201-3/+3
| | | | | | | Comparing an unsigned to be superior or equals to 0 is always true, instead move the assert before the substraction and compare it to the value to substract. Message-Id: <20220119192945.36654-2-etienne.brateau@gmail.com>
* libpager: fix a comparison between signed and unsignedSamuel Thibault2022-01-201-2/+2
| | | | Reported-by: Etienne Brateau <etienne.brateau@gmail.com>
* libpager: pager_write_page () should not unmap pageSergey Bugaev2021-05-081-3/+3
| | | | | Clarify this in the documentation, and fix the storeio implementation. Message-Id: <20210508153144.332832-2-bugaevc@gmail.com>
* libpager: Properly zero-initialize pagemapSergey Bugaev2021-05-071-0/+2
| | | | | | Unlike mmap () and calloc (), reallocarray () does not automatically zero-fill the newly allocated memory. Do so explicitly. Message-Id: <CAN9u=Hd21Es7Kc4tVBAUeLaKo9CWKO1e577TqnXMzmmvwLi22Q@mail.gmail.com>
* libpager: Use libc heap for pagemapSergey Bugaev2021-05-072-19/+12
| | | | | | | | | libc already implements the functionality for allocating and managing memory blocks like the pagemap. Using libc functions gives us some additional niceties like overflow checking in reallocarray (). it also means that we will not allocate a whole page of memory if we need to store just a few integers. Message-Id: <20210506125631.79117-7-bugaevc@gmail.com>
* libpager: Fix overallocating pagemapSergey Bugaev2021-05-071-4/+5
| | | | | | | | The code tried to round up the allocation size to a multiple of page size. But we actually allocate newsize * sizeof (*p->pagemap) bytes, not newsize bytes, which meant allocations were sizeof (*p->pagemap) times larger than they needed to be. Message-Id: <20210506125631.79117-6-bugaevc@gmail.com>
* libpager: Store pagemapsize as vm_size_tSergey Bugaev2021-05-062-2/+2
| | | | | | On a 64-bit system, there can be a lot more pages than a 32-bit int can fit. Message-Id: <20210506125631.79117-5-bugaevc@gmail.com>
* libpager: Do not flush in-core pages on offerSergey Bugaev2021-05-061-7/+0
| | | | | | | | | | | pager_offer_page () is documented to may ignore the offered page if the kernel already has a copy in core (indeed, that's what Mach does). However the current behavior is the inverse of that: it asks the kernel to flush (i.e. drop) its in-core copy, and replace it with the offered one. Fix this by not doing that, and calling memory_object_data_supply () directly. Message-Id: <20210506125631.79117-3-bugaevc@gmail.com>
* libpager: Fix mixing up success and errorSergey Bugaev2021-05-061-13/+14
| | | | | | _pager_pagemap_resize () returns an error or 0 on success, not a boolean. Message-Id: <20210506125631.79117-2-bugaevc@gmail.com>
* Fix build with -fno-commonSamuel Thibault2020-03-312-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | which will be the default in gcc-10. * acpi/acpifs.h (fs, acpifs_maptime): Add extern qualifier. * boot/private.h (verbose): Likewise. * eth-multiplexer/netfs_impl.h (multiplexer_maptime): Likewise. * eth-multiplexer/vdev.h (port_bucket, vdev_portclass): Likewise. * exec/priv.h (port_bucket, execboot_portclass): Likewise. * ext2fs/ext2fs.h (sblock, sblock_dirty, block_size, log2_block_size, log2_dev_blocks_per_fs_block, log2_stat_blocks_per_fs_block, zeroblock, frag_size, frags_per_block, inodes_per_block, itb_per_group, db_per_group, desc_per_block, addr_per_block, groups_count, node_to_page_lock, generation_lock, next_generation, group_desc_image, global_pokel, modified_global_blocks, use_xattr_translator_records): Likewise. * hostmux/hostmux.h (hostmux_maptime): Likewise. * isofs/isofs.h (host_name, mounted_on, disk_image, disk_image_len, logical_block_size, sblock): Likewise. * libdiskfs/diskfs.h (diskfs_shortcut_symlink, diskfs_shortcut_chrdev, diskfs_shortcut_blkdev, diskfs_shortcut_fifo, diskfs_shortcut_ifsock, diskfs_create_symlink_hook, diskfs_read_symlink_hook): Likewise. * libnetfs/callbacks.h (_netfs_translator_callback1, _netfs_translator_callback2): Likewise. * libnetfs/priv.h (netfs_mtime): Likewise. * libpager/priv.h (_pager_class): Likewise. * libtrivfs/trivfs.h (trivfs_check_access_hook, trivfs_check_open_hook, trivfs_open_hook, trivfs_protid_create_hook, trivfs_peropen_create_hook, trivfs_protid_destroy_hook, trivfs_peropen_destroy_hook, trivfs_getroot_hook): Likewise. * lwip/lwip-hurd.h (lwip_bucket, socketport_class, addrport_class, shutdown_notify_class, lwip_protid_portclasses, lwip_cntl_portclasses, lwip_bootstrap_portclass, fsys_identity, lwipcntl, lwip_owner, lwip_group): Likewise. * lwip/port/include/netif/hurdtunif.h (tunnel_cntlclass, tunnel_class): Likewise. * nfs/nfs.h (main_udp_socket, hostname, mapped_time): Likewise. * nfsd/nfsd.h (mapped_time, authserver): Likewise. * pci-arbiter/pcifs.h (fs, pcifs_maptime): Likewise. * pci-arbiter/startup.h (pci_shutdown_notify_class, arrange_shutdown_notification): Likewise. * pfinet/pfinet.h (pfinet_bucket, addrport_class, socketport_class, fsys_identity, pfinetctl, pfinet_owner, pfinet_group): Likewise. * pflocal/sserver.h (sock_port_bucket): Likewise. * proc/proc.h (authserver, self_proc, init_proc, startup_proc, proc_bucket, proc_class, generic_port_class, exc_class, generic_port, kernel_proc, global_lock): Likewise. * term/term.h (termstate, termflags, global_lock, carrier_alert, select_alert, pty_select_alert, term_bucket, tty_cntl_class, tty_class, cttyid_class, pty_class, pty_cntl_class, termctl, ptyctl, inputq, rawq, outputq, remote_input_mode, external_processing, term_owner, term_group, term_mode, bottom): Likewise. * usermux/usermux.h (usermux_maptime): Likewise. * utils/msgids.h (msgid_argp): Likewise. * libdiskfs/priv.h (_diskfs_mtime): Remove definition. * lwip/options.h (lwip_argp): Add prototype. * mach-defpager/priv.h (partitions): Name structure. (all_partitions): Add extern qualifier. * acpi/main.c (acpifs_maptime, fs): New variables. * exec/main.c (port_bucket, execboot_portclass): Likewise. * ext2fs/ext2fs.c (sblock, sblock_dirty, block_size, log2_block_size, log2_dev_blocks_per_fs_block, log2_stat_blocks_per_fs_block, frag_size, frags_per_block, inodes_per_block, itb_per_group, db_per_group, desc_per_block, addr_per_block, groups_count, next_generation, group_desc_image, global_pokel, use_xattr_translator_records): Likewise. * isofs/main.c (host_name, mounted_on, logical_block_size, sblock): Likewise. * libpager/pager-create.c (_pager_class): Likewise. * lwip/port/netif/hurdtunif.c (tunnel_cntlclass, tunnel_class): Likewise. * mach-defpager/default_pager.c (all_partitions): Likewise. * nfs/main.c (main_udp_socket, hostname, mapped_time): Likewise. * nfsd/main.c (mapped_time, authserver): Likewise. * pci-arbiter/main.c (fs, pcifs_maptime): Likewise. * pci-arbiter/startup.c (*pci_shutdown_notify_class): Likewise. * pfinet/main.c (pfinetctl, pfinet_owner, pfinet_group, pfinet_bucket, addrport_class, socketport_class, fsys_identity): Likewise. * proc/main.c (authserver, self_proc, init_proc, startup_proc, proc_bucket, proc_class, generic_port_class, exc_class, generic_port, kernel_proc, global_lock): Likewise. * term/main.c (termstate, termflags, global_lock, carrier_alert, select_alert, pty_select_alert, term_bucket, tty_cntl_class, tty_class, cttyid_class, pty_class, pty_cntl_class, termctl, ptyctl, outputq, remote_input_mode, external_processing, term_owner, term_group, term_mode, bottom): Likewise. * usermux/usermux.c (usermux_mapped_time): Rename to usermux_maptime. * lwip/main.c: Include "options.h". (lwip_argp, netif_list): Remove declarations. (lwip_bucket, socketport_class, addrport_class, shutdown_notify_class, lwip_cntl_portclasses, lwip_bootstrap_portclass, lwip_owner, lwip_group, fsys_identity, lwipcntl): New variables. * eth-multiplexer/multiplexer.c (multiplexer_maptime): Add variable. * hostmux/hostmux.c (hostmux_mapped_time): Rename variable to hostmux_maptime * libdiskfs/extra-version.c: Rename file to... * libdiskfs/priv.c: ... new file. (diskfs_shortcut_symlink, diskfs_shortcut_chrdev, diskfs_shortcut_blkdev, diskfs_shortcut_fifo, diskfs_shortcut_ifsock, diskfs_create_symlink_hook, diskfs_read_symlink_hook): Add weak variables. * libdiskfs/Makefile (OTHERSRCS): Replace extra-version.c with priv.c. * libtrivfs/priv.c: New file. * libtrivfs/Makefile (OTHERSRCS): Add priv.c * libcons/extra-version.c: Rename file to... * libcons/priv.c: ... new file. * libcons/Makefile (SRCS): Replace extra-version.c with priv.c. Fix build with #
* Use our own variant of 'assert' and 'assert_perror'.Justus Winter2017-08-054-23/+23
| | | | | Our variants print stack traces on failures. This will make locating errors much easier.
* Remove support for the deprecated external memory interface.Justus Winter2016-12-101-11/+0
| | | | | | * libpager/stubs.c (_pager_S_memory_object_data_write): Drop stub. * mach-defpager/default_pager.c (seqnos_memory_object_data_write): Drop function.
* Fix buildSamuel Thibault2016-11-201-1/+1
| | | | | | * libpager/pager-memcpy.c (pager_memcpy): Pass 1 as second parameter to sigsetjmp. * libstore/memobj.c (memobj_memcpy): Likewise.
* libpager, libstore: Fix crash on ENOSPC while writing dataSamuel Thibault2016-11-201-2/+3
| | | | | | | | | | | | | We need to save blocked signals, otherwise longjmp will not unblock SIGSEGV/SIGBUS, and thus next exception will kill us. Also, we need to make sure that the preemptor is set at the right window in main memory before letting a handler see it. * libpager/pager-memcpy.c (do_memcpy): Call __sync_synchronize() between aligning the fault preemptor and actually accessing data. (fault): Use siglongjmp instead of longjmp. (pager_memcpy): Use sigsetjmp instead of setjmp. * libstore/memobj.c (copy, fault, memobj_memcpy): Likewise.
* libpager: fix returning error on data_unlockBrent W. Baccala2016-11-141-1/+1
| | | | | | | | | | | The _pager_lock_object call needs to be asynchronous because libpager is single threaded, at least in the sense that individual memory objects only process one request at a time.  In this case, we're processing a data_unlock request, and would have to handle a lock_completed message before lock_object would return (synchronously). * libpager/data-unlock.c (_pager_S_memory_object_data_unlock): Pass 0 to sync parameter of _pager_lock_object() call.
* Mark library stubs as weakSamuel Thibault2016-10-301-3/+3
| | | | | | | | | | | | | | | | | | | | | So that static linking of e.g. console.static can work. * libdiskfs/io-stubs.c (diskfs_S_io_readsleep, diskfs_S_io_eofnotify, diskfs_S_io_postnotify, diskfs_S_io_readnotify): Mark weak. * libnetfs/fsstubs.c (netfs_S_file_notice_changes, netfs_S_file_getfh, netfs_S_ifsock_getsockaddr): Likewise. * libnetfs/fsysstubs.c (netfs_S_fsys_getfile: netfs_S_fsys_getpriv, netfs_S_fsys_init, netfs_S_fsys_forward, netfs_S_fsys_startup): Likewise. * libpager/stubs.c (_pager_S_memory_object_copy, _pager_S_memory_object_data_write, _pager_S_memory_object_supply_completed): Likewise. * libtrivfs/fsys-stubs.c (trivfs_S_fsys_startup, trivfs_S_fsys_getpriv, trivfs_S_fsys_init, trivfs_S_fsys_getfile): Likewise. * libtrivfs/io-stubs.c (trivfs_S_io_map_cntl, trivfs_S_io_get_conch, trivfs_S_io_release_conch, trivfs_S_io_eofnotify, trivfs_S_io_prenotify, trivfs_S_io_postnotify, trivfs_S_io_readsleep, trivfs_S_io_sigio, trivfs_S_io_readnotify): Likewise.
* libpager: provide 'pager_create_alloc'Justus Winter2016-08-072-9/+49
| | | | | | | | | | | | | | | | | | | | | Add a variant to 'pager_create' that allocates memory for the user hook next to the pager data increasing locality. * console/pager.c (pager_clear_user_data): Fix type of 'idx', do not free 'upi'. (user_pager_create): Use the new function. * doc/hurd.texi: Document new function. * ext2fs/pager.c (pager_clear_user_data): Don't free 'upi'. (diskfs_get_filemap): Use the new function. * fatfs/pager.c (pager_clear_user_data): Don't free 'upi'. (diskfs_get_filemap): Use the new function. * isofs/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.
* libpager: add missing includeJustus Winter2016-04-271-0/+1
| | | | * libpager/demuxer.c: Include <assert.h>.
* Fix race condition in ext2fs when remountingJames Clarke2015-09-063-18/+137
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On some systems, ext2fs.static would regularly hang at startup, as a race condition meant it would process paging requests while remounting. To fix this, libpager has been altered to allow inhibiting and resuming its worker threads, and ext2fs uses this to inhibit paging while remounting. * console/pager.c (pager_requests): New variable. (user_pager_init): Updated call to pager_start_workers to use new pager_requests variable. * daemons/runsystem.sh: Removed artificial delay working around the race condition. * ext2fs/ext2fs.c (diskfs_reload_global_state): Call new inhibit_ext2_pager and resume_ext2_pager functions, and leave sblock as non-NULL so it will be munmapped. * ext2fs/ext2fs.h (inhibit_ext2_pager,resume_ext2_pager): New functions. * ext2fs/pager.c (file_pager_requests): New variable. (create_disk_pager): Updated call to pager_start_workers to use new file_pager_requests variable. (inhibit_ext2_pager,resume_ext2_pager): New functions. * fatfs/fatfs.h (inhibit_fat_pager,resume_fat_pager): New functions. * fatfs/pager.c (file_pager_requests): New variable. (create_fat_pager): Updated call to pager_start_workers to use new file_pager_requests variable. (inhibit_fat_pager,resume_fat_pager): New functions. * libdiskfs/disk-pager.c (diskfs_disk_pager_requests): New variable. (diskfs_start_disk_pager): Updated call to pager_start_workers to use new diskfs_disk_pager_requests variable. * libdiskfs/diskfs-pager.h (diskfs_disk_pager_requests): New variable. * libpager/demuxer.c (struct pager_requests): Renamed struct requests to struct pager_requests. Replaced queue with queue_in and queue_out pointers. Added inhibit_wakeup field. (pager_demuxer): Updated to use new queue_in/queue_out pointers. Only wake up workers if not inhibited. (worker_func): Updated to use new queue_in/queue_out pointers. Final worker thread to sleep notifies the inhibit_wakeup condition variable. (pager_start_workers): Added out parameter for the requests instance. Allocate heap space shared by both queues. Initialise new inhibit_wakeup condition. (pager_inhibit_workers,pager_resume_workers): New functions. * libpager/pager.h (struct pager_requests): Public forward definition. (pager_start_workers): Added out parameter for the requests instance. (pager_inhibit_workers,pager_resume_workers): New functions. * libpager/queue.h (queue_empty): New function. * storeio/pager.c (pager_requests): New variable. (init_dev_paging): Updated call to pager_start_workers to use new pager_requests variable.
* lib*: Fix typos in comments (found by codespell)Stefan Weil2015-01-032-2/+2
| | | | Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Replace `bcopy' with `memcpy' or `memmove' as appropriateJustus Winter2014-12-101-1/+1
| | | | | | | | | | | | | | | | | | | * ext2fs/inode.c: Replace `bcopy' with `memcpy' or `memmove' as appropriate. * ext2fs/pager.c: Likewise. * isofs/lookup.c: Likewise. * isofs/main.c: Likewise. * isofs/rr.c: Likewise. * libdiskfs/file-get-trans.c: Likewise. * libiohelp/return-buffer.c: Likewise. * libpager/pagemap.c: Likewise. * libpipe/pq.c: Likewise. * libpipe/pq.h: Likewise. * libstore/unzipstore.c: Likewise. * mach-defpager/default_pager.c: Likewise. * pfinet/ethernet.c: Likewise. * pfinet/tunnel.c: Likewise. * storeio/dev.c: Likewise.
* libpager: use libports notification functionsJustus Winter2014-12-105-109/+5
| | | | | | | | | | | | Now that we do not use sequence numbers anymore, we can simply use libports notification server functions. * libpager/Makefile (SRCS): Drop `no-senders.c', and `notify-stubs.c'. (OBJS): Drop `notifyServer.o'. * libpager/demuxer.c (pager_demuxer): Use libports server functions. * libpager/mig-mutate.h: Drop all notification mutators. * libpager/no-senders.c: Remove file. * libpager/notify-stubs.c: Likewise.
* libpager: remove the `seqno' parametersJustus Winter2014-12-1014-45/+24
| | | | | | | | | | | | | | | | | * libpager/Makefile (MIGSFLAGS): Drop `-DSEQNOS'. * libpager/priv.h (struct pager): Drop fields `seqno' and `waitingforseqno'. * libpager/chg-compl.c: Adopt 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/pager-create.c: Likewise. * libpager/stubs.c: Likewise.
* libpager: add a payload-aware intrans functionJustus Winter2014-12-072-0/+9
| | | | | * libpager/mig-decls.h (begin_using_pager_payload): New function. * libpager/mig-mutate.h: Add mutators.
* libpager: make the request queue more memory-efficientJustus Winter2014-11-231-17/+49
| | | | | | | | | | | | | | | | | | Previously, `pager_demuxer' allocated a chunk of memory for the response message. But if memory gets scarce, the kernel will issue a large number of paging requests to free up memory. In such a situation, allocating memory is dangerous. Fix this by not allocating space for the response message, rather, use a chunk of the workers stack space. Also, we only handle the `notify' and `memory_object' protocol, which both only contain simple routines, we only need a `mig_response_header_t'. * libpager/demuxer.c (struct request): Remove `inp' and `outp'. (request_inp): New function. (pager_demuxer): Do not allocate memory for the response. (mig_reply_setup): New function. (worker_func): Adjust accordingly.
* Avoid hitting VM_MAX_ADDRESSSamuel Thibault2014-11-101-1/+3
| | | | | | * libpager/pager-memcpy.c (pager_memcpy): Reset address passed to vm_map on each loop, to avoid potentially monotonically increasing up to VM_MAX_ADDRESS.
* Deal with odd kernel behaviorSamuel Thibault2014-11-091-1/+1
| | | | | | | | | | | | | | Some versions of gnumach actually take address as a mapping hint, and would fail if the hint is bogus. Make sure to pass 0 for those versions. * console/pager.c (user_pager_create): Make sure to set *user to 0 before calling vm_map. * libdiskfs/disk-pager.c (diskfs_start_disk_pager): Make sure to set *image to 0 before calling vm_map. * libpager/pager-memcpy.c (pager_memcpy): Set window to 0 before calling vm_map. * tmpfs/node.c (diskfs_get_filemap): Make sure to set np->dn->u.reg.memref to 0 before calling vm_map.
* libpager: use a fixed number of threadsJustus Winter2014-11-0316-142/+342
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, libpager used an unbounded number of threads to receive messages from the pager bucket. It used sequence barriers to execute the requests to order requests to each object. The sequence barriers are implemented in seqnos.c. A server function uses _pager_wait_for_seqno to wait for its sequence number and _pager_release_seqno to release it, or it uses _pager_update_seqno to do both operations in one step. These sequence barriers divide each server function in three parts: A, B, and C. A_i happens "before" the sequence barrier i, B_i happens "in order", C_i happens "after" the sequence barrier. This partial order < has the following properties: * This order is *per object*. Requests to different objects are not ordered. * A_i < B_i, B_i < C_i (due to the structure of the code) * B_i < B_{i+1} (this is due to the sequence barriers) * Note that only the B parts are ordered by the sequence numbers, we are free to execute C_i and C_{i+1} in any possible order. The same argument applies to the A parts. The sequence barriers are implemented using a very simple ticket algorithm. Every request, even the invalid ones, is processed by a thread, and waits until the ticket count reaches its seqno, does some work in-order, then increments the ticket and awakes all threads that have piled up up to this moment. All of them except one will then discover that it's not their turn yet and go to sleep again. Creating one thread per request has proven to be problematic as memory_object requests often arrive in large batches. This patch does two things: * Use a single thread to receive messages from the port bucket. All incoming request are put into a queue. * Use a fixed-number of threads (though even one is actually enough) to execute the the server functions. If multiple threads are used, a work-delegation mechanism ensures that the per object order < is preserved. For reference, I used the following command to create workloads that highlight the problem this patch is addressing: % settrans t .../ext2fs --sync=30 /dev/sd2s1 ... % /usr/bin/time zsh -c 'for ((i=0; i < 1500; i++)); do dd if=/dev/zero of=t/src/$i bs=4k count=290 2>/dev/null echo -n . if ((i % 100 == 0)) ; then echo -n $i; fi done' * libpager/queue.h: New file. * libpager/demuxer.c: Manage a queue of requests received from the port bucket. (pager_demuxer): Just decode the server function and enqueue the request. (worker_func): New function that consumes and executes the requests from the queue. (service_paging_requests): New function. (pager_start_workers): Likewise. * libpager/data-request.c: Remove the seqno barriers. * libpager/data-return.c: Likewise. * libpager/data-unlock.c: Likewise. * libpager/chg-compl.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/seqnos.c: Remove file. * libpager/stubs.c: Likewise. * libpager/pager.h (pager_demuxer): Drop declaration. (pager_start_workers): New declaration. * libpager/priv.h: Remove the _pager_seqno declarations. * libpager/Makefile (SRCS): Drop seqnos.c. * console/pager.c (user_pager_init): Call pager_start_workers. * libdiskfs/disk-pager.c: Likewise. * storeio/pager.c: Likewise. * ext2fs/pager.c (service_paging_requests): Remove function. (create_disk_pager): Start separate file pager using `pager_start_workers'. * fatfs/pager.c (service_paging_requests): Remove function. (create_fat_pager): Start separate file pager using `pager_start_workers'.
* Add missing linefeedSamuel Thibault2014-08-231-2/+2
| | | | | * libpager/object-terminate.c (_pager_seqnos_memory_object_terminate): Add missing linefeed in error message.
* libpager: drop unused fields from struct pagerJustus Winter2014-05-261-2/+0
| | | | * libpager/priv.h (struct pager): Drop fields next, pprev.
* libpager: fix notify_port_t receiver lookupsJustus Winter2014-04-151-13/+8
| | | | | | | | | This fixes one more occurence of a notify_port_t receiver lookup that I overlooked in 5a4926dd52aed56913cbe10592063ff0da753700. * libpager/no-senders.c: Include "notify_S.h" so that the compiler can spot such mistakes in the future. (_pager_do_seqnos_mach_notify_no_senders): Fix receiver lookup.
* libpager: fix notify_port_t receiver lookupsJustus Winter2014-04-142-10/+17
| | | | | * libpager/mig-mutate.h: Add mutators. * libpager/notify-stubs.c: Adjust accordingly.
* libpager: fix receiver lookupsJustus Winter2014-04-0213-52/+108
| | | | | | | | | | | | | | | | | | | | | | Previously, the receiver lookup was done manually in all the server functions. Use mig translator functions instead. * libpager/mig-decls.h: New file. * libpager/mig-mutate.h: Likewise. * libpager/Makefile (MIGSFLAGS): Include mig-mutate.h. * libpager/chg-compl.c: Fix receiver lookups. * libpager/data-request.c: Likewise. * libpager/data-return.c: Likewise. * libpager/data-unlock.c: Likewise. * libpager/lock-completed.c: Likewise. * libpager/object-init.c: Likewise. * libpager/object-terminate.c: Likewise. * libpager/stubs.c: Likewise. * libpager/seqnos.c (_pager_update_seqno): Move the actual functionality... (_pager_update_seqno_p): ... into a new function that can be called with a pointer to struct pager. * libpager/priv.h (_pager_update_seqno_p): New declaration.
* libpager: fix potential deadlockJustus Winter2014-03-211-2/+5
| | | | | | | | | This patch releases the interlock before doing an rpc call, analogous to 901c61a1d25e7c8963e51012760a82730eda1910. * libpager/pager-attr.c (pager_change_attributes): Release interlock before calling memory_object_change_attributes, to let the callbacks take it.
* libpager: fix comment of pager_change_attributesJustus Winter2014-03-212-6/+6
| | | | | * libpager/pager-attr.c: Fix comment. * libpager/pager.h: Likewise.
* libpager: improve the pager_demuxer functionJustus Winter2014-02-251-11/+11
| | | | | | | | | | Handle multiple request types as recommended by the Mach Server Writer's Guide section 4, subsection "Handling Multiple Request Types". This avoids initializing the reply message in every X_server function. The reply message has already been properly initialized in libports, so there is no need to call mig_reply_setup. * libpager/demuxer.c (pager_demuxer): Improve the demuxer function.
* Normalize whitespace at the end of each file to '\n'Justus Winter2013-11-099-12/+0
| | | | | Some files were not normalized. In console/motd.UTF8 the additional newline is intentional. Empty files were excluded as well.