2021-06-10 22:02:00 +03:00
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2021-04-20 01:43:45 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ebpf_platform.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
2021-05-28 00:41:26 +03:00
|
|
|
typedef struct _ebpf_epoch_work_item ebpf_epoch_work_item_t;
|
|
|
|
|
2021-04-23 19:48:13 +03:00
|
|
|
/**
|
|
|
|
* @brief Initialize the eBPF epoch tracking module.
|
|
|
|
*
|
2021-05-20 22:38:58 +03:00
|
|
|
* @retval EBPF_SUCCESS The operation was successful.
|
|
|
|
* @retval EBPF_NO_MEMORY Unable to allocate resources for this
|
2021-04-23 19:48:13 +03:00
|
|
|
* operation.
|
|
|
|
*/
|
2021-05-20 22:38:58 +03:00
|
|
|
ebpf_result_t
|
2021-04-20 01:43:45 +03:00
|
|
|
ebpf_epoch_initiate();
|
|
|
|
|
2021-04-23 19:48:13 +03:00
|
|
|
/**
|
|
|
|
* @brief Uninitialize the eBPF epoch tracking module.
|
|
|
|
*
|
|
|
|
*/
|
2021-04-20 01:43:45 +03:00
|
|
|
void
|
|
|
|
ebpf_epoch_terminate();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Called prior to touching memory with lifetime under epoch control.
|
2021-05-20 22:38:58 +03:00
|
|
|
* @retval EBPF_SUCCESS The operation was successful.
|
|
|
|
* @retval EBPF_NO_MEMORY Unable to allocate per-thread
|
2021-04-20 01:43:45 +03:00
|
|
|
* tracking state.
|
|
|
|
*/
|
2021-05-20 22:38:58 +03:00
|
|
|
ebpf_result_t
|
2021-04-20 01:43:45 +03:00
|
|
|
ebpf_epoch_enter();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Called after touching memory with lifetime under epoch control.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ebpf_epoch_exit();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Allocate memory under epoch control.
|
|
|
|
* @param[in] size Size of memory to allocate
|
|
|
|
* @returns Pointer to memory block allocated, or null on failure.
|
|
|
|
*/
|
|
|
|
void*
|
2021-06-07 23:07:24 +03:00
|
|
|
ebpf_epoch_allocate(size_t size);
|
2021-04-20 01:43:45 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Free memory under epoch control.
|
|
|
|
* @param[in] memory Allocation to be freed once epoch ends.
|
|
|
|
*/
|
|
|
|
void
|
2021-08-27 04:00:15 +03:00
|
|
|
ebpf_epoch_free(_Frees_ptr_opt_ void* memory);
|
2021-04-20 01:43:45 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @Brief Release any memory that is associated with expired epochs.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ebpf_epoch_flush();
|
|
|
|
|
2021-05-28 00:41:26 +03:00
|
|
|
/**
|
|
|
|
* @brief Allocate an epoch work item; a work item that can be scheduled to
|
|
|
|
* run when the current epoch ends.
|
|
|
|
*
|
|
|
|
* @param[in] callback_context Context to pass to the callback function.
|
|
|
|
* @param[in] callback Callback function to run on epoch end.
|
|
|
|
* @return Pointer to work item that can be scheduled.
|
|
|
|
*/
|
|
|
|
ebpf_epoch_work_item_t*
|
2021-08-27 04:00:15 +03:00
|
|
|
ebpf_epoch_allocate_work_item(_In_ void* callback_context, _In_ void (*callback)(void* context));
|
2021-05-28 00:41:26 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Schedule a previously allocated work-item to run when the current
|
|
|
|
* epoch ends.
|
|
|
|
*
|
|
|
|
* @param[in] work_item Pointer to work item to run on epoch end.
|
|
|
|
*/
|
|
|
|
void
|
2021-08-27 04:00:15 +03:00
|
|
|
ebpf_epoch_schedule_work_item(_In_ ebpf_epoch_work_item_t* work_item);
|
2021-05-28 00:41:26 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Free an epoch work item.
|
|
|
|
*
|
|
|
|
* @param[in] work_item Pointer to work item to free.
|
|
|
|
*/
|
|
|
|
void
|
2021-08-27 04:00:15 +03:00
|
|
|
ebpf_epoch_free_work_item(_Frees_ptr_opt_ ebpf_epoch_work_item_t* work_item);
|
2021-05-28 00:41:26 +03:00
|
|
|
|
2021-04-20 01:43:45 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|