platform/core/system/resourced.git
5 years agoFix incorrect errno check 95/212195/8
Baumann [Fri, 16 Aug 2019 11:04:26 +0000 (13:04 +0200)]
Fix incorrect errno check

Change-Id: Ifbe35f844c00d1df41ca7f04556a97b9d922e368
Signed-off-by: Baumann <a.baumann@samsung.com>
5 years agoExtract D-Bus signal name definitions 88/210988/15
Michal Bloch [Fri, 26 Jul 2019 15:22:19 +0000 (17:22 +0200)]
Extract D-Bus signal name definitions

Change-Id: I304e540307fb7565a80d4d88190e652d4a808330

5 years agoIntroduce D-Bus pid query. 84/210984/14
Michal Bloch [Fri, 26 Jul 2019 13:04:19 +0000 (15:04 +0200)]
Introduce D-Bus pid query.

Will be used in future patches.

Change-Id: I4893b9bc63a60b2ee3f2a3de3ad5788d4993ac46

5 years agoCheck GVariant correctness for DBus calls 35/207635/15
Michal Bloch [Tue, 30 Jul 2019 11:31:38 +0000 (13:31 +0200)]
Check GVariant correctness for DBus calls

Change-Id: Id4c7dd8bbf99ac47ae4ab41f4c88cd5eb36b6980
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
5 years agoRefactor out some needless repetition 60/211160/4 accepted/tizen/unified/20190904.224514 submit/tizen/20190904.140208
Michal Bloch [Tue, 30 Jul 2019 10:34:49 +0000 (12:34 +0200)]
Refactor out some needless repetition

Change-Id: Ibba71119e587affb05da27919c087537a903267c

5 years agoFix double free 51/212951/1 accepted/tizen/unified/20190829.040204 submit/tizen/20190828.131328 submit/tizen/20190828.162915
Michal Bloch [Wed, 28 Aug 2019 11:52:34 +0000 (13:52 +0200)]
Fix double free

Change-Id: I6d9d9b4d4a6f7bd3de13f675a580ae8b1dd519ed
Signed-off-by: Michal Bloch <m.bloch@partner.samsung.com>
5 years agoFix a memory leak 50/212950/1
Michal Bloch [Wed, 28 Aug 2019 11:53:23 +0000 (13:53 +0200)]
Fix a memory leak

Change-Id: I0a6d5aed3646065d39876d36132eeb49f57f7729
Signed-off-by: Michal Bloch <m.bloch@partner.samsung.com>
5 years agoheart: Increase heart module priority 29/212629/2 submit/tizen/20190823.122228
Karol Lewandowski [Fri, 23 Aug 2019 09:31:48 +0000 (11:31 +0200)]
heart: Increase heart module priority

This should ensure that heart moudule is always properly initialized,
as it does not depend on external signal notification (as needed for
late modules which wait for BootingDone signal).

Change-Id: I2c0884c77e1bb2e04e390d2e863d6ba5472f9357

5 years agosignal handler: Depend on D-Bus policy as single source for policy information 19/212419/2 accepted/tizen/unified/20190826.000109 submit/tizen/20190822.134540 submit/tizen/20190823.062038
Karol Lewandowski [Wed, 21 Aug 2019 08:55:45 +0000 (10:55 +0200)]
signal handler: Depend on D-Bus policy as single source for policy information

If something has to be blocked, it has to be blocked by standard D-Bus policy.
This reverts commit 26f17bcd9864ebc3bc0ec068a5dea8cabda01198 (effectively).

Change-Id: Ifad4e830cf490247d4781f59ae3d6d0c8e74719c

5 years agoFix some incorrect method call replies 59/211159/2
Michal Bloch [Tue, 30 Jul 2019 11:18:39 +0000 (13:18 +0200)]
Fix some incorrect method call replies

Change-Id: I8be8d489738749de1e657f97cc342e3baaed9132
Signed-off-by: Michal Bloch <m.bloch@partner.samsung.com>
5 years agoMerge "Update (formerly) deviced booting signal paths" into tizen submit/tizen/20190814.170318
Karol Lewandowski [Wed, 14 Aug 2019 16:28:12 +0000 (16:28 +0000)]
Merge "Update (formerly) deviced booting signal paths" into tizen

5 years agoRestrict access to vip-release-agent 46/212046/2
Michal Bloch [Tue, 13 Aug 2019 13:24:05 +0000 (15:24 +0200)]
Restrict access to vip-release-agent

 * file mode: 755 → 700
 * SMACK access label: "_" → "System"

Change-Id: I2c725a75a11d60b0c63c2f7d00579cd96cb3a815
Signed-off-by: Michal Bloch <m.bloch@partner.samsung.com>
5 years agoUpdate (formerly) deviced booting signal paths 30/212030/1
Michal Bloch [Mon, 12 Aug 2019 15:17:46 +0000 (17:17 +0200)]
Update (formerly) deviced booting signal paths

BootingDone is under system.Booting and EarlyBootingDone no longer exists.

Change-Id: I4e91e037784a454e51bf7c3b639df08076031a30
Signed-off-by: Michal Bloch <m.bloch@partner.samsung.com>
5 years agoMerge "Remove unused feature "default-extra-dependencies"" into tizen
Karol Lewandowski [Fri, 9 Aug 2019 13:37:53 +0000 (13:37 +0000)]
Merge "Remove unused feature "default-extra-dependencies"" into tizen

5 years agoMinor const correctness 83/210983/1
Michal Bloch [Fri, 26 Jul 2019 12:36:07 +0000 (14:36 +0200)]
Minor const correctness

Change-Id: Iccd107b4e0858480abbe1b62108f386d3d36db65
Signed-off-by: Michal Bloch <m.bloch@partner.samsung.com>
5 years agoRemove unused feature "default-extra-dependencies" 06/209106/4
INSUN PYO [Tue, 2 Jul 2019 07:50:25 +0000 (16:50 +0900)]
Remove unused feature "default-extra-dependencies"

"default-extra-dependencies" was a feature used in an unpublished
version of systemd but has since been dropped.

This has been replaced by a delayed target in public systemd.

Change-Id: Ie6929b26bdd45c157ad4527c6da7fec9a7df7622

5 years agoRelease 5.5.2 54/209954/1 submit/tizen/20190712.184306 submit/tizen/20190722.101820 submit/tizen/20190724.105257
Michal Bloch [Fri, 12 Jul 2019 12:50:53 +0000 (14:50 +0200)]
Release 5.5.2

 - port some heart and lowmem related code
 - miscellaneous fixes

Change-Id: I5e2ab97866be4a5369fbca34a25e4f89a612cfdc
Signed-off-by: Michal Bloch <m.bloch@partner.samsung.com>
5 years agoFix a null pointer dereference 45/209545/1
Michal Bloch [Mon, 8 Jul 2019 13:29:24 +0000 (15:29 +0200)]
Fix a null pointer dereference

Change-Id: Ib8d841c9ab8a7e7448a0545791cc3455b1a67903
Signed-off-by: Michal Bloch <m.bloch@partner.samsung.com>
5 years agoMerge changes I349c8798,I6222a416,Id06cad1d,I0994ea8c into tizen submit/tizen/20190704.121256 submit/tizen/20190705.134528
Karol Lewandowski [Fri, 28 Jun 2019 13:49:26 +0000 (13:49 +0000)]
Merge changes I349c8798,I6222a416,Id06cad1d,I0994ea8c into tizen

* changes:
  Port (merge) `lowmem-system` for resourced to handle lowmem of systemd units
  memory: restart timer after changing timeout interval
  memory: reset swappiness to memcg directories which have been already created by systemd.
  lowmem: add to control systemd services

5 years agoMerge changes from topic "resourced-porting-2019" into tizen
Karol Lewandowski [Fri, 28 Jun 2019 13:48:05 +0000 (13:48 +0000)]
Merge changes from topic "resourced-porting-2019" into tizen

* changes:
  lowmem: broadcast event when some process uses memory over limit
  proc: check minimum value of oom score adj about all UI applications
  heart-cpu: consider the service app type while considering the cpu time for process.

5 years agoEnsure resourced is started before user session 07/208607/2
Karol Lewandowski [Wed, 26 Jun 2019 10:15:42 +0000 (12:15 +0200)]
Ensure resourced is started before user session

resourced listens on AUL signals from lauchpad, and it has to be
started before it.

Change-Id: I6a161d8555824c696a53d462aa7bacef747e18e9

5 years agolowmem: broadcast event when some process uses memory over limit 23/207423/4
ByungSoo Kim [Tue, 13 Nov 2018 07:48:04 +0000 (16:48 +0900)]
lowmem: broadcast event when some process uses memory over limit

Other process can receive this broadcast signal
when resourced kills the process which uses memory over limit.

Change-Id: I77fe18a71c7d09df47b9144e47d43c7965864f6b
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
5 years agoproc: check minimum value of oom score adj about all UI applications 89/207289/4
ByungSoo Kim [Mon, 28 May 2018 05:15:57 +0000 (14:15 +0900)]
proc: check minimum value of oom score adj about all UI applications

Resourced groups UI and service applications with same package name
and controls oom score adj of service app according to changing UI app.
But even if there are other applications with lower oom score adj such as widget or clock,
service applications goes to the background state abnormally.
So, it requires to check oom score value of all UI applications.

Change-Id: I4b032affe761d071c4bc5eb337d1f4fa38dfb7bf
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
5 years agoheart-cpu: consider the service app type while considering the cpu time for process. 88/207288/4
Jiban Prakash [Thu, 10 May 2018 13:13:34 +0000 (18:43 +0530)]
heart-cpu: consider the service app type while considering the cpu time for process.

Change-Id: I5e9ff9f241aad365d2e1d69d3239743df3a9765b
Signed-off-by: Jiban Prakash <p.jiban@samsung.com>
5 years agoPort (merge) `lowmem-system` for resourced to handle lowmem of systemd units 89/207889/3
Michal Bloch [Thu, 27 Jun 2019 12:12:30 +0000 (14:12 +0200)]
Port (merge) `lowmem-system` for resourced to handle lowmem of systemd units

Change-Id: I349c8798f5308580b63829edac13eb12055eda14

5 years agomemory: restart timer after changing timeout interval 88/207888/3
ByungSoo Kim [Mon, 16 Apr 2018 13:52:18 +0000 (22:52 +0900)]
memory: restart timer after changing timeout interval

glib timer can't change timeout interval in same timer source.
If it wants to change timeout interval, it should destroy current timer
nd attach new timer again.

Change-Id: I6222a416e0e16402585ae4b6f836ccdae3c347dc
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
5 years agomemory: reset swappiness to memcg directories which have been already created by... 87/207887/3
ByungSoo Kim [Tue, 28 Mar 2017 06:03:17 +0000 (15:03 +0900)]
memory: reset swappiness to memcg directories which have been already created by systemd.

Systemd makes all cgroup directories as soon as it starts.
So, if someone tires to change default swappiness by using sysctl,
kernel can't change systemd cgroup directories with changed value
because they are already created.
So, resourced can search all systemd cgroup directories
while it reassigns memory limit.
At that time, it will check swappiness and reset again
with current swappiness of root memcgroup.

Change-Id: Id06cad1decff768daa042f61f84e63ba9d733f03
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
5 years agolowmem: add to control systemd services 86/207886/3
ByungSoo Kim [Tue, 28 Mar 2017 05:40:09 +0000 (14:40 +0900)]
lowmem: add to control systemd services

Resourced doesn't know systemd services which are included in memcg of systemd slice.
If resourced can check these processes, it will be useful for resourced
to control LMK, mem limit and so on.

Change-Id: I0994ea8c8a7c707cfd6000ef0dcd9d96c31c7176
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
5 years agoMerge "swap: remove const type in the swap module ops" into tizen
Karol Lewandowski [Wed, 19 Jun 2019 15:28:23 +0000 (15:28 +0000)]
Merge "swap: remove const type in the swap module ops" into tizen

5 years agoswap: remove const type in the swap module ops 87/207287/3
minsoo kim [Tue, 3 Apr 2018 14:00:06 +0000 (23:00 +0900)]
swap: remove const type in the swap module ops

The swap module ops also has RW variables to set the values at runtime
from kernel node.
It should remove the const type.

Change-Id: Ifece59f241aad365d2e1d69d3239743df3a9765b
Signed-off-by: ByungSoo Kim <bs1770.kim@samsung.com>
Signed-off-by: minsoo kim <ms203.kim@samsung.com>
5 years agoRemove the "retry in case it works" antipattern. 41/207641/2
Michal Bloch [Mon, 10 Jun 2019 10:53:17 +0000 (12:53 +0200)]
Remove the "retry in case it works" antipattern.

Change-Id: I54e987f7d797183ed099fdf9d1fd471fa3e233b0
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
5 years agoSilence a SVACE complaint. 39/207639/2
Michal Bloch [Mon, 10 Jun 2019 10:22:04 +0000 (12:22 +0200)]
Silence a SVACE complaint.

"[Major] Possible missing lock before accessing to the ''data'' variable"

SVACE believes that `data` should be handled under a mutex because
it is usually handled under a mutex above, but it is in fact a regular
local variable and the case at hand is for when mutex unlock fails.

Change-Id: Ife1df6a9d2761f56f1ca579f1acb0c94e254a83c
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
5 years agoHeart : Added NULL check handing for pointer before deferencing. 83/206383/1
“JIBAN [Tue, 25 Jul 2017 10:01:34 +0000 (15:31 +0530)]
Heart : Added NULL check handing for pointer before deferencing.

[Model] Z4
[BinType]
[Customer] NA

[Issue#] P170720-06362
[Request] NA
[Occurrence Version] NA

[Problem] NULL check handle was missing before deferencing the pointer
[Measure] Added NULL check handing for pointer before deferencing.
[Checking Method]

[Team] SYSTEM FRAMEWORK
[Developer] p.jiban
[Solution company] Samsung

Change-Id: I9df1acad5d2ea4848924e9a3328635514f90d793
Signed-off-by: “JIBAN <p.jiban@samsung.com>
Change-Id: I23830d2715c4f1dca81bb7bdf8e5f81b37319098
Signed-off-by: “JIBAN <p.jiban@samsung.com>
5 years agoRelease 5.5.1 54/205954/1 submit/tizen/20190513.123842
Michal Bloch [Fri, 10 May 2019 14:12:11 +0000 (16:12 +0200)]
Release 5.5.1

 - new cgroup for bg-locked processes
 - add an option to activate background reclaim
 - early reclaim controllable through config
 - misc bugfixes and maintenance

Change-Id: I3fb7eedc67d11a04fbe2ff75a1b2f801abf9a0af
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
5 years agoMerge "Replace a call to a missing method with a warning" into tizen
Karol Lewandowski [Thu, 9 May 2019 15:16:14 +0000 (15:16 +0000)]
Merge "Replace a call to a missing method with a warning" into tizen

5 years agoMerge "tracing: introduce _W warning macro" into tizen
Karol Lewandowski [Thu, 9 May 2019 15:15:55 +0000 (15:15 +0000)]
Merge "tracing: introduce _W warning macro" into tizen

5 years agoReplace a call to a missing method with a warning 92/205692/3
Michal Bloch [Wed, 8 May 2019 11:11:10 +0000 (13:11 +0200)]
Replace a call to a missing method with a warning

system-popup doesn't actually expose the MalfunctionNotifierLaunch method,
at least the upstream version. The function was only disabled instead of
completely removed to give any potential legacy systems or forks time to
adapt.

Change-Id: I45884184b4b7734bbe9b1c24692e7fd62d4df258
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
5 years agotracing: introduce _W warning macro 91/205691/1
Michal Bloch [Wed, 8 May 2019 10:48:11 +0000 (12:48 +0200)]
tracing: introduce _W warning macro

Change-Id: If8dd95102ecb8d251c6de2648c0e10f858c70a61
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
5 years agoFix system-popup DBus call signatures 84/205584/4
Michal Bloch [Wed, 8 May 2019 10:02:52 +0000 (12:02 +0200)]
Fix system-popup DBus call signatures

Popup wants an array of string-string dictionary entries while
these functions used to send a bunch of "raw" strings.

Change-Id: I70d3a350a04b4bc514b960159d7d8ce68a914abe
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
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>