From 76308c2e1f7bf09686b14b797562d0e98efba97d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 24 Nov 2020 18:38:41 +0100 Subject: [PATCH] Kernel: Reduce ByteBuffer thrashing in inode block list generation Instead of creating and destroying a new ByteBuffer for every block we process during block list generation, just use stack memory instead. --- Kernel/FileSystem/Ext2FileSystem.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index 3ecbd951e1..26767b31ad 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -484,13 +484,10 @@ Vector Ext2FS::block_list_for_inode_impl(const ext2_inode& e auto process_block_array = [&](unsigned array_block_index, auto&& callback) { if (include_block_list_blocks) add_block(array_block_index); - unsigned count = min(blocks_remaining, entries_per_block); - size_t read_size = count * sizeof(__u32); - auto array_block = ByteBuffer::create_uninitialized(read_size); - auto buffer = UserOrKernelBuffer::for_kernel_buffer(array_block.data()); - read_block(array_block_index, &buffer, read_size, 0); - ASSERT(array_block); - auto* array = reinterpret_cast(array_block.data()); + auto count = min(blocks_remaining, entries_per_block); + u32 array[count]; + auto buffer = UserOrKernelBuffer::for_kernel_buffer((u8*)array); + read_block(array_block_index, &buffer, sizeof(array), 0); for (BlockIndex i = 0; i < count; ++i) callback(array[i]); };