summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKalesh Singh <kaleshsingh@google.com>2021-07-16 13:09:37 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-07-16 13:09:37 +0000
commit78467df0faff17d6232a1f5cc1bcd506e83f73b2 (patch)
tree25d439fc28129b235f3da1493f09a96019d16c75
parent98964f343527897e19197ba6847495b968a31812 (diff)
parent849e2defdd660aff25ffd898413123256f33d749 (diff)
downloadplatform_system_memory_libmeminfo-78467df0faff17d6232a1f5cc1bcd506e83f73b2.tar.gz
platform_system_memory_libmeminfo-78467df0faff17d6232a1f5cc1bcd506e83f73b2.tar.bz2
platform_system_memory_libmeminfo-78467df0faff17d6232a1f5cc1bcd506e83f73b2.zip
libdmabufinfo: Remove GetDmabufAttachmentStats am: 849e2defdd
Original change: https://android-review.googlesource.com/c/platform/system/memory/libmeminfo/+/1761690 Change-Id: Ic41690b8dd123d7f0d4e0950e1bf2aa821c342b6
-rw-r--r--libdmabufinfo/dmabuf_sysfs_stats.cpp48
-rw-r--r--libdmabufinfo/include/dmabufinfo/dmabuf_sysfs_stats.h25
2 files changed, 3 insertions, 70 deletions
diff --git a/libdmabufinfo/dmabuf_sysfs_stats.cpp b/libdmabufinfo/dmabuf_sysfs_stats.cpp
index f797f7a..e5a6486 100644
--- a/libdmabufinfo/dmabuf_sysfs_stats.cpp
+++ b/libdmabufinfo/dmabuf_sysfs_stats.cpp
@@ -45,35 +45,6 @@ static bool ReadUintFromFile(const std::string& path, unsigned int* val) {
return true;
}
-static bool GetDmabufAttachmentStats(const std::string& attachment_dir_path,
- std::vector<DmabufAttachmentInfo>& info) {
- std::unique_ptr<DIR, int (*)(DIR*)> dir(opendir(attachment_dir_path.c_str()), closedir);
-
- if (!dir) {
- PLOG(ERROR) << "Unable to access: " << attachment_dir_path;
- return false;
- }
-
- struct dirent* dent;
- while ((dent = readdir(dir.get()))) {
- if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, "..")) continue;
- std::string attachment_entry_path =
- ::android::base::StringPrintf("%s/%s", attachment_dir_path.c_str(), dent->d_name);
-
- std::string dev_path;
- if (!android::base::Readlink(attachment_entry_path + "/device", &dev_path)) return false;
-
- DmabufAttachmentInfo attachInfo = {};
- attachInfo.device = android::base::Basename(dev_path);
- if (!ReadUintFromFile(attachment_entry_path + "/map_counter", &attachInfo.map_count))
- return false;
-
- info.emplace_back(attachInfo);
- }
-
- return true;
-}
-
bool ReadBufferExporter(unsigned int inode, std::string* exporter,
const std::string& dmabuf_sysfs_path) {
std::string exporter_path =
@@ -92,8 +63,7 @@ bool GetDmabufSysfsStats(DmabufSysfsStats* stats, const std::string& dmabuf_sysf
// clear stats
*stats = {};
- // Iterate over all the buffer directories to save exporter name, size, mmap
- // count and attachment information.
+ // Iterate over all the buffer directories to save exporter name, and size.
struct dirent* dent;
while ((dent = readdir(dir.get()))) {
if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, "..")) continue;
@@ -127,10 +97,6 @@ bool GetDmabufSysfsStats(DmabufSysfsStats* stats, const std::string& dmabuf_sysf
stats->total_.size += info.size;
stats->total_.buffer_count++;
- // Read attachments on this buffer.
- std::string attachment_dir = buf_entry_path + "/attachments";
- if (!GetDmabufAttachmentStats(attachment_dir, info.attachments)) return false;
-
stats->buffer_stats_.emplace_back(info);
// update exporter_info_ map.
@@ -142,18 +108,6 @@ bool GetDmabufSysfsStats(DmabufSysfsStats* stats, const std::string& dmabuf_sysf
struct DmabufTotal total = {.size = info.size, .buffer_count = 1};
stats->exporter_info_[info.exp_name] = total;
}
-
- // update importer_info_ map.
- for (auto& attachment : info.attachments) {
- auto imp_stats = stats->importer_info_.find(attachment.device);
- if (imp_stats != stats->importer_info_.end()) {
- imp_stats->second.size += info.size;
- imp_stats->second.buffer_count++;
- } else {
- struct DmabufTotal total = {.size = info.size, .buffer_count = 1};
- stats->importer_info_[attachment.device] = total;
- }
- }
}
return true;
diff --git a/libdmabufinfo/include/dmabufinfo/dmabuf_sysfs_stats.h b/libdmabufinfo/include/dmabufinfo/dmabuf_sysfs_stats.h
index c7729ea..a7c0841 100644
--- a/libdmabufinfo/include/dmabufinfo/dmabuf_sysfs_stats.h
+++ b/libdmabufinfo/include/dmabufinfo/dmabuf_sysfs_stats.h
@@ -23,29 +23,16 @@ namespace android {
namespace dmabufinfo {
/*
- * struct DmabufAttachmentInfo: Information about an attachment on the DMA-BUF.
- *
- * @device: Name of the attaching device.
- * @map_count: The number of distinct mappings of the attachment.
- */
-struct DmabufAttachmentInfo {
- std::string device;
- unsigned int map_count;
-};
-
-/*
* struct DmabufInfo: Represents information about a DMA-BUF.
*
* @inode: The unique inode number for the buffer.
* @exp_name: Name of the exporter of the buffer.
* @size: Size of the buffer.
- * @attachments: represents all attachments on the DMA-BUF.
*/
struct DmabufInfo {
unsigned int inode;
std::string exp_name;
unsigned int size;
- std::vector<DmabufAttachmentInfo> attachments;
};
struct DmabufTotal {
@@ -59,9 +46,6 @@ class DmabufSysfsStats {
inline const std::unordered_map<std::string, struct DmabufTotal>& exporter_info() const {
return exporter_info_;
}
- inline const std::unordered_map<std::string, struct DmabufTotal>& importer_info() const {
- return importer_info_;
- }
inline uint64_t total_size() const { return total_.size; }
inline unsigned int total_count() const { return total_.buffer_count; }
@@ -70,13 +54,12 @@ class DmabufSysfsStats {
private:
std::vector<DmabufInfo> buffer_stats_;
std::unordered_map<std::string, struct DmabufTotal> exporter_info_;
- std::unordered_map<std::string, struct DmabufTotal> importer_info_;
struct DmabufTotal total_;
};
/*
- * Reads and parses DMA-BUF statistics from sysfs to create per-buffer,
- * per-exporter and per-importer stats.
+ * Reads and parses DMA-BUF statistics from sysfs to create per-buffer
+ * and per-exporter stats.
*
* @stats: output argument that will be populated with information from DMA-BUF sysfs stats.
* @path: Not for use by clients, to be used only for unit testing.
@@ -97,10 +80,6 @@ bool GetDmabufSysfsStats(DmabufSysfsStats* stats,
bool GetDmabufTotalExportedKb(uint64_t* total_exported,
const std::string& path = "/sys/kernel/dmabuf/buffers");
-/* Reads the total mmap count of the DMA buffer with @inode */
-bool ReadBufferTotalMmapCount(unsigned int inode, unsigned int* mmap_count,
- const std::string& dmabuf_sysfs_path = "/sys/kernel/dmabuf/buffers");
-
/* Reads the exporter name of the DMA buffer with @inode */
bool ReadBufferExporter(unsigned int inode, std::string* exporter,
const std::string& dmabuf_sysfs_path = "/sys/kernel/dmabuf/buffers");