Commit f0c72121 authored by Dorel Coman's avatar Dorel Coman Committed by Oliver Horst
Browse files

memguard: cleanup, improved function names and comments

parent 6ebd6e73
......@@ -9,19 +9,17 @@
*
* The original code was discontinued from Linux v4.3
*/
#include "memguard/ewma.h"
#include <arm_neon.h>
#include <stdint-gcc.h>
#include "memguard/ewma.h"
#include <tgmath.h>
void ewma_init(struct ewma *avg, unsigned long factor, unsigned long weight)
{
//TODO: check warn
// WARN_ON(!is_power_of_2(weight) || !is_power_of_2(factor));
// avg->weight = (unsigned long) log2(weight);
// avg->factor = (unsigned long) log2(factor);
// avg->weight = (unsigned long) log2(weight);
// avg->factor = (unsigned long) log2(factor);
avg->internal = 0;
}
......
......@@ -286,10 +286,6 @@ void suspend_task_routine(void *pvParameter1, uint32_t ulParameter2);
void memguard_init()
{
uint32_t core_id = pmu_get_core_id();
uint32_t val = MIN_GUARANTEED_BANDWIDTH;
// we are saving in the GIC the core id, so to be sure
XScuGic_SetCpuID(core_id);
Xil_DCacheDisable();
......@@ -313,7 +309,7 @@ void memguard_init()
}
#endif
// task activated at the beginning of scheduling to setup the timer and then deleted
/* task activated at the beginning of scheduling to setup the timer and then deleted */
xTaskCreate(memguard_setup_task, "Memguard", configMINIMAL_STACK_SIZE, NULL,
MEMGUARD_SETUP_TASK_PRIORITY, &memguard_task_handle);
......@@ -321,9 +317,9 @@ void memguard_init()
memguard_set_new_task(memguard_task_handle, BANDWIDTH_ASS_MEMGUARD_TASK_IN_MB_PER_S, pdTRUE);
}
void memguard_set_new_task(TaskHandle_t pxCreatedTask, uint32_t quota_in_MB_s, BaseType_t prediction_allowed)
void memguard_set_new_task(TaskHandle_t task_handle, uint32_t quota_in_MB_s, BaseType_t prediction_allowed)
{
if(pxCreatedTask != NULL){
if(task_handle != NULL){
memguard_task_info *new_task_info = malloc(sizeof(memguard_task_info));
// static quota assigned to task
......@@ -346,17 +342,17 @@ void memguard_set_new_task(TaskHandle_t pxCreatedTask, uint32_t quota_in_MB_s, B
guaranteed bandwidth */
configASSERT(val_read <= MIN_GUARANTEED_BANDWIDTH + BANDWIDTH_ASS_MEMGUARD_TASK*NUMBER_CORES);
vTaskSetMemguardTaskInfo(pxCreatedTask, new_task_info);
vTaskSetMemguardTaskInfo(task_handle, new_task_info);
}
}
void memguard_notify_task_suspended(TaskHandle_t xTask)
void memguard_notify_task_suspended(TaskHandle_t task_handle)
{
#if (MEMGUARD_TEST)
start_memguard_trace();
#endif
memguard_task_info *task_info = (memguard_task_info *) pvTaskGetMemguardTaskInfo(xTask);
memguard_task_info *task_info = (memguard_task_info *) pvTaskGetMemguardTaskInfo(task_handle);
task_info->tsk_susp_by_user = pdTRUE;
#if (MEMGUARD_TEST)
......@@ -364,13 +360,13 @@ void memguard_notify_task_suspended(TaskHandle_t xTask)
#endif
}
void memguard_notify_task_resumed(TaskHandle_t xTask)
void memguard_notify_task_resumed(TaskHandle_t task_handle)
{
#if (MEMGUARD_TEST)
start_memguard_trace();
#endif
memguard_task_info *task_info = (memguard_task_info *) pvTaskGetMemguardTaskInfo(xTask);
memguard_task_info *task_info = (memguard_task_info *) pvTaskGetMemguardTaskInfo(task_handle);
task_info->tsk_susp_by_user = pdFALSE;
#if (MEMGUARD_TEST)
......@@ -378,7 +374,7 @@ void memguard_notify_task_resumed(TaskHandle_t xTask)
#endif
}
BaseType_t memguard_task_susp_by_memguard(TaskHandle_t xTask)
BaseType_t memguard_is_task_susp_by_memguard(TaskHandle_t xTask)
{
#if (MEMGUARD_TEST)
start_memguard_trace();
......@@ -395,17 +391,17 @@ BaseType_t memguard_task_susp_by_memguard(TaskHandle_t xTask)
return task_info->tsk_susp_by_memguard;
}
void memguard_reset_task_info(TaskHandle_t taskHandle)
void memguard_reset_task_info(TaskHandle_t task_handle)
{
uint32_t new_quota;
if(taskHandle == memguard_task_handle)
if(task_handle == memguard_task_handle)
return;
TaskStatus_t status;
vTaskGetInfo(taskHandle, &status, pdFALSE, eInvalid);
vTaskGetInfo(task_handle, &status, pdFALSE, eInvalid);
memguard_task_info *task_info = pvTaskGetMemguardTaskInfo(taskHandle);
memguard_task_info *task_info = pvTaskGetMemguardTaskInfo(task_handle);
/* Checking the case of inability of using all statically assigned memory
in the last window - in this case we compensate the difference for the next window */
......@@ -460,7 +456,7 @@ void memguard_reset_task_info(TaskHandle_t taskHandle)
/* If the task wasn't suspended */
if(task_info->tsk_susp_by_user == pdFALSE){
vTaskResume(taskHandle);
vTaskResume(task_handle);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment