From c6ee79ce388772e847063f6d52111db54b0bbc71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 16 Jan 2008 20:30:16 +0000 Subject: [PATCH] * vm_create_anonymous_area() now accepts B_ANY_KERNEL_BLOCK_ADDRESS. * As a temporary work-around for the current slab allocator's area usage, I added the CACHE_LARGE_SLAB flag, which will force the allocator to use larger areas. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23564 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/slab/Slab.h | 6 +++--- src/system/kernel/slab/Slab.cpp | 24 +++++++++++++++++++----- src/system/kernel/vm/vm.cpp | 1 + 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/headers/private/kernel/slab/Slab.h b/headers/private/kernel/slab/Slab.h index 5fec6f346d..a7586a87c0 100644 --- a/headers/private/kernel/slab/Slab.h +++ b/headers/private/kernel/slab/Slab.h @@ -1,9 +1,8 @@ /* + * Copyright 2008, Axel Dörfler. All Rights Reserved. * Copyright 2007, Hugo Santos. All Rights Reserved. - * Distributed under the terms of the MIT License. * - * Authors: - * Hugo Santos, hugosantos@gmail.com + * Distributed under the terms of the MIT License. */ #ifndef _SLAB_SLAB_H_ #define _SLAB_SLAB_H_ @@ -17,6 +16,7 @@ enum { /* create_object_cache_etc flags */ CACHE_NO_DEPOT = 1 << 0, CACHE_UNLOCKED_PAGES = 1 << 1, + CACHE_LARGE_SLAB = 1 << 2, /* object_cache_alloc flags */ CACHE_DONT_SLEEP = 1 << 8, diff --git a/src/system/kernel/slab/Slab.cpp b/src/system/kernel/slab/Slab.cpp index fd6076bcae..f0de142d38 100644 --- a/src/system/kernel/slab/Slab.cpp +++ b/src/system/kernel/slab/Slab.cpp @@ -1,4 +1,5 @@ /* + * Copyright 2008, Axel Dörfler. All Rights Reserved. * Copyright 2007, Hugo Santos. All Rights Reserved. * Distributed under the terms of the MIT License. * @@ -39,6 +40,7 @@ #define TRACE_CACHE(cache, format, bananas...) do { } while (0) #endif +#define CACHE_ALIGN_ON_SIZE (30 << 1) static const int kMagazineCapacity = 32; static const size_t kCacheColorPeriod = 8; @@ -273,10 +275,15 @@ area_allocate_pages(object_cache *cache, void **pages, uint32 flags) if (cache->flags & CACHE_UNLOCKED_PAGES) lock = B_NO_LOCK; + uint32 addressSpec = B_ANY_KERNEL_ADDRESS; + if ((cache->flags & CACHE_ALIGN_ON_SIZE) != 0 + && cache->slab_size != B_PAGE_SIZE) + addressSpec = B_ANY_KERNEL_BLOCK_ADDRESS; + // if we are allocating, it is because we need the pages immediatly // so we lock them. when moving the slab to the empty list we should // unlock them, and lock them again when getting one from the empty list. - area_id areaId = create_area(cache->name, pages, B_ANY_KERNEL_ADDRESS, + area_id areaId = create_area(cache->name, pages, addressSpec, cache->slab_size, lock, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); if (areaId < 0) return areaId; @@ -523,13 +530,17 @@ create_small_object_cache(const char *name, size_t object_size, SmallObjectCache *cache = new (buffer) SmallObjectCache(); - if (object_cache_init(cache, name, object_size, alignment, maximum, flags, - cookie, constructor, destructor, reclaimer) < B_OK) { + if (object_cache_init(cache, name, object_size, alignment, maximum, + flags | CACHE_ALIGN_ON_SIZE, cookie, constructor, destructor, + reclaimer) < B_OK) { delete_cache(cache); return NULL; } - cache->slab_size = B_PAGE_SIZE; + if ((flags & CACHE_LARGE_SLAB) != 0) + cache->slab_size = max_c(16 * B_PAGE_SIZE, 1024 * object_size); + else + cache->slab_size = B_PAGE_SIZE; return cache; } @@ -553,7 +564,10 @@ create_hashed_object_cache(const char *name, size_t object_size, return NULL; } - cache->slab_size = max_c(16 * B_PAGE_SIZE, 8 * object_size); + if ((flags & CACHE_LARGE_SLAB) != 0) + cache->slab_size = max_c(256 * B_PAGE_SIZE, 128 * object_size); + else + cache->slab_size = max_c(16 * B_PAGE_SIZE, 8 * object_size); cache->lower_boundary = __fls0(cache->object_size); return cache; diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp index c5a8fe5a01..31e41cc545 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -1409,6 +1409,7 @@ vm_create_anonymous_area(team_id team, const char *name, void **address, case B_EXACT_ADDRESS: case B_BASE_ADDRESS: case B_ANY_KERNEL_ADDRESS: + case B_ANY_KERNEL_BLOCK_ADDRESS: break; default: