Skip to content
Snippets Groups Projects
Select Git revision
  • pu
  • passt default
  • master
  • todo
  • next
  • maint
  • v2.8.0-rc1
  • v2.8.0-rc0
  • v2.7.2
  • v2.7.1
  • v2.7.0
  • v2.6.5
  • v2.7.0-rc3
  • v2.7.0-rc2
  • v2.7.0-rc1
  • v2.7.0-rc0
  • v2.6.4
  • v2.6.3
  • v2.6.2
  • v2.6.1
  • v2.3.10
  • v2.5.4
  • v2.4.10
  • v2.6.0
  • v2.6.0-rc3
  • v2.5.3
26 results

advice.h

Blame
  • processgroup.cpp 11.00 KiB
    /*
     *  Copyright 2014 Google, Inc
     *
     *  Licensed under the Apache License, Version 2.0 (the "License");
     *  you may not use this file except in compliance with the License.
     *  You may obtain a copy of the License at
     *
     *      http://www.apache.org/licenses/LICENSE-2.0
     *
     *  Unless required by applicable law or agreed to in writing, software
     *  distributed under the License is distributed on an "AS IS" BASIS,
     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     *  See the License for the specific language governing permissions and
     *  limitations under the License.
     */
    
    //#define LOG_NDEBUG 0
    #define LOG_TAG "libprocessgroup"
    
    #include <assert.h>
    #include <dirent.h>
    #include <errno.h>
    #include <fcntl.h>
    #include <inttypes.h>
    #include <signal.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <sys/stat.h>
    #include <sys/types.h>
    #include <unistd.h>
    
    #include <chrono>
    #include <memory>
    #include <mutex>
    #include <set>
    #include <string>
    #include <thread>
    
    #include <android-base/file.h>
    #include <android-base/logging.h>
    #include <android-base/properties.h>
    #include <android-base/stringprintf.h>
    #include <android-base/strings.h>
    #include <private/android_filesystem_config.h>
    
    #include <processgroup/processgroup.h>
    
    using android::base::GetBoolProperty;
    using android::base::StartsWith;
    using android::base::StringPrintf;
    using android::base::WriteStringToFile;
    
    using namespace std::chrono_literals;
    
    #define MEM_CGROUP_PATH "/dev/memcg/apps"
    #define MEM_CGROUP_TASKS "/dev/memcg/apps/tasks"
    #define ACCT_CGROUP_PATH "/acct"
    
    #define PROCESSGROUP_CGROUP_PROCS_FILE "/cgroup.procs"
    
    std::once_flag init_path_flag;
    
    static const std::string& GetCgroupRootPath() {
        static std::string cgroup_root_path;
        std::call_once(init_path_flag, [&]() {
            // low-ram devices use per-app memcg by default, unlike high-end ones
            bool low_ram_device = GetBoolProperty("ro.config.low_ram", false);
            bool per_app_memcg =
                GetBoolProperty("ro.config.per_app_memcg", low_ram_device);