aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetri Savolainen <petri.savolainen@nokia.com>2022-10-17 15:48:41 +0300
committerMatias Elo <matias.elo@nokia.com>2022-11-30 12:43:46 +0200
commit47a8ec02bfbe25827c2d8a5e3fc67e331467da10 (patch)
treed4e8719175d7ca8b1c4953f02956fe64585441ef
parentc8fc5e4a97890a388b897faa6409da39e77432b3 (diff)
api: system: add memory usage information
Added odp_system_meminfo() function to retrieve information of ODP memory usage. Usage information includes both application initiated and implementation internal memory allocations. Signed-off-by: Petri Savolainen <petri.savolainen@nokia.com> Reviewed-by: Harman Kalra <hkalra@marvell.com> Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com>
-rw-r--r--include/odp/api/spec/system_info.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/include/odp/api/spec/system_info.h b/include/odp/api/spec/system_info.h
index a73263984..118d8f895 100644
--- a/include/odp/api/spec/system_info.h
+++ b/include/odp/api/spec/system_info.h
@@ -24,6 +24,9 @@ extern "C" {
* @{
*/
+/** Maximum memory block name length in chars (including null char) */
+#define ODP_SYSTEM_MEMBLOCK_NAME_LEN 64
+
/**
* CPU instruction set architecture (ISA) families
*/
@@ -192,6 +195,70 @@ typedef struct odp_system_info_t {
} odp_system_info_t;
/**
+ * Memory information
+ */
+typedef struct odp_system_meminfo_t {
+ /**
+ * Total mapped memory
+ *
+ * Total amount of memory (in bytes) in all memory pages that are reserved by
+ * this ODP instance from the system.
+ */
+ uint64_t total_mapped;
+
+ /**
+ * Total memory usage
+ *
+ * Total amount of memory (in bytes) that is currently in use by this ODP instance.
+ * This is a subset of 'total_mapped' bytes.
+ */
+ uint64_t total_used;
+
+ /**
+ * Total memory usage overheads
+ *
+ * Total amount of memory (in bytes) that is currently consumed by roundings to
+ * alignment/block/page size limits, etc. overheads. This is a subset of 'total_used'
+ * bytes.
+ */
+ uint64_t total_overhead;
+
+} odp_system_meminfo_t;
+
+/**
+ * Memory block information
+ */
+typedef struct odp_system_memblock_t {
+ /** Memory block name */
+ char name[ODP_SYSTEM_MEMBLOCK_NAME_LEN];
+
+ /** Start address of the block */
+ uintptr_t addr;
+
+ /**
+ * Memory usage
+ *
+ * Total amount of memory (in bytes) that is used by this block.
+ */
+ uint64_t used;
+
+ /**
+ * Memory usage overheads
+ *
+ * Total amount of memory (in bytes) that is currently consumed by rounding to
+ * alignment/block/page size limits, etc. overheads. This is a subset of 'used' bytes.
+ */
+ uint64_t overhead;
+
+ /** Memory page size in bytes
+ *
+ * Page size used for this block.
+ */
+ uint64_t page_size;
+
+} odp_system_memblock_t;
+
+/**
* Retrieve system information
*
* Fills in system information structure on success. The call is not intended
@@ -205,6 +272,27 @@ typedef struct odp_system_info_t {
int odp_system_info(odp_system_info_t *info);
/**
+ * Retrieve ODP memory usage information
+ *
+ * Retrieves information about ODP memory usage for debugging and monitoring purposes. A successful
+ * call fills in system memory info and outputs up to 'num' elements into memory block info array.
+ * Each array element represents a memory block used due to an API call (SHM reservation, pool
+ * creation, etc) or an implementation internal memory allocation.
+ *
+ * When return value is 'num' or less, it indicates the number of elements written. If return value
+ * is larger than 'num', all 'num' elements were written and the return value indicates the number
+ * of elements that would have been written into a large enough array.
+ *
+ * @param[out] info Pointer to memory info struct for output
+ * @param[out] block Pointer memory block info array for output
+ * @param num Maximum number of array elements to output (0 ... array size)
+ *
+ * @return Number of array elements written / would have been written
+ * @retval <0 on failure
+ */
+int32_t odp_system_meminfo(odp_system_meminfo_t *info, odp_system_memblock_t block[], int32_t num);
+
+/**
* Default system huge page size in bytes
*
* @return Default huge page size in bytes