800 means 80%.
Example: FragLevel=800
-2.7 Section: CpuSched
+2.7 Section: MemoryBackgroundReclaim
+=============================
+Key: AfterScreenDim
+Value: (yes|1|ok|on|no|0|off)
+Comment: Specify whether memory is reclaimed
+ from most recently used background app.
+ If value is (yes|1|ok|on), background reclaim on.
+ If value is (no|0|off), background reclaim off.
+Example: AfterScreenDim=yes
+
+2.8 Section: CpuSched
=====================
Key: CpuSchedFeature
Value: <feature>([,]+<feature>)*
<cpu rt period> is an decimal integer value.
Example: CpuRTRuntime=900ms
-2.8 Section: CpuAffinity
+2.9 Section: CpuAffinity
========================
Key: ForegroundApps
Value: (<core num>|<core range>)(,(<core num>|<core range>))*
<core range> is: <core num>-<core num>
Example: ForegroundApps=1,2,3-5
-2.9 Section: CpuBoostingLevelStrong
+2.10 Section: CpuBoostingLevelStrong
===================================
Key: CpuSched
Value: <schedule scheme>
<priority> is an decimal integer value.
Example: CpuRTPriority=50
-2.10 Section: CpuBoostingLevelMedium
+2.11 Section: CpuBoostingLevelMedium
====================================
Key: CpuSched
Value: <schedule scheme>
<priority> is an decimal integer value.
Example: CpuRTPriority=50
-2.11 Section: CpuBoostingLevelWeak
+2.12 Section: CpuBoostingLevelWeak
==================================
Key: CpuSched
Value: <schedule scheme>
[MemoryCompaction]
FragLevel=800
+[MemoryBackgroundReclaim]
+# Unset this option if it causes any unexepcted issue (e.g. jerky animation).
+AfterScreenDim=yes
+
[CpuSched]
CpuSchedFeature=no_rt_runtime_share
CpuRTRuntime=950ms
#include "dedup-common.h"
#include "compact-common.h"
#include "cpu-common.h"
+#include "reclaim-config.h"
#include "procfs.h"
#include "memory-common.h"
return RESOURCED_ERROR_FAIL;
}
+ struct reclaim_conf *reclaim_conf = config_get_reclaim_conf();
+ if (reclaim_conf == NULL) {
+ _E("[CONFIG] reclaim configuration is NULL");
+ return RESOURCED_ERROR_FAIL;
+ }
+
struct cpu_sched_conf *cpu_sched_conf = get_cpu_sched_conf();
if (cpu_sched_conf == NULL) {
_E("[CONFIG] cpu_sched configuration is NULL");
result->name, result->value, result->section);
}
}
+ else if (!strncmp(result->section, BACKGROUND_RECLAIM_SECTION,
+ strlen(BACKGROUND_RECLAIM_SECTION) + 1)) {
+ if (!strncmp(result->name, AFTER_SCREEN_DIM_CONF,
+ strlen(AFTER_SCREEN_DIM_CONF) + 1))
+ reclaim_conf->screen_dim = config_parse_bool(result->value);
+ else
+ _W("[CONFIG] Unknown configuration name (%s)"
+ " and value (%s) on section (%s)",
+ result->name, result->value, result->section);
+ }
else if (!strncmp(result->section, CPU_SCHED_SECTION,
strlen(CPU_SCHED_SECTION)+1)) {
if (!strncmp(result->name, CPU_SCHED_FEATURE_NAME_CONF,
#define DEDUP_SECTION "MemoryDedup"
#define KSM_SECTION "MemoryKsm"
#define COMPACTION_SECTION "MemoryCompaction"
+#define BACKGROUND_RECLAIM_SECTION "MemoryBackgroundReclaim"
#define CPU_SCHED_SECTION "CpuSched"
#define CPU_AFFINITY_SECTION "CpuAffinity"
#define CPU_BOOSTING_LEVEL_STRONG_SECTION "CpuBoostingLevelStrong"
#define PAGES_TO_SCAN_WITH_BOOST_NAME_CONF "PagesToScanWithBoost"
#define COMPACTION_ENABLE_NAME_CONF "CompactionEnable"
#define FRAG_LEVEL_NAME_CONF "FragLevel"
+#define AFTER_SCREEN_DIM_CONF "AfterScreenDim"
#define FOREGROUND_APPS_NAME_CONF "ForegroundApps"
#define CPU_AFFINITY_NAME_CONF "CpuAffinity"
#define CPU_BOOSTING_STALL_GOVERNOR_NAME_CONF "CpuBoostingStallGovernor"
--- /dev/null
+/*
+ * resourced
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "trace.h"
+#include "reclaim-config.h"
+
+static struct reclaim_conf *reclaim_conf = NULL;
+
+struct reclaim_conf *config_get_reclaim_conf(void)
+{
+ if (!reclaim_conf) {
+ reclaim_conf = (struct reclaim_conf *)calloc(1, sizeof (struct reclaim_conf));
+ if (!reclaim_conf) {
+ _E("Failed to alloc memory for reclaim configuration");
+ return NULL;
+ }
+
+ reclaim_conf->screen_dim = false;
+ }
+
+ return reclaim_conf;
+}
+
+void config_free_reclaim_conf(void)
+{
+ if (reclaim_conf)
+ free(reclaim_conf);
+}
--- /dev/null
+/*
+ * resourced
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @file reclaim-config.h
+ * @desc reclaim config header
+ **/
+
+#ifndef __RECLAIM_CONFIG_H__
+#define __RECLAIM_CONFIG_H__
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+struct reclaim_conf {
+ bool screen_dim;
+};
+
+struct reclaim_conf *config_get_reclaim_conf(void);
+void config_free_reclaim_conf(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __RECLAIM_CONFIG_H__ */
#include "dedup-common.h"
#include "const.h"
#include "memory-common.h"
+#include "reclaim-config.h"
#define MAX_PROACTIVE_HIGH_VICTIMS 4
#define FOREGROUND_VICTIMS 1
}
static int fragmentation_size;
+static bool g_bg_reclaim = false;
+
const char *lowmem_convert_cgroup_type_to_str(int type)
{
static const char *type_table[] =
static void load_configs(void)
{
struct memcg_conf *memcg_conf = get_memcg_conf();
+ struct reclaim_conf *reclaim_conf = config_get_reclaim_conf();
/* set MemoryGroupLimit section */
for (int cgroup = MEMCG_THROTTLING; cgroup < MEMCG_END; cgroup++) {
lowmem_action_init(memcg_conf->service.action, memcg_conf->widget.action,
memcg_conf->guiapp.action, memcg_conf->background.action);
+ /* set MemoryBackgroundReclaim section */
+ if (!reclaim_conf)
+ goto free_memcg_conf;
+
+ g_bg_reclaim = reclaim_conf->screen_dim;
+
+ config_free_reclaim_conf();
+
+free_memcg_conf:
free_memcg_conf();
}
/* print info of POPUP section */
_I("[POPUP] oom popup is %s", oom_popup_enable == true ? "enabled" : "disabled");
+
+ _I("Background reclaim enabled = %d", g_bg_reclaim);
}
/* To Do: should we need lowmem_fd_start, lowmem_fd_stop ?? */