platform/core/system/resourced.git
5 years agoDBus helpers: say more about the error 83/205583/4
Michal Bloch [Tue, 7 May 2019 15:57:11 +0000 (17:57 +0200)]
DBus helpers: say more about the error

Change-Id: Id340067a830b70959c650b24dc76c838f313bb74
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
5 years agoDBus helpers: add a version accepting GVariant 82/205582/3
Michal Bloch [Tue, 7 May 2019 13:49:04 +0000 (15:49 +0200)]
DBus helpers: add a version accepting GVariant

This allows passing parameter packs more complex than `append_variant`
can produce. This commit just introduces this interface without making
any functions actually use it yet.

Change-Id: If0b3e3ae16913fde11df637ffd59842edaa7cf53
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
5 years agoReclaim at boot now controllable from the config 25/204825/4
Michal Bloch [Fri, 26 Apr 2019 14:59:40 +0000 (16:59 +0200)]
Reclaim at boot now controllable from the config

Introduce two new config fields to `swap.conf`:
 * `ReclaimAtBoot` controls whether this behaviour happens at all (bool)
 * `TimerReclaimAtBoot` controls how long (in seconds) to wait
   until the reclaim happens after booting is done (int)

The feature is now disabled by default.
When enabled, the default timer is still 60s.

Change-Id: I5008248541169156070b3c24fdd7b275e39b8f56
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
5 years agoMerge "tests: change core_pattern to /dev/null temporarily" into tizen
Karol Lewandowski [Mon, 25 Mar 2019 12:30:33 +0000 (12:30 +0000)]
Merge "tests: change core_pattern to /dev/null temporarily" into tizen

5 years agoMerge "Add author's commentary to ade9c91f8b" into tizen
Karol Lewandowski [Mon, 25 Mar 2019 12:23:40 +0000 (12:23 +0000)]
Merge "Add author's commentary to ade9c91f8b" into tizen

5 years agofind . -name "*.c" -exec chmod -x {} ; 99/201799/1
Michal Bloch [Tue, 19 Mar 2019 12:55:29 +0000 (13:55 +0100)]
find . -name "*.c" -exec chmod -x {} ;

Change-Id: I590deb0dda83094a3825bc9bf3d20d876c196059
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
5 years agotests: change core_pattern to /dev/null temporarily 27/200827/2
Łukasz Stelmach [Mon, 4 Mar 2019 15:31:02 +0000 (16:31 +0100)]
tests: change core_pattern to /dev/null temporarily

Change coredump handler temporarily to avoid timeouts due to lengthy
core processing.

Change-Id: I516f88fd65c18535e15117b6864424ccc1d71b5b
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
5 years agoAdd author's commentary to ade9c91f8b 24/200824/1
swift.kim [Mon, 4 Mar 2019 13:37:06 +0000 (14:37 +0100)]
Add author's commentary to ade9c91f8b

Change-Id: Idb9eb462fcdb5e929630ffb1e4956f84fe918dac

5 years agotests: Add watchdog test 09/200709/7 accepted/tizen/unified/20190307.231005 submit/tizen/20190301.133444
Łukasz Stelmach [Wed, 27 Feb 2019 13:23:49 +0000 (14:23 +0100)]
tests: Add watchdog test

Add .editorconfig too by the way

Change-Id: If2722c9ac0a4b9e39a986620dc91cfb187ecf154
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
5 years agowatchdog: Check types of parameters explicitly 82/200382/4
Łukasz Stelmach [Thu, 21 Feb 2019 18:43:24 +0000 (19:43 +0100)]
watchdog: Check types of parameters explicitly

Change-Id: Ie8e307c6f1628e481543ad90535fcb99b530c419
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
5 years agowatchdog: DBus method handler need to return a message 81/200381/4
Łukasz Stelmach [Thu, 21 Feb 2019 18:20:00 +0000 (19:20 +0100)]
watchdog: DBus method handler need to return a message

A DBus method handler needs to send a return message to a caller even
if the message is empty.

Change-Id: I037c3d4da8f3810f769fa5bc9ab830fbe9f3ce5e
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
5 years agowatchdog: Do not check message signature 80/200380/3
Łukasz Stelmach [Thu, 21 Feb 2019 18:04:26 +0000 (19:04 +0100)]
watchdog: Do not check message signature

There is no need to check parameter types, because glib handles it before
calling a handler.

Change-Id: I930809d05205ddc00aa3fe5d8bb156108004f754
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
5 years agolowmem: Add an option to activate background reclaim 32/200432/2
swift.kim [Fri, 22 Feb 2019 09:35:14 +0000 (18:35 +0900)]
lowmem: Add an option to activate background reclaim

An option is added to conf to proactively reclaim the background
memory usage when the device screen goes dim.

Change-Id: I97f39c2be4938e6c2e0f7bddc608aaf0393d0ae2

5 years agolowmem: A new cgroup for bg-locked processes 31/200431/2
swift.kim [Fri, 22 Feb 2019 08:13:28 +0000 (17:13 +0900)]
lowmem: A new cgroup for bg-locked processes

Some long-lived processes such as background-locked or favorite apps
were not previously under proper control of LMK or swap. Some devices
with a number of such apps run in background (e.g. a wearable device
with home screen widgets) might not perform efficiently with respect
to memory they use. Thus we want to give lowmem a little chance to do
something more with processes in this separate memcg.

Change-Id: I1c59fa749688f283fc5f7d6a49d22c7e3c1d8b10

5 years agoproc-stat: Initialize pai earlier than proc_set_oom_score_adj 30/200430/2
swift.kim [Fri, 22 Feb 2019 07:55:26 +0000 (16:55 +0900)]
proc-stat: Initialize pai earlier than proc_set_oom_score_adj

pai structure has first to be initialized before oom score to take
any effect.

Change-Id: Ie58a9e0e17e2074479cb077f882eb0ee165ca7df

5 years agoswap: Fix typo and clean up 29/200429/2
swift.kim [Fri, 22 Feb 2019 06:42:20 +0000 (15:42 +0900)]
swap: Fix typo and clean up

- Typos (e.g. MODLE, RECLIAM)
- Misleading notifier handler (swap_activate_handler instead of swap_booting_done)

Change-Id: I087ecbaf199c5414084e8648cb3ac9ef363d4c7d

5 years agopackaging: Bump version 50/200050/1 accepted/tizen/unified/20190218.163125 submit/tizen/20190218.104917
Karol Lewandowski [Mon, 18 Feb 2019 10:41:54 +0000 (11:41 +0100)]
packaging: Bump version

Let the version follow target tizen release.

Change-Id: I97cc5e6c1c92300f8cd5c4d0dbb19fe1c3dd388b

5 years agocommon: Fix logic error in g_variant_is_of_type() 49/200049/1
Karol Lewandowski [Mon, 18 Feb 2019 10:34:58 +0000 (11:34 +0100)]
common: Fix logic error in g_variant_is_of_type()

Change-Id: I93fa5444993daa71ee5eb55a4c8377171b1d786c

5 years agocommon: file-helper: Remove unused code 11/199811/4 submit/tizen/20190215.113808
Karol Lewandowski [Thu, 14 Feb 2019 14:34:10 +0000 (15:34 +0100)]
common: file-helper: Remove unused code

Change-Id: Id0728f6acf74bd71289cf185f3ab165274b0d5f3

5 years agomemory: Add D-Bus type checking to remaining handlers 17/199717/6
Karol Lewandowski [Thu, 14 Feb 2019 08:18:36 +0000 (09:18 +0100)]
memory: Add D-Bus type checking to remaining handlers

Change-Id: I5db0d57456965f008e45357bbbba4c8e28632ee6

5 years agomemory: Unify D-Bus PID type to be always int32 32/199132/6
Karol Lewandowski [Mon, 4 Feb 2019 15:26:41 +0000 (16:26 +0100)]
memory: Unify D-Bus PID type to be always int32

This commit changes following two D-Bus signal signatures to expect
PID argument as int32 type, not as uint32:

 - "SetPerceptible" (u) -> (i)
 - "SetPlatformSwap" (u) -> (i)

The reason for the change is following:

 - Different signal handlers in memory module use different type
   for PID argument (eg. "SetMemLimit" uses (i), "SetPerceptible"
   and "SetPlatformSwap" use (u))

 - PID is already of int32 type in the most of resourced D-Bus
   functions

 - Listed functions already use int32 in selected Tizen Product
   forks (Mobile)

Note: The type is not compatible with D-Bus' spec GetUnixProcessID
      (which expects uint32).  Int32 PID is Tizen's system's specific.

Change-Id: I428a75bd4a61a75ad1e4c8684aa32e1c3ed716ad

5 years agocommon: Add helper macros for D-Bus handlers 08/199808/3
Karol Lewandowski [Thu, 14 Feb 2019 13:45:36 +0000 (14:45 +0100)]
common: Add helper macros for D-Bus handlers

Change-Id: Ic1364f9f26db759ac1a8949410d2a97303950d78

5 years agocommon: Remove unused macros 07/199807/3
Karol Lewandowski [Thu, 14 Feb 2019 12:44:07 +0000 (13:44 +0100)]
common: Remove unused macros

Change-Id: Ic72bd40be1423875e3f1a7f449a167b7ffd5a266

5 years agoRemove a proc_app_info structure allocated during prelaunch 75/192775/3
Łukasz Stelmach [Fri, 9 Nov 2018 08:26:50 +0000 (09:26 +0100)]
Remove a proc_app_info structure allocated during prelaunch

A proc_app_info structure allocated during prelaunch request needs not
only to be freed, but also removed from appropriate lists to prevent
use-after-free errors.

Change-Id: I5473682603a7700d8d6a23553924e9e1b0d594fa
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
5 years agoswap: FIX Do not setup swap after resourced restart 87/199087/1 accepted/tizen/unified/20190213.071904 submit/tizen/20190212.103739
Konrad Kuchciak [Fri, 1 Feb 2019 12:13:37 +0000 (13:13 +0100)]
swap: FIX Do not setup swap after resourced restart

Change-Id: I1aa3bdf1ab5b2781238b3830389dccf7599e081a
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
5 years agoproc: Remove support for unused Signal and WatchdogResult messages 00/197800/2 submit/tizen/20190131.154945
Łukasz Stelmach [Wed, 16 Jan 2019 09:34:26 +0000 (10:34 +0100)]
proc: Remove support for unused Signal and WatchdogResult messages

Change-Id: I7afc7650c92b205396f108fa19f6fe06343ec686
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
5 years agoproc: introduce watchdog handler 02/197702/2
ByungSoo Kim [Mon, 6 Aug 2018 11:01:10 +0000 (20:01 +0900)]
proc: introduce watchdog handler

It is new management to trigger watchdog.
Anyone sends dbus signal to register, start and stop the watchdog.
Resourced will make the watchdog timer with gslist.
And it also considers freezer, device suspend and application lifecycle.

Change-Id: Ib9bae3e02e7d156505e10835b8bb7ce3a3932f9a
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
5 years agoFix SVACE issue 54/198454/1 submit/tizen/20190124.153144
Łukasz Stelmach [Thu, 24 Jan 2019 14:07:19 +0000 (15:07 +0100)]
Fix SVACE issue

Reported issue:

    Pointer 'heart_db', which was assigned NULL value at heart-memory.c:415,
    is dereferenced at heart-memory.c:483 by calling function
    'sqlite3_prepare_v2'.

Make logging_get_default_db() return a db handle via the second argument.

Change-Id: I3d1e107674143a748c30caa01b13c7dbe56fb06b
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
5 years agoFix paths in commit a37205f1 85/198085/1 accepted/tizen/unified/20190128.061303 accepted/tizen/unified/20190128.061517 submit/tizen/20190118.112553 submit/tizen/20190122.115159
Łukasz Stelmach [Fri, 18 Jan 2019 10:00:48 +0000 (11:00 +0100)]
Fix paths in commit a37205f1

Change-Id: I62027d088b35d303b84a6b060a91dd714e9725b9
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
5 years agoFix SVACE issue 91/197991/1 submit/tizen/20190117.123423
Łukasz Stelmach [Thu, 17 Jan 2019 10:53:53 +0000 (11:53 +0100)]
Fix SVACE issue

Reported issue:

    Return value 'return value of lowmem_press_eventfd_read(...)' of
    a function 'lowmem_press_eventfd_read' called at
    vmpressure-lowmem-handler.c:1791 is not checked. The return value
    was got from function 'read' and it may indicate error code.

Reading from an eventfd does not fail unless the buffer is too small. The
return value can be ignored.

Change-Id: If3ec72efb7d17049b1eaed18761ed0d8cc6853bb
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
5 years agoFix a potential unterminated string. 25/196825/1
Michal Bloch [Fri, 4 Jan 2019 14:14:12 +0000 (15:14 +0100)]
Fix a potential unterminated string.

Change-Id: Ied0aa33284c3b424707f62cd4aea30df506c89b0
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
5 years agoThe swap module requires mkswap(8) and dd(1) to set up swap properly 05/196005/1
Łukasz Stelmach [Thu, 20 Dec 2018 12:50:59 +0000 (13:50 +0100)]
The swap module requires mkswap(8) and dd(1) to set up swap properly

Change-Id: Ia650d3f523b00c21a5436a84ecf31caff1fd1a07

5 years agoFix log message formatting strings to strictly format printf(3) requirements 72/194872/2 accepted/tizen/unified/20181211.141124 submit/tizen/20181210.110223
Łukasz Stelmach [Fri, 7 Dec 2018 14:09:03 +0000 (15:09 +0100)]
Fix log message formatting strings to strictly format printf(3) requirements

Change-Id: I72d78ffe5e1de46f7a839987ad6aeefc3b3f9584
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
6 years agoswap: Do not set the limit for empty cgroups 77/191977/1
Łukasz Stelmach [Mon, 22 Oct 2018 13:18:54 +0000 (15:18 +0200)]
swap: Do not set the limit for empty cgroups

When a cgroup is empty the limit is set to 0, which disables adding any
processes to the group. Such situations need to be avoided.

Change-Id: I0a49ecc9df131da306154fac485360d45c4c6383

6 years agoMerge "Allow requests to synchronise CPU usage history" into tizen
Karol Lewandowski [Wed, 17 Oct 2018 07:06:37 +0000 (07:06 +0000)]
Merge "Allow requests to synchronise CPU usage history" into tizen

6 years agoMerge "policy: Do not deny delivery of signals" into tizen
Karol Lewandowski [Wed, 17 Oct 2018 07:06:19 +0000 (07:06 +0000)]
Merge "policy: Do not deny delivery of signals" into tizen

6 years agoAllow requests to synchronise CPU usage history 10/191410/1
Łukasz Stelmach [Tue, 16 Oct 2018 15:46:32 +0000 (17:46 +0200)]
Allow requests to synchronise CPU usage history

Change-Id: Id34e6df068a4e078f64999c7c9153897daf80b7c

6 years agoswap: Do not setup swap after resourced restart 92/189992/1
Paweł Szewczyk [Tue, 25 Sep 2018 15:12:55 +0000 (17:12 +0200)]
swap: Do not setup swap after resourced restart

To avoid reconfiguration and possible loss of swapped data, or setting
up multiple swap devices, we assume that swap is configured after boot
and survive resourced restarts.
The side effect is that for change of swap configuration a reboot is
needed.

Change-Id: I874be98ed2a491ce932202987ae99113aa2519c0
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agoswap: match zswap parameters of kernel node 16/187516/6 submit/tizen/20180925.081123 submit/tizen/20181008.080213
ByungSoo Kim [Tue, 10 Apr 2018 12:33:57 +0000 (21:33 +0900)]
swap: match zswap parameters of kernel node

zswap has four parameter values such as zpool, enabled, max_pool_percent and compressor.
When resourced wants to enable zswap in swap.conf,
some values should be set in sysfs node of zswap.

Change-Id: I9d8fd3cab056b949bad11a8dc4459e2ee06c7954
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agoswap: add delay about early swap 15/187515/5
Donghwan Jeong [Fri, 18 Aug 2017 08:19:47 +0000 (17:19 +0900)]
swap: add delay about early swap

Previously, resourced swapped system memory as soon as system session was finished.
It is while initializing both system and user session processes.
So this point makes a sluggish issue during running application.
It is necessary to add delay after initializing swap.

Change-Id: Icc32cdc167670a10c1ed7d42ccd16efc5fc64a1c
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agoswap: trigger swap LMK when only available memory is short 14/187514/5
Donghwan Jeong [Fri, 18 Aug 2017 08:19:20 +0000 (17:19 +0900)]
swap: trigger swap LMK when only available memory is short

There were frequent swap LMK logs in the device.
When swap was full, swap triggered LMK very often even though there was enough available memory.
It is because swap checks all buddy information, it requires to check
available memory before running LMK in case of swap full.

Change-Id: Ib24dd77557d095cfd3f61e32ba3d0e30342df405
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: Donghwan Jeong <dh.jeong@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agoswap: fix and update swap module about encryption 13/187513/5
Marcin Jabrzyk [Mon, 7 Aug 2017 13:28:15 +0000 (15:28 +0200)]
swap: fix and update swap module about encryption

While testing file-based swap module, some errors were found
about handling encryption of swapfile.

After changes encyption type is checked for various
types and makes sure that swap module operation will be correct.

To enable swap encryption following kernel config options must be enabled:
BLK_DEV_CRYPTOLOOP = y
CRYPTO_AES = y

Change-Id: I70501832bfcbcfe4df0523877f683f5212e79c7e
Signed-off-by: Marcin Jabrzyk <m.jabrzyk@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agoswap: try to swap memory from the root memcg as much as possible 12/187512/5
ByungSoo Kim [Wed, 12 Jul 2017 13:22:01 +0000 (22:22 +0900)]
swap: try to swap memory from the root memcg as much as possible

Previous commit "swap: trigger early reclaiming about unused memory of system processes"
introduced early swap about system processes after finishing booting.
But, the root memcg doesn't have much anon usage in memory.stat of cgroup
because most memory has been already migrated to child cgroups.
So, it is no necessary to check anon usage of the root memcg.
But instead, if resourced checks memory.usage_in_bytes of the root memcg,
it can swap memory of system process as much as possible.

Change-Id: I04955b6e486d9cc1167fd8bc58b04287e9774e44
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agoswap: adjust sysfs atribute from max_pool_size to max_pool_percent 11/187511/4
Marcin Jabrzyk [Mon, 3 Jul 2017 08:10:30 +0000 (10:10 +0200)]
swap: adjust sysfs atribute from max_pool_size to max_pool_percent

Apparantly there is only max_pools_percent to be set for zswap.

Change-Id: Id5b58cefdd577bcd88ffa9e156e5109f0755c00c
Signed-off-by: Marcin Jabrzyk <m.jabrzyk@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agoswap: change lmk type for searching all processes in case of zram full 10/187510/4
WaLyong Cho [Wed, 28 Jun 2017 01:44:09 +0000 (10:44 +0900)]
swap: change lmk type for searching all processes in case of zram full

Change-Id: I9424f277b0e191ae7761090b308e4c901bd55d25
Signed-off-by: WaLyong Cho <walyong.cho@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agoswap: control swappiness dynamically 09/187509/4
ByungSoo Kim [Tue, 13 Jun 2017 05:31:25 +0000 (14:31 +0900)]
swap: control swappiness dynamically

User space can control amount of swap by changing swappiness value.
Resourced swap can have basically two strategies.
- set default swappiness (60) before triggering force reclaim node.
  : Setting the value to the force reclaim node means to save memory as much as possilbe.
    But, if it has smaller swappiness value, there is no impact.
    Therefore, even though it has low swappiness value such as zero,
    use default swappiness value (60) before writing node and restore previous value after reclaiming.
- set minimum swappiness in case of swap full
  : If swap device is not enough space, trying to swap memory will be overhead.
    While resourced triggers early LMK, it should have minimum value.

Change-Id: If3ba566caf41a73bb22620b8e7f2403303a067be
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agoswap: check kernel fragmentation through /proc/buddyinfo 08/187508/4
ByungSoo Kim [Tue, 13 Jun 2017 05:27:12 +0000 (14:27 +0900)]
swap: check kernel fragmentation through /proc/buddyinfo

Most kernel doesn't support migration and compaction of zmalloc.
So, if zmalloc uses much kernel memory and makes fragmentation,
there is no high order buddy and it causes the failure of fork().

Change-Id: I5407d5d53bbcc2facb85b4482cff5ddfb536201d
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agoswap: trigger early LMK when swap space is not enough. 07/187507/4
ByungSoo Kim [Tue, 13 Jun 2017 05:11:40 +0000 (14:11 +0900)]
swap: trigger early LMK when swap space is not enough.

If swap device is almost full and there is no improvement to compact zram,
it means that there are many background processes or some process makes memory leak.
It will sometime make a sluggish or hangup issue.
So, it requires to trigger proactive oom killer.
Especially in case of zram, it is necessary to check memory usage of swap cgroup.
If it is enough, trigger reclaiming memory about background applications.
Otherwise, find mallicious process in all memory cgroups.

Change-Id: I14e97f7e1b58545de221ff5cf1a674153d9e98a5
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agolowmem: add new api for triggering early LMK in swap module 06/187506/4
ByungSoo Kim [Tue, 13 Jun 2017 04:58:01 +0000 (13:58 +0900)]
lowmem: add new api for triggering early LMK in swap module

If swap devices are almost full, it can make sluggish issue.
So, it requries to trigger early LMK in swap modules.
And it is necessary to insert LMK type in order to decide
whether LMK will kill background applications or find out mallicious system daemons.

Change-Id: I6e215f41ec1b3282f15f67f8df81439f9f21fba8
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agolowmem: unified function for triggering LMK 05/187505/4
ByungSoo Kim [Tue, 13 Jun 2017 04:47:48 +0000 (13:47 +0900)]
lowmem: unified function for triggering LMK

There are many points to trigger LMK inspite of not OOM case.
It can be unified with multiple variables.
If there is no value in input argument, it will use default value.

Change-Id: I76d8bca7c817396a810d77540851d1841375b68b
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agoswap: add new module for zswap 04/187504/4
ByungSoo Kim [Tue, 13 Jun 2017 04:39:27 +0000 (13:39 +0900)]
swap: add new module for zswap

zswap is similar with zram+file swap.
But it has own pool size named zpool and requires "CONFIG_ZSWAP" kernel configuration.
And it uses SWAP_PRI_DISABLE priority
so it will be enabled alone in spite of declaring multiple swap devices
in config file.
Moreover duplicated functions with fileswap move common swap code.

Change-Id: Id35a30f59fe072ea22a8a5be6504e4836ddceaa1
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agoswap: control priority about multiple swap devices 03/187503/4
ByungSoo Kim [Tue, 13 Jun 2017 04:28:26 +0000 (13:28 +0900)]
swap: control priority about multiple swap devices

Give different priority value to multiple swap devices.
Each swap modules can have four types such as
disable, low, default, high.
Swap list of kernel has low-to-high order
while swap ordering is high-to-low.
If swap priority is low, it will be initialized eariler in resourced.
And if some module has SWAP_PRI_DISABLE,
it doesn't allow to add other swap devices.

However, if all swap devices are enabled with priority,
it can't be changed at runtime.

Change-Id: If6a467fa49364fa26ec7d870a31f968b94b7b19f
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agoswap: add new module for fileswap 02/187502/4
ByungSoo Kim [Tue, 13 Jun 2017 04:21:16 +0000 (13:21 +0900)]
swap: add new module for fileswap

fileswap will be supported after mounting loop device with crypto.

Change-Id: I7852f25c78b9b62a7b0e8dae74bd2d64dc916090
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agocommon: add losetup() api for supporting loop device in resourced 01/187501/4
ByungSoo Kim [Tue, 13 Jun 2017 04:10:19 +0000 (13:10 +0900)]
common: add losetup() api for supporting loop device in resourced

The function losetup sets up and controls loop devices.
Resourced will use this api in order to generalize loop device and use crypto.

Change-Id: Ic6677d67cb3361492db12ded809413f1778e4a04
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agoswap: modulize zram swap 00/187500/4
ByungSoo Kim [Tue, 13 Jun 2017 01:38:08 +0000 (10:38 +0900)]
swap: modulize zram swap

Move all zram functions to modulized zramswap.c file.
Main swap.c operates only swap thread and call ops functions.

Change-Id: I4ab5c07f5c2cd045c03ef87f8e75f82425fe86c3
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agoproc: add new api for getting /proc/swaps information 99/187499/4
Paweł Szewczyk [Thu, 23 Aug 2018 11:07:43 +0000 (13:07 +0200)]
proc: add new api for getting /proc/swaps information

/proc/swaps provides many information about swap status.
But it requires parsing each argument.
So proc will support new api and structure.

Change-Id: Icde84b89c7a9215b57fdf55c910f31d05c82e2f2
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agocommon: provide parsing multiple data types 98/187498/4
ByungSoo Kim [Tue, 13 Jun 2017 02:34:22 +0000 (11:34 +0900)]
common: provide parsing multiple data types

add define_parser macro in order to support parsing multiple data types.
It came from systemd after changing arguments.
It can be moved to support these apis in libsystem.

Change-Id: Iee4599293b486baf59fc1a499cf27e1ab6472794
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agoconfig-parser: add new style config parser 97/187497/4
ByungSoo Kim [Fri, 17 Feb 2017 11:56:32 +0000 (20:56 +0900)]
config-parser: add new style config parser

The new api config_parse_new() is added to parse the ini formatted
config fille.
It comes from tizen 2.4.

Change-Id: I04d49fd473046d9387398570b218287e77acf894
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agoswap: prepare modulization of swap devices 96/187496/3
ByungSoo Kim [Mon, 12 Jun 2017 14:22:18 +0000 (23:22 +0900)]
swap: prepare modulization of swap devices

Resourced swap can support multiple swap devices.
It makes new structure with each callback and new api for adding modules.

Change-Id: I1b243f00032541ee2a5d320c1aff322a599a9a39
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agomemory: use path name for getting memcg info instead of mi structure 95/187495/3
ByungSoo Kim [Mon, 12 Jun 2017 13:19:45 +0000 (22:19 +0900)]
memory: use path name for getting memcg info instead of mi structure

Only lowmem module knows all lists of memcg structure.
But other modules sometimes want to get memcg information.
so, it is better to use path name.
And, the function cgroup_get_memory_stat supports to get memory.stat
more easily with gperf lookup table.

Change-Id: Ica1ebfae95d0b0260d65a2ee50d5bced90a90e68
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agoswap: remove unused dbus signal 94/187494/3
ByungSoo Kim [Mon, 12 Jun 2017 13:00:52 +0000 (22:00 +0900)]
swap: remove unused dbus signal

It was old code which no one uses dbus call for getting swap status.

Change-Id: Iedadd0244799bcaf0a52615f7d92b8c400557525
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agoswap: check swap status whether kernel enables configurations 91/187491/3
ByungSoo Kim [Mon, 12 Jun 2017 12:50:18 +0000 (21:50 +0900)]
swap: check swap status whether kernel enables configurations

don't assume that resourced can only support zram.
resourced will support multiple swap scenarios such as zram, file and zswap.
But instead, kernel should enable MEMCG_SWAP.

Change-Id: I3786e434601095460216d3b952d6a920422d6d74
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
6 years agopolicy: Do not deny delivery of signals 47/189947/1
Karol Lewandowski [Mon, 24 Sep 2018 12:10:15 +0000 (14:10 +0200)]
policy: Do not deny delivery of signals

Deny only D-Bus method calls as resourced need to receive various
system signals (eg. aul's AppStatusChange) and act on them.

Change-Id: Ia88ccb52474255b3154f3dc488292f4806e3b2cd

6 years agoFail module logging initalization if logging_init() fails 53/189653/1 accepted/tizen_5.0_unified accepted/tizen/5.0/unified/20181102.021616 accepted/tizen/unified/20180920.155224 submit/tizen/20180920.072124 submit/tizen_5.0/20181101.000004
Łukasz Stelmach [Wed, 19 Sep 2018 10:04:50 +0000 (12:04 +0200)]
Fail module logging initalization if logging_init() fails

This will probably prevent the whole module from initializing properly,
if it requires logging, but prevents the whole resourced from blowing up.

Change-Id: Ic7a544a1fe66402e20a4974f006c3d5fd09aa7af
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
6 years agoAvoid iterating over a NULL hash 73/189573/1 submit/tizen/20180919.012109
Łukasz Stelmach [Tue, 18 Sep 2018 14:37:46 +0000 (16:37 +0200)]
Avoid iterating over a NULL hash

Change-Id: I7f783bf192bb27e9d3748208d8f9a551420dc298
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
6 years agoMerge "heart: Ignore unknown sections in config file" into tizen
Lukasz Stelmach [Mon, 17 Sep 2018 09:08:38 +0000 (09:08 +0000)]
Merge "heart: Ignore unknown sections in config file" into tizen

6 years agoMerge "Simplify D-Bus policy" into tizen
Lukasz Stelmach [Fri, 14 Sep 2018 14:02:57 +0000 (14:02 +0000)]
Merge "Simplify D-Bus policy" into tizen

6 years agoSimplify D-Bus policy 98/187798/2
Karol Lewandowski [Tue, 28 Aug 2018 10:53:11 +0000 (12:53 +0200)]
Simplify D-Bus policy

This change should bring no functional changes but it makes policy
much easier to read and iterpret.

Change-Id: Icd92de3074b44f26dea7b53e82158d929365dcc5
Suggested-by: SangHyeok Oh <sangheyok.oh@samsung.com>
6 years agofix zombie thread by detaching to avoid resource leak 51/188051/1 accepted/tizen/unified/20180831.165151 submit/tizen/20180830.162343
Ravi Guntur [Tue, 20 Mar 2018 05:06:40 +0000 (10:36 +0530)]
fix zombie thread by detaching to avoid resource leak

Signed-off-by: Ravi Guntur <ravi.g@samsung.com>
Change-Id: I8ee2881eb91474ecbddd6b42e1795df3fc5e28ac

6 years agoheart: Ignore unknown sections in config file 21/187821/1
Paweł Szewczyk [Tue, 28 Aug 2018 15:00:35 +0000 (17:00 +0200)]
heart: Ignore unknown sections in config file

Config file heart.conf contains sections other than [HEART]. They should
not cause this file parsing to fail, we can just ignore them.

Change-Id: I5116731b4d79cb7cc60b578443a942bdb754d077

6 years agoMerge "Update the ProcessCrashed signal signature" into tizen accepted/tizen/unified/20180824.162514 submit/tizen/20180822.121814 submit/tizen/20180823.142438
Mateusz Moscicki [Wed, 22 Aug 2018 11:03:10 +0000 (11:03 +0000)]
Merge "Update the ProcessCrashed signal signature" into tizen

6 years agoUpdate the ProcessCrashed signal signature 68/186568/1
Mateusz Moscicki [Thu, 9 Aug 2018 07:20:21 +0000 (09:20 +0200)]
Update the ProcessCrashed signal signature

Change-Id: I3a924889e0ca0e0385ed72f76fc9e4370bda13e6

6 years agoFix inconsistent string ownership 12/185812/2
Michal Bloch [Thu, 2 Aug 2018 11:42:44 +0000 (13:42 +0200)]
Fix inconsistent string ownership

Usually the PPI structure owns its own strdup'd copy of the pkgname string.
However, sometimes it shared it in a non-owning way with another structure
which risked the possibility of trying to use it after that other structure
had already been destroyed.

Change-Id: I71433d24137ef8e96325e9a2aeece53b51b079b5
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
6 years agoheart : remove PID argument of D-Bus 94/185194/2
Kichan Kwon [Fri, 27 Jul 2018 01:53:42 +0000 (10:53 +0900)]
heart : remove PID argument of D-Bus

Change-Id: Id6f91871513d322a38d34c43be8b2438b903b4f6
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
6 years agoDisable "reboot on VIP death" behavior on poweroff 60/183760/9 accepted/tizen/unified/20180727.063754 submit/tizen/20180726.113419
Michal Bloch [Fri, 13 Jul 2018 13:47:52 +0000 (15:47 +0200)]
Disable "reboot on VIP death" behavior on poweroff

This is done because it is normal for VIPs to die throughout a poweroff,
yet having the poweroff replaced by a reboot is undesirable.

Beware: there is a fallback that mounts (binds) `/bin/true`
as the usual release agent, `/usr/bin/vip-release-agent`,
which might cause surprises if the system somehow survives
the shutdown (e.g. because it is disabled for debugging).

Change-Id: I15c40a681de2f58aceb66862988f15ef454b6f8a
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
6 years agoDon't listen to DeviceD power off signal 84/184384/4 accepted/tizen/unified/20180725.060434 submit/tizen/20180724.051636
Michal Bloch [Tue, 17 Jul 2018 13:10:54 +0000 (15:10 +0200)]
Don't listen to DeviceD power off signal

DeviceD currently sends the ChangeState signal on the PowerOff interface,
which causes resourced's main loop to quit, before the PrePowerOff method
is called (which then is not handled). With PrePowerOff uncalled, the VIP
cgroup is left mounted, which causes the platform to reboot on the death
of any VIP process. This makes it impossible to do a regular poweroff as
VIPs die throughout which replaces the poweroff with a reboot.

Removing the signal handler is safe as the signal is somewhat redundant.
Quitting the main loop happens eventually regardless since at some point
DeviceD sends SIGTERM (which also quits the main loop).

Change-Id: I552e4575ad97ae377a96daa0cba24bbe03c0d3bf
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
6 years agoUse update-alternatives to manage resourced.common and resourced.light 85/181685/3 accepted/tizen/unified/20180620.131530 submit/tizen/20180619.111527
Łukasz Stelmach [Thu, 14 Jun 2018 14:30:04 +0000 (16:30 +0200)]
Use update-alternatives to manage resourced.common and resourced.light

Build both resourced.common and resourced.light with a single spec
file. Use symbolic links managed with update-alternatives to provide
/usr/bin/resourced with either of binaries.

Change-Id: I4d8a1e90a6b09ef55063e3fcffbfe636638635a3
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
6 years agoRevert "Build resourced-light with a separate spec" 84/181684/1
Łukasz Stelmach [Fri, 15 Jun 2018 12:47:54 +0000 (14:47 +0200)]
Revert "Build resourced-light with a separate spec"

This reverts commit 2c98c32aadc7758430786aa822464e73484c6a1c.

Change-Id: Id3dccca129cdd71171a23b354c46a52dc1d96c91

6 years agoMerge "Refactor dbus_heart_get_cpu_data() and heart_cpu_get_data() functions" into...
Karol Lewandowski [Wed, 13 Jun 2018 14:55:44 +0000 (14:55 +0000)]
Merge "Refactor dbus_heart_get_cpu_data() and heart_cpu_get_data() functions" into tizen

6 years agoAllow access to battery information for unprivileged processes 59/181159/2
Łukasz Stelmach [Fri, 8 Jun 2018 14:57:51 +0000 (16:57 +0200)]
Allow access to battery information for unprivileged processes

It appears battery information should be available to unprivileged
processes. Tizen documentation[1] does not mention any privileges are
required to access the information.

[1] https://developer.tizen.org/development/guides/web-application/w3chtml5supplementary-features/device/battery-status

Change-Id: I495cc9c83bcc7bc1cd3e7b8bc42d1fc661ed1137
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
6 years agoExpose ProcExclude as a method call 79/178579/4
Łukasz Stelmach [Fri, 4 May 2018 13:23:34 +0000 (15:23 +0200)]
Expose ProcExclude as a method call

Change-Id: I1fa8be9305d50d8c27924e6e94785cb888731b74
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
6 years agoImprove dbus message handling 78/178578/3
Łukasz Stelmach [Wed, 2 May 2018 13:31:27 +0000 (15:31 +0200)]
Improve dbus message handling

Change-Id: Ibc679a21c2a6eb588d9dfcfa86b8f5dff3d9016c
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
6 years agoRefactor dbus_heart_get_cpu_data() and heart_cpu_get_data() functions 66/180066/2
Łukasz Stelmach [Thu, 24 May 2018 12:20:51 +0000 (14:20 +0200)]
Refactor dbus_heart_get_cpu_data() and heart_cpu_get_data() functions

Remove duplicated code from dbus_heart_get_cpu_data() leaving only DBus
interfacing code. Call heart_cpu_get_data() to retrieve data.

Change-Id: I2f19a164507e3dfedccd93b75524f1734c5850cb
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
6 years agoMerge "Bump version of the resourced-light package" into tizen
Łukasz Stelmach [Thu, 24 May 2018 12:49:59 +0000 (12:49 +0000)]
Merge "Bump version of the resourced-light package" into tizen

6 years agoBump version of the resourced-light package 50/180050/1
Łukasz Stelmach [Thu, 24 May 2018 11:00:59 +0000 (13:00 +0200)]
Bump version of the resourced-light package

Change-Id: Id731eea1dd77ec1c99f597c884f57f69b1b7f4b9
Fixes: 875a2080
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
6 years agoMerge "Enable swap module in resourced-light" into tizen
Karol Lewandowski [Wed, 23 May 2018 14:39:53 +0000 (14:39 +0000)]
Merge "Enable swap module in resourced-light" into tizen

6 years agoUse the sysfs interface for zram introduced in Linux 4.11 19/179819/1
Łukasz Stelmach [Tue, 22 May 2018 10:34:55 +0000 (12:34 +0200)]
Use the sysfs interface for zram introduced in Linux 4.11

Change-Id: If6a5132f0727feddb4acdb462b64409881038c20
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
6 years agoIntroduce functions to read an n-th field from a file 18/179818/1
Łukasz Stelmach [Tue, 22 May 2018 10:04:27 +0000 (12:04 +0200)]
Introduce functions to read an n-th field from a file

Change-Id: I4d3c13f684968240b41fedc76ec3274889ff318a
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
6 years agoMove fwrite_array() next to other write functions 17/179817/1
Łukasz Stelmach [Tue, 22 May 2018 10:03:38 +0000 (12:03 +0200)]
Move fwrite_array() next to other write functions

Change-Id: I62c6b0dcaa8d92b4b8de01e27b5b38a8157208fa
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
6 years agoEnable swap module in resourced-light 70/176070/2
Mateusz Moscicki [Mon, 16 Apr 2018 09:11:32 +0000 (11:11 +0200)]
Enable swap module in resourced-light

Change-Id: I2e191cf69449950a953273e116cb0e44caaf2230

6 years agoMerge "Set the default DBus policy for send and own to deny" into tizen submit/tizen/20180523.100558
Karol Lewandowski [Thu, 17 May 2018 13:20:00 +0000 (13:20 +0000)]
Merge "Set the default DBus policy for send and own to deny" into tizen

6 years agoMerge "Build resourced-light with a separate spec" into tizen
Karol Lewandowski [Thu, 17 May 2018 13:16:00 +0000 (13:16 +0000)]
Merge "Build resourced-light with a separate spec" into tizen

6 years agorelease : 0.5.4 77/178777/1 accepted/tizen/unified/20180515.063724 submit/tizen/20180514.045434
Kichan Kwon [Mon, 14 May 2018 04:40:09 +0000 (13:40 +0900)]
release : 0.5.4

Change-Id: I7012181cad6a50657d23b372721ad517954424e5
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
6 years agoSet the default DBus policy for send and own to deny 26/178726/1
Łukasz Stelmach [Fri, 11 May 2018 11:45:54 +0000 (13:45 +0200)]
Set the default DBus policy for send and own to deny

Change-Id: If607185a252fc7d15b603aeb8e0065c643631726
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
6 years agoClear Gerror before exit 21/178621/1
Kichan Kwon [Fri, 11 May 2018 02:14:50 +0000 (11:14 +0900)]
Clear Gerror before exit

Change-Id: I0915d884811234dd8e36a6788bd3a6b1d531c01b
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
6 years agoBuild resourced-light with a separate spec 11/177111/2
Łukasz Stelmach [Fri, 20 Apr 2018 12:19:35 +0000 (14:19 +0200)]
Build resourced-light with a separate spec

Due to limitations of RPM it is impossible to build two RPM packages
containing files with different content and the same name. To work
around this limitation we create a separate spec in the repository to
avoid renaming binaries in %post scripts, which messes the RPM database
and makes it impossible to discover the origin of the binary.

Change-Id: I7d71096237320e1cbf878e9cbaa48c767d9c7fce

6 years agoFix heap-use-after-free error detected by Adress Sanitizer. 17/178117/1 submit/tizen/20180509.124204
Elmurod Talipov [Mon, 30 Apr 2018 02:50:11 +0000 (11:50 +0900)]
Fix heap-use-after-free error detected by Adress Sanitizer.

 - rt_task is released in proc_runtime_info_task_cb(), when
   proc_runtime_info_task() is called, and result is written to pipe.
   This happens before the thread is finished, which will create problem
   for accessing rt_task->task_name.

Change-Id: I8eea8e05aef80250d48a9046cdcc26a2681df3ae
Signed-off-by: Elmurod Talipov <e.talipov@samsung.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
6 years agorelease : 0.5.3 27/171927/1 accepted/tizen/unified/20180313.162811 submit/tizen/20180308.070108
Kichan Kwon [Thu, 8 Mar 2018 07:00:04 +0000 (16:00 +0900)]
release : 0.5.3

Change-Id: I60c8344f159820b1499a92ee2b8afe41bec887b1
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
6 years agoMerge remote-tracking branch 'origin/tizen_4.0' into tizen 19/171919/1
Kichan Kwon [Thu, 8 Mar 2018 06:07:35 +0000 (15:07 +0900)]
Merge remote-tracking branch 'origin/tizen_4.0' into tizen

Change-Id: I0802f410007bcb2ce798f640972a7840274447ce
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
6 years agomemory : ignore empty zone 06/171906/2
Kichan Kwon [Thu, 8 Mar 2018 05:54:04 +0000 (14:54 +0900)]
memory : ignore empty zone

- Some devices make a zone but don't allocate any pages for it
- In addition, fix divided by zero

Change-Id: Ifb11ce58384b0731706f5366a491ddb9f422fc90
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>