-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
locking heap wrapper #1337
locking heap wrapper #1337
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In init_pagecache(), pc->completions is initialized as an objcache, and is not locked. It should be locked instead (there is also an XXX comment that says this at pagecache.c:1320), because completions can be allocated and deallocated from that objcache without the kernel lock.
In platform/pc/service.c, offset_block_io() calls allocate_merge() on the general kernel heap; since this can be called without the kernel lock (e.g. via pagecache_write_sg_finish -> filesystem_storage_write -> write_extent), it should use a locked heap instead. |
I addressed the errors @francescolavra found and removed the unnecessary size parameter from locking_heap_wrapper. |
…tions to locked heap locking_heap under src/kernel; use locking for sg_init, init_pagecache and virtio net; SMP_ENABLE by default for CI; host filesystems on locked heap; pagecache_write_sg_finish should not update write_count and apply completions on a read error; put xen grant_entry heap on locked
…ecessary size parameter from locking_heap_wrapper, fill meta field; use locking wrapper on pagecache completion objcache; offset_block_io: allocate merge off of locked heap; revert SMP_ENABLE for merge into master
As enumerated in #1302, there are many paths in the kernel where the kernel lock is not held and yet allocations or deallocations are being made from one of the kernel heaps. To address this issue, these changes introduce a "locked" kernel heap, using a wrapper heap which wraps heap methods with spinlock aquires, which helps to make such paths safe.
As the interface for the id heap is fairly complex and wouldn't be covered by a generic heap wrapper, a "locking" flag is specified on ID heap creation. The virtual huge and page heaps are now locking and thus safe to use from any context. The "backed" heap uses the locking wrapper, and a "locked" variant of general (using another mcache instance) is created for general-purpose allocations outside of the kernel lock. Allocations made under protection of the kernel lock should continue to use the general heap, as this will avoid unnecessary spinlock operations.
Note: SMP is enabled temporarily in this branch just to run through CI - it will be removed before merging (and until we agree it's safe to enable by default).