liblmkd_utils: Adding get kill count interface am: 05e8c7bbda am: 3cd5c9cc3f
Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/3086709 Change-Id: I96e44c3bdc49c2cdda32bac211af65353e520f4b Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
0359abe3f7
|
|
@ -85,6 +85,19 @@ enum boot_completed_notification_result {
|
||||||
*/
|
*/
|
||||||
enum boot_completed_notification_result lmkd_notify_boot_completed(int sock);
|
enum boot_completed_notification_result lmkd_notify_boot_completed(int sock);
|
||||||
|
|
||||||
|
enum get_kill_count_err_result {
|
||||||
|
GET_KILL_COUNT_SEND_ERR = -1,
|
||||||
|
GET_KILL_COUNT_RECV_ERR = -2,
|
||||||
|
GET_KILL_COUNT_FORMAT_ERR = -3,
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the number of kills LMKD has performed.
|
||||||
|
* On success returns number of kills.
|
||||||
|
* On error, get_kill_count_err_result integer value.
|
||||||
|
*/
|
||||||
|
int lmkd_get_kill_count(int sock, struct lmk_getkillcnt* params);
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
#endif /* _LIBLMKD_UTILS_H_ */
|
#endif /* _LIBLMKD_UTILS_H_ */
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,27 @@ enum boot_completed_notification_result lmkd_notify_boot_completed(int sock) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int lmkd_get_kill_count(int sock, struct lmk_getkillcnt* params) {
|
||||||
|
LMKD_CTRL_PACKET packet;
|
||||||
|
int size;
|
||||||
|
|
||||||
|
size = lmkd_pack_set_getkillcnt(packet, params);
|
||||||
|
if (TEMP_FAILURE_RETRY(write(sock, packet, size)) < 0) {
|
||||||
|
return (int)GET_KILL_COUNT_SEND_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
size = TEMP_FAILURE_RETRY(read(sock, packet, CTRL_PACKET_MAX_SIZE));
|
||||||
|
if (size < 0) {
|
||||||
|
return (int)GET_KILL_COUNT_RECV_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size != 2 * sizeof(int) || lmkd_pack_get_cmd(packet) != LMK_GETKILLCNT) {
|
||||||
|
return (int)GET_KILL_COUNT_FORMAT_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return packet[1];
|
||||||
|
}
|
||||||
|
|
||||||
int create_memcg(uid_t uid, pid_t pid) {
|
int create_memcg(uid_t uid, pid_t pid) {
|
||||||
return createProcessGroup(uid, pid, true) == 0 ? 0 : -1;
|
return createProcessGroup(uid, pid, true) == 0 ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue