Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7f62f31 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "GpuMem perfetto producer"

parents f94c06fc b9f62d6b
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@ cc_defaults {
        "libcutils",
        "libcutils",
        "libgfxstats",
        "libgfxstats",
        "libgpumem",
        "libgpumem",
        "libgpumemtracer",
        "libgraphicsenv",
        "libgraphicsenv",
        "liblog",
        "liblog",
        "libutils",
        "libutils",
+8 −2
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@
#include <gpumem/GpuMem.h>
#include <gpumem/GpuMem.h>
#include <gpustats/GpuStats.h>
#include <gpustats/GpuStats.h>
#include <private/android_filesystem_config.h>
#include <private/android_filesystem_config.h>
#include <tracing/GpuMemTracer.h>
#include <utils/String8.h>
#include <utils/String8.h>
#include <utils/Trace.h>
#include <utils/Trace.h>
#include <vkjson.h>
#include <vkjson.h>
@@ -48,8 +49,13 @@ const String16 sDump("android.permission.DUMP");
const char* const GpuService::SERVICE_NAME = "gpu";
const char* const GpuService::SERVICE_NAME = "gpu";


GpuService::GpuService()
GpuService::GpuService()
      : mGpuMem(std::make_unique<GpuMem>()), mGpuStats(std::make_unique<GpuStats>()) {
      : mGpuMem(std::make_shared<GpuMem>()),
    std::thread asyncInitThread([this]() { mGpuMem->initialize(); });
        mGpuStats(std::make_unique<GpuStats>()),
        mGpuMemTracer(std::make_unique<GpuMemTracer>()) {
    std::thread asyncInitThread([this]() {
        mGpuMem->initialize();
        mGpuMemTracer->initialize(mGpuMem);
    });
    asyncInitThread.detach();
    asyncInitThread.detach();
};
};


+3 −1
Original line number Original line Diff line number Diff line
@@ -30,6 +30,7 @@ namespace android {


class GpuMem;
class GpuMem;
class GpuStats;
class GpuStats;
class GpuMemTracer;


class GpuService : public BnGpuService, public PriorityDumper {
class GpuService : public BnGpuService, public PriorityDumper {
public:
public:
@@ -75,8 +76,9 @@ private:
    /*
    /*
     * Attributes
     * Attributes
     */
     */
    std::unique_ptr<GpuMem> mGpuMem;
    std::shared_ptr<GpuMem> mGpuMem;
    std::unique_ptr<GpuStats> mGpuStats;
    std::unique_ptr<GpuStats> mGpuStats;
    std::unique_ptr<GpuMemTracer> mGpuMemTracer;
    std::string developerDriverPath;
    std::string developerDriverPath;
};
};


+23 −0
Original line number Original line Diff line number Diff line
@@ -31,6 +31,29 @@ public:
    void initialize();
    void initialize();
    // dumpsys interface
    // dumpsys interface
    void dump(const Vector<String16>& args, std::string* result);
    void dump(const Vector<String16>& args, std::string* result);
    bool isInitialized() { return mInitialized.load(); }

    // Traverse the map and send each value read back to the callback function.
    // Used for tracing.
    template <typename lambda>
    void traceGpuMemTotals(lambda tracerCallback) {
        auto res = mGpuMemTotalMap.getFirstKey();
        if (!res.ok()) return;
        uint64_t key = res.value();
        while (true) {
            uint32_t gpu_id = key >> 32;
            uint32_t pid = key;

            res = mGpuMemTotalMap.readValue(key);
            if (!res.ok()) break;
            uint64_t size = res.value();

            tracerCallback(gpu_id, pid, size);
            res = mGpuMemTotalMap.getNextKey(key);
            if (!res.ok()) break;
            key = res.value();
        }
    }


private:
private:
    // Friend class for testing.
    // Friend class for testing.
+41 −0
Original line number Original line Diff line number Diff line
// Copyright 2020 The Android Open Source Project
//
// 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.

cc_library_shared {
    name: "libgpumemtracer",
    srcs: [
        "GpuMemTracer.cpp",
    ],
    shared_libs: [
        "libgpumem",
        "libbase",
        "liblog",
        "libutils",
    ],
    static_libs: [
        "libperfetto_client_experimental",
    ],
    export_include_dirs: ["include"],
    export_static_lib_headers: [
        "libperfetto_client_experimental",
    ],
    cppflags: [
        "-Wall",
        "-Werror",
        "-Wformat",
        "-Wthread-safety",
        "-Wunused",
        "-Wunreachable-code",
    ],
}
Loading