#resource-optimizer source folders
SET(RESOURCE_OPTIMIZER_SOURCE_DIR ${SOURCE_DIR}/resource-optimizer)
+SET(CPU_RESOURCE_OPTIMIZER_SOURCE_DIR ${RESOURCE_OPTIMIZER_SOURCE_DIR}/cpu)
SET(MEMORY_RESOURCE_OPTIMIZER_SOURCE_DIR ${RESOURCE_OPTIMIZER_SOURCE_DIR}/memory)
SET(DEDUP_SOURCE_DIR ${RESOURCE_OPTIMIZER_SOURCE_DIR}/memory/dedup)
SET(SWAP_SOURCE_DIR ${RESOURCE_OPTIMIZER_SOURCE_DIR}/memory/swap)
[MemoryGroupLimit]
-VipGroupLimit= 100%
+VipGroupLimit= 100%
HighGroupLimit= 100%
-MediumGroupLimit=90%
+MediumGroupLimit= 90%
LowestGroupLimit= 70%
[MemoryLevelThreshold]
-MediumLevel= 400MB
-LowLevel= 300MB
-CriticalLevel= 200MB
-OomLevel= 160MB
-OomPopup=no
+MediumLevel= 400MB
+LowLevel= 300MB
+CriticalLevel= 200MB
+OomLevel= 160MB
+OomPopup= no
[MemoryAppTypeLimit]
ServicePerAppLimitAction=128MB,kill
[MemoryAppStatusLimit]
BackgroundPerAppLimitAction=768MB,kill
-
-[CpuAffinity]
-ForegroundApps=1,2,4-6
-[Swap]
-Enable=1
+[MemorySwap]
+SwapEnable=1
ReclaimAtBoot=yes
-Type=zram+zswap
+SwapType=zram+zswap
VipGroupSwappiness=0
HighGroupSwappiness=5
MediumGroupSwappiness=10
LowestGroupSwappiness=20
-[Zram]
+[MemoryZram]
CompAlgorithm=zstd
-Ratio=0.4
+ZramRatio=0.4
-[Zswap]
+[MemoryZswap]
PoolRatio=40
PoolType=z3fold
-[Dedup]
-Enable=1
+[MemoryDedup]
+DedupEnable=1
DedupAtBoot=yes
ScanOnLowmem=true
-[Ksm]
-Mode=oneshot
-#Mode=periodic
+[MemoryKsm]
+KsmMode=oneshot
+#KsmMode=periodic
PagesToScan=100
PagesToScanWithBoost=1000
-[Compaction]
-Enable=1
+[MemoryCompaction]
+CompactionEnable=1
FragLevel=800
+
+[CpuAffinity]
+ForegroundApps=1,2,4-6
%define cpu_module ON
%define memory_module ON
%define watchdog_module ON
-%define compaction_module ON
%define confdir %{_sysconfdir}/resourced
%define plugindir %{_libdir}/resourced/plugins
-DCMAKE_BUILD_TYPE=Release \
-DCPU_MODULE=%{cpu_module} \
-DMEMORY_MODULE=%{memory_module} \
- -DCOMPACTION_MODULE=%{compaction_module} \
-DPROC_WATCHDOG=%{watchdog_module} \
-DRD_SYS_ETC=%{TZ_SYS_ETC} \
-DRD_SYS_DATA=%{TZ_SYS_GLOBALUSER_DATA} \
%{plugindir}/libheart.so
%{plugindir}/libswap.so
%{plugindir}/libdedup.so
+%{plugindir}/libcompaction.so
+%{plugindir}/libcpu-sched.so
%attr(700, root, root) %{TZ_SYS_ETC}/dump.d/module.d/dump_heart_data.sh
%files bin
)
#compaction module
-IF("${COMPACTION_MODULE}" STREQUAL "ON")
- FILE(GLOB FILES "${COMPACTION_SOURCE_DIR}/*.c")
- FOREACH(FILE ${FILES})
- SET(SOURCES ${SOURCES} ${FILE})
- ENDFOREACH()
-ENDIF()
+#IF("${COMPACTION_MODULE}" STREQUAL "ON")
+# FILE(GLOB FILES "${COMPACTION_SOURCE_DIR}/*.c")
+# FOREACH(FILE ${FILES})
+# SET(SOURCES ${SOURCES} ${FILE})
+# ENDFOREACH()
+#ENDIF()
IF("${PROC_WATCHDOG}" STREQUAL "ON")
SET(SOURCES ${SOURCES}
${SWAP_SOURCE_DIR}/zramswap.c)
TARGET_LINK_LIBRARIES(swap resourced-private-api ${RESOURCED_REQUIRE_PKGS_LDFLAGS})
INSTALL(TARGETS swap DESTINATION ${MAKE_INSTALL_PREFIX}${RD_PLUGIN_PATH})
-INSTALL(FILES ${CONF_DIR}/optimizer.conf DESTINATION ${RD_CONFIG_PATH})
ADD_LIBRARY(dedup MODULE
${DEDUP_SOURCE_DIR}/dedup.c)
TARGET_LINK_LIBRARIES(dedup resourced-private-api ${RESOURCED_REQUIRE_PKGS_LDFLAGS})
INSTALL(TARGETS dedup DESTINATION ${MAKE_INSTALL_PREFIX}${RD_PLUGIN_PATH})
+ADD_LIBRARY(compaction MODULE
+ ${COMPACTION_SOURCE_DIR}/compaction.c)
+TARGET_LINK_LIBRARIES(compaction resourced-private-api ${RESOURCED_REQUIRE_PKGS_LDFLAGS})
+INSTALL(TARGETS compaction DESTINATION ${MAKE_INSTALL_PREFIX}${RD_PLUGIN_PATH})
+
+ADD_LIBRARY(cpu-sched MODULE
+ ${CPU_RESOURCE_OPTIMIZER_SOURCE_DIR}/cpu-sched.c)
+TARGET_LINK_LIBRARIES(cpu-sched resourced-private-api ${RESOURCED_REQUIRE_PKGS_LDFLAGS})
+INSTALL(TARGETS cpu-sched DESTINATION ${MAKE_INSTALL_PREFIX}${RD_PLUGIN_PATH})
+
+
+INSTALL(FILES ${CONF_DIR}/optimizer.conf DESTINATION ${RD_CONFIG_PATH})
+
ADD_LIBRARY(heart MODULE
${RESOURCE_MONITOR_SOURCE_DIR}/heart.c
${ABNORMAL_MONITOR_SOURCE_DIR}/heart-abnormal.c
}
if (!strncmp(result->section, SWAP_SECTION, strlen(SWAP_SECTION)+1)) {
- if (!strncmp(result->name, ENABLE_CONF, strlen(ENABLE_CONF)+1)) {
+ if (!strncmp(result->name, SWAP_ENABLE_CONF, strlen(SWAP_ENABLE_CONF)+1)) {
if (!strncmp(result->value, "yes", 4) ||
!strncmp(result->value, "1", 2) ||
!strncmp(result->value, "ok", 3))
return RESOURCED_ERROR_FAIL;
}
}
- else if (!strncmp(result->name, TYPE_CONF,
- strlen(TYPE_CONF)+1)) {
+ else if (!strncmp(result->name, SWAP_TYPE_CONF,
+ strlen(SWAP_TYPE_CONF)+1)) {
if (strlen(result->value) + 1 > sizeof(swap_conf->type)) {
_E("Size of swap_conf->type is not enough");
return RESOURCED_ERROR_OUT_OF_MEMORY;
strncpy(swap_conf->zram.algorithm, result->value,
sizeof(swap_conf->zram.algorithm) - 1);
}
- else if (!strncmp(result->name, RATIO_CONF, strlen(RATIO_CONF)+1)) {
+ else if (!strncmp(result->name, ZRAM_RATIO_CONF, strlen(ZRAM_RATIO_CONF)+1)) {
swap_conf->zram.ratio = atof(result->value);
}
else {
}
}
else if (!strncmp(result->section, ZSWAP_SECTION, strlen(ZSWAP_SECTION)+1)) {
- if (!strncmp(result->name, CRYPT_TYPE_CONF, strlen(CRYPT_TYPE_CONF)+1)) {
- if (strlen(result->value) + 1 > sizeof(swap_conf->zswap.type)) {
- _E("Size of swap_conf->zswap.type is not enough");
- return RESOURCED_ERROR_OUT_OF_MEMORY;
- }
- strncpy(swap_conf->zswap.type, result->value,
- sizeof(swap_conf->zswap.type) - 1);
- }
- else if (!strncmp(result->name, FILE_SIZE_CONF, strlen(FILE_SIZE_CONF)+1)) {
- swap_conf->zswap.filesize = atol(result->value);
- }
- else if (!strncmp(result->name, POOL_RATIO_CONF, strlen(POOL_RATIO_CONF)+1)) {
+ if (!strncmp(result->name, POOL_RATIO_CONF, strlen(POOL_RATIO_CONF)+1)) {
swap_conf->zswap.pool_ratio = atof(result->value);
}
else if (!strncmp(result->name, POOL_TYPE_CONF, strlen(POOL_TYPE_CONF)+1)) {
result->name, result->value, result->section);
}
}
- else if (!strncmp(result->section, FILE_SWAP_SECTION, strlen(FILE_SWAP_SECTION)+1)) {
- if (!strncmp(result->name, CRYPT_TYPE_CONF, strlen(CRYPT_TYPE_CONF)+1)) {
- if (strlen(result->value) + 1 > sizeof(swap_conf->fileswap.type)) {
- _E("Size of swap_conf->fileswap.type is not enough");
- return RESOURCED_ERROR_OUT_OF_MEMORY;
- }
- strncpy(swap_conf->fileswap.type, result->value,
- sizeof(swap_conf->fileswap.type) - 1);
- }
- else if (!strncmp(result->name, FILE_SIZE_CONF, strlen(FILE_SIZE_CONF)+1)) {
- swap_conf->fileswap.filesize = atol(result->value);
- }
- else {
- _E("[DEBUG] Unknown configuration name (%s) and value (%s) on section (%s)",
- result->name, result->value, result->section);
- }
- }
else if (!strncmp(result->section, DEDUP_SECTION, strlen(DEDUP_SECTION)+1)) {
- if (!strncmp(result->name, ENABLE_CONF, strlen(ENABLE_CONF)+1)) {
+ if (!strncmp(result->name, DEDUP_ENABLE_CONF, strlen(DEDUP_ENABLE_CONF)+1)) {
if (!strncmp(result->value, "yes", 4) ||
!strncmp(result->value, "1", 2) ||
!strncmp(result->value, "ok", 3))
}
}
else if (!strncmp(result->section, KSM_SECTION, strlen(KSM_SECTION)+1)) {
- if (!strncmp(result->name, MODE_CONF, strlen(MODE_CONF)+1)) {
+ if (!strncmp(result->name, KSM_MODE_CONF, strlen(KSM_MODE_CONF)+1)) {
if (strlen(result->value) + 1 > sizeof(dedup_conf->ksm.mode)) {
_E("Size of swap_conf->type is not enough");
return RESOURCED_ERROR_OUT_OF_MEMORY;
}
}
else if (!strncmp(result->section, COMPACTION_SECTION, strlen(COMPACTION_SECTION)+1)) {
- if (!strncmp(result->name, ENABLE_CONF, strlen(ENABLE_CONF)+1)) {
+ if (!strncmp(result->name, COMPACTION_ENABLE_CONF, strlen(COMPACTION_ENABLE_CONF)+1)) {
if (!strncmp(result->value, "yes", 4) ||
!strncmp(result->value, "1", 2) ||
!strncmp(result->value, "ok", 3) ||
result->name, result->value, result->section);
}
}
+ else if (!strncmp(result->section, CPU_AFFINITY_SECTION,
+ strlen(CPU_AFFINITY_SECTION)+1)) {
+ int error = RESOURCED_ERROR_NONE;
+
+ if (!strncmp(result->name, FOREGROUND_APPS,
+ strlen(FOREGROUND_APPS) + 1)) {
+ error = set_cpucg_conf(result->name, result->value);
+ }
+ else {
+ _E("[DEBUG] Unknown configuration name (%s) and value (%s) on section (%s)",
+ result->name, result->value, result->section);
+ }
+
+ return error;
+ }
else {
_E("[DEBUG] Unknown section name (%s) and value (%s) on section (%s)",
result->name, result->value, result->section);
return error;
}
- else if (!strncmp(result->section, CPU_AFFINITY_SECTION,
- strlen(CPU_AFFINITY_SECTION)+1)) {
- int error = RESOURCED_ERROR_NONE;
-
- if (!strncmp(result->name, FOREGROUND_APPS,
- strlen(FOREGROUND_APPS) + 1)) {
- error = set_cpucg_conf(result->name, result->value);
- }
- else {
- _E("[DEBUG] Unknown configuration name (%s) and value (%s) on section (%s)",
- result->name, result->value, result->section);
- }
-
- return error;
- }
else {
_E("[DEBUG] Unknown section name (%s) and value (%s) on section (%s)",
result->name, result->value, result->section);
}
-
+
return RESOURCED_ERROR_NONE;
}
#define MEMORY_LEVEL_THRESHOLD_SECTION "MemoryLevelThreshold"
#define MEMORY_APP_TYPE_LIMIT_SECTION "MemoryAppTypeLimit"
#define MEMORY_APP_STATUS_LIMIT_SECTION "MemoryAppStatusLimit"
-#define CPU_AFFINITY_SECTION "CpuAffinity"
/* optimizer.conf */
-#define SWAP_SECTION "Swap"
-#define ZRAM_SECTION "Zram"
-#define ZSWAP_SECTION "Zswap"
-#define FILE_SWAP_SECTION "FileSwap"
-#define DEDUP_SECTION "Dedup"
-#define KSM_SECTION "Ksm"
-#define COMPACTION_SECTION "Compaction"
+#define SWAP_SECTION "MemorySwap"
+#define ZRAM_SECTION "MemoryZram"
+#define ZSWAP_SECTION "MemoryZswap"
+#define DEDUP_SECTION "MemoryDedup"
+#define KSM_SECTION "MemoryKsm"
+#define COMPACTION_SECTION "MemoryCompaction"
+#define CPU_AFFINITY_SECTION "CpuAffinity"
/* configuration name */
/* limiter.conf */
-#define SERVICE_NAME_CONF "Service"
-#define APP_NAME_CONF "App"
-#define CPU_CGROUP_NAME_CONF "CpuGroup"
-#define MEM_CGROUP_NAME_CONF "MemGroup"
-#define MEM_LIMIT_ACTION_NAME_CONF "MemLimitAction"
-#define CPU_PRIORITY_NAME_CONF "CpuPriority"
-#define ACTION_ON_FAILURE_NAME_CONF "ActionOnFailure"
-#define WATCHDOG_ACTION_NAME_CONF "WatchdogAction"
-#define VIP_GROUP_LIMIT_CONF "VipGroupLimit"
-#define HIGH_GROUP_LIMIT_CONF "HighGroupLimit"
-#define MEDIUM_GROUP_LIMIT_CONF "MediumGroupLimit"
-#define LOWEST_GROUP_LIMIT_CONF "LowestGroupLimit"
-#define MEDIUM_LEVEL_CONF "MediumLevel"
-#define LOW_LEVEL_CONF "LowLevel"
-#define CRITICAL_LEVEL_CONF "CriticalLevel"
-#define OOM_LEVEL_CONF "OomLevel"
-#define OOM_POPUP_CONF "OomPopup"
+#define SERVICE_NAME_CONF "Service"
+#define APP_NAME_CONF "App"
+#define CPU_CGROUP_NAME_CONF "CpuGroup"
+#define MEM_CGROUP_NAME_CONF "MemGroup"
+#define MEM_LIMIT_ACTION_NAME_CONF "MemLimitAction"
+#define CPU_PRIORITY_NAME_CONF "CpuPriority"
+#define ACTION_ON_FAILURE_NAME_CONF "ActionOnFailure"
+#define WATCHDOG_ACTION_NAME_CONF "WatchdogAction"
+#define VIP_GROUP_LIMIT_CONF "VipGroupLimit"
+#define HIGH_GROUP_LIMIT_CONF "HighGroupLimit"
+#define MEDIUM_GROUP_LIMIT_CONF "MediumGroupLimit"
+#define LOWEST_GROUP_LIMIT_CONF "LowestGroupLimit"
+#define MEDIUM_LEVEL_CONF "MediumLevel"
+#define LOW_LEVEL_CONF "LowLevel"
+#define CRITICAL_LEVEL_CONF "CriticalLevel"
+#define OOM_LEVEL_CONF "OomLevel"
+#define OOM_POPUP_CONF "OomPopup"
#define SERVICE_PER_APP_LIMIT_ACTION "ServicePerAppLimitAction"
#define WIDGET_PER_APP_LIMIT_ACTION "WidgetPerAppLimitAction"
#define GUI_PER_APP_LIMIT_ACTION "GUIPerAppLimitAction"
#define BACKGROUND_PER_APP_LIMIT_ACTION "BackgroundPerAppLimitAction"
-#define FOREGROUND_APPS "ForegroundApps"
-/* optimizer.cnof */
-#define ENABLE_CONF "Enable"
+/* optimizer.conf */
+#define SWAP_ENABLE_CONF "SwapEnable"
#define RECLAIM_AT_BOOT_CONF "ReclaimAtBoot"
-#define TYPE_CONF "Type"
+#define SWAP_TYPE_CONF "SwapType"
#define VIP_GROUP_SWAPPINESS_CONF "VipGroupSwappiness"
#define HIGH_GROUP_SWAPPINESS_CONF "HighGroupSwappiness"
#define MEDIUM_GROUP_SWAPPINESS_CONF "MediumGroupSwappiness"
#define LOWEST_GROUP_SWAPPINESS_CONF "LowestGroupSwappiness"
#define COMP_ALGORITHM_CONF "CompAlgorithm"
-#define RATIO_CONF "Ratio"
-#define CRYPT_TYPE_CONF "CryptType"
-#define FILE_SIZE_CONF "FileSize"
+#define ZRAM_RATIO_CONF "ZramRatio"
#define POOL_RATIO_CONF "PoolRatio"
#define POOL_TYPE_CONF "PoolType"
+#define DEDUP_ENABLE_CONF "DedupEnable"
#define DEDUP_AT_BOOT_CONF "DedupAtBoot"
#define SCAN_ON_LOWMEM_CONF "ScanOnLowmem"
-#define MODE_CONF "Mode"
+#define KSM_MODE_CONF "KsmMode"
#define PAGES_TO_SCAN_CONF "PagesToScan"
#define PAGES_TO_SCAN_WITH_BOOST_CONF "PagesToScanWithBoost"
+#define COMPACTION_ENABLE_CONF "CompactionEnable"
#define FRAG_LEVEL_CONF "FragLevel"
+#define FOREGROUND_APPS "ForegroundApps"
/* configuration value */
#define CGROUP_VIP_VALUE_CONF "vip"
};
struct zswap_conf {
- char type[MAX_TYPE_LENGTH - 1];
- long filesize;
float pool_ratio;
char pool_type[MAX_TYPE_LENGTH -1];
};
-struct fileswap_conf {
- char type[MAX_TYPE_LENGTH - 1];
- long filesize;
-};
-
struct swap_conf {
bool enable;
bool boot_reclaim_enable;
int swappiness[CGROUP_END];
struct zram_conf zram;
struct zswap_conf zswap;
- struct fileswap_conf fileswap;
};
struct swap_conf *get_swap_conf(void);
static int swap_file_conf(void *data)
{
- struct fileswap_conf *fileswap_conf = (struct fileswap_conf *)data;
- if (!fileswap_conf) {
- _E("Fileswap configuration should not be NULL");
- return RESOURCED_ERROR_FAIL;
- }
-
- if (check_valid_compressor(fileswap_conf->type) == RESOURCED_ERROR_NONE)
- strncpy(file_control.crypt_type, fileswap_conf->type, MAX_TYPE_LENGTH-1);
-
- if (fileswap_conf->filesize > 0)
- file_control.swap_file_size = fileswap_conf->filesize;
-
_I("[DEBUG] fileswap crypt type = %s", file_control.crypt_type);
_I("[DEBUG] fileswap file size = %ld", file_control.swap_file_size);
else if (!strncmp(swaps->name, "ZSWAP", 6))
r = swaps->conf(&swap_conf->zswap);
else if (!strncmp(swaps->name, "FILESWAP", 9))
- r = swaps->conf(&swap_conf->fileswap);
+ r = swaps->conf(NULL);
}
free_swap_conf:
return RESOURCED_ERROR_FAIL;
}
- if (check_valid_compressor(zswap_conf->type) == RESOURCED_ERROR_NONE)
- strncpy(zswap_control.crypt_type, zswap_conf->type, MAX_TYPE_LENGTH-1);
-
- if (zswap_conf->filesize > 0)
- zswap_control.zswap_file_size = zswap_conf->filesize;
-
if (zswap_conf->pool_ratio > 0.0)
zswap_control.zpool_ratio = zswap_conf->pool_ratio;