Merge changes I22e6d914,Iabe7ecd9,I79bdb89e,I6a3cedc7
* changes: Make two error messages more detailed Use the 'override' keyword where appropriate Micro-optimize CgroupMap::ActivateControllers() Make class SetTimerSlackAction easier to maintain
This commit is contained in:
commit
e261623906
4 changed files with 28 additions and 34 deletions
|
@ -231,7 +231,8 @@ int CgroupMap::ActivateControllers(const std::string& path) const {
|
|||
const ACgroupController* controller = ACgroupFile_getController(i);
|
||||
if (ACgroupController_getFlags(controller) &
|
||||
CGROUPRC_CONTROLLER_FLAG_NEEDS_ACTIVATION) {
|
||||
std::string str = std::string("+") + ACgroupController_getName(controller);
|
||||
std::string str("+");
|
||||
str.append(ACgroupController_getName(controller));
|
||||
if (!WriteStringToFile(str, path + "/cgroup.subtree_control")) {
|
||||
return -errno;
|
||||
}
|
||||
|
|
|
@ -211,7 +211,7 @@ void removeAllProcessGroups() {
|
|||
for (std::string cgroup_root_path : cgroups) {
|
||||
std::unique_ptr<DIR, decltype(&closedir)> root(opendir(cgroup_root_path.c_str()), closedir);
|
||||
if (root == NULL) {
|
||||
PLOG(ERROR) << "Failed to open " << cgroup_root_path;
|
||||
PLOG(ERROR) << __func__ << " failed to open " << cgroup_root_path;
|
||||
} else {
|
||||
dirent* dir;
|
||||
while ((dir = readdir(root.get())) != nullptr) {
|
||||
|
@ -297,7 +297,8 @@ static int DoKillProcessGroupOnce(const char* cgroup, uid_t uid, int initialPid,
|
|||
// This happens when process is already dead
|
||||
return 0;
|
||||
}
|
||||
PLOG(WARNING) << "Failed to open process cgroup uid " << uid << " pid " << initialPid;
|
||||
PLOG(WARNING) << __func__ << " failed to open process cgroup uid " << uid << " pid "
|
||||
<< initialPid;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -183,6 +183,12 @@ bool SetTimerSlackAction::ExecuteForTask(int tid) const {
|
|||
return true;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool SetTimerSlackAction::ExecuteForTask(int) const {
|
||||
return true;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
bool SetAttributeAction::ExecuteForProcess(uid_t, pid_t pid) const {
|
||||
|
|
|
@ -65,22 +65,19 @@ class SetClampsAction : public ProfileAction {
|
|||
public:
|
||||
SetClampsAction(int boost, int clamp) noexcept : boost_(boost), clamp_(clamp) {}
|
||||
|
||||
virtual bool ExecuteForProcess(uid_t uid, pid_t pid) const;
|
||||
virtual bool ExecuteForTask(int tid) const;
|
||||
bool ExecuteForProcess(uid_t uid, pid_t pid) const override;
|
||||
bool ExecuteForTask(int tid) const override;
|
||||
|
||||
protected:
|
||||
int boost_;
|
||||
int clamp_;
|
||||
};
|
||||
|
||||
// To avoid issues in sdk_mac build
|
||||
#if defined(__ANDROID__)
|
||||
|
||||
class SetTimerSlackAction : public ProfileAction {
|
||||
public:
|
||||
SetTimerSlackAction(unsigned long slack) noexcept : slack_(slack) {}
|
||||
|
||||
virtual bool ExecuteForTask(int tid) const;
|
||||
bool ExecuteForTask(int tid) const override;
|
||||
|
||||
private:
|
||||
unsigned long slack_;
|
||||
|
@ -88,25 +85,14 @@ class SetTimerSlackAction : public ProfileAction {
|
|||
static bool IsTimerSlackSupported(int tid);
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
class SetTimerSlackAction : public ProfileAction {
|
||||
public:
|
||||
SetTimerSlackAction(unsigned long) noexcept {}
|
||||
|
||||
virtual bool ExecuteForTask(int) const { return true; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// Set attribute profile element
|
||||
class SetAttributeAction : public ProfileAction {
|
||||
public:
|
||||
SetAttributeAction(const ProfileAttribute* attribute, const std::string& value)
|
||||
: attribute_(attribute), value_(value) {}
|
||||
|
||||
virtual bool ExecuteForProcess(uid_t uid, pid_t pid) const;
|
||||
virtual bool ExecuteForTask(int tid) const;
|
||||
bool ExecuteForProcess(uid_t uid, pid_t pid) const override;
|
||||
bool ExecuteForTask(int tid) const override;
|
||||
|
||||
private:
|
||||
const ProfileAttribute* attribute_;
|
||||
|
@ -118,10 +104,10 @@ class SetCgroupAction : public ProfileAction {
|
|||
public:
|
||||
SetCgroupAction(const CgroupController& c, const std::string& p);
|
||||
|
||||
virtual bool ExecuteForProcess(uid_t uid, pid_t pid) const;
|
||||
virtual bool ExecuteForTask(int tid) const;
|
||||
virtual void EnableResourceCaching(ResourceCacheType cache_type);
|
||||
virtual void DropResourceCaching(ResourceCacheType cache_type);
|
||||
bool ExecuteForProcess(uid_t uid, pid_t pid) const override;
|
||||
bool ExecuteForTask(int tid) const override;
|
||||
void EnableResourceCaching(ResourceCacheType cache_type) override;
|
||||
void DropResourceCaching(ResourceCacheType cache_type) override;
|
||||
|
||||
const CgroupController* controller() const { return &controller_; }
|
||||
|
||||
|
@ -140,10 +126,10 @@ class WriteFileAction : public ProfileAction {
|
|||
public:
|
||||
WriteFileAction(const std::string& path, const std::string& value, bool logfailures);
|
||||
|
||||
virtual bool ExecuteForProcess(uid_t uid, pid_t pid) const;
|
||||
virtual bool ExecuteForTask(int tid) const;
|
||||
virtual void EnableResourceCaching(ResourceCacheType cache_type);
|
||||
virtual void DropResourceCaching(ResourceCacheType cache_type);
|
||||
bool ExecuteForProcess(uid_t uid, pid_t pid) const override;
|
||||
bool ExecuteForTask(int tid) const override;
|
||||
void EnableResourceCaching(ResourceCacheType cache_type) override;
|
||||
void DropResourceCaching(ResourceCacheType cache_type) override;
|
||||
|
||||
private:
|
||||
std::string path_, value_;
|
||||
|
@ -179,10 +165,10 @@ class ApplyProfileAction : public ProfileAction {
|
|||
ApplyProfileAction(const std::vector<std::shared_ptr<TaskProfile>>& profiles)
|
||||
: profiles_(profiles) {}
|
||||
|
||||
virtual bool ExecuteForProcess(uid_t uid, pid_t pid) const;
|
||||
virtual bool ExecuteForTask(int tid) const;
|
||||
virtual void EnableResourceCaching(ProfileAction::ResourceCacheType cache_type);
|
||||
virtual void DropResourceCaching(ProfileAction::ResourceCacheType cache_type);
|
||||
bool ExecuteForProcess(uid_t uid, pid_t pid) const override;
|
||||
bool ExecuteForTask(int tid) const override;
|
||||
void EnableResourceCaching(ProfileAction::ResourceCacheType cache_type) override;
|
||||
void DropResourceCaching(ProfileAction::ResourceCacheType cache_type) override;
|
||||
|
||||
private:
|
||||
std::vector<std::shared_ptr<TaskProfile>> profiles_;
|
||||
|
|
Loading…
Reference in a new issue