Module: kamailio
Branch: master
Commit: 111aefd82f4f885be5a4d4d6a4a2ad432dba9e5e
URL:
https://github.com/kamailio/kamailio/commit/111aefd82f4f885be5a4d4d6a4a2ad4…
Author: Camille Oudot <camille.oudot(a)orange.com>
Committer: Camille Oudot <camille.oudot(a)orange.com>
Date: 2015-05-18T11:47:10+02:00
Revert "mem: TLSF use larger first level bitmap"
back to using 32bits bitmaps, limiting the maximum pool size to 512 GiB
This reverts commit 5e04515410c7d7ebedf6c4bc8c917f736b37acba.
---
Modified: mem/tlsf.c
---
Diff:
https://github.com/kamailio/kamailio/commit/111aefd82f4f885be5a4d4d6a4a2ad4…
Patch:
https://github.com/kamailio/kamailio/commit/111aefd82f4f885be5a4d4d6a4a2ad4…
---
diff --git a/mem/tlsf.c b/mem/tlsf.c
index ac76be8..124409e 100644
--- a/mem/tlsf.c
+++ b/mem/tlsf.c
@@ -167,15 +167,7 @@ typedef struct control_t
size_t max_fragments;
#endif
/* Bitmaps for free lists. */
-#if defined (TLSF_64BIT)
-# define TLSF_FL_ZERO 0L
-# define TLSF_FL_ONE 1L
- unsigned long fl_bitmap;
-#else
-# define TLSF_FL_ZERO 0
-# define TLSF_FL_ONE 1
unsigned int fl_bitmap;
-#endif
unsigned int sl_bitmap[FL_INDEX_COUNT];
/* Head of free lists. */
@@ -374,7 +366,7 @@ static block_header_t* search_suitable_block(control_t* control, int*
fli, int*
if (!sl_map)
{
/* No block exists. Search in the next largest first-level list. */
- const unsigned int fl_map = control->fl_bitmap & (~TLSF_FL_ZERO << (fl +
1));
+ const unsigned int fl_map = control->fl_bitmap & (~0 << (fl + 1));
if (!fl_map)
{
/* No free blocks available, memory has been exhausted. */
@@ -416,7 +408,7 @@ static void remove_free_block(control_t* control, block_header_t*
block, int fl,
/* If the second bitmap is now empty, clear the fl bitmap. */
if (!control->sl_bitmap[fl])
{
- control->fl_bitmap &= ~(TLSF_FL_ONE << fl);
+ control->fl_bitmap &= ~(1 << fl);
}
}
}
@@ -442,7 +434,7 @@ static void insert_free_block(control_t* control, block_header_t*
block, int fl,
** and second-level bitmaps appropriately.
*/
control->blocks[fl][sl] = block;
- control->fl_bitmap |= (TLSF_FL_ONE << fl);
+ control->fl_bitmap |= (1 << fl);
control->sl_bitmap[fl] |= (1 << sl);
#if defined TLSF_STATS
TLSF_INCREASE_FRAGMENTS(control);
@@ -621,7 +613,7 @@ static void control_construct(control_t* control)
control->block_null.next_free = &control->block_null;
control->block_null.prev_free = &control->block_null;
- control->fl_bitmap = TLSF_FL_ZERO;
+ control->fl_bitmap = 0;
for (i = 0; i < FL_INDEX_COUNT; ++i)
{
control->sl_bitmap[i] = 0;
@@ -672,7 +664,7 @@ int tlsf_check(tlsf_t tlsf)
{
for (j = 0; j < SL_INDEX_COUNT; ++j)
{
- const int fl_map = control->fl_bitmap & (TLSF_FL_ONE << i);
+ const int fl_map = control->fl_bitmap & (1 << i);
const int sl_list = control->sl_bitmap[i];
const int sl_map = sl_list & (1 << j);
const block_header_t* block = control->blocks[i][j];