Skip to content

Commit a2caf36

Browse files
galakAnas Nashif
authored andcommitted
kernel: Remove deprecated k_mem_pool_defrag code
Remove references to k_mem_pool_defrag and any related bits associated with mem_pool defrag that don't make sense anymore. Signed-off-by: Kumar Gala <[email protected]>
1 parent 5e9c13a commit a2caf36

File tree

8 files changed

+0
-147
lines changed

8 files changed

+0
-147
lines changed

include/kernel.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3662,17 +3662,6 @@ extern int k_mem_pool_alloc(struct k_mem_pool *pool, struct k_mem_block *block,
36623662
*/
36633663
extern void k_mem_pool_free(struct k_mem_block *block);
36643664

3665-
/**
3666-
* @brief Defragment a memory pool.
3667-
*
3668-
* This is a no-op API preserved for backward compatibility only.
3669-
*
3670-
* @param pool Unused
3671-
*
3672-
* @return N/A
3673-
*/
3674-
static inline void __deprecated k_mem_pool_defrag(struct k_mem_pool *pool) {}
3675-
36763665
/**
36773666
* @} end addtogroup mem_pool_apis
36783667
*/

kernel/Kconfig

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -359,48 +359,6 @@ config NUM_PIPE_ASYNC_MSGS
359359
endmenu
360360

361361
menu "Memory Pool Options"
362-
choice
363-
prompt "Memory pool block allocation policy"
364-
default MEM_POOL_SPLIT_BEFORE_DEFRAG
365-
help
366-
This option specifies how a memory pool reacts if an unused memory
367-
block of the required size is not available.
368-
369-
config MEM_POOL_SPLIT_BEFORE_DEFRAG
370-
bool "Split a larger block before merging smaller blocks"
371-
help
372-
This option instructs a memory pool to try splitting a larger unused
373-
block if an unused block of the required size is not available; only
374-
if no such blocks exist will the memory pool try merging smaller unused
375-
blocks. This policy attempts to limit the cost of performing automatic
376-
partial defragmentation of the memory pool, at the cost of fragmenting
377-
the memory pool's larger blocks.
378-
379-
config MEM_POOL_DEFRAG_BEFORE_SPLIT
380-
bool "Merge smaller blocks before splitting a larger block"
381-
help
382-
This option instructs a memory pool to try merging smaller unused
383-
blocks if an unused block of the required size is not available; only
384-
if this does not generate a sufficiently large block will the memory
385-
pool try splitting a larger unused block. This policy attempts to
386-
preserve the memory pool's larger blocks, at the cost of performing
387-
automatic partial defragmentations more frequently.
388-
389-
config MEM_POOL_SPLIT_ONLY
390-
bool "Split a larger block, but never merge smaller blocks"
391-
help
392-
This option instructs a memory pool to try splitting a larger unused
393-
block if an unused block of the required size is not available; if no
394-
such blocks exist the block allocation operation fails. This policy
395-
attempts to limit the cost of defragmenting the memory pool by avoiding
396-
automatic partial defragmentation, at the cost of requiring the
397-
application to explicitly request a full defragmentation of the memory
398-
pool when an allocation fails. Depending on how a memory pool is used,
399-
it may be more efficient for a memory pool to perform an occasional
400-
full defragmentation than to perform frequent partial defragmentations.
401-
402-
endchoice
403-
404362
config HEAP_MEM_POOL_SIZE
405363
int
406364
prompt "Heap memory pool size (in bytes)"

tests/benchmarks/footprint/src/main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ static pfunc func_array[] = {
107107
/* mem pools */
108108
(pfunc)k_mem_pool_alloc,
109109
(pfunc)k_mem_pool_free,
110-
(pfunc)k_mem_pool_defrag,
111110
(pfunc)k_malloc,
112111
(pfunc)k_free,
113112

tests/kernel/mem_pool/mem_pool/README.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ tc_start() - Test Memory Pool and Heap APIs
3535
Testing k_mem_pool_alloc(K_NO_WAIT) ...
3636
Testing k_mem_pool_alloc(timeout) ...
3737
Testing k_mem_pool_alloc(K_FOREVER) ...
38-
Testing k_mem_pool_defragment() ...
3938
Testing k_malloc() and k_free() ...
4039
===================================================================
4140
PASS - RegressionTask.

tests/kernel/mem_pool/mem_pool/src/pool.c

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@
2525

2626
#define NUM_BLOCKS 64
2727

28-
#define DEFRAG_BLK_TEST 2222
29-
3028
/* size of stack area used by each thread */
3129
#define STACKSIZE 512
3230

3331
K_SEM_DEFINE(ALTERNATE_SEM, 0, 1);
34-
K_SEM_DEFINE(DEFRAG_SEM, 0, 1);
3532
K_SEM_DEFINE(REGRESS_SEM, 0, 1);
3633
K_SEM_DEFINE(HELPER_SEM, 0, 1);
3734

@@ -84,19 +81,6 @@ static struct TEST_CASE getwt_set[] = {
8481
{ &block_list[4], &POOL_ID, 256, TENTH_SECOND, -EAGAIN }
8582
};
8683

87-
static struct TEST_CASE defrag[] = {
88-
{ &block_list[0], &POOL_ID, 64, 0, 0 },
89-
{ &block_list[1], &POOL_ID, 64, 0, 0 },
90-
{ &block_list[2], &POOL_ID, 64, 0, 0 },
91-
{ &block_list[3], &POOL_ID, 64, 0, 0 },
92-
{ &block_list[4], &POOL_ID, 256, 0, 0 },
93-
{ &block_list[5], &POOL_ID, 256, 0, 0 },
94-
{ &block_list[6], &POOL_ID, 256, 0, 0 },
95-
{ &block_list[7], &POOL_ID, 1024, 0, 0 },
96-
{ &block_list[8], &POOL_ID, 1024, 0, 0 },
97-
{ &block_list[9], &POOL_ID, 1024, 0, 0 }
98-
};
99-
10084
/**
10185
*
10286
* @brief Compare the two blocks
@@ -357,72 +341,6 @@ int pool_block_get_wait_test(void)
357341
return TC_PASS;
358342
}
359343

360-
/**
361-
*
362-
* @brief Task responsible for defragmenting the pool POOL_ID
363-
*
364-
* @return N/A
365-
*/
366-
367-
void defrag_task(void)
368-
{
369-
k_sem_take(&DEFRAG_SEM, K_FOREVER); /* Wait to be activated */
370-
371-
k_mem_pool_defrag(&POOL_ID);
372-
373-
k_sem_give(&REGRESS_SEM); /* defrag_task is finished */
374-
}
375-
376-
/**
377-
*
378-
* pool_defrag_test -
379-
*
380-
* @return TC_PASS on success, TC_FAIL on failure
381-
*/
382-
383-
int pool_defrag_test(void)
384-
{
385-
int rv;
386-
struct k_mem_block new_block;
387-
388-
/* Get a bunch of blocks */
389-
390-
rv = pool_block_get_work("k_mem_pool_alloc", pool_block_get_func,
391-
defrag, ARRAY_SIZE(defrag));
392-
if (rv != TC_PASS) {
393-
return TC_FAIL;
394-
}
395-
396-
397-
k_sem_give(&DEFRAG_SEM); /* Activate defrag_task */
398-
399-
/*
400-
* Block on getting another block from the pool.
401-
* This will allow defrag_task to execute so that we can get some
402-
* better code coverage. 500 ms is expected to more than sufficient
403-
* time for defrag_task to finish.
404-
*/
405-
406-
rv = k_mem_pool_alloc(&POOL_ID, &new_block, DEFRAG_BLK_TEST, 500);
407-
if (rv != -EAGAIN) {
408-
TC_ERROR("k_mem_pool_alloc() returned %d, not %d\n", rv,
409-
-EAGAIN);
410-
return TC_FAIL;
411-
}
412-
413-
rv = k_sem_take(&REGRESS_SEM, K_NO_WAIT);
414-
if (rv != 0) {
415-
TC_ERROR("defrag_task did not finish in allotted time!\n");
416-
return TC_FAIL;
417-
}
418-
419-
/* Free the allocated blocks */
420-
421-
free_blocks(defrag, ARRAY_SIZE(defrag));
422-
423-
return TC_PASS;
424-
}
425-
426344
/**
427345
*
428346
* @brief Alternate task in the test suite
@@ -557,10 +475,6 @@ void test_mem_pool(void)
557475
tc_rc = pool_block_get_wait_test();
558476
zassert_equal(tc_rc, TC_PASS, "pool block wait failure");
559477

560-
TC_PRINT("Testing k_mem_pool_defragment() ...\n");
561-
tc_rc = pool_defrag_test();
562-
zassert_equal(tc_rc, TC_PASS, "pool defrag failure");
563-
564478
tc_rc = pool_malloc_test();
565479
zassert_equal(tc_rc, TC_PASS, "pool malloc failure");
566480
}
@@ -569,9 +483,6 @@ void test_mem_pool(void)
569483
K_THREAD_DEFINE(t_alternate, STACKSIZE, alternate_task, NULL, NULL, NULL,
570484
6, 0, K_NO_WAIT);
571485

572-
K_THREAD_DEFINE(t_defrag, STACKSIZE, defrag_task, NULL, NULL, NULL,
573-
7, 0, K_NO_WAIT);
574-
575486
K_THREAD_DEFINE(t_helper, STACKSIZE, helper_task, NULL, NULL, NULL,
576487
7, 0, K_NO_WAIT);
577488

tests/kernel/mem_pool/mem_pool_concept/src/test_mpool_merge_fail_diff_parent.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ void test_mpool_alloc_merge_failed_diff_parent(void)
3333
k_mem_pool_free(&block[i]);
3434
}
3535
/* 3. request a big block, expected failed to merge*/
36-
k_mem_pool_defrag(&mpool1);
3736
zassert_true(k_mem_pool_alloc(&mpool1, &block_fail, BLK_SIZE_MAX,
3837
TIMEOUT) == -EAGAIN, NULL);
3938

tests/kernel/mem_pool/mem_pool_concept/src/test_mpool_merge_fail_diff_size.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ void test_mpool_alloc_merge_failed_diff_size(void)
4545
k_mem_pool_free(&block[i]);
4646
}
4747
/* 3. request a big block, expected failed to merge*/
48-
k_mem_pool_defrag(&mpool3);
4948
zassert_true(k_mem_pool_alloc(&mpool3, &block_fail, BLK_SIZE_MAX,
5049
TIMEOUT) == -EAGAIN, NULL);
5150

tests/kernel/mem_pool/mem_pool_threadsafe/src/test_mpool_threadsafe.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ static void tmpool_api(void *p1, void *p2, void *p3)
7171
k_mem_pool_free(&block[i]);
7272
}
7373
}
74-
k_mem_pool_defrag(pool);
7574

7675
k_sem_give(&sync_sema);
7776
}

0 commit comments

Comments
 (0)