Merge "meminfo: Fix dmabufinfo total ref accounting"
This commit is contained in:
commit
32afafa67e
2 changed files with 12 additions and 8 deletions
|
|
@ -130,7 +130,7 @@ static bool ReadDmaBufFdRefs(pid_t pid, std::vector<DmaBuffer>* dmabufs) {
|
||||||
if (buf->count() == 0)
|
if (buf->count() == 0)
|
||||||
buf->SetCount(count);
|
buf->SetCount(count);
|
||||||
buf->AddFdRef(pid);
|
buf->AddFdRef(pid);
|
||||||
return true;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
DmaBuffer& db =
|
DmaBuffer& db =
|
||||||
|
|
|
||||||
|
|
@ -30,17 +30,21 @@ struct DmaBuffer {
|
||||||
public:
|
public:
|
||||||
DmaBuffer(ino_t inode, uint64_t size, uint64_t count, const std::string& exporter,
|
DmaBuffer(ino_t inode, uint64_t size, uint64_t count, const std::string& exporter,
|
||||||
const std::string& name)
|
const std::string& name)
|
||||||
: inode_(inode), size_(size), count_(count), exporter_(exporter), name_(name) {}
|
: inode_(inode), size_(size), count_(count), exporter_(exporter), name_(name) {
|
||||||
|
total_refs_ = 0;
|
||||||
|
}
|
||||||
~DmaBuffer() = default;
|
~DmaBuffer() = default;
|
||||||
|
|
||||||
// Adds one file descriptor reference for the given pid
|
// Adds one file descriptor reference for the given pid
|
||||||
void AddFdRef(pid_t pid) {
|
void AddFdRef(pid_t pid) {
|
||||||
AddRefToPidMap(pid, &fdrefs_);
|
AddRefToPidMap(pid, &fdrefs_);
|
||||||
|
total_refs_++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adds one map reference for the given pid
|
// Adds one map reference for the given pid
|
||||||
void AddMapRef(pid_t pid) {
|
void AddMapRef(pid_t pid) {
|
||||||
AddRefToPidMap(pid, &maprefs_);
|
AddRefToPidMap(pid, &maprefs_);
|
||||||
|
total_refs_++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters for each property
|
// Getters for each property
|
||||||
|
|
@ -48,7 +52,7 @@ struct DmaBuffer {
|
||||||
const std::unordered_map<pid_t, int>& fdrefs() const { return fdrefs_; }
|
const std::unordered_map<pid_t, int>& fdrefs() const { return fdrefs_; }
|
||||||
const std::unordered_map<pid_t, int>& maprefs() const { return maprefs_; }
|
const std::unordered_map<pid_t, int>& maprefs() const { return maprefs_; }
|
||||||
ino_t inode() const { return inode_; }
|
ino_t inode() const { return inode_; }
|
||||||
uint64_t total_refs() const { return fdrefs_.size() + maprefs_.size(); }
|
uint64_t total_refs() const { return total_refs_; }
|
||||||
uint64_t count() const { return count_; };
|
uint64_t count() const { return count_; };
|
||||||
const std::string& name() const { return name_; }
|
const std::string& name() const { return name_; }
|
||||||
const std::string& exporter() const { return exporter_; }
|
const std::string& exporter() const { return exporter_; }
|
||||||
|
|
@ -65,6 +69,7 @@ struct DmaBuffer {
|
||||||
ino_t inode_;
|
ino_t inode_;
|
||||||
uint64_t size_;
|
uint64_t size_;
|
||||||
uint64_t count_;
|
uint64_t count_;
|
||||||
|
uint64_t total_refs_;
|
||||||
std::string exporter_;
|
std::string exporter_;
|
||||||
std::string name_;
|
std::string name_;
|
||||||
std::unordered_map<pid_t, int> fdrefs_;
|
std::unordered_map<pid_t, int> fdrefs_;
|
||||||
|
|
@ -81,7 +86,6 @@ struct DmaBuffer {
|
||||||
// Read and return current dma buf objects from
|
// Read and return current dma buf objects from
|
||||||
// DEBUGFS/dma_buf/bufinfo. The references to each dma buffer are not
|
// DEBUGFS/dma_buf/bufinfo. The references to each dma buffer are not
|
||||||
// populated here and will return an empty vector.
|
// populated here and will return an empty vector.
|
||||||
//
|
|
||||||
// Returns false if something went wrong with the function, true otherwise.
|
// Returns false if something went wrong with the function, true otherwise.
|
||||||
bool ReadDmaBufInfo(std::vector<DmaBuffer>* dmabufs,
|
bool ReadDmaBufInfo(std::vector<DmaBuffer>* dmabufs,
|
||||||
const std::string& path = "/sys/kernel/debug/dma_buf/bufinfo");
|
const std::string& path = "/sys/kernel/debug/dma_buf/bufinfo");
|
||||||
|
|
@ -89,13 +93,13 @@ bool ReadDmaBufInfo(std::vector<DmaBuffer>* dmabufs,
|
||||||
|
|
||||||
// Read and return dmabuf objects for a given process without the help
|
// Read and return dmabuf objects for a given process without the help
|
||||||
// of DEBUGFS
|
// of DEBUGFS
|
||||||
//
|
|
||||||
// Returns false if something went wrong with the function, true otherwise.
|
// Returns false if something went wrong with the function, true otherwise.
|
||||||
bool ReadDmaBufInfo(pid_t pid, std::vector<DmaBuffer>* dmabufs);
|
bool ReadDmaBufInfo(pid_t pid, std::vector<DmaBuffer>* dmabufs);
|
||||||
|
|
||||||
// Append dmabuf objects for a given process without the help
|
// Append new dmabuf objects from a given process to an existing vector.
|
||||||
// of DEBUGFS to an existing vector
|
// When the vector contains an existing element with a matching inode,
|
||||||
//
|
// the reference counts will be updated.
|
||||||
|
// Does not depend on DEBUGFS.
|
||||||
// Returns false if something went wrong with the function, true otherwise.
|
// Returns false if something went wrong with the function, true otherwise.
|
||||||
bool AppendDmaBufInfo(pid_t pid, std::vector<DmaBuffer>* dmabufs);
|
bool AppendDmaBufInfo(pid_t pid, std::vector<DmaBuffer>* dmabufs);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue