blob: 72e3f4a2bc125d245e102fa35d89fc3f58ce735b [file] [log] [blame]
Suren Baghdasaryan0f100512018-01-24 16:51:41 -08001/*
2 * Copyright 2018 Google, Inc
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _LIBLMKD_UTILS_H_
18#define _LIBLMKD_UTILS_H_
19
20#include <sys/cdefs.h>
21#include <sys/types.h>
22
23#include <lmkd.h>
24
25__BEGIN_DECLS
26
27/*
28 * Connects to lmkd process and returns socket handle.
29 * On success returns socket handle.
30 * On error, -1 is returned, and errno is set appropriately.
31 */
32int lmkd_connect();
33
34/*
35 * Registers a process with lmkd and sets its oomadj score.
36 * On success returns 0.
37 * On error, -1 is returned.
38 * In the case of error errno is set appropriately.
39 */
40int lmkd_register_proc(int sock, struct lmk_procprio *params);
41
42/*
43 * Creates memcg directory for given process.
44 * On success returns 0.
45 * -1 is returned if path creation failed.
46 * -2 is returned if tasks file open operation failed.
47 * -3 is returned if tasks file write operation failed.
48 * In the case of error errno is set appropriately.
49 */
50int create_memcg(uid_t uid, pid_t pid);
51
52__END_DECLS
53
54#endif /* _LIBLMKD_UTILS_H_ */