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>
This commit is contained in:
parent
adb54f81bf
commit
4c6d3d737f
3 changed files with 20 additions and 1 deletions
|
|
@ -39,6 +39,14 @@ int lmkd_connect();
|
|||
*/
|
||||
int lmkd_register_proc(int sock, struct lmk_procprio *params);
|
||||
|
||||
/*
|
||||
* Unregisters a process previously registered with lmkd.
|
||||
* On success returns 0.
|
||||
* On error, -1 is returned.
|
||||
* In the case of error errno is set appropriately.
|
||||
*/
|
||||
int lmkd_unregister_proc(int sock, struct lmk_procremove *params);
|
||||
|
||||
/*
|
||||
* Creates memcg directory for given process.
|
||||
* On success returns 0.
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ static inline void lmkd_pack_get_procremove(LMKD_CTRL_PACKET packet,
|
|||
* Warning: no checks performed, caller should ensure valid parameters.
|
||||
*/
|
||||
static inline size_t lmkd_pack_set_procremove(LMKD_CTRL_PACKET packet,
|
||||
struct lmk_procprio* params) {
|
||||
struct lmk_procremove* params) {
|
||||
packet[0] = htonl(LMK_PROCREMOVE);
|
||||
packet[1] = htonl(params->pid);
|
||||
return 2 * sizeof(int);
|
||||
|
|
|
|||
|
|
@ -42,6 +42,17 @@ int lmkd_register_proc(int sock, struct lmk_procprio *params) {
|
|||
return (ret < 0) ? -1 : 0;
|
||||
}
|
||||
|
||||
int lmkd_unregister_proc(int sock, struct lmk_procremove *params) {
|
||||
LMKD_CTRL_PACKET packet;
|
||||
size_t size;
|
||||
int ret;
|
||||
|
||||
size = lmkd_pack_set_procremove(packet, params);
|
||||
ret = TEMP_FAILURE_RETRY(write(sock, packet, size));
|
||||
|
||||
return (ret < 0) ? -1 : 0;
|
||||
}
|
||||
|
||||
int create_memcg(uid_t uid, pid_t pid) {
|
||||
char buf[256];
|
||||
int tasks_file;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue