From 11debaf6e42791116afaf167883ea2c73f88db66 Mon Sep 17 00:00:00 2001 From: Hugo Santos Date: Sun, 29 Apr 2007 20:55:44 +0000 Subject: [PATCH] added CACHE_UNLOCKED_PAGES flag to allow caches' pages to be created with no locking instead of full locking. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20911 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/slab/Base.h | 1 + src/system/kernel/slab/Slab.cpp | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/headers/private/kernel/slab/Base.h b/headers/private/kernel/slab/Base.h index 7090e5f8e9..06e5d037ef 100644 --- a/headers/private/kernel/slab/Base.h +++ b/headers/private/kernel/slab/Base.h @@ -18,6 +18,7 @@ extern "C" { enum { /* create_object_cache_etc flags */ CACHE_NO_DEPOT = 1 << 0, + CACHE_UNLOCKED_PAGES = 1 << 1, /* 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 a617e0e885..8e171c2638 100644 --- a/src/system/kernel/slab/Slab.cpp +++ b/src/system/kernel/slab/Slab.cpp @@ -260,11 +260,15 @@ allocate_pages(object_cache *cache, void **pages, uint32 flags) { TRACE_CACHE(cache, "allocate pages (%lu, 0x0%lx)", cache->slab_size, flags); + uint32 lock = B_FULL_LOCK; + if (cache->flags & CACHE_UNLOCKED_PAGES) + lock = B_NO_LOCK; + // 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, - cache->slab_size, B_FULL_LOCK, B_READ_AREA | B_WRITE_AREA); + cache->slab_size, lock, B_READ_AREA | B_WRITE_AREA); if (areaId < 0) return areaId;