Commit Graph

473 Commits

Author SHA1 Message Date
Muhammad Qureshi 0eefbff7b9 Link libstatssocket as a shared library. am: 87168c0e26 am: 2171a0c2f4 am: e18b6d0b90
Change-Id: I3c9c5d48f57fc57e34c059a4863856a90607ae03
2020-02-14 22:37:37 +00:00
Muhammad Qureshi e18b6d0b90 Link libstatssocket as a shared library. am: 87168c0e26 am: 2171a0c2f4
Change-Id: Idb85f7875499f727744bd7b6cbe2f40ff7991efe
2020-02-14 22:19:30 +00:00
Muhammad Qureshi 2171a0c2f4 Link libstatssocket as a shared library. am: 87168c0e26
Change-Id: I02b53349508cfead1d6a43704b39ad648bf8e3f0
2020-02-14 22:00:51 +00:00
Muhammad Qureshi 87168c0e26 Link libstatssocket as a shared library.
As part of moving libstatssocket into statsd apex, libstatssocket will
only be available as a shared library.

Bug: 145923416
Test: m
Change-Id: Ia6b13dcd378011c201b2595d2b3f3fc14213011b
2020-02-12 16:42:53 -08:00
Automerger Merge Worker 5ce5183e22 [automerger skipped] DO NOT MERGE - Empty merge qt-qpr1-dev-plus-aosp-without-vendor (6129114) into stage-aosp-master am: 45cb77c5bc am: 5759b94152 -s ours
am skip reason: subject contains skip directive

Change-Id: Id1f72e87196c7e6e20c65a3110f2719c8adf373a
2020-01-16 01:58:50 +00:00
Automerger Merge Worker 5759b94152 DO NOT MERGE - Empty merge qt-qpr1-dev-plus-aosp-without-vendor (6129114) into stage-aosp-master am: 45cb77c5bc
Change-Id: Id74bdff1f30e8a1a6da7ddd6c2c989eb1e0f889e
2020-01-16 01:46:18 +00:00
Xin Li 45cb77c5bc DO NOT MERGE - Empty merge qt-qpr1-dev-plus-aosp-without-vendor (6129114) into stage-aosp-master
Bug: 146167222
Change-Id: I0adb962a42c190f863a301731f8cf53237821555
2020-01-15 15:59:17 -08:00
Automerger Merge Worker 80db5e76e1 Use generated code for logging events to statsd am: ed8fe8465a am: 0ecafff527 am: 08a1f55b5c
Change-Id: Ia4cfd02666dbd8269f4dcde0fec6309e00dd9069
2020-01-15 23:32:46 +00:00
Automerger Merge Worker 08a1f55b5c Use generated code for logging events to statsd am: ed8fe8465a am: 0ecafff527
Change-Id: I3a438b1f43acd9e02031f1da3c66927ace16e607
2020-01-15 23:21:52 +00:00
Muhammad Qureshi 0ecafff527 Use generated code for logging events to statsd
am: ed8fe8465a

Change-Id: I7c80056a8453345552042728e3eea7c5ef5ccdca
2020-01-15 15:03:59 -08:00
Muhammad Qureshi ed8fe8465a Use generated code for logging events to statsd
Use the autogenerated libstatslog_lmkd to send events to statsd

The logging schema for statsd is changing as part of statsd becoming
a Mainline module in R. The autogenerated code will handle the schema
change.

Bug: 145887874
Test: m -j
Test: atest android.cts.statsd.atom.UidAtomTests#testLmkKillOccurred

Change-Id: Ibae4cd822807369a799d5c1f6a9c51272e38a074
2020-01-13 12:16:47 -08:00
Automerger Merge Worker 81ac3f6b11 lmkd: Restrict lmkd unsolicited notifications only to subscribed recipients am: 36baf44179 am: 9c7233e6c7 am: 1c18c3396b
Change-Id: I068d6335c7a0e09756cc343fb198261b0050472e
2019-12-23 23:26:38 +00:00
Automerger Merge Worker 1c18c3396b lmkd: Restrict lmkd unsolicited notifications only to subscribed recipients am: 36baf44179 am: 9c7233e6c7
Change-Id: Ib77c400f901477dce48127fc87e3531c113db2d9
2019-12-23 23:15:52 +00:00
Suren Baghdasaryan 9c7233e6c7 lmkd: Restrict lmkd unsolicited notifications only to subscribed recipients
am: 36baf44179

Change-Id: Iccb0b07c089bcf345e2dd8b5b08f412f3a891b9a
2019-12-23 15:02:33 -08:00
Suren Baghdasaryan 36baf44179 lmkd: Restrict lmkd unsolicited notifications only to subscribed recipients
lmkd unsolicited notifications can cause lmkd to block if clients are not
consuming them. Fix that by sending notifications to only subscribed
clients. Introduce LMK_SUBSCRIBE command to allow lmkd clients to subscribe
to event notifications. The only asynchronous event currently supported is
LMK_ASYNC_EVENT_KILL.

Bug: 146597855
Test: fill up send buffer using lmkd_unit_test
Test: confirm lmkd does not block after the fix
Change-Id: I014159aa55b59081f4b9ed53ecd160a49c0682bb
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-12-23 12:35:29 -08:00
Automerger Merge Worker a09aecfe6a lmkd_test: align proc_name with lmkd am: f2ead0ca1a am: 3cfaed6e43 am: 6b9bcd6944
Change-Id: I9a6e9d497f281000578512d9ec9a0abdf8433e23
2019-12-21 04:36:15 +00:00
Automerger Merge Worker 6b9bcd6944 lmkd_test: align proc_name with lmkd am: f2ead0ca1a am: 3cfaed6e43
Change-Id: I78837e4a72b0086498a5b6824d2a7c4ad5b86e86
2019-12-21 04:22:51 +00:00
Martin Liu 3cfaed6e43 lmkd_test: align proc_name with lmkd
am: f2ead0ca1a

Change-Id: If6fa397d5b2a2292270cec666bf8b05dd1bac183
2019-12-20 20:04:21 -08:00
Martin Liu f2ead0ca1a lmkd_test: align proc_name with lmkd
This change is to align how we get proc_name
between lmkd and lmkd_unit_test or it will always
fail when we run command such as ./lmkd_unit_test
under the device shell.

Bug: 146415484
Test: Verified using lmkd_unit_test
Change-Id: I3a6ebf0747a1054c5758b91fbacf3179b66b56c3
2019-12-20 11:12:06 +08:00
Automerger Merge Worker 053c05d93d Build lmkd as C++ am: 43f3d2b190 am: 9309a1b376 am: bd6dddceaf
Change-Id: I5adc4aa6051b636e5e166ad162193c2d18a5b616
2019-12-16 17:47:17 +00:00
Automerger Merge Worker bd6dddceaf Build lmkd as C++ am: 43f3d2b190 am: 9309a1b376
Change-Id: I44b4400d1d499a773e1ec0d716e417a189085724
2019-12-16 17:35:43 +00:00
Tom Cherry 9309a1b376 Build lmkd as C++
am: 43f3d2b190

Change-Id: I372c6b437070c09952dc4c84863db324d4aad912
2019-12-16 09:21:23 -08:00
Tom Cherry 43f3d2b190 Build lmkd as C++
Bug: 145669697
Test: build
Change-Id: I4fb2a9a900c8a6915ee84cc3d82434596301b24b
2019-12-13 08:40:30 -08:00
Automerger Merge Worker 908ad06a0f lmkd: Support to send unsolicited message to clients am: 5c48096d8d am: 3123c4746c am: 2b3ba70636
Change-Id: If6b12904d3bd8dd62b4762c00c11b1cb12f1fbbb
2019-12-13 02:25:46 +00:00
Automerger Merge Worker 2b3ba70636 lmkd: Support to send unsolicited message to clients am: 5c48096d8d am: 3123c4746c
Change-Id: I3f81a8cc8fb2f81a20e84a27334082a36d4af991
2019-12-13 01:47:08 +00:00
Jing Ji 3123c4746c lmkd: Support to send unsolicited message to clients
am: 5c48096d8d

Change-Id: Idf8184718f6e5a1ed13c1ce3476df81a59335d7d
2019-12-12 16:38:17 -08:00
Jing Ji 5c48096d8d lmkd: Support to send unsolicited message to clients
For now the only unsolicited message from lmkd is the process
kills on memory pressure.

Bug: 136036078
Test: atest ApplicationExitInfoTest

Change-Id: I503fd6a45ebab5276460b0ab978ebb2b8431dc0d
Signed-off-by: Jing Ji <jji@google.com>
2019-12-12 08:53:04 -08:00
George Burgess IV dc399add21 lmkd: fix an overallocation am: a5845e7b60 am: 7b28974872
am: 66e5e052f4

Change-Id: I8f8ff65ed45f7c8bfdafcd6f9ea85bd035178f26
2019-12-09 14:07:40 -08:00
George Burgess IV 66e5e052f4 lmkd: fix an overallocation am: a5845e7b60
am: 7b28974872

Change-Id: Ic0fab4e8d6aaa68fa82f926c6bbc7aed5656810e
2019-12-09 14:04:34 -08:00
George Burgess IV 7b28974872 lmkd: fix an overallocation
am: a5845e7b60

Change-Id: I923b746aed263de036baf61b4dde787e1bb1e402
2019-12-09 14:02:45 -08:00
George Burgess IV a5845e7b60 lmkd: fix an overallocation
pidhash is defined as an array of pointers:

static struct proc** pidhash = NULL;

...So we should be allocating `LINE_MAX * sizeof(struct proc *)` elems
here. Given the current constants here, this saves ~130KB, so not a big
deal, but still convenient.

Caught by clang's static analyzer:
system/memory/lmkd/statslog.c:354:19: warning: Result of 'calloc' is
converted to a pointer of type 'struct proc *', which is incompatible
with sizeof operand type 'struct proc'
[clang-analyzer-unix.MallocSizeof]

Bug: None
Test: TreeHugger
Change-Id: Iee9ca00a3a2a0ecababe9810d2ffcfc42169dd25
2019-12-09 11:02:08 -08:00
Suren Baghdasaryan a93503e3d7 lmkd: Support process types when registering a process
Add an optional process type field into lmkd registration protocol so that
applications can be distinguished from services.

Bug: 129011369
Test: boot and verify native service registration
Change-Id: Ie610b5d07cbe247a55ab31bc079ee5c5923bea11
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-11-07 18:19:15 +00:00
Suren Baghdasaryan 7d3c5c6ea2 lmkd: Add library function to unregister a process
Introduce lmkd_unregister_proc helper function. Fix a bug where
lmkd_pack_set_procremove used a wrong structure as a parameter.

Bug: 129011369
Test: verify process record removal when it is manually killed
Change-Id: I7ab5a499f6b1c6eecfdba4d0a5ec916053e2726a
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-11-07 18:18:54 +00:00
Suren Baghdasaryan f2cbefd298 lmkd: Prepare lmkd to support connection from init process
In order to register native services init needs ability to communicate with
lmkd. Make liblmkd_utils library available in recovery mode so that init
can link to it and add a data socket in lmkd to support additional
connection from init. Ensure SOCK_CLOEXEC type for lmkd socket to prevent
init children from inheriting it.

Bug: 129011369
Test: boot and verify native service registration
Change-Id: Iaa4f59282fb10f838f6811571e97d55754b1bd41
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-11-07 18:18:46 +00:00
Suren Baghdasaryan 945658abc4 lmkd: Restrict process record modifications to the client that created it
Associate each registered process with the PID of the lmkd client that
registered it to prevent one client from updating records of another
client.

Bug: 129011369
Test: boot and verify native service registration
Change-Id: Id8ca7bb6314df225d04da6469b523d2cdc237eaa
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-11-07 18:15:04 +00:00
Greg Kaiser 352e1d9575 Merge "lmkd: Remove unnecessary conditional"
am: 6b0e789a21

Change-Id: Iaa24b3f79aa09fa3957c91b55a28c170196afd50
2019-10-11 07:46:38 -07:00
Greg Kaiser 5e80ed5ff6 lmkd: Remove unnecessary conditional
We want poll_handler to be handler_info, so it's more efficient
to just unconditionally assign it.

Test: TreeHugger
Change-Id: I55b5164da1817ef77b5d455eb618f9a2471afc5c
2019-10-10 06:52:23 -07:00
Suren Baghdasaryan f9c3a891c5 Merge "lmkd: Track processes using pidfds"
am: d11c6f7fd8

Change-Id: I7cf396167954f51d3c7a092b5eebc54826f69f88
2019-10-09 11:13:15 -07:00
Suren Baghdasaryan ddcd0f67fc Merge "lmkd: Add support for process death notifications"
am: 530098cebc

Change-Id: I9316ebe6e9b8497f2a34dfb5a6423e216a73811f
2019-10-09 09:47:08 -07:00
Suren Baghdasaryan a10157c0d3 lmkd: Track processes using pidfds
lmkd uses PIDs to track processes, however occasionally a PID of a process
might be reused without lmkd detecting that. This can happen if originally
registered process crashes, PID numbers wrap around and the same PID gets
reused for a different process. In this situation lmkd might kill a wrong
process. To prevent this issue from occurring lmkd will track processes
using their pidfd. During process registration lmkd calls sys_pidfd_open
and stores returned pidfd with the process record. Returned pidfd will not
be reused until lmkd closes it which happens only after the process is
unregistered. This way lmkd ensures that process identification is unique
and can't be reused.

Bug: 135608568
Test: lmkd_unit_test with and without pidfd kernel support
Change-Id: Ida10ea13905c250e47f792cdd6bd2e65aeaa3709
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-10-08 18:15:34 -07:00
Suren Baghdasaryan bc99e1b702 lmkd: Add support for process death notifications
With pidfd polling support lmkd can detect process death without periodic
polling. Implement mechanism to detect kernel pidfd support using
pidfd_open syscall existence as an indicator. Implement the logic to use
pidfd to wait for process death.

Bug: 135608568
Test: lmkd_unit_test with and without pidfd kernel support
Change-Id: Ic6db7e50893534467f5130a7f998b66fb4451272
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-10-08 18:15:12 -07:00
Suren Baghdasaryan 770e14e1d6 Merge "lmkd: Fix string null termination in proc_get_size and proc_get_name"
am: d72d846754

Change-Id: I8f94dffd1583861289df8fd68ea5d18ace4238dc
2019-10-07 16:09:35 -07:00
Suren Baghdasaryan 632f1c5365 lmkd: Fix string null termination in proc_get_size and proc_get_name
Fix string null termination and cleanup proc_get_size and proc_get_name
functions.

Bug: 74119935
Test: lmkd_unit_test
Change-Id: Ied176b8d347b672b91866ac59a813d4ff349930a
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-10-07 12:50:38 -07:00
George Burgess IV b384307d44 Merge "lmkd: fix an uninit value bug"
am: 50816f0c21

Change-Id: Ia5d1982c11006897758d203d30e3fc7b62993616
2019-10-02 23:09:48 -07:00
Greg Kaiser b09ca44774 Merge "lmkd: Avoid potential out of buffer write"
am: 3d8fbfada6

Change-Id: Id7063aea8c8d5fb380e123af49cb3bb61c7fd449
2019-10-02 14:06:25 -07:00
George Burgess IV 3b36b904d6 lmkd: fix an uninit value bug
Caught by clang's static analyzer:
system/core/lmkd/lmkd.c:930:9: warning: 1st function call argument is an
uninitialized value [clang-analyzer-core.CallAndMessage]

Bug: None
Test: TreeHugger
Change-Id: I9dc8e97d6aa22ea977fa06553d957a31a9df8819
2019-10-02 19:55:41 +00:00
Treehugger Robot 3f5cb4c0d8 Merge "lmkd: Avoid potential out of buffer write" 2019-10-02 16:29:27 +00:00
Suren Baghdasaryan df37c06db4 Merge "lmkd: Change meminfo_log into killinfo_log and log additional fields"
am: c763c399a9

Change-Id: I9a4d5ee618f5eb3819718c151173f732aa45eeef
2019-10-02 07:35:45 -07:00
Greg Kaiser 259984f730 lmkd: Avoid potential out of buffer write
Our buffer needs enough space for the '\0' terminator character
as well.

Test: TreeHugger
Change-Id: Ib85d08dacf87b93d5f8b35b033ca0ec478868e66
2019-10-02 07:07:32 -07:00
Suren Baghdasaryan 12cacaedc0 lmkd: Change meminfo_log into killinfo_log and log additional fields
meminfo_log is used to log the state of the memory at the time of a kill.
Instead of reporting kill information and meminfo separately let's combine
them into one killinfo_log report. While normal logs can be trimmed by
chatty, meminfo_log uses a separate log context which gives it a better
chance of survival. As a result we will have all the information relevant
to a kill in one report which has higher chance of surviving chatty.

Bug: 74119935
Test: lmkd_unit_test
Change-Id: I83a9c12d538e1fb107721b04fdafc3c6c0d83b60
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-10-01 23:26:56 +00:00