Merge "libprocessgroup: Remove prctl interface for setting timer slack" into main
This commit is contained in:
commit
cd2475ccf6
2 changed files with 7 additions and 27 deletions
|
|
@ -203,33 +203,15 @@ bool SetClampsAction::ExecuteForTask(int) const {
|
||||||
// To avoid issues in sdk_mac build
|
// To avoid issues in sdk_mac build
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
|
|
||||||
bool SetTimerSlackAction::IsTimerSlackSupported(pid_t tid) {
|
|
||||||
auto file = StringPrintf("/proc/%d/timerslack_ns", tid);
|
|
||||||
|
|
||||||
return (access(file.c_str(), W_OK) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SetTimerSlackAction::ExecuteForTask(pid_t tid) const {
|
bool SetTimerSlackAction::ExecuteForTask(pid_t tid) const {
|
||||||
static bool sys_supports_timerslack = IsTimerSlackSupported(tid);
|
const auto file = StringPrintf("/proc/%d/timerslack_ns", tid);
|
||||||
|
if (!WriteStringToFile(std::to_string(slack_), file)) {
|
||||||
// v4.6+ kernels support the /proc/<tid>/timerslack_ns interface.
|
if (errno == ENOENT) {
|
||||||
// TODO: once we've backported this, log if the open(2) fails.
|
// This happens when process is already dead
|
||||||
if (sys_supports_timerslack) {
|
return true;
|
||||||
auto file = StringPrintf("/proc/%d/timerslack_ns", tid);
|
|
||||||
if (!WriteStringToFile(std::to_string(slack_), file)) {
|
|
||||||
if (errno == ENOENT) {
|
|
||||||
// This happens when process is already dead
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
PLOG(ERROR) << "set_timerslack_ns write failed";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Remove when /proc/<tid>/timerslack_ns interface is backported.
|
|
||||||
if (tid == 0 || tid == GetThreadId()) {
|
|
||||||
if (prctl(PR_SET_TIMERSLACK, slack_) == -1) {
|
|
||||||
PLOG(ERROR) << "set_timerslack_ns prctl failed";
|
|
||||||
}
|
}
|
||||||
|
PLOG(ERROR) << "set_timerslack_ns write failed";
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -114,8 +114,6 @@ class SetTimerSlackAction : public ProfileAction {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned long slack_;
|
unsigned long slack_;
|
||||||
|
|
||||||
static bool IsTimerSlackSupported(pid_t tid);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set attribute profile element
|
// Set attribute profile element
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue