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)
+SET(COMPACTION_SOURCE_DIR ${RESOURCE_OPTIMIZER_SOURCE_DIR}/memory/compaction)
#resource-limiter source folders
SET(RESOURCE_LIMITER_SOURCE_DIR ${SOURCE_DIR}/resource-limiter)
--- /dev/null
+Resourced Configurations
+========================
+
+File Names
+==========
+1. limiter.conf : configurations to limit resources
+2. optimizer.conf : configurations to optimize resources
+3. monitor.conf : configurations to monitor resources
+4. process.conf : configurations to manage process
+
+Sections
+========
+Section name should be located between '[' and ']'.
+The order between sections does not matter and
+the order of configurations within a section is also not important.
+
+1. limiter.conf
+===============
+
+1.1 VIP_PROCESS
+===============
+Format: PREDEFINE=<process name>
+Comment: add vip processes in this section.
+ these processes will be located in the VIP cgroup (maximum cpu and memory) and
+ they won't be killed by a low memory killer(LMK).
+ex)PREDEFINE=app1
+ PREDEFINE=app2
+
+1.2 OOM_FIXED_APPS
+==================
+Format: APP NAME=<SCORE>
+Comment: add app names with their oom_score_adjs in this section.
+ do not set the score with the predefined scores described at the procfs.h.
+ the range of SCORE should be OOMADJ_SERVICE_MIN < SCORE < OOMADJ_BACKGRD_LOCKED
+ex)app1=323
+ app2=415
+
+1.3 Memory
+==========
+Format: ThresholdDedup=<Threshold>
+Comment: specify threshold(MB) of dedup level
+ex)ThresholdDedup=30
+
+Format: ThresholdSwap=<Threshold>
+Comment: specify threshold(MB) of swap level
+ex)ThresholdSwap=20
+
+Format: ThresholdLow=<Threshold>
+Comment: specify threshold(MB) of low level
+ex)ThresholdLow=15
+
+Format: ThresholdMedium=<Threshold>
+Comment: specify threshold(MB) of medium level
+ex)ThresholdMedium=10
+
+Format: ThresholdLeave=<Threshold leave>
+Comment: specify threshold leave of medium level
+ex)ThresholdLeave=20
+
+Format: ThresholdRatioDedup=<Threshold ratio>
+Comment: specify threshold ratio(%) of dedup level
+ex)ThresholdRatioDedup=30
+
+Format: ThresholdRatioSwap=<Threshold ratio>
+Comment: specify threshold ratio(%) of swap level
+ex)ThresholdRatioSwap=25
+
+Format: ThresholdRatioLow=<Threshold ratio>
+Comment: specify threshold ratio(%) of low level
+ex)ThresholdRatioLow=20
+
+Format: ThresholdRatioMedium=<Threshold ratio>
+Comment: specify threshold ratio(%) of medium level
+ex)ThresholdRatioMedium=15
+
+Format: ThresholdRatioLeave=<Threshold leave ratio>
+Comment: specify threshold leave ratio(%) of medium level
+ex)ThresholdRatioLeave=30
+
+Format: ForegroundRatio=<ratio>
+Comment: specify memory limit ratio(0.0<= ratio <=1.0) of foreground apps(High cgroup)
+ex)ForegroundRatio=0.3
+
+Format: BackgroundRatio=<ratio>
+Comment: specify memory limit ratio(0.0<= ratio <=1.0) of background apps(Medium cgroup).
+ Unset this option if it causes any unexepcted issue (e.g. jerky animation).
+ex)BackgroundRatio=0.2
+
+Format: LowRatio=<ratio>
+Comment: specify memory limit ratio(0.0<= ratio <=1.0) of old background apps(Lowest cgroup)
+ex)LowRatio=0.1
+
+Format: NumMaxVictims=<#victim>
+Comment: specify the number of victims
+ex)NumMaxVictims=10
+
+Format: ProactiveThreshold=<threshold>
+Comment: specify threshold(MB) of proactive memory killer
+ex)ProactiveThreshold=30
+
+Format: ProactiveLeave=<threshold leave>
+Comment: specify threshold leave(MB) of proactive memory killer
+ex)ProactiveLeave=50
+
+Format: EventLevel=<event level>
+Comment: specify the level of vmpressure among (low, medium, critical)
+ex)EventLevel="low"
+
+Format: SWAPPINESS=<swappiness>
+Comment: specify swappiness of the root cgroup
+ex)SWAPPINESS=6
+
+Format: FOREGROUND_SWAPPINESS=<swappiness>
+Comment: specify swappiness of the High cgroup
+ex)FOREGROUND_SWAPPINESS=6
+
+Format: BACKGROUND_SWAPPINESS=<swappiness>
+Comment: specify swappiness of the Medium cgroup
+ex)BACKGROUND_SWAPPINESS=6
+
+Format: LOW_SWAPPINESS=<swappiness>
+Comment: specify swappiness of the Lowest cgroup
+ex)LOW_SWAPPINESS=6
+
+Format: NumFragSize=<fragmentation size>
+Comment: specify external fragmentation size of "Normal" zone.
+ the fragmentation_size is the minimum count of order-2 pages in the kernel zone.
+ if #32K_PAGE + (#64K_PAGE * 2) + (#128K_PAGE * 4) + (#256K_PAGE * 8) < NumFragSize,
+ then compact memory in the kernel zone.
+ex)NumFragSize=300
+
+1.4 POPUP
+=========
+Format: oom_popup=<yes or no>
+Comment: specify whether a popup is needed or not when the process is killed by LMK or
+ proactive killer
+ex)oom_popup=no
+
+1.5 BackgroundReclaim
+=====================
+Format: AfterScreenDim=<yes or no>
+Comment: specify whether background memory reclaim is needed when LCD_OFF signal is caught.
+ This will cause force reclaim or memory limit on Medium cgroup.
+ex)AfterScreenDim=yes
+
+1.6 Logging
+===========
+Format: Enable=<1 or 0>
+Comment: specify whether logging is needed or not.
+ if "Enable" value is 1, then resourced makes a memps log during LMK.
+ex)Enable=1
+
+Format: LogPath=<path>
+Comment: specify logging path
+ex)LogPath=/var/log
+
+Format: MaxNumLogfile=<num>
+Comment: specify maximum number of log files
+ex)MaxNumLogfile=50
+
+Format: PrefixMemps=<name>
+Comment: specify prefix of memps log file
+ex)PrefixMemps=memps
+
+Format: PrefixMempsMemLimit=<name>
+Comment: specify prefix of memps log file for apps managed by independent cgroup
+ex)PrefixMemps=memps_per_app
+
+1.7 MemLimit
+============
+Format: MemLimitTrigger=<trigger>
+Comment: specify type (oom, threshold, others) of trigger for apps managed by independent cgroup
+ oom: regiter event using oom_control and kill process in kernel
+ threshold: regiter event using usage_in_bytes and kill process in resourced
+ others: don't register any event for memory limit
+ex)MemLimitTrigger=oom
+
+Format: MemLimit<type>=<memory>
+Comment: specify meory limit(MB) for app <type>
+ex)MemLimitService=128 (service type app)
+ MemLimitWidget=128 (widget type app)
+ MemLimitGUIApp=128 (guiapp type app)
+ MemLimitBgApp=100 (background state app)
+
+1.8 CPU
+=======
+Format: <type>PREDEFINE=<app name>
+Comment: specify type and its app name.
+ it makes effect of cpu cgroup, cpu priority, and iopriority
+ex)LAZY_PREDEFINE=app1
+ PREDEFINE=app2
+ BOOTING_PREDEFINE=app3
+ WRT_PREDEFINE=app4
+
+Format: BACKGROUND_CPU_SHARE=<ratio>
+Comment: specify ratio(%) of background cpu share(= Medium cgroup/root cgroup * 100)
+ex)BACKGROUND_CPU_SHARE=50
+
+Format: QUOTA_CPU_SHARE=<ratio>
+Comment: specify ratio(%) of quota cpu share(= Lowest cgroup/root cgroup * 100)
+ex)QUOTA_CPU_SHARE=25
+
+Format: QUOTA_MAX_BANDWIDTH=<ratio>
+Comment: specify ratio(%s) of quota cpu bandwidth
+ (cpu.cfs_quota_us = cpu.cfs_period_us * ratio/100)
+ex)QUOTA_MAX_BANDWIDTH=100
+
+1.9 CPU-SCHED
+=============
+Format: foreground=<core>,<core>-<core>
+Comment: specify cpu affinity of each core
+ex)foreground=1,2,3-5
+
+2. optimizer.conf
+=================
+
+2.1 SWAP
+========
+Format: Enable=<1 or 0>
+Comment: specify whether swap is needed or not.
+ Enable=yes or 1 or true / Disalbe=no or 0 or false.
+ to prevent thrashing, do not set "ReclaimAtBootThreshold" too low.
+ex)Enable=1
+
+Format: Type=<type>
+Comment: specify swap type among (zram, file, zswap).
+ multiple swap devices are specified with '+'.
+ for example, both zram and file are enable by zram+file (default is zram).
+ex)Type=zram
+
+Format: ReclaimAtBoot=<yes or no>
+Comment: specify whether reclaim is needed at boot time
+ex)ReclaimAtBoot=yes
+
+Format: TimerReclaimAtBoot=<time>
+Comment: specify delay time(sec) after booting is complete
+ex)TimerReclaimAtBoot=0
+
+Format: ReclaimAtBootThreshold=<bytes>
+Comment: specify threshold of memory reclaim at boot time
+ if memory saving is lower than the threshold, then memory reclaim will stop
+ex)ReclaimAtBootThreshold=20M
+
+Format: ReclaimBootMaxTry=<#tries>
+Comment: specify the maximun number of memory reclaim at boot time
+ex)ReclaimBootMaxTry
+
+Format: ReclaimBootInterval=<time>
+Comment: specify time interval(sec) between the reclaiming at boot time
+ex)ReclaimBootInterval=1
+
+2.2 ZRAM
+========
+Format: COMP_ALGORITHM=<algorithm>
+Comment: specify algorithm for zram swap
+ex)COMP_ALGORITHM=zstd
+
+Format: RATIO=<ratio>
+Comment: specify ratio(<= 1) of zram swap
+ex)RATIO=0.4
+
+2.3 FILE
+========
+Format: CryptType=<type>
+Comment: specify crypto type
+ex)CryptType=aes
+
+Format: FileSize=<byte>
+Comment: specify file size of swap file
+ex)FileSize=20M
+
+2.4 ZSWAP
+=========
+Format: CryptType=<type>
+Comment: specify crypto type of swap
+ex)CryptType=aes
+
+Format: FileSize=<byte>
+Comment: specify file size of swap
+ex)FileSize=20M
+
+Format: PoolRatio=25
+Comment: specify percent of max pool (/sys/module/zswap/parameters/max_pool_percent)
+ex)PoolRatio=25
+
+Format: PoolType=<type>
+Comment: specify zswap type (/sys/module/zswap/parameters/zpool)
+ex)PoolType=z3fold
+
+2.5 DEDUP
+=========
+Format: Enable=<1 or 0>
+Comment: specify whether KSM-based dedup is needed or not
+ Enable=yes or 1 or true / Disalbe=no or 0 or false
+ex)Enable=1
+
+Format: DedupAtBoot=<yes or no>
+Comment: specify whether dedup is needed at boot time
+ex)DedupAtBoot=yes
+
+Format: DedupAtBootDelayMs=<time>
+Comment: specify delay time(msec) after booting is complete
+ex)DedupAtBootDelayMs=60000
+
+Format: ScanOnLowmem=<true or false>
+Comment: specify whether scanning for dedup is invoked by low memory event or periodic timer
+ex)ScanOnLowmem=true
+
+Format: StatIntervalMs=<time>
+Comment: specify time interval(msec) between KSM stat
+ex)StatIntervalMs=60000
+
+Format: FullScanIntervalMs
+Comment: specify time interval(msec) between full scans
+ex)FullScanIntervalMs=60000
+
+Format: PartialScanIntervalMs
+Comment: specify time interval(msec) between partial scans
+ex)PartialScanIntervalMs=30000
+
+2.6 KSM
+=======
+Format: Mode=<mode>
+Comment: specify KSM mode between periodic and oneshot
+ periodic mode: the kernel manages all behaviors of deduplication.
+ oneshot mode: the KSM daemon only performs deduplication
+ex)Mode=oneshot
+
+Format: PagesToScan=<#page>
+Comment: specify pages to scan for deduplication
+ex)PagesToScan=30
+
+Format: SleepMs=<time>
+Comment: specify sleep time(msec) after scanning is complete
+ex)SleepMs=3000
+
+Format: FullScanIntervalMs=<time>
+Comment: specify time interval(msec) between KSM deduplication (/sys/kernel/mm/ksm/full_scan_interval)
+ex)FullScanIntervalMs=3000
+
+Format: ScanBoost=<#page>
+Comment: specify pages to scan for boosting partial scan.
+ ScanBoost is normally larger than 'PagesToScan'
+ex)ScanBoost=1000
+
+2.7 Compaction
+==============
+Format: CompactEnable=<1 or 0>
+Comment: specify whether compaction is needed or not
+ex)CompactEnable=1
+
+Format: Fraglevel=<level>
+Comment: specify external fragmentation size of the kernel zone.
+ conditions for triggering compaction.
+ex)Fraglevel=800
+
+3. monitor.conf
+===============
+
+3.1 HEART
+=========
+Format: <device>=<ON or OFF>
+Comment: specify whether devices(ABNORMAL, BATTERY, CPU, MEMORY, STORAGE) for logging are needed or not
+ex)BATTERY=ON
+ CPU=ON
+ MEMORY=OFF
+ STORAGE=ON
+ ABNORMAL=OFF
+
+3.2 BATTERY_POWER_MODE
+======================
+Format: POWER_NORMAL_MODE=<power>
+Comment: specify power of normal mode
+ex)POWER_NORMAL_MODE=676
+
+Format: POWER_SAVING_MODE=<power>
+Comment: specify power of saving mode
+ex)POWER_SAVING_MODE=750
+
+Format: ULTRA_SAVING_MODE=<power>
+Comment: specify power of ultra saving mode
+ex)ULTRA_SAVING_MODE=1947
+
+3.3 BATTERY_<capacity>
+======================
+Format: LOGIC_V2=<1 or 0>
+Comment: specify whether logic_v2 is supported or not
+ex)LOGIC_V2=1
+
+Format: DISCHARGE_FAST=<time>
+Comment: specify total time(min) taken when device is discharging at fastest rate
+ex)DISCHARGE_FAST=700
+
+Format: DISCHARGE_SLOW=<time>
+Comment: specify total time(min) taken when device is discharging at slowest rate
+ex)DISCHARGE_SLOW=12000
+
+Format: AVERAGE_PWR=<float>
+Comment: Avarage power consumed in UPS mode
+ex)AVERAGE_PWR=35.0
+
+Format: BATTERY_CAPACITY=<capacity>
+Comment: specify battery capacity(min)
+ex)BATTERY_CAPACITY=12000
+
+Format: LOGIC_RUL=<1 or 0>
+Comment: specify whether remaining usefull life (RUL) prediction logic is supported or not
+ex)LOGIC_RUL=1
+
+Format: OCV_SOC_POLY_COEF=<degree (coef_1) ... (coef_n)>
+Comment: specify degree and each coefficients
+ex)OCV_SOC_POLY_COEF=6 3402.664 42.031 -1.76745 0.034798 -0.00030516 0.0000010116
+
+4. process.conf
+===============
+
+4.1 APPUSAGE
+============
+Format: APPUSAGE=<ON or OFF>
+Comment: specify whether favorite apps are required or not
+ex)APPUSAGE=ON
+
+Format: PREDEFINE=<app name>
+Comment: specify favorite apps
+ex) PREDEFINE=app1
+
+4.2 WATCHDOG_EXCLUDED_PROCESSES
+===============================
+Format: PREDEFINE=<app name>
+Comment: specify watchdog excluded app list
+ex)PREDEFINE=app1
+
+4.3 BLOCK
+=========
+Format: activate=<TRUE or FALSE>
+Comment: specify whether user's home directories monitoring is required or not
+ex)activate=TRUE
+
+Format: mode=<type>
+Comment: specify monitor mode(DISABLE,, ACCESS, READ, WRITE) of directories
+ex)mode=WRITE
+
+Format: exclude=<name>
+Comment: specify excluded path
+ex)exclude=SLP_debug
+
+Format: include=<name>
+Comment: specify included path
+ex)include=DOWNLOADABLE
+
+Format: logging=<type>
+Comment: specify logging type.
+ DLOG=0x1, FILE=0x2, DB=0x4
+ex)logging=5
+++ /dev/null
-# activate {TRUE, FALSE}
-# mode {DISABLE, ACCESS, READ, WRITE}
-# logging { DLOG = 0x1, FILE = 0x2, DB = 0x4}
-[MONITOR]
-activate=TRUE
-mode=WRITE
-include=DOWNLOADABLE
-exclude=SLP_debug
-exclude_proc=mtp-responder
-logging=5
+++ /dev/null
-#foreground=1,2,4-6
+++ /dev/null
-[CONTROL]
-# predefined process list
-LAZY_PREDEFINE=net-config
-PREDEFINE=indicator-win
-PREDEFINE=windicator
-BOOTING_PREDEFINE=quickpanel
-WRT_PREDEFINE=wrt_launchpad_daemon
-BOOTING_PREDEFINE=volume
-BOOTING_PREDEFINE=nvitemd
-# relative cpu share
-# ROOT_CPU_SHARE=100 : fixed
-BACKGROUND_CPU_SHARE=50
-QUOTA_CPU_SHARE=25
-# max relative cpu time (max=100)
-QUOTA_MAX_BANDWIDTH=100
+++ /dev/null
-[DEDUP]
-## DEDUP module parameters
-# Enable/Disable KSM daemon. (default is disable)
-# Enable=yes or 1 or true / Disable=no or 0 or false
-# all numeric values should be given in milliseconds
-Enable=1
-DedupAtBoot=yes
-DedupAtBootDelayMs=60000
-# if FullScanTimerIntervalMs is 0, deduplication is performed
-# only when the system in low-memory state (triggered by other controller)
-# In LKSM, there are two scan modes: partial-scan and full-scan.
-# - Partial-scan: the KSM daemon scans a subset of processes and their pages
-# - Full-scan: the KSM daemon scans pages of whole processes
-# PartialScanIntervalMs: a minimum interval for partial scan
-# FullScanIntervalMs: a minimum interval for full scan
-ScanOnLowmem=true
-StatIntervalMs=60000
-PartialScanIntervalMs=10000
-FullScanIntervalMs=600000
-
-[KSM]
-## KSM parameters
-# KSM modes: periodic and oneshot
-# periodic mode: means that the kernel manages all behaviors of deduplication
-# oneshot mode: means that the KSM daemon only performs deduplication
-# when the resourced triggers it
-Mode=oneshot
-#Mode=periodic
-
-## KSM scanning parameter
-# PagesToScan: the number of pages that KSM daemon scans when it wakes up
-# Sleep: once the KSM daemon scans given pages, it sleeps for a given interval (ms)
-# FullScanIntervalMS: used in the periodic mode, the value decides the interval of full scanning
-# ScanBoost: for partial scans, PagesToScan is temporarily boosted by this value
-PagesToScan=100
-SleepMs=20
-FullScanIntervalMs=60000
-ScanBoost=1000
--- /dev/null
+[VIP_PROCESS]
+# predefined process list
+PREDEFINE=enlightenment
+PREDEFINE=dbus-daemon
+PREDEFINE=amd
+PREDEFINE=launchpad_preloading_preinitializing_daemon
+PREDEFINE=process_pool_launchpad_preloading_preinitializing_daemon
+
+[OOM_FIXED_APPS]
+# predefined OOM-fixed app list
+# Format : YOUR_APP=SCORE
+# OOMADJ_SERVICE_MIN < SCORE < OOMADJ_BACKGRD_LOCKED
+# NOTICE : do not set the score with the predefined value
+# you can see the predefined value at the procfs.h
+
+# Use the ratio of the available memory to the total memory as vmpressure threshold.
+# If used with [Memory#] section, the last threshold will be applied.
+[Memory]
+NumMaxVictims=10
+#ThresholdRatioDedup=30 # %
+#ThresholdRatioSwap=24 # %
+#ThresholdRatioLow=12 # %
+#ThresholdRatioMedium=10 # %
+#ThresholdRatioLeave=15 # %
+#NumMaxVictims=1
+
+[POPUP]
+oom_popup=no
+
+[BackgroundReclaim]
+# Unset this option if it causes any unexepcted issue (e.g. jerky animation).
+AfterScreenDim=yes
+
+[MemLimit]
+# Control memory limit
+# values for MemLimitTrigger :
+# oom (regiter event using oom_control and kill process in kernel)
+# threshold(regiter event using usage_in_bytes and kill process in resourced)
+# others(don't register any event for memory limit)
+MemLimitTrigger=oom
+
+# Memory limits for each supported application types. Effective only when MemLimitTrigger
+# is set to oom or threshold.
+MemLimitService=128 # MB
+# MemLimitWidget=160 # MB
+# MemLimitGUIApp=1024 # MB
+
+# Following configuration option sets memory limit for background GUI
+# and Widget applications. It's valid to set this option only if
+# both MemLimitWidget and MemLimitGUIApp are set.
+# MemLimitBgApp=768 # MB
+
+[Logging]
+Enable=1
+# memps logpath
+# memps: OOM log
+# memps_memlimit: lowmem limit log
+MaxNumLogfile=50 # default: 50
+LogPath=/var/log # default: /var/log
+# logfile prefix
+PrefixMemps=memps
+PrefixMempsMemLimit=memps_memlimit
+
+[CPU]
+# predefined process list
+LAZY_PREDEFINE=net-config
+PREDEFINE=indicator-win
+PREDEFINE=windicator
+BOOTING_PREDEFINE=quickpanel
+WRT_PREDEFINE=wrt_launchpad_daemon
+BOOTING_PREDEFINE=volume
+BOOTING_PREDEFINE=nvitemd
+# relative cpu share
+# ROOT_CPU_SHARE=100 : fixed
+BACKGROUND_CPU_SHARE=50
+QUOTA_CPU_SHARE=25
+# max relative cpu time (max=100)
+QUOTA_MAX_BANDWIDTH=100
+
+[CPU-SCHED]
+#foreground=1,2,4-6
--- /dev/null
+[VIP_PROCESS]
+# predefined process list
+PREDEFINE=enlightenment
+PREDEFINE=dbus-daemon
+PREDEFINE=amd
+PREDEFINE=launchpad_preloading_preinitializing_daemon
+PREDEFINE=process_pool_launchpad_preloading_preinitializing_daemon
+
+[OOM_FIXED_APPS]
+# predefined OOM-fixed app list
+# Format : YOUR_APP=SCORE
+# OOMADJ_SERVICE_MIN < SCORE < OOMADJ_BACKGRD_LOCKED
+# NOTICE : do not set the score with the predefined value
+# you can see the predefined value at the procfs.h
+
+[Memory]
+NumMaxVictims=10
+
+[POPUP]
+oom_popup=no
+
+[BackgroundReclaim]
+# Unset this option if it causes any unexepcted issue (e.g. jerky animation).
+AfterScreenDim=yes
+
+[MemLimit]
+# Control memory limit
+# values for MemLimitTrigger :
+# oom (regiter event using oom_control and kill process in kernel)
+# threshold(regiter event using usage_in_bytes and kill process in resourced)
+# others(don't register any event for memory limit)
+MemLimitTrigger=none
+# How long does the resourced allow that each service applications use memory
+# But, it only allows to enable when the MemLimitTrigger option is oom or threshold.
+MemLimitService=128 # MB
+
+[CPU]
+# predefined process list
+LAZY_PREDEFINE=net-config
+PREDEFINE=indicator-win
+PREDEFINE=windicator
+BOOTING_PREDEFINE=quickpanel
+WRT_PREDEFINE=wrt_launchpad_daemon
+BOOTING_PREDEFINE=volume
+BOOTING_PREDEFINE=nvitemd
+# relative cpu share
+# ROOT_CPU_SHARE=100 : fixed
+BACKGROUND_CPU_SHARE=50
+QUOTA_CPU_SHARE=25
+# max relative cpu time (max=100)
+QUOTA_MAX_BANDWIDTH=100
+
+[CPU-SCHED]
+#foreground=1,2,4-6
--- /dev/null
+[VIP_PROCESS]
+PREDEFINE=enlightenment
+PREDEFINE=dbus-daemon
+PREDEFINE=amd
+PREDEFINE=launchpad_preloading_preinitializing_daemon
+PREDEFINE=process_pool_launchpad_preloading_preinitializing_daemon
+
+[OOM_FIXED_APPS]
+
+[Memory]
+NumMaxVictims=10
+#ThresholdRatioDedup=30 # %
+#ThresholdRatioSwap=24 # %
+#ThresholdRatioLow=12 # %
+#ThresholdRatioMedium=10 # %
+#ThresholdRatioLeave=15 # %
+#NumMaxVictims=1
+
+[POPUP]
+oom_popup=no
+
+[BackgroundReclaim]
+AfterScreenDim=yes
+
+[MemLimit]
+MemLimitTrigger=oom
+MemLimitService=128 # MB
+# MemLimitWidget=160 # MB
+# MemLimitGUIApp=1024 # MB
+# MemLimitBgApp=768 # MB
+
+[Logging]
+Enable=0
+MaxNumLogfile=50 # default: 50
+LogPath=/var/log # default: /var/log
+#PrefixMemps=memps
+#PrefixMempsMemLimit=memps_memlimit
+
+[CPU]
+LAZY_PREDEFINE=net-config
+PREDEFINE=indicator-win
+PREDEFINE=windicator
+BOOTING_PREDEFINE=quickpanel
+WRT_PREDEFINE=wrt_launchpad_daemon
+BOOTING_PREDEFINE=volume
+BOOTING_PREDEFINE=nvitemd
+BACKGROUND_CPU_SHARE=50
+QUOTA_CPU_SHARE=25
+QUOTA_MAX_BANDWIDTH=100
+
+[CPU-SCHED]
+#foreground=1,2,4-6
+++ /dev/null
-[VIP_PROCESS]
-# predefined process list
-PREDEFINE=enlightenment
-PREDEFINE=dbus-daemon
-PREDEFINE=amd
-PREDEFINE=launchpad_preloading_preinitializing_daemon
-PREDEFINE=process_pool_launchpad_preloading_preinitializing_daemon
-
-# Use the ratio of the available memory to the total memory as vmpressure threshold.
-# If used with [Memory#] section, the last threshold will be applied.
-#[MemoryRatio]
-#ThresholdRatioDedup=30 # %
-#ThresholdRatioSwap=24 # %
-#ThresholdRatioLow=12 # %
-#ThresholdRatioMedium=10 # %
-#ThresholdRatioLeave=15 # %
-#NumMaxVictims=1
-
-[Memory64]
-# Threshold to start dedup
-ThresholdDedup=16 # MB
-
-# Threshold to start swap
-ThresholdSwap=15 # MB
-
-# Threshold to start reclaim
-ThresholdLow=8 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=5 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=8 # MB
-
-# Number of max victims
-NumMaxVictims=1
-
-[Memory256]
-# Threshold to start dedup
-ThresholdDedup=60 # MB
-
-# Threshold to start swap
-ThresholdSwap=40 # MB
-
-# Threshold to start reclaim
-ThresholdLow=20 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=10 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=20 # MB
-
-# Number of max victims
-NumMaxVictims=2
-
-[Memory448]
-# Threshold to start dedup
-ThresholdDedup=120 # MB
-
-# Threshold to start swap
-ThresholdSwap=100 # MB
-
-# Threshold to start reclaim
-ThresholdLow=60 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=50 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=70 # MB
-
-# Threshold for proactive memory killer
-ProactiveThreshold=80 # MB
-
-# Leave Threshold for proactive memory killer
-ProactiveLeave=100 # MB
-
-# Number of max victims
-NumMaxVictims=5
-
-[Memory512]
-# Threshold to start dedup
-ThresholdDedup=140 # MB
-
-# Threshold to start swap
-ThresholdSwap=100 # MB
-
-# Threshold to start reclaim
-ThresholdLow=70 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=60 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=80 # MB
-
-# Threshold for proactive memory killer
-ProactiveThreshold=80 # MB
-
-# Leave Threshold for proactive memory killer
-ProactiveLeave=100 # MB
-
-# Number of max victims
-NumMaxVictims=5
-
-[Memory768]
-# Threshold to start dedup
-ThresholdDedup=180 # MB
-
-# Threshold to start swap
-ThresholdSwap=150 # MB
-
-# Threshold to start reclaim
-ThresholdLow=90 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=80 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=100 # MB
-
-# Threshold for proactive memory killer
-ProactiveThreshold=100 # MB
-
-# Leave Threshold for proactive memory killer
-ProactiveLeave=130 # MB
-
-# Number of max victims
-NumMaxVictims=5
-
-[Memory1024]
-# Threshold to start dedup
-ThresholdDedup=400 # MB
-
-# Threshold to start swap
-ThresholdSwap=300 # MB
-
-# Threshold to start reclaim
-ThresholdLow=120 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=100 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=150 # MB
-
-# Threshold for proactive memory killer
-ProactiveThreshold=150 # MB
-
-# Leave Threshold for proactive memory killer
-ProactiveLeave=230 # MB
-
-# Number of max victims
-NumMaxVictims=5
-
-[Memory2048]
-# Threshold to start dedup
-ThresholdDedup=400 # MB
-
-# Threshold to start swap
-ThresholdSwap=300 # MB
-
-# Threshold to start reclaim
-ThresholdLow=200 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=160 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=300 # MB
-
-# Number of max victims
-NumMaxVictims=10
-
-[Memory3072]
-# Threshold to start dedup
-ThresholdDedup=600 # MB
-
-# Threshold to start swap
-ThresholdSwap=500 # MB
-
-# Threshold to start reclaim
-ThresholdLow=400 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=250 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=500 # MB
-
-# Number of max victims
-NumMaxVictims=10
-
-[POPUP]
-oom_popup=no
-
-[BackgroundReclaim]
-# Unset this option if it causes any unexepcted issue (e.g. jerky animation).
-AfterScreenDim=yes
-
-[Compaction]
-CompactEnable=1
-# External fragmentation level
-# The higher the level the less restrictive
-# conditions for triggering compaction.
-Fraglevel=800
-
-[MemLimit]
-# Control memory limit
-# values for MemLimitTrigger :
-# oom (regiter event using oom_control and kill process in kernel)
-# threshold(regiter event using usage_in_bytes and kill process in resourced)
-# others(don't register any event for memory limit)
-MemLimitTrigger=oom
-
-# Memory limits for each supported application types. Effective only when MemLimitTrigger
-# is set to oom or threshold.
-MemLimitService=128 # MB
-# MemLimitWidget=160 # MB
-# MemLimitGUIApp=1024 # MB
-
-# Following configuration option sets memory limit for background GUI
-# and Widget applications. It's valid to set this option only if
-# both MemLimitWidget and MemLimitGUIApp are set.
-# MemLimitBgApp=768 # MB
-
-[Logging]
-Enable=1
-# memps logpath
-# memps: OOM log
-# memps_memlimit: lowmem limit log
-MaxNumLogfile=50 # default: 50
-LogPath=/var/log # default: /var/log
-# logfile prefix
-PrefixMemps=memps
-PrefixMempsMemLimit=memps_memlimit
+++ /dev/null
-[VIP_PROCESS]
-# predefined process list
-PREDEFINE=enlightenment
-PREDEFINE=dbus-daemon
-PREDEFINE=amd
-PREDEFINE=launchpad_preloading_preinitializing_daemon
-PREDEFINE=process_pool_launchpad_preloading_preinitializing_daemon
-
-[Memory64]
-# Threshold to start swap
-ThresholdSwap=15 # MB
-
-# Threshold to start reclaim
-ThresholdLow=8 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=5 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=8 # MB
-
-# Number of max victims
-NumMaxVictims=1
-
-[Memory256]
-# Threshold to start swap
-ThresholdSwap=40 # MB
-
-# Threshold to start reclaim
-ThresholdLow=20 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=10 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=20 # MB
-
-# Number of max victims
-NumMaxVictims=2
-
-[Memory448]
-# Threshold to start swap
-ThresholdSwap=100 # MB
-
-# Threshold to start reclaim
-ThresholdLow=60 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=50 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=70 # MB
-
-# Threshold for proactive memory killer
-ProactiveThreshold=80 # MB
-
-# Leave Threshold for proactive memory killer
-ProactiveLeave=100 # MB
-
-# Number of max victims
-NumMaxVictims=5
-
-[Memory512]
-# Threshold to start swap
-ThresholdSwap=100 # MB
-
-# Threshold to start reclaim
-ThresholdLow=70 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=60 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=80 # MB
-
-# Threshold for proactive memory killer
-ProactiveThreshold=80 # MB
-
-# Leave Threshold for proactive memory killer
-ProactiveLeave=100 # MB
-
-# Number of max victims
-NumMaxVictims=5
-
-[Memory768]
-# Threshold to start swap
-ThresholdSwap=150 # MB
-
-# Threshold to start reclaim
-ThresholdLow=90 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=80 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=100 # MB
-
-# Threshold for proactive memory killer
-ProactiveThreshold=100 # MB
-
-# Leave Threshold for proactive memory killer
-ProactiveLeave=130 # MB
-
-# Number of max victims
-NumMaxVictims=5
-
-[Memory1024]
-# Threshold to start swap
-ThresholdSwap=300 # MB
-
-# Threshold to start reclaim
-ThresholdLow=120 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=100 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=150 # MB
-
-# Threshold for proactive memory killer
-ProactiveThreshold=150 # MB
-
-# Leave Threshold for proactive memory killer
-ProactiveLeave=230 # MB
-
-# Number of max victims
-NumMaxVictims=5
-
-[Memory2048]
-# Threshold to start swap
-ThresholdSwap=300 # MB
-
-# Threshold to start reclaim
-ThresholdLow=200 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=160 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=300 # MB
-
-# Number of max victims
-NumMaxVictims=10
-
-[POPUP]
-oom_popup=no
-
-[BackgroundReclaim]
-# Unset this option if it causes any unexepcted issue (e.g. jerky animation).
-AfterScreenDim=yes
-
-[Compaction]
-CompactEnable=0
-# External fragmentation level
-# The higher the level the less restrictive
-# conditions for triggering compaction.
-Fraglevel=800
-
-[MemLimit]
-# Control memory limit
-# values for MemLimitTrigger :
-# oom (regiter event using oom_control and kill process in kernel)
-# threshold(regiter event using usage_in_bytes and kill process in resourced)
-# others(don't register any event for memory limit)
-MemLimitTrigger=none
-# How long does the resourced allow that each service applications use memory
-# But, it only allows to enable when the MemLimitTrigger option is oom or threshold.
-MemLimitService=128 # MB
+++ /dev/null
-[VIP_PROCESS]
-# predefined process list
-PREDEFINE=enlightenment
-PREDEFINE=dbus-daemon
-PREDEFINE=amd
-PREDEFINE=launchpad_preloading_preinitializing_daemon
-PREDEFINE=process_pool_launchpad_preloading_preinitializing_daemon
-
-# Use the ratio of the available memory to the total memory as vmpressure threshold.
-# If used with [Memory#] section, the last threshold will be applied.
-#[MemoryRatio]
-#ThresholdRatioDedup=30 # %
-#ThresholdRatioSwap=24 # %
-#ThresholdRatioLow=12 # %
-#ThresholdRatioMedium=10 # %
-#ThresholdRatioLeave=15 # %
-#NumMaxVictims=1
-
-[Memory64]
-# Threshold to start dedup
-ThresholdDedup=16 # MB
-
-# Threshold to start swap
-ThresholdSwap=15 # MB
-
-# Threshold to start reclaim
-ThresholdLow=8 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=5 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=8 # MB
-
-# Number of max victims
-NumMaxVictims=1
-
-[Memory256]
-# Threshold to start dedup
-ThresholdDedup=60 # MB
-
-# Threshold to start swap
-ThresholdSwap=40 # MB
-
-# Threshold to start reclaim
-ThresholdLow=20 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=10 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=20 # MB
-
-# Number of max victims
-NumMaxVictims=2
-
-[Memory448]
-# Threshold to start dedup
-ThresholdDedup=120 # MB
-
-# Threshold to start swap
-ThresholdSwap=100 # MB
-
-# Threshold to start reclaim
-ThresholdLow=60 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=50 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=70 # MB
-
-# Threshold for proactive memory killer
-ProactiveThreshold=80 # MB
-
-# Leave Threshold for proactive memory killer
-ProactiveLeave=100 # MB
-
-# Number of max victims
-NumMaxVictims=5
-
-[Memory512]
-# Threshold to start dedup
-ThresholdDedup=140 # MB
-
-# Threshold to start swap
-ThresholdSwap=100 # MB
-
-# Threshold to start reclaim
-ThresholdLow=70 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=60 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=80 # MB
-
-# Threshold for proactive memory killer
-ProactiveThreshold=80 # MB
-
-# Leave Threshold for proactive memory killer
-ProactiveLeave=100 # MB
-
-# Number of max victims
-NumMaxVictims=5
-
-[Memory768]
-# Threshold to start dedup
-ThresholdDedup=180 # MB
-
-# Threshold to start swap
-ThresholdSwap=150 # MB
-
-# Threshold to start reclaim
-ThresholdLow=90 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=80 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=100 # MB
-
-# Threshold for proactive memory killer
-ProactiveThreshold=100 # MB
-
-# Leave Threshold for proactive memory killer
-ProactiveLeave=130 # MB
-
-# Number of max victims
-NumMaxVictims=5
-
-[Memory1024]
-# Threshold to start dedup
-ThresholdDedup=400 # MB
-
-# Threshold to start swap
-ThresholdSwap=300 # MB
-
-# Threshold to start reclaim
-ThresholdLow=120 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=100 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=150 # MB
-
-# Threshold for proactive memory killer
-ProactiveThreshold=150 # MB
-
-# Leave Threshold for proactive memory killer
-ProactiveLeave=230 # MB
-
-# Number of max victims
-NumMaxVictims=5
-
-[Memory2048]
-# Threshold to start dedup
-ThresholdDedup=400 # MB
-
-# Threshold to start swap
-ThresholdSwap=300 # MB
-
-# Threshold to start reclaim
-ThresholdLow=200 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=160 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=300 # MB
-
-# Number of max victims
-NumMaxVictims=10
-
-[Memory3072]
-# Threshold to start dedup
-ThresholdDedup=600 # MB
-
-# Threshold to start swap
-ThresholdSwap=500 # MB
-
-# Threshold to start reclaim
-ThresholdLow=400 # MB
-
-# Threshold to start low memory killer
-ThresholdMedium=250 # MB
-
-# Threshold to stop low memory killer
-ThresholdLeave=500 # MB
-
-# Number of max victims
-NumMaxVictims=10
-
-[POPUP]
-oom_popup=no
-
-[BackgroundReclaim]
-# Unset this option if it causes any unexepcted issue (e.g. jerky animation).
-AfterScreenDim=yes
-
-[Compaction]
-CompactEnable=1
-# External fragmentation level
-# The higher the level the less restrictive
-# conditions for triggering compaction.
-Fraglevel=800
-
-[MemLimit]
-# Control memory limit
-# values for MemLimitTrigger :
-# oom (regiter event using oom_control and kill process in kernel)
-# threshold(regiter event using usage_in_bytes and kill process in resourced)
-# others(don't register any event for memory limit)
-MemLimitTrigger=oom
-
-# Memory limits for each supported application types. Effective only when MemLimitTrigger
-# is set to oom or threshold.
-MemLimitService=128 # MB
-# MemLimitWidget=160 # MB
-# MemLimitGUIApp=1024 # MB
-
-# Following configuration option sets memory limit for background GUI
-# and Widget applications. It's valid to set this option only if
-# both MemLimitWidget and MemLimitGUIApp are set.
-# MemLimitBgApp=768 # MB
-
-[Logging]
-Enable=1
-# memps logpath
-# memps: OOM log
-# memps_memlimit: lowmem limit log
-MaxNumLogfile=50 # default: 50
-LogPath=/var/log # default: /var/log
-# logfile prefix
-PrefixMemps=memps
-PrefixMempsMemLimit=memps_memlimit
POWER_SAVING_MODE=750
ULTRA_SAVING_MODE=1947
-# OCV_SOC_POLY_COEF=(DEGREE) (COEF_1) ... (COEF_N)
-
[BATTERY_2600]
LOGIC_V2=1
DISCHARGE_FAST=700
--- /dev/null
+[SWAP]
+Enable=1
+ReclaimAtBoot=yes
+TimerReclaimAtBoot=0
+ReclaimAtBootThreshold=20M
+ReclaimAtBootMaxTry=2
+ReclaimAtBootInterval=1
+Type=zram
+
+[ZRAM]
+COMP_ALGORITHM=zstd
+RATIO=0.4
+
+[FILE]
+CryptType=aes
+FileSize=30M
+
+[ZSWAP]
+PoolRatio=40
+PoolType=z3fold
+
+[DEDUP]
+Enable=1
+DedupAtBoot=yes
+DedupAtBootDelayMs=60000
+ScanOnLowmem=true
+StatIntervalMs=60000
+PartialScanIntervalMs=10000
+FullScanIntervalMs=600000
+
+[KSM]
+Mode=oneshot
+#Mode=periodic
+
+PagesToScan=100
+SleepMs=20
+FullScanIntervalMs=60000
+ScanBoost=1000
+
+[Compaction]
+CompactEnable=1
+Fraglevel=800
[APPUSAGE]
APPUSAGE=ON
-# predefined favorite app list
-# Format : PREDEFINE=YOUR_FAVORITE_APP
-
-[OOM_FIXED_APPS]
-# predefined OOM-fixed app list
-# Format : YOUR_APP=SCORE
-# OOMADJ_SERVICE_MIN < SCORE < OOMADJ_BACKGRD_LOCKED
-# NOTICE : do not set the score with the predefined value
-# you can see the predefined value at the procfs.h
[WATCHDOG_EXCLUDED_PROCESSES]
-# predefined watchdog excluded process list
-# Format : PREDEFINE=EXCLUDED_PROCESS_NAME
PREDEFINE=indicator-win
PREDEFINE=lockscreen
PREDEFINE=quickpanel
PREDEFINE=volume
PREDEFINE=data-provider-master
+
+[BLOCK]
+activate=TRUE
+mode=WRITE
+include=DOWNLOADABLE
+exclude=SLP_debug
+exclude_proc=mtp-responder
+logging=5
+++ /dev/null
-[SWAP]
-## Enable/Disable swap devices. (default is disable)
-# Enable=yes or 1 or true / Disalbe=no or 0 or false
-# To prevent thrashing, do not set "ReclaimAtBootThreshold" too low.
-
-Enable=1
-ReclaimAtBoot=yes
-TimerReclaimAtBoot=0
-## Belows are meaningful only if 'ReclaimAtBoot' is enabled.
-ReclaimAtBootThreshold=20M
-ReclaimAtBootMaxTry=2
-ReclaimAtBootInterval=1
-
-## swap device type. zram, file and zswap are available.
-## Multiple swap devices are specified witn '+'.
-## For example, both zram and file are enable by zram+file. (default is zram)
-Type=zram
-
-[ZRAM]
-## zram parameter
-COMP_ALGORITHM=zstd
-## swap ratio
-RATIO=0.4
-
-[FILE]
-## Swap file encryption type. Currently, 'none' or 'aes' available.
-CryptType=aes
-## Maximum swap file size
-FileSize=30M
-
-[ZSWAP]
-PoolRatio=40
-PoolType=z3fold
%define cpu_module ON
%define memory_module ON
%define vip_agent_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} \
-DVIP_AGENT=%{vip_agent_module} \
-DRD_SYS_ETC=%{TZ_SYS_ETC} \
-DRD_SYS_DATA=%{TZ_SYS_GLOBALUSER_DATA} \
# https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#ordering
# List of configuration files provided by this package - update when any new config file is added!
-%define config_files block cpu cpu-sched heart memory process swap dedup
+%define config_files limiter optimizer monitor process
for i in %{confdir}/*.conf; do
if [ "$i" = %{confdir}/"*.conf" ]; then
fi
%post config-tv
-%{_sbindir}/update-alternatives --install %{confdir}/memory.conf resourced-config-memory %{confdir}/configs/config-memory-profile-tv.conf 150
+%{_sbindir}/update-alternatives --install %{confdir}/limiter.conf resourced-config-limiter %{confdir}/configs/config-limiter-profile-tv.conf 150
%preun config-tv
if [ $1 -eq 0 ]; then
- %{_sbindir}/update-alternatives --remove resourced-config-memory %{confdir}/configs/config-memory-profile-tv.conf
+ %{_sbindir}/update-alternatives --remove resourced-config-limiter %{confdir}/configs/config-limiter-profile-tv.conf
fi
%post config-iot-headless
-%{_sbindir}/update-alternatives --install %{confdir}/memory.conf resourced-config-memory %{confdir}/configs/config-memory-profile-iot-headless.conf 150
+%{_sbindir}/update-alternatives --install %{confdir}/limiter.conf resourced-config-limiter %{confdir}/configs/config-limiter-profile-iot-headless.conf 150
%preun config-iot-headless
if [ $1 -eq 0 ]; then
- %{_sbindir}/update-alternatives --remove resourced-config-memory %{confdir}/configs/config-memory-profile-iot-headless.conf
+ %{_sbindir}/update-alternatives --remove resourced-config-limiter %{confdir}/configs/config-limiter-profile-iot-headless.conf
fi
%files
%config %{_sysconfdir}/dbus-1/system.d/org.tizen.resourced.conf
%{_unitdir}/resourced.service
%{_unitdir}/multi-user.target.wants/resourced.service
-%{confdir}/configs/config-memory.conf
+%{confdir}/configs/config-limiter.conf
+%{confdir}/configs/config-optimizer.conf
%{confdir}/configs/config-process.conf
-%{confdir}/configs/config-swap.conf
-%{confdir}/configs/config-dedup.conf
-%{confdir}/configs/config-block.conf
-%{confdir}/configs/config-heart.conf
-%{confdir}/configs/config-cpu.conf
-%{confdir}/configs/config-cpu-sched.conf
+#%{confdir}/configs/config-swap.conf
+#%{confdir}/configs/config-dedup.conf
+#%{confdir}/configs/config-block.conf
+%{confdir}/configs/config-monitor.conf
+#%{confdir}/configs/config-cpu.conf
+#%{confdir}/configs/config-cpu-sched.conf
%files config-tv
%manifest resourced.manifest
-%{confdir}/configs/config-memory-profile-tv.conf
+%{confdir}/configs/config-limiter-profile-tv.conf
%files config-iot-headless
%manifest resourced.manifest
-%{confdir}/configs/config-memory-profile-iot-headless.conf
+%{confdir}/configs/config-limiter-profile-iot-headless.conf
%if %{?vip_agent_module} == ON
%files vip-release-agent
${FREEZER_SOURCE_DIR}
)
+#compaction module
+IF("${COMPACTION_MODULE}" STREQUAL "ON")
+ FILE(GLOB FILES "${COMPACTION_SOURCE_DIR}/*.c")
+ FOREACH(FILE ${FILES})
+ SET(SOURCES ${SOURCES} ${FILE})
+ ENDFOREACH()
+ENDIF()
IF("${VIP_AGENT}" STREQUAL "ON")
SET(SOURCES ${SOURCES}
${BLOCK_SOURCE_DIR}/block-monitor.c)
TARGET_LINK_LIBRARIES(block resourced-private-api ${RESOURCED_REQUIRE_PKGS_LDFLAGS})
INSTALL(TARGETS block DESTINATION ${MAKE_INSTALL_PREFIX}${RD_PLUGIN_PATH})
-INSTALL(FILES ${CONF_DIR}/block.conf DESTINATION ${RD_CONFIG_PATH})
ADD_DEFINITIONS("-DFREEZER_DIR=\"${LIB_INSTALL_DIR}\"")
ADD_LIBRARY(freezer MODULE ${FREEZER_SOURCE_DIR}/freezer.c)
${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}/swap.conf DESTINATION ${RD_CONFIG_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})
-INSTALL(FILES ${CONF_DIR}/dedup.conf DESTINATION ${RD_CONFIG_PATH})
ADD_LIBRARY(heart MODULE
${RESOURCE_MONITOR_SOURCE_DIR}/heart.c
${RESOURCE_MONITOR_SOURCE_DIR}/logging.c)
TARGET_LINK_LIBRARIES(heart resourced-private-api ${RESOURCED_REQUIRE_PKGS_LDFLAGS})
INSTALL(TARGETS heart DESTINATION ${MAKE_INSTALL_PREFIX}${RD_PLUGIN_PATH})
-INSTALL(FILES ${CONF_DIR}/heart.conf DESTINATION ${RD_CONFIG_PATH})
+INSTALL(FILES ${CONF_DIR}/monitor.conf DESTINATION ${RD_CONFIG_PATH})
CONFIGURE_FILE(${RESOURCE_MONITOR_SOURCE_DIR}/dump_heart_data.sh.in ${RESOURCE_MONITOR_SOURCE_DIR}/dump_heart_data.sh @ONLY)
INSTALL(FILES ${RESOURCE_MONITOR_SOURCE_DIR}/dump_heart_data.sh DESTINATION ${RD_SYS_ETC}/dump.d/module.d)
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE WORLD_EXECUTE)
IF("${MEMORY_MODULE}" STREQUAL "ON")
- INSTALL(FILES ${CONF_DIR}/memory.conf DESTINATION ${RD_CONFIG_PATH})
- INSTALL(FILES ${CONF_DIR}/memory-profile-tv.conf DESTINATION ${RD_CONFIG_PATH})
- INSTALL(FILES ${CONF_DIR}/memory-profile-iot-headless.conf DESTINATION ${RD_CONFIG_PATH})
-ENDIF()
-
-IF("${CPU_MODULE}" STREQUAL "ON")
- INSTALL(FILES ${CONF_DIR}/cpu.conf
- DESTINATION ${RD_CONFIG_PATH} RENAME cpu.conf)
- INSTALL(FILES ${CONF_DIR}/cpu-sched.conf
- DESTINATION ${RD_CONFIG_PATH} RENAME cpu-sched.conf)
+ INSTALL(FILES ${CONF_DIR}/limiter.conf DESTINATION ${RD_CONFIG_PATH})
+ INSTALL(FILES ${CONF_DIR}/limiter-profile-tv.conf DESTINATION ${RD_CONFIG_PATH})
+ INSTALL(FILES ${CONF_DIR}/limiter-profile-iot-headless.conf DESTINATION ${RD_CONFIG_PATH})
ENDIF()
IF("${VIP_AGENT}" STREQUAL "ON")
#define CGROUP_PER_PROCESS_NAME ""
#define CGROUP_GROUP_NAME ""
+#define CGROUP_VIP_LIST_DIR RD_CONFIG_PATH"/limiter.conf.d"
+#define CGROUP_VIP_CONF_SUFFIX ".conf"
+
#define CGROUP_DEFAULT_USE_HIERARCHY false
/*
* [cgroup information]
unsigned int i;
for (i = CGROUP_ROOT; i < CGROUP_END; i++) {
-// struct memcg_info *mi = memcg_tree[i]->info;
struct memcg_info *mi = get_memcg_info(i);
memcg_write_params_info(mi);
}
/* open conf file */
f = fopen(file_name, "r");
if (!f) {
- _E("Failed to open file %s", file_name);
+ _E("[DEBUG] Failed to open file %s", file_name);
ret = -EIO;
goto error;
}
}
}
}
- _D("Success to load %s", file_name);
+ _D("[DEBUG] Success to load %s", file_name);
fclose(f);
return 0;
error:
if (f)
fclose(f);
- _E("Failed to read %s:%d!", file_name, lineno);
+ _E("[DEBUG] Failed to read %s:%d!", file_name, lineno);
return ret;
}
extern "C" {
#endif /* __cplusplus */
-#define DEDUP_CONF_FILE RD_CONFIG_FILE(dedup)
+#define DEDUP_CONF_FILE RD_CONFIG_FILE(optimizer)
#define DEDUP_SYSFS_KSM_PATH "/sys/kernel/mm/ksm"
/* KSM operations */
#define SWAP_ZRAM_SYSFILE "/sys/block/zram0/"
#define SWAP_FILE_NAME "/opt/usr/.swapfile"
-#define SWAP_CONF_FILE RD_CONFIG_FILE(swap)
+#define SWAP_CONF_FILE RD_CONFIG_FILE(optimizer)
enum swap_state {
SWAP_ARG_START = -1,
#include "appinfo-list.h"
#include "storage-helper.h"
-#define BLOCK_CONF_FILE RD_CONFIG_FILE(block)
-#define BLOCK_CONF_SECTION "MONITOR"
+#define BLOCK_CONF_FILE RD_CONFIG_FILE(process)
+#define BLOCK_CONF_SECTION "BLOCK"
#define BLOCK_CONF_ACTIVATED "TRUE"
static GSList *block_monitor_list;
return RESOURCED_ERROR_NO_DATA;
if (!MATCH(result->section, BLOCK_CONF_SECTION))
- return RESOURCED_ERROR_NO_DATA;
+ return RESOURCED_ERROR_NONE;
if (MATCH(result->name, "activate")) {
if (!strncmp(result->value, BLOCK_CONF_ACTIVATED,
#include "resourced.h"
#include "trace.h"
-#define PRIORITY_CONF_FILE RD_CONFIG_FILE(process)
+#define PRIORITY_CONF_FILE RD_CONFIG_FILE(limiter)
#define FIXED_OOM_CONF_SECTION "OOM_FIXED_APPS"
return RESOURCED_ERROR_INVALID_PARAMETER;
if (!strncmp(result->section, FIXED_OOM_CONF_SECTION, strlen(FIXED_OOM_CONF_SECTION) + 1)) {
+
/* Set predefined OOM score */
score = atoi(result->value);
static void vip_load_configs(void)
{
- DIR *dirp;
- struct dirent *ent;
+ int count;
+ int idx;
+ struct dirent **namelist;
- if ((dirp = opendir(VIP_CONF_DIR)) == NULL) {
- _E("Failed to open %s, %m", VIP_CONF_DIR);
+ if ((count = scandir(VIP_CONF_DIR, &namelist, NULL, alphasort)) == -1) {
+ _W("[DEBUG] failed to opendir (%s)", VIP_CONF_DIR);
return;
}
- while ((ent = readdir(dirp))) {
+ for (idx = 0; idx < count; idx++) {
char path[PATH_MAX] = {0, };
- if (!strstr(ent->d_name, VIP_CONF_SUFFIX))
+ if (!strstr(namelist[idx]->d_name, VIP_CONF_SUFFIX))
continue;
- snprintf(path, sizeof(path), "%s/%s", VIP_CONF_DIR, ent->d_name);
-
- config_parse(path, vip_load_config, (void *)ent->d_name);
+ snprintf(path, sizeof(path), "%s/%s", VIP_CONF_DIR, namelist[idx]->d_name);
+ config_parse(path, vip_load_config, (void *)namelist[idx]->d_name);
+ free(namelist[idx]);
}
- closedir(dirp);
+ free(namelist);
/* print result */
GList *elem1, *elem2;
#include "file-helper.h"
#include "util.h"
-#define CPU_SCHED_CONF_FILE RD_CONFIG_FILE(cpu-sched)
+#define CPU_SCHED_CONF_FILE RD_CONFIG_FILE(limiter)
+#define CPU_SCHED_CONF_SECTION "CPU-SCHED"
#define CPU_SCHED_FG_NAME "foreground"
#define MOUNTS_PATH "/proc/mounts"
#define CPUSET_CGROUP "/sys/fs/cgroup/cpuset"
assert(data);
+ if (strncmp(result->section, CPU_SCHED_CONF_SECTION, strlen(CPU_SCHED_CONF_SECTION)+1))
+ return RESOURCED_ERROR_NONE;
+
bool is_fg = !strcmp(result->name, CPU_SCHED_FG_NAME);
char *name = strdup(result->name);
#include "file-helper.h"
#include "cpu-cgroup.h"
-#define CPU_CONF_FILE RD_CONFIG_FILE(cpu)
-#define CPU_CONF_SECTION "CONTROL"
+#define CPU_CONF_FILE RD_CONFIG_FILE(limiter)
+#define CPU_CONF_SECTION "CPU"
#define CPU_CONF_PREDEFINE "PREDEFINE"
#define CPU_CONF_BOOTING "BOOTING_PREDEFINE"
#define CPU_CONF_WRT "WRT_PREDEFINE"
return -EINVAL;
if (strncmp(result->section, CPU_CONF_SECTION, strlen(CPU_CONF_SECTION)+1))
- return RESOURCED_ERROR_NO_DATA;
+ return RESOURCED_ERROR_NONE;
+
if (!strncmp(result->name, CPU_CONF_PREDEFINE, strlen(CPU_CONF_PREDEFINE)+1)) {
pid = find_pid_from_cmdline(result->value);
if (pid > 0) {
{
int ret_code;
- _D("resourced cpu init start");
+ _D("[DEBUG] resourced cpu init start");
//ret_code = cgroup_make_subdir(CPUCG_PATH, "background", NULL);
ret_code = cgroup_make_full_subdir(CPUCG_PATH);
ret_value_msg_if(ret_code < 0, ret_code, "cpu cgroup init failed\n");
if (cpu_quota_enabled())
register_notifier(RESOURCED_NOTIFIER_APP_SUSPEND_READY,
cpu_restrict_state);
+
return RESOURCED_ERROR_NONE;
}
#include "dbus-handler.h"
#include "safe-kill.h"
-#define MEM_CONF_FILE RD_CONFIG_FILE(memory)
+#define MEM_CONF_FILE RD_CONFIG_FILE(limiter)
#define MEMLIMIT_CONFIG_SECTION "MemLimit"
#define MEMLIMIT_CONFIG_TRIGGER "MemLimitTrigger"
exec_cmd(ARRAY_SIZE(argv), argv);
}
-// make_memps_log(MEMLOG_MEMPS_MEMLIMIT, mlog->pid, mlog->appname);
+ make_memps_log(MEMLOG_MEMPS_MEMLIMIT, mlog->pid, mlog->appname);
return RESOURCED_ERROR_NONE;
}
#define MEMPS_EXEC_PATH "usr/bin/memps"
//#define MEMCG_MOVE_CHARGE_PATH "memory.move_charge_at_immigrate"
//#define MEMCG_EVENTFD_MEMORY_PRESSURE "memory.pressure_level"
-#define MEM_CONF_FILE RD_CONFIG_FILE(memory)
+#define MEM_CONF_FILE RD_CONFIG_FILE(limiter)
+#define MEM_SECTION "Memory"
#define MEM_VIP_SECTION "VIP_PROCESS"
#define MEM_VIP_PREDEFINE "PREDEFINE"
#define MEM_POPUP_SECTION "POPUP"
#define CGROUP_ROOT_64_THRES_LOW 8 /* MB */
#define CGROUP_ROOT_64_THRES_MEDIUM 5 /* MB */
#define CGROUP_ROOT_64_THRES_LEAVE 8 /* MB */
+#define CGROUP_ROOT_64_NUM_VICTIMS 1
/* thresholds for 256M RAM */
#define PROACTIVE_256_THRES 50 /* MB */
#define CGROUP_ROOT_256_THRES_LOW 20 /* MB */
#define CGROUP_ROOT_256_THRES_MEDIUM 10 /* MB */
#define CGROUP_ROOT_256_THRES_LEAVE 20 /* MB */
+#define CGROUP_ROOT_256_NUM_VICTIMS 2
/* threshold for 448M RAM */
-#define PROACTIVE_448_THRES 120 /* MB */
+#define PROACTIVE_448_THRES 80 /* MB */
#define PROACTIVE_448_LEAVE 100 /* MB */
-#define CGROUP_ROOT_448_THRES_DEDUP 60 /* MB */
+#define CGROUP_ROOT_448_THRES_DEDUP 120 /* MB */
#define CGROUP_ROOT_448_THRES_SWAP 100 /* MB */
-#define CGROUP_ROOT_448_THRES_LOW 50 /* MB */
-#define CGROUP_ROOT_448_THRES_MEDIUM 40 /* MB */
-#define CGROUP_ROOT_448_THRES_LEAVE 60 /* MB */
+#define CGROUP_ROOT_448_THRES_LOW 60 /* MB */
+#define CGROUP_ROOT_448_THRES_MEDIUM 50 /* MB */
+#define CGROUP_ROOT_448_THRES_LEAVE 70 /* MB */
+#define CGROUP_ROOT_448_NUM_VICTIMS 5
/* threshold for 512M RAM */
-#define PROACTIVE_512_THRES 80 /* MB */
-#define PROACTIVE_512_LEAVE 100 /* MB */
+#define PROACTIVE_512_THRES 100 /* MB */
+#define PROACTIVE_512_LEAVE 80 /* MB */
#define CGROUP_ROOT_512_THRES_DEDUP 140 /* MB */
#define CGROUP_ROOT_512_THRES_SWAP 100 /* MB */
-#define CGROUP_ROOT_512_THRES_LOW 50 /* MB */
-#define CGROUP_ROOT_512_THRES_MEDIUM 40 /* MB */
-#define CGROUP_ROOT_512_THRES_LEAVE 60 /* MB */
+#define CGROUP_ROOT_512_THRES_LOW 70 /* MB */
+#define CGROUP_ROOT_512_THRES_MEDIUM 60 /* MB */
+#define CGROUP_ROOT_512_THRES_LEAVE 80 /* MB */
+#define CGROUP_ROOT_512_NUM_VICTIMS 5
/* threshold for 768 RAM */
#define PROACTIVE_768_THRES 100 /* MB */
-#define PROACTIVE_768_LEAVE 120 /* MB */
+#define PROACTIVE_768_LEAVE 130 /* MB */
#define CGROUP_ROOT_768_THRES_DEDUP 180 /* MB */
#define CGROUP_ROOT_768_THRES_SWAP 150 /* MB */
-#define CGROUP_ROOT_768_THRES_LOW 100 /* MB */
-#define CGROUP_ROOT_768_THRES_MEDIUM 60 /* MB */
+#define CGROUP_ROOT_768_THRES_LOW 90 /* MB */
+#define CGROUP_ROOT_768_THRES_MEDIUM 80 /* MB */
#define CGROUP_ROOT_768_THRES_LEAVE 100 /* MB */
+#define CGROUP_ROOT_768_NUM_VICTIMS 5
/* threshold for more than 1024M RAM */
-#define PROACTIVE_1024_THRES 150 /* MB */
-#define PROACTIVE_1024_LEAVE 300 /* MB */
+#define PROACTIVE_1024_THRES 230 /* MB */
+#define PROACTIVE_1024_LEAVE 150 /* MB */
#define CGROUP_ROOT_1024_THRES_DEDUP 400 /* MB */
#define CGROUP_ROOT_1024_THRES_SWAP 300 /* MB */
-#define CGROUP_ROOT_1024_THRES_LOW 200 /* MB */
+#define CGROUP_ROOT_1024_THRES_LOW 120 /* MB */
#define CGROUP_ROOT_1024_THRES_MEDIUM 100 /* MB */
#define CGROUP_ROOT_1024_THRES_LEAVE 150 /* MB */
+#define CGROUP_ROOT_1024_NUM_VICTIMS 5
/* threshold for more than 2048M RAM */
#define PROACTIVE_2048_THRES 200 /* MB */
#define CGROUP_ROOT_2048_THRES_LOW 200 /* MB */
#define CGROUP_ROOT_2048_THRES_MEDIUM 160 /* MB */
#define CGROUP_ROOT_2048_THRES_LEAVE 300 /* MB */
+#define CGROUP_ROOT_2048_NUM_VICTIMS 10
/* threshold for more than 3072M RAM */
#define PROACTIVE_3072_THRES 300 /* MB */
#define PROACTIVE_3072_LEAVE 700 /* MB */
-#define CGROUP_ROOT_3072_THRES_DEDUP 500 /* MB */
-#define CGROUP_ROOT_3072_THRES_SWAP 400 /* MB */
-#define CGROUP_ROOT_3072_THRES_LOW 300 /* MB */
+#define CGROUP_ROOT_3072_THRES_DEDUP 600 /* MB */
+#define CGROUP_ROOT_3072_THRES_SWAP 500 /* MB */
+#define CGROUP_ROOT_3072_THRES_LOW 400 /* MB */
#define CGROUP_ROOT_3072_THRES_MEDIUM 250 /* MB */
-#define CGROUP_ROOT_3072_THRES_LEAVE 400 /* MB */
+#define CGROUP_ROOT_3072_THRES_LEAVE 500 /* MB */
+#define CGROUP_ROOT_3072_NUM_VICTIMS 10
static unsigned proactive_threshold;
static unsigned proactive_leave;
return RESOURCED_ERROR_FAIL;
}
-// if (!memps_log)
-// make_memps_log(MEMLOG_MEMPS, pid, appname);
+ if (!memps_log)
+ make_memps_log(MEMLOG_MEMPS, pid, appname);
// pai = find_app_info(pid);
lowmem_launch_oompopup();
oom_popup = true;
}
-// if (memps_log)
-// make_memps_log(MEMLOG_MEMPS, pid, appname);
+ if (memps_log)
+ make_memps_log(MEMLOG_MEMPS, pid, appname);
return RESOURCED_ERROR_NONE;
}
return should_be_freed;
}
-//static int lowmem_get_pids_proc(GArray *pids, bool add_app)
static int lowmem_get_pids_proc(GArray *pids)
{
DIR *dp;
if (pgid < 1)
continue;
- if(!is_app(pid))
+ if(is_app(pid) != 1)
continue;
if (proc_get_oom_score_adj(pid, &oom) < 0) {
* It can find malicious system process even though it has low oom score.
*/
if (start_oom == OOMADJ_SU)
- //lowmem_get_pids_proc(candidates, false);
lowmem_get_pids_proc(candidates);
if (start_oom <= OOMADJ_BACKGRD_LOCKED || start_oom >= OOMADJ_BACKGRD_OLD)
retry:
/* Prepare LMK to start doing it's job. Check preconditions. */
-// calualate_range_of_oom(lmk_type, &start_oom, &end_oom);
if (calculate_range_of_oom(cgroup_type, &start_oom, &end_oom))
goto done;
status = LOWMEM_RECLAIM_RETRY;
}
done:
- _I("[LMK] Done: killed %d processes reclaimed=%uMB remaining=%uMB shortfall=%uMB status=%s\n",
- count, total_size, reclaim_size, shortfall,
- convert_status_to_str(status));
+ _I("[LMK] Done: killed %d processes reclaimed=%uMB remaining=%uMB shortfall=%uMB status=%s",
+ count, total_size, reclaim_size, shortfall, convert_status_to_str(status));
+
/* After we finish reclaiming it's worth to remove oldest memps logs */
if (count && memlog_enabled)
request_helper_worker(CLEAR_LOGS, memlog_path, clear_logs, NULL);
return mem_state;
}
-static int load_vip_config(struct parse_result *result, void *user_data)
+static int vip_load_config(struct parse_result *result, void *user_data)
{
char *app_name;
if (!strcmp(result->name, MEM_VIP_PREDEFINE)) {
app_name = g_strdup(result->value);
+
+ /* check whether this app is already registered or not */
+ for (int vip_index = 0; vip_index < vip_apps->len; vip_index++) {
+ char *vip_name = g_ptr_array_index(vip_apps, vip_index);
+ if (!strncmp(vip_name, app_name, strlen(app_name) + 1))
+ return RESOURCED_ERROR_NONE;
+ }
+
g_ptr_array_add(vip_apps, (gpointer)app_name);
}
if (strncmp(result->section, MEM_BG_RECLAIM_SECTION, strlen(MEM_BG_RECLAIM_SECTION)+1))
return RESOURCED_ERROR_NONE;
+ else {
+ _I("[DEBUG] SECTION=%s", result->section);
+ }
if (!strncmp(result->name, MEM_BG_RECLAIM_STRING, strlen(MEM_BG_RECLAIM_STRING)+1)) {
if (!strncmp(result->value, "yes", strlen("yes")+1))
bg_reclaim = false;
}
- _I("Background reclaim enabled = %d", bg_reclaim);
return RESOURCED_ERROR_NONE;
}
-static int load_mem_config(struct parse_result *result, void *user_data)
+static int load_popup_config(struct parse_result *result, void *user_data)
{
if (!result)
return RESOURCED_ERROR_INVALID_PARAMETER;
if (strncmp(result->section, MEM_POPUP_SECTION, strlen(MEM_POPUP_SECTION)+1))
return RESOURCED_ERROR_NONE;
+ else {
+ _I("[DEBUG] SECTION=%s", result->section);
+ }
if (!strncmp(result->name, MEM_POPUP_STRING, strlen(MEM_POPUP_STRING)+1)) {
if (!strncmp(result->value, "yes", strlen("yes")+1))
- oom_popup_enable = 1;
+ oom_popup_enable = true;
else if (!strncmp(result->value, "no", strlen("no")+1))
- oom_popup_enable = 0;
+ oom_popup_enable = false;
}
- _I("oom_popup_enable = %d", oom_popup_enable);
return RESOURCED_ERROR_NONE;
}
-static int load_mem_logconfig(struct parse_result *result, void *user_data)
+static int load_mem_log_config(struct parse_result *result, void *user_data)
{
if (!result)
return RESOURCED_ERROR_INVALID_PARAMETER;
if (strncmp(result->section, MEM_LOGGING_SECTION, strlen(MEM_LOGGING_SECTION)+1))
return RESOURCED_ERROR_NONE;
+ else {
+ _I("[DEBUG] SECTION=%s", result->section);
+ }
if (!strncmp(result->name, "Enable", strlen("Enable")+1)) {
memlog_enabled = atoi(result->value);
return RESOURCED_ERROR_NONE;
}
-static int set_memory_config(const char *section_name, const struct parse_result *result)
+//static int set_memory_config(const char *section_name, const struct parse_result *result)
+static int set_memory_config(struct parse_result *result, void *user_data)
{
- if (!result || !section_name)
- return -EINVAL;
+// if (!result || !section_name)
+ if (!result)
+ return RESOURCED_ERROR_NONE;
- if (strncmp(result->section, "MemoryRatio", strlen("MemoryRatio")+1)
- && strncmp(result->section, section_name, strlen(section_name)+1))
+ if (strncmp(result->section, MEM_SECTION, strlen(MEM_SECTION)+1))
+// && strncmp(result->section, section_name, strlen(section_name)+1))
return RESOURCED_ERROR_NONE;
+ else {
+ _I("[DEBUG] SECTION=%s", result->section);
+ }
if (!strncmp(result->name, "ThresholdDedup", strlen("ThresholdDedup")+1)) {
int value = atoi(result->value);
int value = atoi(result->value);
num_max_victims = value;
/*
- * calculate number of kill victims between check memory available
- * depends on number of max kill victims
+ * calculate the number of victims to be killed between memory checks.
+ * this value depends on the number of max victims
*/
num_vict_between_check = value > MAX_MEMORY_CGROUP_VICTIMS/2
? 3 : value > MAX_MEMORY_CGROUP_VICTIMS/4
return RESOURCED_ERROR_NONE;
}
-static int memory_load_config(struct parse_result *result, void *user_data)
-{
- const char *section = (const char *) user_data;
-
- return set_memory_config(section, result);
-}
-
/* setup memcg parameters depending on total ram size. */
static void setup_memcg_params(void)
{
- int i;
unsigned long long total_ramsize = BYTE_TO_MBYTE(totalram);
- const char *section;
_D("Total: %llu MB", total_ramsize);
if (total_ramsize <= MEM_SIZE_64) {
memcg_set_threshold(CGROUP_ROOT, LOWMEM_LOW, CGROUP_ROOT_64_THRES_LOW);
memcg_set_threshold(CGROUP_ROOT, LOWMEM_MEDIUM, CGROUP_ROOT_64_THRES_MEDIUM);
memcg_set_leave_threshold(CGROUP_ROOT, CGROUP_ROOT_64_THRES_LEAVE);
- section = "Memory64";
+ num_max_victims = CGROUP_ROOT_64_NUM_VICTIMS;
} else if (total_ramsize <= MEM_SIZE_256) {
/* set thresholds for ram size 256M */
proactive_threshold = PROACTIVE_256_THRES;
memcg_set_threshold(CGROUP_ROOT, LOWMEM_LOW, CGROUP_ROOT_256_THRES_LOW);
memcg_set_threshold(CGROUP_ROOT, LOWMEM_MEDIUM, CGROUP_ROOT_256_THRES_MEDIUM);
memcg_set_leave_threshold(CGROUP_ROOT, CGROUP_ROOT_256_THRES_LEAVE);
- section = "Memory256";
+ num_max_victims = CGROUP_ROOT_256_NUM_VICTIMS;
} else if (total_ramsize <= MEM_SIZE_448) {
/* set thresholds for ram size 448M */
proactive_threshold = PROACTIVE_448_THRES;
memcg_set_threshold(CGROUP_ROOT, LOWMEM_LOW, CGROUP_ROOT_448_THRES_LOW);
memcg_set_threshold(CGROUP_ROOT, LOWMEM_MEDIUM, CGROUP_ROOT_448_THRES_MEDIUM);
memcg_set_leave_threshold(CGROUP_ROOT, CGROUP_ROOT_448_THRES_LEAVE);
- section = "Memory448";
+ num_max_victims = CGROUP_ROOT_448_NUM_VICTIMS;
} else if (total_ramsize <= MEM_SIZE_512) {
/* set thresholds for ram size 512M */
proactive_threshold = PROACTIVE_512_THRES;
memcg_set_threshold(CGROUP_ROOT, LOWMEM_LOW, CGROUP_ROOT_512_THRES_LOW);
memcg_set_threshold(CGROUP_ROOT, LOWMEM_MEDIUM, CGROUP_ROOT_512_THRES_MEDIUM);
memcg_set_leave_threshold(CGROUP_ROOT, CGROUP_ROOT_512_THRES_LEAVE);
- section = "Memory512";
+ num_max_victims = CGROUP_ROOT_512_NUM_VICTIMS;
} else if (total_ramsize <= MEM_SIZE_768) {
/* set thresholds for ram size 512M */
proactive_threshold = PROACTIVE_768_THRES;
memcg_set_threshold(CGROUP_ROOT, LOWMEM_LOW, CGROUP_ROOT_768_THRES_LOW);
memcg_set_threshold(CGROUP_ROOT, LOWMEM_MEDIUM, CGROUP_ROOT_768_THRES_MEDIUM);
memcg_set_leave_threshold(CGROUP_ROOT, CGROUP_ROOT_768_THRES_LEAVE);
- section = "Memory768";
+ num_max_victims = CGROUP_ROOT_768_NUM_VICTIMS;
} else if (total_ramsize <= MEM_SIZE_1024) {
/* set thresholds for ram size more than 1G */
proactive_threshold = PROACTIVE_1024_THRES;
memcg_set_threshold(CGROUP_ROOT, LOWMEM_LOW, CGROUP_ROOT_1024_THRES_LOW);
memcg_set_threshold(CGROUP_ROOT, LOWMEM_MEDIUM, CGROUP_ROOT_1024_THRES_MEDIUM);
memcg_set_leave_threshold(CGROUP_ROOT, CGROUP_ROOT_1024_THRES_LEAVE);
- section = "Memory1024";
+ num_max_victims = CGROUP_ROOT_1024_NUM_VICTIMS;
} else if (total_ramsize <= MEM_SIZE_2048) {
proactive_threshold = PROACTIVE_2048_THRES;
proactive_leave = PROACTIVE_2048_LEAVE;
memcg_set_threshold(CGROUP_ROOT, LOWMEM_LOW, CGROUP_ROOT_2048_THRES_LOW);
memcg_set_threshold(CGROUP_ROOT, LOWMEM_MEDIUM, CGROUP_ROOT_2048_THRES_MEDIUM);
memcg_set_leave_threshold(CGROUP_ROOT, CGROUP_ROOT_2048_THRES_LEAVE);
- section = "Memory2048";
+ num_max_victims = CGROUP_ROOT_2048_NUM_VICTIMS;
} else {
proactive_threshold = PROACTIVE_3072_THRES;
proactive_leave = PROACTIVE_3072_LEAVE;
memcg_set_threshold(CGROUP_ROOT, LOWMEM_LOW, CGROUP_ROOT_3072_THRES_LOW);
memcg_set_threshold(CGROUP_ROOT, LOWMEM_MEDIUM, CGROUP_ROOT_3072_THRES_MEDIUM);
memcg_set_leave_threshold(CGROUP_ROOT, CGROUP_ROOT_3072_THRES_LEAVE);
- section = "Memory3072";
+ num_max_victims = CGROUP_ROOT_3072_NUM_VICTIMS;
}
- config_parse(MEM_CONF_FILE, memory_load_config, (void *)section);
-
- for (i = 0; i < LOWMEM_MAX_LEVEL; i++)
- _I("set threshold for state '%s' to %u MB", convert_memstate_to_str(i), get_root_memcg_info()->threshold[i]);
-
- _I("set number of max victims as %d", num_max_victims);
- _I("set threshold leave to %u MB", get_root_memcg_info()->threshold_leave);
- _I("set proactive threshold to %u MB", proactive_threshold);
- _I("set proactive low memory killer leave to %u MB", proactive_leave);
}
/*static void init_memcg_params(void)
for (vip_index = 0; vip_index < vip_apps->len; vip_index++) {
vip_name = g_ptr_array_index(vip_apps, vip_index);
- if (strncmp(vip_name, proc_name, strlen(proc_name)))
+ if (strncmp(vip_name, proc_name, strlen(proc_name) + 1))
continue;
if (pid > 0) {
}
}
+static void load_configs(const char *path)
+{
+ _I("[DEBUG] path=%s", path);
+
+ if (config_parse(path, set_memory_config, NULL))
+ _E("[DEBUG] (%s-mem) parse Fail", path);
+
+ if (config_parse(path, load_popup_config, NULL))
+ _E("[DEBUG] (%s-popup) parse Fail", path);
+
+ if (config_parse(path, load_bg_reclaim_config, NULL))
+ _E("[DEBUG] (%s-bg-reclaim) parse Fail", path);
+
+ if (config_parse(path, load_mem_log_config, NULL))
+ _E("[DEBUG] (%s-mem-log) parse Fail", path);
+
+ if (config_parse(path, vip_load_config, NULL))
+ _E("[DEBUG] (%s-vip) parse Fail", path);
+}
+
+static void load_per_vendor_configs(void)
+{
+ int count;
+ int idx;
+ struct dirent **namelist;
+
+ if ((count = scandir(CGROUP_VIP_LIST_DIR, &namelist, NULL, alphasort)) == -1) {
+ _W("[DEBUG] failed to opendir (%s)", CGROUP_VIP_LIST_DIR);
+ return;
+ }
+
+ for (idx = 0; idx < count; idx++) {
+ char path[PATH_MAX] = {0, };
+
+ if (!strstr(namelist[idx]->d_name, CGROUP_VIP_CONF_SUFFIX))
+ continue;
+
+ snprintf(path, sizeof(path), "%s/%s", CGROUP_VIP_LIST_DIR, namelist[idx]->d_name);
+ load_configs(path);
+ free(namelist[idx]);
+ }
+
+ free(namelist);
+}
+
+static void print_mem_configs(void)
+{
+ /* print info of Memory section */
+ for (int mem_lvl = 0; mem_lvl < LOWMEM_MAX_LEVEL; mem_lvl++)
+ _I("[DEBUG] set threshold for state '%s' to %u MB",
+ convert_memstate_to_str(mem_lvl), get_root_memcg_info()->threshold[mem_lvl]);
+
+ _I("[DEBUG] set number of max victims as %d", num_max_victims);
+ _I("[DEBUG] set threshold leave to %u MB", get_root_memcg_info()->threshold_leave);
+ _I("[DEBUG] set proactive threshold to %u MB", proactive_threshold);
+ _I("[DEBUG] set proactive low memory killer leave to %u MB", proactive_leave);
+
+ /* print info of POPUP section */
+ _I("[DEBUG] oom popup is %s", oom_popup_enable == true ? "enabled" : "disabled");
+
+ /* print info of BackgroundReclaim section */
+ _I("[DEBUG] Background reclaim is %s", bg_reclaim == true ? "enabled" : "disabled");
+
+ /* print info of Logging section */
+ _I("[DEBUG] memory logging is %s", memlog_enabled == 1 ? "enabled" : "disabled");
+ _I("[DEBUG] memory logging path is %s", memlog_path);
+ _I("[DEBUG] the max number of memory logging is %d", memlog_nr_max);
+ _I("[DEBUG] the batch threshold of memory log is %d", memlog_remove_batch_thres);
+ _I("[DEBUG] prefix of memps is %s", memlog_prefix[MEMLOG_MEMPS]);
+ _I("[DEBUG] prefix of memlimit memps is %s", memlog_prefix[MEMLOG_MEMPS_MEMLIMIT]);
+
+ /* print info of VIP_PROCESS section */
+ _I("[DEBUG] vip app list is");
+ for (int vip_index = 0; vip_index < vip_apps->len; vip_index++) {
+ char *vip_name = g_ptr_array_index(vip_apps, vip_index);
+ _I("\t[DEBUG] %s", vip_name);
+ }
+}
+
/* To Do: should we need lowmem_fd_start, lowmem_fd_stop ?? */
static int lowmem_init(void)
{
int ret = RESOURCED_ERROR_NONE;
_D("resourced memory init start");
+
+ /* init memcg */
ret = cgroup_make_full_subdir(MEMCG_PATH);
ret_value_msg_if(ret < 0, ret, "memory cgroup init failed\n");
memcg_params_init();
+ setup_memcg_params();
get_total_memory();
- setup_memcg_params();
+
+ /* allocate vip list memory */
if (allocate_vip_app_list() != RESOURCED_ERROR_NONE)
_E("allocate_vip_app_list FAIL");
- if (config_parse(MEM_CONF_FILE, load_vip_config, NULL))
- _E("(%s) parse Fail", MEM_CONF_FILE);
+ /* default configuration */
+ load_configs(MEM_CONF_FILE);
+ /* parse /etc/resourced/limiter.conf.d/xxx configurations*/
+ load_per_vendor_configs();
+ print_mem_configs();
+ /* vip_list is only needed at the set_vip_list */
if (set_vip_list() != RESOURCED_ERROR_NONE)
_E("set_vip_list FAIL");
-
- /* vip_list is only needed at the set_vip_list */
free_vip_app_list();
- config_parse(MEM_CONF_FILE, load_mem_config, NULL);
- config_parse(MEM_CONF_FILE, load_bg_reclaim_config, NULL);
- config_parse(MEM_CONF_FILE, load_mem_logconfig, NULL);
+ /* this function should be called after parsing configurations */
memcg_write_params();
+ /* make a worker thread called low memory killer */
ret = lowmem_activate_worker();
if (ret) {
_E("oom thread create failed\n");
bool supported;
ret = system_info_get_platform_bool("tizen.org/feature/battery", &supported);
- if (ret != SYSTEM_INFO_ERROR_NONE || !supported)
+ if (ret != SYSTEM_INFO_ERROR_NONE || !supported) {
return RESOURCED_ERROR_NOTIMPL;
+ }
ret = heart_battery_stats_init_db();
if (ret != RESOURCED_ERROR_NONE) {
DEVICED_INTERFACE_BATTERY, GET_BATTERY_CAPACITY,
heart_battery_capacity_status, NULL);
if (ret < 0)
- _E("Failed to add a capacity status signal handler");
+ _E("heart module failed to add a capacity status signal handler");
ret = d_bus_register_signal(DEVICED_PATH_BATTERY,
DEVICED_INTERFACE_BATTERY, GET_CHARGER_STATUS,
heart_battery_charger_status, NULL);
if (ret < 0)
- _E("Failed to add a charger status signal handler");
+ _E("heart module failed to add a charger status signal handler");
heart_read_battery_total_capacity();
config_parse(HEART_CONF_FILE_PATH, heart_battery_config, NULL);
+ _I("heart config init");
+
heart_battery_mode_factor_init();
if (module->init)
ret = module->init(data);
if (ret != RESOURCED_ERROR_NONE)
- _E("Fail to initialize [HEART-%s] module\n", module->name);
+ _W("Fail to initialize [HEART-%s] module\n", module->name);
}
}
extern "C" {
#endif /* __cplusplus */
-#define HEART_CONF_FILE_PATH RD_CONFIG_FILE(heart)
+#define HEART_CONF_FILE_PATH RD_CONFIG_FILE(monitor)
#define HEART_FILE_PATH RD_SYS_DATA"/heart"
#define HEART_USER_FILE_PATH "%s/data/heart"
#define HEART_CONF_SECTION "HEART"
#define ZONE_MAX_NR 4
#define PROC_COMPACT_ENTRY "/proc/sys/vm/compact_memory"
-#define MEM_CONF_FILE RD_CONFIG_FILE(memory)
+#define COMPACT_CONF_FILE RD_CONFIG_FILE(optimizer)
#define COMPACT_CONFIG_SECTION "Compaction"
#define COMPACT_CONFIG_ENABLE "CompactEnable"
char *e = NULL;
/* Single config section is expected */
- if (!result->section || strcmp(COMPACT_CONFIG_SECTION, result->section))
+ if (!result->section ||
+ strncmp(result->section, COMPACT_CONFIG_SECTION, strlen(COMPACT_CONFIG_SECTION)+1))
return RESOURCED_ERROR_NONE;
if (!result->name || !result->value)
struct compact_control *compact;
int result = RESOURCED_ERROR_OUT_OF_MEMORY;
+ _I("[DEBUG] compact init");
+
pthread_mutex_lock(&compact_data.drained_lock);
if (compact_data.compact) {
- _E("Unbalanced calls to compact module load/unload\n");
+ _E("[DEBUG] Unbalanced calls to compact module load/unload\n");
result = RESOURCED_ERROR_NONE;
goto leave;
}
result = pthread_mutex_init(&compact->lock, NULL);
if (result) {
- _E("Failed to init compact lock: %m");
+ _E("[DEBUG] Failed to init compact lock: %m");
goto cleanup_all;
}
/* Load configuration */
- config_parse(MEM_CONF_FILE, compact_config_parse,
+ config_parse(COMPACT_CONF_FILE, compact_config_parse,
compact);
if (compact->status & COMPACT_SKIP) {
- _I("Compaction module disabled.");
+ _I("[DEBUG] Compaction module disabled.");
result = RESOURCED_ERROR_FAIL;
goto cleanup_all;
}
static int dedup_scanning_once(enum ksm_scan_mode mode)
{
int ret;
- _D("[DEDUP] Invoke scanning once to KSM (mode: %d)", mode);
+ _D("[DEBUG] Invoke scanning once to KSM (mode: %d)", mode);
ret = dedup_check_and_scanning_once(mode);
return ret;
}
if (mode != KSM_SCAN_NONE) {
- _I("[DEDUP] dedup: %d-th %s deduplication triggering", nr_dedup++,
+ _I("[DEBUG] dedup: %d-th %s deduplication triggering", nr_dedup++,
(mode == KSM_SCAN_FULL ? "FULL" : "PARTIAL"));
if (!dedup_on_lowmem) {
dedup_scanning_once(KSM_SCAN_FULL);
static gboolean dedup_activate_timer_cb(gpointer data)
{
dedup_activating_timer = NULL;
- _D("[DEDUP] dedup activating callback called");
+ _D("[DEBUG] dedup activating callback called");
dedup_activate_in_module();
return false;
}
if (dedup_at_boot_enable) {
/* if dedup_at_boot_enable is disabled,
* other daemon should activate dedup */
- _D("[DEDUP] dedup booting done is called");
+ _D("[DEBUG] dedup booting done is called");
if (dedup_at_boot_delay > 0)
dedup_activating_timer =
g_timeout_source_new_seconds(dedup_at_boot_delay);
if (val >= dedup_param_ranges[ltype][0] &&
val < dedup_param_ranges[ltype][1]) {
*var = val;
- _I("Success to parse parameters, val: %d of %s in %s section",
+ _I("[DEBUG] Success to parse parameters, val: %d of %s in %s section",
val, lvalue, section);
} else
- _E("Failed to parse parameters, ignoring: %s of %s in %s section",
+ _E("[DEBUG] Failed to parse parameters, ignoring: %s of %s in %s section",
rvalue, lvalue, section);
} else if (!strncmp(section, KSM_SECTION, sizeof(KSM_SECTION))) {
if (val >= ksm_param_ranges[ltype][0] &&
val < ksm_param_ranges[ltype][1]) {
*var = val;
- _I("Success to parse parameters, val: %d of %s in %s section",
+ _I("[DEBUG] Success to parse parameters, val: %d of %s in %s section",
val, lvalue, section);
} else
- _E("Failed to parse parameters, ignoring: %s of %s in %s section",
+ _E("[DEBUG] Failed to parse parameters, ignoring: %s of %s in %s section",
rvalue, lvalue, section);
} else
- _E("Unknown section: %s", section);
+ _E("[DEBUG] Unknown section: %s", section);
return 0;
}
ret = config_parse_new(DEDUP_CONF_FILE, (void*) items);
if (ret < 0) {
- _E("Failed to parse configuration file: %d", ret);
+ _E("[DEBUG] Failed to parse configuration file: %d", ret);
return ret;
}
+ _I("[DEBUG] dedup init");
+
ksm_params[KSM_PARAM_PAGES_TO_SCAN] = arg_ksm_pages_to_scan;
ksm_params[KSM_PARAM_SLEEP_MSECS] = arg_ksm_sleep;
ksm_params[KSM_PARAM_FULL_SCAN_INTERVAL] = arg_ksm_full_scan_interval;
dedup_partial_scan_interval /= 1000;
dedup_full_scan_interval /= 1000;
- _I("[DEDUP] deduplication mode: %s", dedup_mode == DEDUP_MODE_PERIODIC ?
+ _I("[DEBUG] deduplication mode: %s", dedup_mode == DEDUP_MODE_PERIODIC ?
"kernel-managed" : "resourced-triggered");
- _I("[DEDUP] deduplication on boot: %s", dedup_at_boot_enable ? "true" : "false");
- _I("[DEDUP] scanning is invoked by %s", dedup_on_lowmem ?
+ _I("[DEBUG] deduplication on boot: %s", dedup_at_boot_enable ? "true" : "false");
+ _I("[DEBUG] scanning is invoked by %s", dedup_on_lowmem ?
"LOWMEM event" : "periodic timer");
- _I("[DEDUP] full scan interval: %d sec", dedup_full_scan_interval);
+ _I("[DEBUG] full scan interval: %d sec", dedup_full_scan_interval);
_I("stat monitoring interval: %d sec", dedup_stat_interval);
- _I("[DEDUP] ksm pages to scan: %d", arg_ksm_pages_to_scan);
- _I("[DEDUP] ksm sleep time: %d", arg_ksm_sleep);
- _I("[DEDUP] ksm full scan interval: %d", arg_ksm_full_scan_interval);
- _I("[DEDUP] ksm scan boost: %d", arg_ksm_scan_boost);
+ _I("[DEBUG] ksm pages to scan: %d", arg_ksm_pages_to_scan);
+ _I("[DEBUG] ksm sleep time: %d", arg_ksm_sleep);
+ _I("[DEBUG] ksm full scan interval: %d", arg_ksm_full_scan_interval);
+ _I("[DEBUG] ksm scan boost: %d", arg_ksm_scan_boost);
return 0;
}
* Check whether CONFIG_LKSM is enabled in kernel.
*/
if (access("/sys/kernel/mm/ksm/run", R_OK) != 0) {
- _E("the kernel don't support KSM, please check kernel configuration");
+ _W("the kernel don't support KSM, please check kernel configuration");
return -ENOENT;
}
if (access("/sys/kernel/mm/ksm/one_shot_scanning", R_OK) != 0) {
- _E("the kernel support KSM but not LKSM, please check kernel configuration");
+ _W("the kernel support KSM but not LKSM, please check kernel configuration");
return -ENOENT;
}
r = config_parse_new(SWAP_CONF_FILE, (void*) items);
if (r < 0) {
- _E("Failed to parse configuration file: %m");
+ _E("[DEBUG] Failed to parse configuration file: %m");
return r;
}
if (algorithm)
strncpy(zram_control.comp_algorithm, algorithm, MAX_TYPE_LENGTH - 1);
+ _I("[DEBUG] algorithm=%s, ratio=%f", algorithm, zram_control.ratio);
+
return 0;
}