Commit Graph

1653 Commits

Author SHA1 Message Date
Suren Baghdasaryan 7bd2b43a2c [automerger skipped] lmkd: Add lmkd README file am: 9dbd937b4c -s ours
am: 2a07f8f940  -s ours

Change-Id: I584d202ea2b20277c2eb8eb1f140d15f2dcafdfa
2018-04-16 13:19:46 -07:00
Suren Baghdasaryan bec5651fb3 [automerger skipped] lmkd: Rename is_go_device variable to better reflect its function
am: 39a22e751b  -s ours

Change-Id: Ieeb82c7e7227a898aea7c3b1a54370f37e70c940
2018-04-16 13:15:14 -07:00
Suren Baghdasaryan 35c1df5249 [automerger skipped] lmkd: Add lmkd README file
am: 9dbd937b4c  -s ours

Change-Id: I6d703f0ad100ae885e7095bcbbe3d4eeee7628c1
2018-04-16 13:14:00 -07:00
Suren Baghdasaryan c482e927a2 lmkd: Optimize frequent file reads by keeping file descriptors open
To check system memory state lmkd is using same files every time vmpressure
event is received. Instead of opening and closing these files every time
we store the file descriptor and use pread() to reread the file from
the beginning.

Bug: 77299493
Bug: 75322373
Change-Id: I8e27f8b9526e82e3cc313a02fce215c2e4dd3d29
Merged-In: I8e27f8b9526e82e3cc313a02fce215c2e4dd3d29
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
(cherry picked from commit d716fe3610aae8cefcc676ade00c7bfd2b823c20)
2018-04-16 09:33:44 -07:00
Suren Baghdasaryan 9b5a5869e9 lmkd: Fix usage of ro.lmk.kill_heaviest_task property
lmkd should use ro.lmk.kill_heaviest_task property to select between
algorithms for victim selection. Set ro.lmk.kill_heaviest_task default
value to false in order to keep it compatible with previous versions
of lmkd (killing the heaviest task is a new mechanism).

Bug: 77299493
Bug: 75322373
Change-Id: I78d2dc79d9c54e636c26665605518d9c87b535b3
Merged-In: I78d2dc79d9c54e636c26665605518d9c87b535b3
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
(cherry picked from commit 818b59b2292f87c3781a6f7a288d10e2453b0d13)
2018-04-16 09:30:29 -07:00
Suren Baghdasaryan efe582c34f lmkd: Rename is_go_device variable to better reflect its function
Rename is_go_device variable to low_ram_device to better reflect
its meaning and relation to ro.config.low_ram variable.

Bug: 77299493
Bug: 75322373
Change-Id: I6e2eaebe79cf2e6edf861f7c602e52a5b573ad0a
Merged-In: I6e2eaebe79cf2e6edf861f7c602e52a5b573ad0a
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
(cherry picked from commit fe2be6cc44073b7ef09ca849004e5072bdf18857)
2018-04-16 09:27:32 -07:00
Suren Baghdasaryan 518668e043 lmkd: Add lmkd README file
Add README file providing lmkd overview and description for its
properties.

Bug: 77299493
Bug: 75322373
Change-Id: I30236dd4ccaa2b48c31dfb80b63f0b82b49b5744
Merged-In: I30236dd4ccaa2b48c31dfb80b63f0b82b49b5744
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
(cherry picked from commit 7e5dea82a5a2f86117722ff11c93bc672ffb7903)
2018-04-16 09:26:40 -07:00
Florian Mayer 796de1cacb Merge commit '6499e5ec' into pi-dev-plus-aosp
am: 7725a9d9aa

Change-Id: Ia4fa295ffbcc520a00310fa1bbeef8e64aa671ef
2018-04-16 08:49:13 -07:00
Florian Mayer d138d4cdfc Merge commit '6499e5ec' into pi-dev-plus-aosp 2018-04-16 14:55:03 +01:00
Florian Mayer 00484817cc Merge commit '6499e5ec' 2018-04-16 11:21:27 +01:00
Suren Baghdasaryan 786e8537fa lmkd: Introduce support for legacy kill algorithm that uses minfree levels
Add ability to switch to the algorithm used by lowmemorykiller driver
for determining when to kill. It uses minfree levels to decide at which
levels of free memory and file cache to kill a process. oom_adj_score
is also determined by comparing current memory resources against minfree
levels.
ro.lmk.use_minfree_levels property is introduces for switching into this
mode. By default it is disabled.

Bug: 77299493
Bug: 75322373
Merged-In: I6b51972951026854a079fcda33d6786b7ed035e4
Change-Id: I6b51972951026854a079fcda33d6786b7ed035e4
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-04-15 16:02:36 +00:00
Suren Baghdasaryan 3bac7a1daf lmkd: Switch to using /proc/meminfo to have access to file cache size
Current mechanism of getting system memory state by using sysinfo()
is not enough because it does not provide information about file cache
size which is needed to correctly assess memory state. Switch to using
data from /proc/meminfo that includes information provided by sysinfo()
and file cache size in addition to that.


Bug: 77299493
Bug: 75322373
Merged-In: I16106fc4f9254f17f776803e60502b7b6474e1b7
Change-Id: I16106fc4f9254f17f776803e60502b7b6474e1b7
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-04-15 10:03:05 +00:00
Suren Baghdasaryan 65f04901ec lmkd: Introduce support for legacy kill algorithm that uses minfree levels
Add ability to switch to the algorithm used by lowmemorykiller driver
for determining when to kill. It uses minfree levels to decide at which
levels of free memory and file cache to kill a process. oom_adj_score
is also determined by comparing current memory resources against minfree
levels.
ro.lmk.use_minfree_levels property is introduces for switching into this
mode. By default it is disabled.

Bug: 77299493
Bug: 75322373
Change-Id: I6b51972951026854a079fcda33d6786b7ed035e4
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-04-15 02:29:57 -07:00
Suren Baghdasaryan 836c9168f0 lmkd: Switch to using /proc/meminfo to have access to file cache size
Current mechanism of getting system memory state by using sysinfo()
is not enough because it does not provide information about file cache
size which is needed to correctly assess memory state. Switch to using
data from /proc/meminfo that includes information provided by sysinfo()
and file cache size in addition to that.

Bug: 77299493
Bug: 75322373
Change-Id: I16106fc4f9254f17f776803e60502b7b6474e1b7
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-04-15 02:13:44 -07:00
Suren Baghdasaryan 7e0d65b65c lmkd: Add zoneinfo and meminfo parsing routines
/proc/zoneinfo and /proc/meminfo contain information necessary for lmkd
to assess system memory state. Add routines to parse these files.


Bug: 77299493
Bug: 75322373
Merged-In: Ie7d80bbb81fd0d2fc0629f6f678e6afc97fed1f6
Change-Id: Ie7d80bbb81fd0d2fc0629f6f678e6afc97fed1f6
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-04-15 07:55:27 +00:00
Suren Baghdasaryan 8796674f2e lmkd: Optimize frequent file reads by keeping file descriptors open
To check system memory state lmkd is using same files every time vmpressure
event is received. Instead of opening and closing these files every time
we store the file descriptor and use pread() to reread the file from
the beginning.


Bug: 77299493
Bug: 75322373
Merged-In: I8e27f8b9526e82e3cc313a02fce215c2e4dd3d29
Change-Id: I8e27f8b9526e82e3cc313a02fce215c2e4dd3d29
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-04-15 07:54:03 +00:00
Suren Baghdasaryan 207ed18611 lmkd: Add zoneinfo and meminfo parsing routines
/proc/zoneinfo and /proc/meminfo contain information necessary for lmkd
to assess system memory state. Add routines to parse these files.

Bug: 77299493
Bug: 75322373
Change-Id: Ie7d80bbb81fd0d2fc0629f6f678e6afc97fed1f6
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-04-14 23:50:14 -07:00
Suren Baghdasaryan 34c6cf2f40 lmkd: Optimize frequent file reads by keeping file descriptors open
To check system memory state lmkd is using same files every time vmpressure
event is received. Instead of opening and closing these files every time
we store the file descriptor and use pread() to reread the file from
the beginning.

Bug: 77299493
Bug: 75322373
Change-Id: I8e27f8b9526e82e3cc313a02fce215c2e4dd3d29
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-04-14 23:50:00 -07:00
Suren Baghdasaryan fc2123fdcf Merge changes I78d2dc79,I6e2eaebe am: bb266150fe am: 4d41a1f882
am: 6607770968

Change-Id: I22db50c6e56549582dd8c8dfcda9794d3989a17c
2018-04-14 17:21:53 -07:00
Suren Baghdasaryan f7e6fd02a1 Merge "lmkd: Add lmkd README file" am: b518418fbb am: 29aca8b0be
am: 94b5686aca

Change-Id: I41ed8e67023a24deb2049b05818d234253bd5ac3
2018-04-14 16:44:00 -07:00
Suren Baghdasaryan 47b64460c0 Merge changes I78d2dc79,I6e2eaebe am: bb266150fe
am: 4d41a1f882

Change-Id: If65529061b6bd49c06b0eae37dd9e196fa805ab7
2018-04-14 16:25:15 -07:00
Suren Baghdasaryan c989cb1e2f Merge "lmkd: Add lmkd README file" am: b518418fbb
am: 29aca8b0be

Change-Id: I0153fae612008cc2fe75a1ae8f29c8c4fe90d4b8
2018-04-14 16:03:45 -07:00
Suren Baghdasaryan 36b2c497e3 lmkd: Fix usage of ro.lmk.kill_heaviest_task property
lmkd should use ro.lmk.kill_heaviest_task property to select between
algorithms for victim selection. Set ro.lmk.kill_heaviest_task default
value to false in order to keep it compatible with previous versions
of lmkd (killing the heaviest task is a new mechanism).

Change-Id: I78d2dc79d9c54e636c26665605518d9c87b535b3
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-04-13 23:24:24 +00:00
Suren Baghdasaryan d1d59f871f lmkd: Rename is_go_device variable to better reflect its function
Rename is_go_device variable to low_ram_device to better reflect
its meaning and relation to ro.config.low_ram variable.

Change-Id: I6e2eaebe79cf2e6edf861f7c602e52a5b573ad0a
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-04-13 23:24:09 +00:00
Suren Baghdasaryan 14b4465450 lmkd: Add lmkd README file
Add README file providing lmkd overview and description for its
properties.

Change-Id: I30236dd4ccaa2b48c31dfb80b63f0b82b49b5744
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2018-04-13 21:36:44 +00:00
Mark Salyzyn 5cb238b41d resolve merge conflicts of f062a2cd9eef32ac9458faee7d056c06f2f4168b to pi-dev-plus-aosp
am: be5235619f

Change-Id: I5ac401c518af4240bb56d867fd10771b3ea1d0a2
2018-04-06 08:20:25 -07:00
Mark Salyzyn 9e918598df resolve merge conflicts of f062a2cd9eef32ac9458faee7d056c06f2f4168b to pi-dev-plus-aosp
Test: I solemnly swear I tested this conflict resolution.
Change-Id: I5eb1bc16bf25b27172b6d2ea355768df2f6d8ff7
2018-04-06 07:56:54 -07:00
Mark Salyzyn b9bd86aeaf Merge "lmkd: test: access /sys/module/lowmemorykiller/ as u:r:shell:s0" am: b69cb7071d am: 4f7d8851a5
am: aa0b84afca

Change-Id: I2b9848ada0bdff52179bebdda05b2695e8293994
2018-04-05 20:02:40 -07:00
Mark Salyzyn ef4b4be3a5 Merge "lmkd: test: access /sys/module/lowmemorykiller/ as u:r:shell:s0" am: b69cb7071d
am: 4f7d8851a5

Change-Id: I1ef7aab68bfb5a11891ef4777f6dc46774120a21
2018-04-05 19:45:16 -07:00
Mark Salyzyn 5cc80b3d98 lmkd: only mlockall() if enabled
Move process initialization, mlockall() and sched_setscheduler() to
only occur if initialization succeeds and is enabled.  This
conserves mlock'd memory and a FIFO processing slot if (deprecated)
kernel lowmemorykiller is active.

Cleanup: Android coding standard compliance.

Test: lmkd_unit_test
Bug: 33808187
Bug: 72838192
Change-Id: I51af0235c8eca4ef958ef2d83a8071ff58b49d78
2018-04-03 14:41:26 +00:00
Mark Salyzyn 930f877944 lmkd: test: access /sys/module/lowmemorykiller/ as u:r:shell:s0
lmkd_unit_test gets an selinux violation when run unprivileged:

lmkd_unit_test: type=1400 audit(0.0:???): avc: denied { search } for
    name="lowmemorykiller" dev="sysfs" ino=??? scontext=u:r:shell:s0
    tcontext=u:object_r:sysfs_lowmemorykiller:s0 tclass=dir
    permissive=0

resulting in log noise.  Check for INKERNEL_MINFREE_PATH existence
after known to be escalated as root user to suppress noise.

Test: lmkd_unit_test as unprivileged user, there should be no audits.
Change-Id: Ia5c7824e7070c98ee6eea20ca53097e4e56d61b6
2018-04-03 14:41:11 +00:00
android-build-team Robot ba824be447 Snap for 4683893 from 136f765fb32bbc8dc8b22645a6fbbf83475d1ec6 to pi-release
Change-Id: Ibe1b07efe8d032d44d2c828bae218c56d4e8078a
2018-03-28 07:25:18 +00:00
Greg Kaiser ef07ddcdd4 [automerger skipped] Merge "lmkd: Protect against buffer overflow" into pi-dev am: 136f765fb3 -s ours
am: f97f242c30  -s ours

Change-Id: I94f783d2f87f7590ee845c70ca27e437f0449cc3
2018-03-28 04:31:01 +00:00
Greg Kaiser 248b2c5611 [automerger skipped] Merge "lmkd: Protect against buffer overflow" into pi-dev
am: 136f765fb3  -s ours

Change-Id: I5f8cf0f5dad1e93cbe51d0fbfad785d6b8bc831d
2018-03-28 03:19:15 +00:00
TreeHugger Robot e5135b856a Merge "lmkd: Protect against buffer overflow" 2018-03-27 23:47:14 +00:00
Greg Kaiser cfca0a30fb lmkd: Protect against buffer overflow
We're passing a 'line' whose backing buffer is PAGE_MAX in size
into memory_stat_parse_line().  We protect overflowing the smaller
LINE_MAX 'key' buffer via some C preprocessing macros to assure
we limit the size.

Test: Local build with LMKD_LOG_STATS set for this file.
Bug: 76220622
Merged-In: I9e50d4270f7099e37a9bfc7fb9b9b95cc7adb086
Change-Id: I9e50d4270f7099e37a9bfc7fb9b9b95cc7adb086
2018-03-27 21:59:31 +00:00
android-build-team Robot d49c7d1ad1 Snap for 4680594 from ca47ae35135d1b77ee89641f972eb60ab7522b5a to pi-release
Change-Id: Ia0ebf1e82b207d979c2300e7ca589d0928531199
2018-03-27 07:27:32 +00:00
Rajeev Kumar 09c53b2c3b [automerger skipped]Merge "Use usel_mkd_stats_log build variable while compiling lmkd with stats logging feature." into pi-dev am: 42c17c8ee5
am: f09c593dd5  -s ours

Change-Id: I99ccf9e683612752670c68173199df0faa98a37b
2018-03-26 23:46:01 +00:00
Rajeev Kumar 9b3719d5f0 Merge "Use usel_mkd_stats_log build variable while compiling lmkd with stats logging feature." into pi-dev
am: 42c17c8ee5

Change-Id: I4d5b2851bb465dfaf0c8c7b863611685aedaf03d
2018-03-26 23:34:24 +00:00
TreeHugger Robot 88bfbef576 Merge "Use usel_mkd_stats_log build variable while compiling lmkd with stats logging feature." into pi-dev 2018-03-26 23:14:23 +00:00
Rajeev Kumar 3c69f0a64d Fix compilation issue when LMKD_LOG_STATS is defined. am: 1c669f764d
am: 716fe89b88

Change-Id: I17664c7b1c66b3f14fd8d1291016c106c3505946
2018-03-26 21:51:59 +00:00
Rajeev Kumar 860ff464e2 Fix compilation issue when LMKD_LOG_STATS is defined.
am: 1c669f764d

Change-Id: I750b6a13b1a897b3dc77e1823a997afe0c40e4a3
2018-03-26 21:46:22 +00:00
Rajeev Kumar 02499a92f0 Fix compilation issue when LMKD_LOG_STATS is defined.
Note: The breakage was caused by http://ag/3621623

Test: mmma system/core/lmkd/
Change-Id: I17033aeedb3183d4777dacb89ec84430ff061b3c
Bug: 74443701
(cherry picked from commit fb25ddd9c9004de9a9ebb1175a6ceaf7aeec0673)
2018-03-26 18:15:25 +00:00
Greg Kaiser 1d721caddc lmkd: Protect against buffer overflow
We're passing a 'line' whose backing buffer is PAGE_MAX in size
into memory_stat_parse_line().  We protect overflowing the smaller
LINE_MAX 'key' buffer via some C preprocessing macros to assure
we limit the size.

Test: Local build with LMKD_LOG_STATS set for this file.
Bug: 76220622
Change-Id: I9e50d4270f7099e37a9bfc7fb9b9b95cc7adb086
2018-03-23 14:30:37 -07:00
Rajeev Kumar 9dd1497b95 Use usel_mkd_stats_log build variable while compiling lmkd with stats logging feature.
Bug: 74443701
Test: Tested manually
Merged-In: Ifa13cc7d1c3ff3ac71a16cf55be5a48ce808ef59
Change-Id: Ifa13cc7d1c3ff3ac71a16cf55be5a48ce808ef59
(cherry picked from commit 083be30783870ce4093d1d5f040f42f9f3c27510)
2018-03-23 20:33:57 +00:00
Rajeev Kumar 6afff4243c Use usel_mkd_stats_log build variable while compiling lmkd with stats logging feature.
Bug: 74443701
Test: Tested manually
Change-Id: Ifa13cc7d1c3ff3ac71a16cf55be5a48ce808ef59
2018-03-22 10:55:36 -07:00
Suren Baghdasaryan a11e49518b Merge "lmkd: Fix the message printed during a kill to avoid confusion" am: 5ea2c4baf1 am: ccb9744562
am: 0bff4732d4

Change-Id: I1c9de7850267c443b91c690baa32973ce56fc50c
2018-03-21 22:25:02 +00:00
Suren Baghdasaryan ec59ef25d3 Merge "lmkd: Suppress error when accessing soft_limit_in_bytes for system_server" am: d4463fd9d7 am: ec2bc88aa1
am: b939f0d45e

Change-Id: Idcf02ae42388bf2188a9782dcb1c36475e821699
2018-03-21 22:16:11 +00:00
Suren Baghdasaryan 9433ba123b Merge "lmkd: Change error to warning when accessing oom_score_adj file" am: a77411f425 am: 3d3e875767
am: d33812455d

Change-Id: I38e27bae540e947706b31b1eb98c51b51e1a2708
2018-03-21 21:44:23 +00:00
Suren Baghdasaryan 0fa401c7b6 Merge "lmkd: Fix the message printed during a kill to avoid confusion" am: 5ea2c4baf1
am: ccb9744562

Change-Id: I45960a335ad426fdd69a2a36268ddfc425f92de0
2018-03-21 19:35:53 +00:00