summaryrefslogtreecommitdiff
path: root/sys/uvm
AgeCommit message (Collapse)Author
2021-12-10Revert "kbind(2): disable system call if not initialized beforePhilip Guenther
first __tfork(2)" The immediate issue is that a process linked with -znow will still perform lazy relocation on objects loaded with dlopen(), but there are possibly other dark corners to plumb to find a better invariant. Problem reported by thfr@
2021-12-07uvm_map_inentry() is provided a format string that says "inside", but thenTheo de Raadt
prints the end which is in the next page. Subtract 1 to avoid confusion.
2021-12-07uvn_reference(): correct printf(9) argument orderScott Soule Cheloha
Thread: https://marc.info/?l=openbsd-tech&m=163884527530326&w=2 ok deraadt@
2021-12-05kbind(2): disable system call if not initialized before first __tfork(2)Scott Soule Cheloha
To unlock kbind(2) we need to protect ps_kbind_addr and ps_kbind_cookie. The simplest way to do this is to disallow kbind(2) initialization after the first __tfork(2) call. If the first thread does not initialize the kbind(2) variables before __tfork(2) then we disable kbind(2) during that first __tfork(2) call. This is guenther@'s patch, I'm just committing it. Discussed with guenther@, deraadt@, kettenis@, and mpi@. ok kettenis@, positive response from mpi@, "I am busy" guenther@
2021-11-11Convert a for loop into LIST_FOREACH to reduce the diff to NetBSD.Theo Buehler
ok millert mpi
2021-10-24Move pmap_{,k}remove() inside uvm_km_pgremove{,_intrsafe}().Martin Pieuchot
Reduce differences with NetBSD, tested by many as part of a larger diff. ok kettenis@
2021-10-24Shuffle variables around and use KASSERT() instead of panic().Martin Pieuchot
No functionnal change. Reduce differences with NetBSD, tested by many as part of a larger diff.
2021-10-23Sprinkle uvm_obj_destroy() over UVM object recycling code.Martin Pieuchot
For now, only assert that the tree of pages is empty in uvm_obj_destroy(). This will soon be used to free the per-UVM object lock. While here call uvm_obj_init() when new vnodes are allocated instead of in uvn_attach(). Because vnodes and there associated UVM object are currently never freed, it isn't easy to know where/when to garbage collect the associated lock. So simply check that the reference of a given object is 0 when uvn_attach(). Tested by many as part of a bigger diff. ok kettenis@
2021-10-20revert vnode: remove VLOCKSWORK and check locking when vop_islocked != nullopSebastien Marie
(both kernel and userland bits) GENERIC + VFSLCKDEBUG is broken with it.
2021-10-19vnode: remove VLOCKSWORK and check locking when vop_islocked != nullopSebastien Marie
This flag is currently used to mark or unmark a vnode to actively check vnode locking semantic (when compiled with VFSLCKDEBUG). Currently, VLOCKSWORK flag isn't properly set for several FS implementation which have full locking support. This commit enable proper checking for them too (cd9660, udf, fuse, msdosfs, tmpfs). Instead of using a particular flag, it directly check if v_op->vop_islocked is nullop or not to activate or not the vnode locking checks. ok mpi@
2021-10-17km_alloc(9) needs to be passed a size that is a multiple of PAGE_SIZE.Patrick Wildt
ok mpi@
2021-10-12Introduce a dummy uvm_obj_destroy() interface. This function will beMark Kettenis
used in the near future (by mpi@) to improve the locking for uvm objects. Introducing this function now will me allow me to call it in the appropriate place in the drm code. ok mpi@, jsg@
2021-10-12Fix the deadlock between uvn_io() and uvn_flush() by restarting the fault.Martin Pieuchot
Do not allow a faulting thread to sleep on a contended vnode lock to prevent lock ordering issues with upcoming per-uobj lock. Also reduce the sleep value for VM_PAGER_AGAIN from 1sec to 5nsec to not add visible slowdown when starting a multi-threaded application with threads that fault on the same vnode (chromium, firefox, etc). Tested by anton@, tb@, robert@ and gnezdo@ ok anton@, tb@ Reported-by: syzbot+e63407b35dff08dbee02@syzkaller.appspotmail.com
2021-10-12Revert the fix for the deadlock between uvn_io() and uvn_flush().Martin Pieuchot
This fix (ab)use the vnode lock to serialize access to some fields of the corresponding pages associated with UVM vnode object and this will create new deadlocks with the introduction of a per-uobj lock. ok anton@
2021-10-05Unref/free amaps before grabbing the KERNEL_LOCK().Martin Pieuchot
This is possible now that amaps & anons are protected by a per-map rwlock. Tested by many as part of a bigger diff. ok kettenis@
2021-09-05Introduce dummy pagers for 'special' subsystems using UVM objects.Martin Pieuchot
Some pmaps (x86, hppa) and the buffer cache rely on UVM objects to allocate and manipulate pages. These objects should not be manipulated by uvm_fault() and do not currently require the same locking enforcement. Use the dummy pagers to explicitly document which UVM functions are meant to manipulate UVM objects (uobj) that do not need the upcoming `vmobjlock' and instead still rely on the KERNEL_LOCK(). Tested by many as part of a larger diff. ok kettenis@, beck@
2021-08-30Fix a locking assertion in error path.Martin Pieuchot
In amap_copy() make the new amap share the source amap's lock right in the begining and only allocate a new one if no anon have been referenced. Issue reported by Thomas L. <tom.longshine at web dot de> on bugs@. ok tb@
2021-06-29remove arch ifdefs around drm.h includeJonathan Gray
ok deraadt@ kettenis@
2021-06-28Make anonymous object reference counting independant from the KERNEL_LOCK().Martin Pieuchot
- Use atomic operations for increment/decrement - Rewrite the loop from uao_swap_off() to only keep a reference to the next item in the list. ok jmatthew@
2021-06-25basic radeondrm / X support for riscv64. Ok kettenis@Matthieu Herrb
- add wscons devices - build radeondrm and add MD uvm bits to support it.
2021-06-17Revert previous: unref of amap outside of the KERNEL_LOCK().Martin Pieuchot
This change introduced or exposed a leak of anons which result in system freezes. anton@ observed a high number of INUSE for anonpl and semarie@ saw multiple processes waiting in the fault handler on "flt_noramX" probably the one related to allocating an anon.
2021-06-16Change the prefix of UVM object functions to match NetBSD's.Martin Pieuchot
For example uvm_objinit() becomes uvm_obj_init(). Reduce differences between the trees and help porting new functions needed for UVM object locking. No functionnal change.
2021-06-15Use a macro to assert that given uobjs correspond to anonymous objects.Martin Pieuchot
Reduce the difference with NetBSD. ok kettenis@
2021-06-15Unref/free amaps before grabbing the KERNEL_LOCK().Martin Pieuchot
This is possible now that amaps & anons are protected by a per-map rwlock. ok kettenis@, jmatthew@
2021-05-31call drmbackoff() on powerpc64 as wellJonathan Gray
ok kettenis@
2021-05-22Use atomic operations for reference counting VM maps.Martin Pieuchot
This is necessary to do this accounting without the KERNEL_LOCK(). ok mvs@, kettenis@
2021-05-20Make use of uao_dropswap_range() in uao_free() instead of re-rolling it.Martin Pieuchot
ok kettenis@
2021-05-16panic does not require a \n at the end. When one is provided, it looks wrong.Theo de Raadt
2021-04-22Keep under #ifdef TMPFS functions to grow/shrink uaobj.Martin Pieuchot
ok patrick@
2021-04-21Convert remaining uvm_km_zalloc(9) to km_alloc(9).Martin Pieuchot
Tested by bluhm@, jj@, kettenis@ and Scott Bennett. ok kettenis@
2021-03-31Introduce UAO_USES_SWHASH() and use tabs instead of spaces in #defines.Martin Pieuchot
No functionnal change, reduce the difference with NetBSD. ok jmatthew@
2021-03-26Remove parenthesis around return value to reduce the diff with NetBSD.Martin Pieuchot
No functional change. ok mlarkin@
2021-03-20Sync some comments in order to reduce the difference with NetBSD.Martin Pieuchot
No functionnal change. ok kettenis@
2021-03-12spellingJonathan Gray
ok mpi@
2021-03-05ansiJonathan Gray
2021-03-04Modify `uvmexp.swpgonly' atomically, required for uvm_fault() w/o KERNEL_LOCK()Martin Pieuchot
ok kettenis@
2021-03-04Bring back previous fix for UVM vnode deadlock.Martin Pieuchot
tb@ reports that refaulting when there's contention on the vnode makes firefox start very slowly on his machine. To revisit when the fault handler will be unlocked. ok anton@ Original commit message: Fix a deadlock between uvn_io() and uvn_flush(). While faulting on a page backed by a vnode, uvn_io() will end up being called in order to populate newly allocated pages using I/O on the backing vnode. Before performing the I/O, newly allocated pages are flagged as busy by uvn_get(), that is before uvn_io() tries to lock the vnode. Such pages could then end up being flushed by uvn_flush() which already has acquired the vnode lock. Since such pages are flagged as busy, uvn_flush() will wait for them to be flagged as not busy. This will never happens as uvn_io() cannot make progress until the vnode lock is released. Instead, grab the vnode lock before allocating and flagging pages as busy in uvn_get(). This does extend the scope in uvn_get() in which the vnode is locked but resolves the deadlock. ok mpi@ Reported-by: syzbot+e63407b35dff08dbee02@syzkaller.appspotmail.com
2021-03-02Fix the deadlock between uvn_io() and uvn_flush() by restarting the fault.Martin Pieuchot
Do not allow a faulting thread to sleep on a contended vnode lock to prevent lock ordering issues with upcoming per-uobj lock. ok anton@ Reported-by: syzbot+e63407b35dff08dbee02@syzkaller.appspotmail.com
2021-03-02Revert the fix for the deadlock between uvn_io() and uvn_flush().Martin Pieuchot
This fix (ab)use the vnode lock to serialize access to some fields of the corresponding pages associated with UVM vnode object and this will create new deadlocks with the introduction of a per-uobj lock. ok anton@
2021-03-01If an anon is associated with a page, acquire its lock before any modification.Martin Pieuchot
This change should have been part of the previous anon-locking diff and is necessary to run the top part of uvm_fault() unlocked. ok jmatthew@
2021-03-01Move the top part of uvm_fault_lower(), the lookup, in its own function.Martin Pieuchot
The name and logic come from NetBSD in order to reduce the difference between the two code bases. No functional change intended. ok tb@
2021-02-23remove unused uvm_mapent_bias()Jonathan Gray
ok mpi@
2021-02-23Move `pgo_fault' handler outside of uvm_fault_lower().Martin Pieuchot
Reduce differences with NetBSD and prepare for `uobj' locking. No functionnal change. ok chris@, kettenis@
2021-02-16Comments & style cleanup, no functional change intended.Martin Pieuchot
- Sync comments with NetBSD including locking details. - Remove superfluous parenthesis and spaces. - Add brackets, even if questionable, to reduce diff with NetBSD - Use for (;;) instead of while(1) - Rename a variable from 'result' into 'error'. - Move uvm_fault() and uvm_fault_upper_lookup() - Add an locking assert in uvm_fault_upper_lookup() ok tb@, mlarkin@
2021-02-15Fix double unlock in uvmfault_anonget().Martin Pieuchot
Reported by and ok jsg@
2021-02-08Revert the convertion of per-process thread into a SMR_TAILQ.Martin Pieuchot
We did not reach a consensus about using SMR to unlock single_thread_set() so there's no point in keeping this change.
2021-01-19(re)Introduce locking for amaps & anons.Martin Pieuchot
A rwlock is attached to every amap and is shared with all its anon. The same lock will be used by multiple amaps if they have anons in common. This should be enough to get the upper part of the fault handler out of the KERNEL_LOCK() which seems to bring up to 20% improvements in builds. This is based/copied/adapted from the most recent work done in NetBSD which is an evolution of the precendent simple_lock scheme. Tested by many, thanks! ok kettenis@, mvs@
2021-01-16Move `access_type' to the fault context.Martin Pieuchot
Fix a regression where the valye wasn't correctly overwritten for wired mapping, introduced in previous refactoring. ok mvs@
2021-01-11Assert that the KERNEL_LOCK() is held in uao_set_swslot().Martin Pieuchot
ok kettenis@
2021-01-09Enforce range with sysctl_int_bounded in swap_encrypt_ctlgnezdo
OK millert@