This patch separates memory info to reserved and system info in stat.
Signed-off-by: Yelin Jeong <yelini.jeong@samsung.com>
NPU_APP_TERMINATED = 4,
} npu_app_status;
+/**
+ * struct npu_mem_info - Describes memory info
+ * @alloc: Size of allocated memory in the device
+ * @freed: Size of freed memory in the device
+ */
+typedef struct {
+ uint64_t alloc;
+ uint64_t freed;
+} npu_mem_info;
+
/**
* @brief Description of npu request (per inference) status
*/
uint32_t num_total_reqs;
uint32_t num_active_reqs;
- uint64_t total_alloc_mem;
- uint64_t total_freed_mem;
+ npu_mem_info reserved;
+ npu_mem_info reserved_cont;
+ npu_mem_info system;
} npu_stat_app;
typedef struct {
#define TRINITY_APP_STAT_MAX 10
#define TRINITY_REQ_STAT_MAX 10
+/**
+ * struct trinity_ioctl_mem_info - Describes memory info
+ * @alloc: Size of allocated memory in the device
+ * @freed: Size of freed memory in the device
+ */
+struct trinity_ioctl_mem_info {
+ __u64 alloc;
+ __u64 freed;
+} __attribute__((packed));
+
/**
* struct trinity_ioctl_stat_app - Describes stat of the target app
* @app_id: Trinity app id (currently, equal to pid)
* @status: Trinity app status
* @num_total_reqs: Number of total requests in app (including finished ones)
* @num_active_reqs: Number of active (running or pending) requests in app
- * @total_alloc_mem: Total size of allocated memory in the device
- * @total_freed_mem: Total size of freed memory in the device
*/
struct trinity_ioctl_stat_app {
__s32 app_id;
__u32 num_total_reqs;
__u32 num_active_reqs;
- __u64 total_alloc_mem;
- __u64 total_freed_mem;
+ struct trinity_ioctl_mem_info reserved;
+ struct trinity_ioctl_mem_info reserved_cont;
+ struct trinity_ioctl_mem_info system;
} __attribute__((packed));
/**
if (ret < 0)
IOCTL_RETURN_ERRNO (TRINITY_IOCTL_STAT_CURRENT_APP);
- *alloc_total = stat.total_alloc_mem;
- *free_total = stat.total_freed_mem;
+ *alloc_total = stat.reserved.alloc;
+ *alloc_total += stat.reserved_cont.alloc;
+ *alloc_total += stat.system.alloc;
+ *free_total = stat.reserved.freed;
+ *free_total += stat.reserved_cont.freed;
+ *free_total += stat.system.freed;
return 0;
}
stat->stat[i].num_total_reqs = stat_app->num_total_reqs;
stat->stat[i].num_active_reqs = stat_app->num_active_reqs;
- stat->stat[i].total_alloc_mem = stat_app->total_alloc_mem;
- stat->stat[i].total_freed_mem = stat_app->total_freed_mem;
+ stat->stat[i].reserved.alloc = stat_app->reserved.alloc;
+ stat->stat[i].reserved.freed = stat_app->reserved.freed;
+ stat->stat[i].reserved_cont.alloc = stat_app->reserved_cont.alloc;
+ stat->stat[i].reserved_cont.freed = stat_app->reserved_cont.freed;
+ stat->stat[i].system.alloc = stat_app->system.alloc;
+ stat->stat[i].system.freed = stat_app->system.freed;
}
return 0;
void incTotalAllocMem (uint64_t size) {
std::unique_lock<std::mutex> lock (mutex_);
- stat_app_.total_alloc_mem += size;
+ stat_app_.reserved.alloc += size;
}
void incTotalFreedMem (uint64_t size) {
std::unique_lock<std::mutex> lock (mutex_);
- stat_app_.total_freed_mem += size;
+ stat_app_.reserved.freed += size;
}
private:
ss_ << "| " << right << setw (15) << stat->name << " ";
ss_ << "| " << right << setw (10) << status_str << " ";
ss_ << "| " << right << setw (9) << fixed << setprecision (2);
- ss_ << (((double) stat->total_alloc_mem) / 1024.0) << " ";
+ ss_ << (((double) stat->reserved.alloc + (double) stat->reserved_cont.alloc + (double) stat->system.alloc) / 1024.0) << " ";
ss_ << "| " << right << setw (6) << stat->num_total_reqs << " |\n";
count++;
}