summaryrefslogtreecommitdiff
path: root/libprocessgroup/processgroup.cpp
diff options
context:
space:
mode:
authorSuren Baghdasaryan <surenb@google.com>2019-04-22 16:08:34 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-04-22 16:08:34 +0000
commit1a043459a93192d52ef03ca730cfafccda1d227d (patch)
treed205e24b5c1ba222dddd8bd340b88171500632dc /libprocessgroup/processgroup.cpp
parent1412f3c99de746c13ee35f19df514863b888eeb8 (diff)
parent8a315d2a3eb65d39f98f639565f7a29196f5e7bd (diff)
Merge "Re-enable file descriptor caching and add option to skip caching"
Diffstat (limited to 'libprocessgroup/processgroup.cpp')
-rw-r--r--libprocessgroup/processgroup.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/libprocessgroup/processgroup.cpp b/libprocessgroup/processgroup.cpp
index abe63dd70..1485ae986 100644
--- a/libprocessgroup/processgroup.cpp
+++ b/libprocessgroup/processgroup.cpp
@@ -112,12 +112,16 @@ static bool isMemoryCgroupSupported() {
return memcg_supported;
}
-bool SetProcessProfiles(uid_t uid, pid_t pid, const std::vector<std::string>& profiles) {
+bool SetProcessProfiles(uid_t uid, pid_t pid, const std::vector<std::string>& profiles,
+ bool use_fd_cache) {
const TaskProfiles& tp = TaskProfiles::GetInstance();
for (const auto& name : profiles) {
- const TaskProfile* profile = tp.GetProfile(name);
+ TaskProfile* profile = tp.GetProfile(name);
if (profile != nullptr) {
+ if (use_fd_cache) {
+ profile->EnableResourceCaching();
+ }
if (!profile->ExecuteForProcess(uid, pid)) {
PLOG(WARNING) << "Failed to apply " << name << " process profile";
}
@@ -129,12 +133,15 @@ bool SetProcessProfiles(uid_t uid, pid_t pid, const std::vector<std::string>& pr
return true;
}
-bool SetTaskProfiles(int tid, const std::vector<std::string>& profiles) {
+bool SetTaskProfiles(int tid, const std::vector<std::string>& profiles, bool use_fd_cache) {
const TaskProfiles& tp = TaskProfiles::GetInstance();
for (const auto& name : profiles) {
- const TaskProfile* profile = tp.GetProfile(name);
+ TaskProfile* profile = tp.GetProfile(name);
if (profile != nullptr) {
+ if (use_fd_cache) {
+ profile->EnableResourceCaching();
+ }
if (!profile->ExecuteForTask(tid)) {
PLOG(WARNING) << "Failed to apply " << name << " task profile";
}