init: Add support for specifying a services i/o priority
Signed-off-by: San Mehat <san@google.com>
This commit is contained in:
parent
1bfb4803ea
commit
4e221f0077
4 changed files with 39 additions and 0 deletions
|
@ -35,6 +35,7 @@
|
|||
#include <sys/reboot.h>
|
||||
|
||||
#include <cutils/sockets.h>
|
||||
#include <cutils/iosched_policy.h>
|
||||
#include <termios.h>
|
||||
#include <linux/kd.h>
|
||||
#include <linux/keychord.h>
|
||||
|
@ -224,6 +225,13 @@ void service_start(struct service *svc, const char *dynamic_args)
|
|||
}
|
||||
}
|
||||
|
||||
if (svc->ioprio_class != IoSchedClass_NONE) {
|
||||
if (android_set_ioprio(getpid(), svc->ioprio_class, svc->ioprio_pri)) {
|
||||
ERROR("Failed to set pid %d ioprio = %d,%d: %s\n",
|
||||
getpid(), svc->ioprio_class, svc->ioprio_pri, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
if (needs_console) {
|
||||
setsid();
|
||||
open_console();
|
||||
|
|
|
@ -146,6 +146,9 @@ struct service {
|
|||
int nkeycodes;
|
||||
int keychord_id;
|
||||
|
||||
int ioprio_class;
|
||||
int ioprio_pri;
|
||||
|
||||
int nargs;
|
||||
/* "MUST BE AT THE END OF THE STRUCT" */
|
||||
char *args[1];
|
||||
|
|
|
@ -75,6 +75,7 @@ enum {
|
|||
KEYWORD(chmod, COMMAND, 2, do_chmod)
|
||||
KEYWORD(loglevel, COMMAND, 1, do_loglevel)
|
||||
KEYWORD(device, COMMAND, 4, do_device)
|
||||
KEYWORD(ioprio, OPTION, 0, 0)
|
||||
#ifdef __MAKE_KEYWORD_ENUM__
|
||||
KEYWORD_COUNT,
|
||||
};
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#include "init.h"
|
||||
#include "property_service.h"
|
||||
|
||||
#include <cutils/iosched_policy.h>
|
||||
|
||||
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
|
||||
#include <sys/_system_properties.h>
|
||||
|
||||
|
@ -155,6 +157,7 @@ int lookup_keyword(const char *s)
|
|||
if (!strcmp(s, "ostname")) return K_hostname;
|
||||
break;
|
||||
case 'i':
|
||||
if (!strcmp(s, "oprio")) return K_ioprio;
|
||||
if (!strcmp(s, "fup")) return K_ifup;
|
||||
if (!strcmp(s, "nsmod")) return K_insmod;
|
||||
if (!strcmp(s, "mport")) return K_import;
|
||||
|
@ -619,6 +622,8 @@ static void parse_line_service(struct parse_state *state, int nargs, char **args
|
|||
return;
|
||||
}
|
||||
|
||||
svc->ioprio_class = IoSchedClass_NONE;
|
||||
|
||||
kw = lookup_keyword(args[0]);
|
||||
switch (kw) {
|
||||
case K_capability:
|
||||
|
@ -636,6 +641,28 @@ static void parse_line_service(struct parse_state *state, int nargs, char **args
|
|||
case K_disabled:
|
||||
svc->flags |= SVC_DISABLED;
|
||||
break;
|
||||
case K_ioprio:
|
||||
if (nargs != 3) {
|
||||
parse_error(state, "ioprio optin usage: ioprio <rt|be|idle> <ioprio 0-7>\n");
|
||||
} else {
|
||||
svc->ioprio_pri = strtoul(args[2], 0, 8);
|
||||
|
||||
if (svc->ioprio_pri < 0 || svc->ioprio_pri > 7) {
|
||||
parse_error(state, "priority value must be range 0 - 7\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (!strcmp(args[1], "rt")) {
|
||||
svc->ioprio_class = IoSchedClass_RT;
|
||||
} else if (!strcmp(args[1], "be")) {
|
||||
svc->ioprio_class = IoSchedClass_BE;
|
||||
} else if (!strcmp(args[1], "idle")) {
|
||||
svc->ioprio_class = IoSchedClass_IDLE;
|
||||
} else {
|
||||
parse_error(state, "ioprio option usage: ioprio <rt|be|idle> <0-7>\n");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case K_group:
|
||||
if (nargs < 2) {
|
||||
parse_error(state, "group option requires a group id\n");
|
||||
|
|
Loading…
Reference in a new issue