summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2018-01-01 15:01:35 +0100
committerStephan Bergmann <sbergman@redhat.com>2018-05-16 08:38:15 +0200
commit6da400912e8c69ae86650e799767da54ee422392 (patch)
treeda5a49a0c8a38c3b0d6c963a73a93e74f357b23f /sal
parent5dcb065d24fd9b57b6dc65a19a8a8c8bbaa22c44 (diff)
[API CHANGE] Remove no longer working rtl_arena -> rtl_cache feature
rtl_arena_create's quantum_cache_max parameter (when non-zero) would have allowed an rtl_arena to internally use an rtl_cache for chunk allocation. (And none of the LO-internal uses of rtl_arena_create makes use of that.) However, with the combination of old ce906b8096081dee15dc8cc96e570d5b0b587955 "skip tricky allocators on G_SLICE=always-malloc" and recent bc6a5d8e79e7d0e7d75ac107aa8e6aa275e434e9 "Disable custom allocator", rtl_cache unconditionally just uses malloc/free now, so the rtl_arena_create quantum_cache_max feature has effectively become irrelevant. As those changes appear to have no negative consequences overall (and help remove quite a chunk of no-longer used code), leave it at that and officially abandon the quantum_cache_max feature. Change-Id: I7d186a4a1589db6a73059c2be164aa81d81aef47 Reviewed-on: https://gerrit.libreoffice.org/54388 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/rtl/alloc_arena.cxx88
-rw-r--r--sal/rtl/alloc_arena.hxx1
-rw-r--r--sal/rtl/alloc_cache.cxx17
-rw-r--r--sal/rtl/alloc_impl.hxx1
4 files changed, 7 insertions, 100 deletions
diff --git a/sal/rtl/alloc_arena.cxx b/sal/rtl/alloc_arena.cxx
index 721df266f442..b321e8e23f91 100644
--- a/sal/rtl/alloc_arena.cxx
+++ b/sal/rtl/alloc_arena.cxx
@@ -609,7 +609,6 @@ rtl_arena_type * rtl_arena_activate(
rtl_arena_type * arena,
const char * name,
sal_Size quantum,
- sal_Size quantum_cache_max,
rtl_arena_type * source_arena,
void * (SAL_CALL * source_alloc)(rtl_arena_type *, sal_Size *),
void (SAL_CALL * source_free) (rtl_arena_type *, void *, sal_Size)
@@ -625,39 +624,14 @@ rtl_arena_type * rtl_arena_activate(
/* roundup to next power of 2 */
quantum = ((sal_Size(1)) << highbit(quantum));
}
- quantum_cache_max = RTL_MEMORY_P2ROUNDUP(quantum_cache_max, quantum);
arena->m_quantum = quantum;
arena->m_quantum_shift = highbit(arena->m_quantum) - 1;
- arena->m_qcache_max = quantum_cache_max;
arena->m_source_arena = source_arena;
arena->m_source_alloc = source_alloc;
arena->m_source_free = source_free;
- if (arena->m_qcache_max > 0)
- {
- char namebuf[RTL_ARENA_NAME_LENGTH + 1];
- int i, n = (arena->m_qcache_max >> arena->m_quantum_shift);
-
- sal_Size size = n * sizeof(rtl_cache_type*);
- arena->m_qcache_ptr = static_cast<rtl_cache_type**>(rtl_arena_alloc (gp_arena_arena, &size));
- if (!(arena->m_qcache_ptr))
- {
- /* out of memory */
- return nullptr;
- }
- for (i = 1; i <= n; i++)
- {
- size = i * arena->m_quantum;
- (void) snprintf (namebuf, sizeof(namebuf), "%s_%" SAL_PRIuUINTPTR, arena->m_name, size);
-#if defined __GNUC__ && __GNUC__ >= 7
-#pragma GCC diagnostic pop
-#endif
- arena->m_qcache_ptr[i - 1] = rtl_cache_create(namebuf, size, 0, nullptr, nullptr, nullptr, nullptr, arena, RTL_CACHE_FLAG_QUANTUMCACHE);
- }
- }
-
/* insert into arena list */
RTL_MEMORY_LOCK_ACQUIRE(&(g_arena_list.m_lock));
QUEUE_INSERT_TAIL_NAMED(&(g_arena_list.m_arena_head), arena, arena_);
@@ -675,26 +649,6 @@ void rtl_arena_deactivate(rtl_arena_type * arena)
QUEUE_REMOVE_NAMED(arena, arena_);
RTL_MEMORY_LOCK_RELEASE(&(g_arena_list.m_lock));
- /* cleanup quantum cache(s) */
- if (arena->m_qcache_max > 0 && arena->m_qcache_ptr)
- {
- int i, n = (arena->m_qcache_max >> arena->m_quantum_shift);
- for (i = 1; i <= n; i++)
- {
- if (arena->m_qcache_ptr[i-1])
- {
- rtl_cache_destroy (arena->m_qcache_ptr[i-1]);
- arena->m_qcache_ptr[i-1] = nullptr;
- }
- }
- rtl_arena_free (
- gp_arena_arena,
- arena->m_qcache_ptr,
- n * sizeof(rtl_cache_type*));
-
- arena->m_qcache_ptr = nullptr;
- }
-
/* check for leaked segments */
if (arena->m_stats.m_alloc > arena->m_stats.m_free)
{
@@ -781,7 +735,7 @@ void rtl_arena_deactivate(rtl_arena_type * arena)
rtl_arena_type * SAL_CALL rtl_arena_create(
const char * name,
sal_Size quantum,
- sal_Size quantum_cache_max,
+ sal_Size,
rtl_arena_type * source_arena,
void * (SAL_CALL * source_alloc)(rtl_arena_type *, sal_Size *),
void (SAL_CALL * source_free) (rtl_arena_type *, void *, sal_Size),
@@ -808,7 +762,6 @@ try_alloc:
arena,
name,
quantum,
- quantum_cache_max,
source_arena,
source_alloc,
source_free
@@ -855,7 +808,7 @@ void * SAL_CALL rtl_arena_alloc(
sal_Size size;
size = RTL_MEMORY_ALIGN(*pSize, arena->m_quantum);
- if (size > arena->m_qcache_max)
+ if (size > 0)
{
/* allocate from segment list */
rtl_arena_segment_type *segment = nullptr;
@@ -874,7 +827,7 @@ void * SAL_CALL rtl_arena_alloc(
/* resize */
assert(segment->m_size >= size);
oversize = segment->m_size - size;
- if (oversize >= arena->m_quantum && oversize >= arena->m_qcache_max)
+ if (oversize >= arena->m_quantum)
{
rtl_arena_segment_type * remainder = nullptr;
rtl_arena_segment_get (arena, &remainder);
@@ -898,16 +851,6 @@ void * SAL_CALL rtl_arena_alloc(
}
RTL_MEMORY_LOCK_RELEASE(&(arena->m_lock));
}
- else if (size > 0)
- {
- /* allocate from quantum cache(s) */
- int index = (size >> arena->m_quantum_shift) - 1;
- assert(arena->m_qcache_ptr[index]);
-
- addr = rtl_cache_alloc (arena->m_qcache_ptr[index]);
- if (addr)
- (*pSize) = size;
- }
}
return addr;
}
@@ -921,7 +864,7 @@ void SAL_CALL rtl_arena_free (
if (arena)
{
size = RTL_MEMORY_ALIGN(size, arena->m_quantum);
- if (size > arena->m_qcache_max)
+ if (size > 0)
{
/* free to segment list */
rtl_arena_segment_type * segment;
@@ -981,31 +924,11 @@ void SAL_CALL rtl_arena_free (
RTL_MEMORY_LOCK_RELEASE(&(arena->m_lock));
}
- else if (size > 0)
- {
- /* free to quantum cache(s) */
- int index = (size >> arena->m_quantum_shift) - 1;
- assert(arena->m_qcache_ptr[index]);
-
- rtl_cache_free (arena->m_qcache_ptr[index], addr);
- }
}
}
void rtl_arena_foreach (rtl_arena_type *arena, ArenaForeachFn foreachFn)
{
- // quantum caches
- if ((arena->m_qcache_max > 0) && (arena->m_qcache_ptr != nullptr))
- {
- int i, n = (arena->m_qcache_max >> arena->m_quantum_shift);
- for (i = 1; i <= n; i++)
- {
- if (arena->m_qcache_ptr[i - 1] != nullptr)
- rtl_cache_foreach (arena->m_qcache_ptr[i - 1],
- foreachFn);
- }
- }
-
/* used segments */
for (int i = 0, n = arena->m_hash_size; i < n; i++)
{
@@ -1131,7 +1054,6 @@ void rtl_arena_init()
&g_machdep_arena,
"rtl_machdep_arena",
rtl_machdep_pagesize(),
- 0, /* no quantum caching */
nullptr, nullptr, nullptr /* no source */
);
assert(gp_machdep_arena);
@@ -1147,7 +1069,6 @@ void rtl_arena_init()
&g_default_arena,
"rtl_default_arena",
rtl_machdep_pagesize(),
- 0, /* no quantum caching */
gp_machdep_arena, /* source */
rtl_machdep_alloc,
rtl_machdep_free
@@ -1165,7 +1086,6 @@ void rtl_arena_init()
&g_arena_arena,
"rtl_arena_internal_arena",
64, /* quantum */
- 0, /* no quantum caching */
gp_default_arena, /* source */
rtl_arena_alloc,
rtl_arena_free
diff --git a/sal/rtl/alloc_arena.hxx b/sal/rtl/alloc_arena.hxx
index 30eac16840a6..120d0ec5ac45 100644
--- a/sal/rtl/alloc_arena.hxx
+++ b/sal/rtl/alloc_arena.hxx
@@ -101,7 +101,6 @@ struct rtl_arena_st
sal_Size m_hash_size; /* m_hash_mask + 1 */
sal_Size m_hash_shift; /* log2(m_hash_size) */
- sal_Size m_qcache_max;
rtl_cache_type ** m_qcache_ptr;
};
diff --git a/sal/rtl/alloc_cache.cxx b/sal/rtl/alloc_cache.cxx
index a24f8661cb8f..f7dd02ab7c8a 100644
--- a/sal/rtl/alloc_cache.cxx
+++ b/sal/rtl/alloc_cache.cxx
@@ -742,21 +742,10 @@ rtl_cache_type * rtl_cache_activate(
cache->m_source = source;
slabsize = source->m_quantum; /* minimum slab size */
- if (flags & RTL_CACHE_FLAG_QUANTUMCACHE)
+ /* waste at most 1/8 of slab */
+ if(slabsize < cache->m_type_size * 8)
{
- /* next power of 2 above 3 * qcache_max */
- if (slabsize < ((sal_Size(1)) << highbit(3 * source->m_qcache_max)))
- {
- slabsize = ((sal_Size(1)) << highbit(3 * source->m_qcache_max));
- }
- }
- else
- {
- /* waste at most 1/8 of slab */
- if(slabsize < cache->m_type_size * 8)
- {
- slabsize = cache->m_type_size * 8;
- }
+ slabsize = cache->m_type_size * 8;
}
slabsize = RTL_MEMORY_P2ROUNDUP(slabsize, source->m_quantum);
diff --git a/sal/rtl/alloc_impl.hxx b/sal/rtl/alloc_impl.hxx
index 0c5340303ae5..38d0f92d733c 100644
--- a/sal/rtl/alloc_impl.hxx
+++ b/sal/rtl/alloc_impl.hxx
@@ -211,7 +211,6 @@ typedef CRITICAL_SECTION rtl_memory_lock_type;
@internal
*/
#define RTL_CACHE_FLAG_NOMAGAZINE (1 << 13) /* w/o magazine layer */
-#define RTL_CACHE_FLAG_QUANTUMCACHE (2 << 13) /* used as arena quantum cache */
enum class AllocMode { CUSTOM, SYSTEM, UNSET };