*/
void dbus_proc_cpu_usage(GDBusMethodInvocation *invocation, GVariant *params);
+/**
+ * @brief DBus method to return the swap usage information of input processes
+ * @since_tizen 6.5
+ *
+ * @param[in] invocation The dbus invocation
+ * @param[in] params Parameters sent by the runtime info API
+ * This should be an array of process IDs.
+ *
+ * @retval The response contains an array of data.
+ * The data contains the swap usage info for the processes (KB).
+ * For invalid process IDs, the data will be INVALID_PROCESS_INFO_FIELD_VALUE.
+ * If the input dbus message does not contain array of integers or if there
+ * are errors in computation, collection and sending of usage info, then the
+ * response dbus message contains only an integer whose value will the error value.
+ */
+void dbus_proc_swap_usage(GDBusMethodInvocation *invocation, GVariant *params);
#endif /* __PROC_USAGE_STATS_H__ */
" <arg type='ai' name='ProcList' direction='in'/>"
" <arg type='a(ii)' name='CpuUsage' direction='out'/>"
" </method>"
+" <method name='ProcSwapUsage'>"
+" <arg type='ai' name='ProcList' direction='in'/>"
+" <arg type='a(i)' name='SwapUsage' direction='out'/>"
+" </method>"
" <method name='CheckAppStatus'>"
" <arg type='i' name='Pid' direction='in'/>"
" <arg type='s' name='Type' direction='in'/>"
{ "ProcCpuUsage", dbus_proc_cpu_usage },
{ "CheckAppStatus", dbus_get_checkappstatus },
{ "GetRamSize", dbus_get_get_ram_size },
+ { "ProcSwapUsage", dbus_proc_swap_usage },
/* Add methods here */
};
result[4] = mem_info[index].shared_dirty;
result[5] = mem_info[index].private_clean;
result[6] = mem_info[index].private_dirty;
- } else {
+ } else if (type == RUNTIME_INFO_TASK_CPU) {
struct process_cpu_usage_s *cpu_usage;
cpu_usage = (struct process_cpu_usage_s *)usage_info_list;
result[0] = cpu_usage[index].utime;
result[1] = cpu_usage[index].stime;
+ } else {
+ int *swap_usage = (int *)usage_info_list;
+ result[0] = swap_usage[index];
}
return RESOURCED_ERROR_NONE;
char buf[TASK_NAME_SIZE];
snprintf(buf, sizeof(buf), TASK_NAME_BASE,
- ((task_type == RUNTIME_INFO_TASK_MEMORY) ? "memory" : "cpu"));
+ ((task_type == RUNTIME_INFO_TASK_MEMORY) ? "memory" :
+ (task_type == RUNTIME_INFO_TASK_CPU) ? "cpu" : "swap" ));
if (!task_name || size <= 0)
return;
#include <unistd.h>
#include <errno.h>
+#include "procfs.h"
#include "proc-main.h"
#include "proc-usage-stats.h"
#include "proc-usage-stats-helper.h"
if (rt_task->task_type == RUNTIME_INFO_TASK_MEMORY)
g_variant_builder_init(&builder, G_VARIANT_TYPE("a(iiiiiii)"));
- else
+ else if (rt_task->task_type == RUNTIME_INFO_TASK_CPU)
g_variant_builder_init(&builder, G_VARIANT_TYPE("a(ii)"));
+ else
+ g_variant_builder_init(&builder, G_VARIANT_TYPE("a(i)"));
/* Populate the reply message with the usage info */
for (i = 0; i < rt_task->task_size; ++i) {
if (rt_task->task_type == RUNTIME_INFO_TASK_MEMORY)
usage = g_variant_new("(iiiiiii)", result[0], result[1], result[2],
result[3], result[4], result[5], result[6]);
- else
+ else if (rt_task->task_type == RUNTIME_INFO_TASK_CPU)
usage = g_variant_new("(ii)", result[0], result[1]);
+ else
+ usage = g_variant_new("(i)", result[0]);
g_variant_builder_add_value(&builder, usage);
}
if (rt_task->task_type == RUNTIME_INFO_TASK_MEMORY)
g_dbus_method_invocation_return_value(rt_task->task_invocation,
g_variant_new("(a(iiiiiii))", &builder));
- else
+ else if (rt_task->task_type == RUNTIME_INFO_TASK_CPU)
g_dbus_method_invocation_return_value(rt_task->task_invocation,
g_variant_new("(a(ii))", &builder));
+ else
+ g_dbus_method_invocation_return_value(rt_task->task_invocation,
+ g_variant_new("(a(i))", &builder));
+
proc_free_runtime_info_task(rt_task);
return false;
mem_info = (struct process_memory_info_s *)rt_task->usage_info_list;
for (i = 0; i < rt_task->task_size; ++i)
proc_get_memory_usage(rt_task->pid_list[i], &mem_info[i]);
- } else {
+ } else if (rt_task->task_type == RUNTIME_INFO_TASK_CPU) {
struct process_cpu_usage_s *cpu_usage;
cpu_usage = (struct process_cpu_usage_s *)rt_task->usage_info_list;
for (i = 0; i < rt_task->task_size; ++i)
proc_get_cpu_usage(rt_task->pid_list[i], &cpu_usage[i]);
+ } else {
+ int *swap_usage = (int *)rt_task->usage_info_list;
+ int swap;
+
+ for (i = 0; i < rt_task->task_size; ++i) {
+ if (proc_get_mem_status(rt_task->pid_list[i], (unsigned int *)&swap, NULL) < 0)
+ swap = INVALID_PROCESS_INFO_FIELD_VALUE;
+ swap_usage[i] = swap;
+ }
}
/* Write to the write end of the pipe depending on the success of
rt_task->task_invocation = invocation;
_D("Received %s usage request, task name is %s",
- (rt_task->task_type == RUNTIME_INFO_TASK_MEMORY) ? "memory" : "cpu",
+ (rt_task->task_type == RUNTIME_INFO_TASK_MEMORY) ? "memory" :
+ (rt_task->task_type == RUNTIME_INFO_TASK_CPU) ? "cpu" : "swap",
rt_task->task_name);
/* Parse arguments to the pids and count it */
if (rt_task->task_type == RUNTIME_INFO_TASK_MEMORY)
rt_task->usage_info_list = (void *)malloc(sizeof(struct process_memory_info_s) * rt_task->task_size);
- else
+ else if (rt_task->task_type == RUNTIME_INFO_TASK_CPU)
rt_task->usage_info_list = (void *)malloc(sizeof(struct process_cpu_usage_s) * rt_task->task_size);
+ else
+ rt_task->usage_info_list = (void *)malloc(sizeof(int) * rt_task->task_size);
+
if (!rt_task->usage_info_list) {
_E("task %s: out of memory: not able to create usage_info_list of rt_task", rt_task->task_name);
ret = -ENOMEM;
proc_runtime_info_request_handler(invocation, params, RUNTIME_INFO_TASK_CPU);
}
+void dbus_proc_swap_usage(GDBusMethodInvocation *invocation, GVariant *params)
+{
+ proc_runtime_info_request_handler(invocation, params, RUNTIME_INFO_TASK_SWAP);
+}
/*
* These D-Bus methods are registered at proc-monitor.c
* because gdbus allows to register object