Skip to content

Commit

Permalink
remove unnecessary size parameter from locking_heap_wrapper, fill met…
Browse files Browse the repository at this point in the history
…a field; use locking wrapper on pagecache completion objcache; offset_block_io: allocate merge off of locked heap
  • Loading branch information
wjhun committed Nov 24, 2020
1 parent 9a9fa29 commit 3ab0437
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
9 changes: 4 additions & 5 deletions platform/pc/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ closure_function(2, 3, void, offset_block_io,
blocks.end += ds;

// split I/O to storage driver to PAGESIZE requests
heap h = heap_general(&heaps);
merge m = allocate_merge(h, sh);
merge m = allocate_merge(heap_locked(&heaps), sh);
status_handler k = apply_merge(m);
while (blocks.start < blocks.end) {
u64 span = MIN(range_span(blocks), MAX_BLOCK_IO_SIZE >> SECTOR_OFFSET);
Expand Down Expand Up @@ -585,14 +584,14 @@ static void init_kernel_heaps()

init_page_tables(&bootstrap, heaps.physical, find_initial_pages());

heaps.backed = locking_heap_wrapper(&bootstrap, physically_backed(&bootstrap, (heap)heaps.virtual_page, (heap)heaps.physical, PAGESIZE), PAGESIZE);
heaps.backed = locking_heap_wrapper(&bootstrap, physically_backed(&bootstrap, (heap)heaps.virtual_page, (heap)heaps.physical, PAGESIZE));
assert(heaps.backed != INVALID_ADDRESS);

heaps.general = allocate_mcache(&bootstrap, heaps.backed, 5, 20, PAGESIZE_2M);
assert(heaps.general != INVALID_ADDRESS);

heaps.locked = locking_heap_wrapper(&bootstrap, allocate_mcache(&bootstrap, heaps.backed, 5, 20, PAGESIZE_2M), 1);
assert(heaps.general != INVALID_ADDRESS);
heaps.locked = locking_heap_wrapper(&bootstrap, allocate_mcache(&bootstrap, heaps.backed, 5, 20, PAGESIZE_2M));
assert(heaps.locked != INVALID_ADDRESS);
}

static void jump_to_virtual(u64 kernel_size, u64 *pdpt, u64 *pdt) {
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ extern timerheap runloop_timers;

heap physically_backed(heap meta, heap virtual, heap physical, u64 pagesize);
void physically_backed_dealloc_virtual(heap h, u64 x, bytes length);
heap locking_heap_wrapper(heap meta, heap parent, bytes size);
heap locking_heap_wrapper(heap meta, heap parent);

void print_stack(context c);
void print_frame(context f);
Expand Down
5 changes: 3 additions & 2 deletions src/kernel/locking_heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static bytes heaplock_total(heap h)
}

/* meta only used on creation */
heap locking_heap_wrapper(heap meta, heap parent, bytes size)
heap locking_heap_wrapper(heap meta, heap parent)
{
heaplock hl = allocate(meta, sizeof(*hl));
if (hl == INVALID_ADDRESS)
Expand All @@ -64,8 +64,9 @@ heap locking_heap_wrapper(heap meta, heap parent, bytes size)
hl->h.destroy = heaplock_destroy;
hl->h.allocated = heaplock_allocated;
hl->h.total = heaplock_total;
hl->h.pagesize = size;
hl->h.pagesize = parent->pagesize;
hl->parent = parent;
hl->meta = meta;
spin_lock_init(&hl->lock);
return (heap)hl;
}
7 changes: 4 additions & 3 deletions src/kernel/pagecache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1317,9 +1317,10 @@ void init_pagecache(heap general, heap contiguous, heap physical, u64 pagesize)
assert(pc->zero_page != INVALID_ADDRESS);

#ifdef KERNEL
/* XXX lock, and move to locked general when ready */
pc->completions = allocate_objcache(general, contiguous,
sizeof(struct page_completion), PAGESIZE);
pc->completions =
locking_heap_wrapper(general, allocate_objcache(general, contiguous,
sizeof(struct page_completion),
PAGESIZE));
assert(pc->completions != INVALID_ADDRESS);
spin_lock_init(&pc->state_lock);
#else
Expand Down

0 comments on commit 3ab0437

Please sign in to comment.