ANDROID: Add dmabuf RSS trace event
Dmabuf RSS is associated with a task, or group of tasks sharing the same mm_struct and files_struct. Any time the RSS counter is modified for a task, or group of tasks, emit a trace event with the current value of the dmabuf RSS counter. This allows for fast tracking of per-process dmabuf RSS by userspace analysis tools like Perfetto, compared to periodically obtaining per-process dmabuf RSS from procfs. Bug: 424646615 Change-Id: I74434dddacc342918cb52b1b9e2fa6679e332764 Signed-off-by: T.J. Mercier <tjmercier@google.com>
This commit is contained in:
committed by
Suren Baghdasaryan
parent
e9f7ac1c25
commit
c8fdc081cf
@@ -31,6 +31,9 @@
|
||||
#include <uapi/linux/dma-buf.h>
|
||||
#include <uapi/linux/magic.h>
|
||||
|
||||
#ifndef __GENKSYMS__
|
||||
#include <trace/events/kmem.h>
|
||||
#endif
|
||||
#include <trace/hooks/dmabuf.h>
|
||||
|
||||
#include "dma-buf-sysfs-stats.h"
|
||||
@@ -211,6 +214,7 @@ static int new_task_dmabuf_record(struct task_struct *task, struct dma_buf *dmab
|
||||
return -ENOMEM;
|
||||
|
||||
dmabuf_info->rss += dmabuf->size;
|
||||
trace_dmabuf_rss_stat(dmabuf_info->rss, dmabuf->size, dmabuf);
|
||||
/*
|
||||
* dmabuf_info->lock protects against concurrent writers, so no
|
||||
* worries about stale rss_hwm between the read and write, and we don't
|
||||
@@ -312,6 +316,7 @@ void dma_buf_unaccount_task(struct dma_buf *dmabuf, struct task_struct *task)
|
||||
list_del(&rec->node);
|
||||
kfree(rec);
|
||||
dmabuf_info->rss -= dmabuf->size;
|
||||
trace_dmabuf_rss_stat(dmabuf_info->rss, -dmabuf->size, dmabuf);
|
||||
atomic64_dec(&get_dmabuf_ext(dmabuf)->num_unique_refs);
|
||||
}
|
||||
err:
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include <linux/types.h>
|
||||
#include <linux/tracepoint.h>
|
||||
#include <trace/events/mmflags.h>
|
||||
#include <linux/dma-buf.h>
|
||||
|
||||
TRACE_EVENT(kmem_cache_alloc,
|
||||
|
||||
@@ -487,6 +488,30 @@ TRACE_EVENT(rss_stat,
|
||||
__print_symbolic(__entry->member, TRACE_MM_PAGES),
|
||||
__entry->size)
|
||||
);
|
||||
|
||||
TRACE_EVENT(dmabuf_rss_stat,
|
||||
|
||||
TP_PROTO(size_t rss, ssize_t rss_delta, struct dma_buf *dmabuf),
|
||||
|
||||
TP_ARGS(rss, rss_delta, dmabuf),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field(size_t, rss)
|
||||
__field(ssize_t, rss_delta)
|
||||
__field(unsigned long, i_ino)
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->rss = rss;
|
||||
__entry->rss_delta = rss_delta;
|
||||
__entry->i_ino = file_inode(dmabuf->file)->i_ino;
|
||||
),
|
||||
|
||||
TP_printk("rss=%zu delta=%zd i_ino=%lu",
|
||||
__entry->rss,
|
||||
__entry->rss_delta,
|
||||
__entry->i_ino)
|
||||
);
|
||||
#endif /* _TRACE_KMEM_H */
|
||||
|
||||
/* This part must be outside protection */
|
||||
|
Reference in New Issue
Block a user