ANDROID: fs: Add vendor hooks for ep_create_wakeup_source & timerfd_create
timerfd doesn't create any wakelocks, but eventpoll can. When it does, it names them after the underlying file descriptor, and since all timerfd file descriptors are named "[timerfd]" (which saves memory on systems like desktops with potentially many timerfd instances), all wakesources created as a result of using the eventpoll-on-timerfd idiom are called... "[timerfd]". However, it becomes impossible to tell which "[timerfd]" wakesource is affliated with which process and hence troubleshooting is difficult. Adding vendor hooks to allow vendor to assign appropriate names to timerfd descriptors and eventoll wakesource. Bug: 155142106 Signed-off-by: Manish Varma <varmam@google.com> Change-Id: I330a42ab48bed4b26d5eb2f636925c66061165ec
This commit is contained in:
parent
434df9f35d
commit
0ff110fbb3
@ -26,6 +26,7 @@
|
|||||||
#include <trace/hooks/gic_v3.h>
|
#include <trace/hooks/gic_v3.h>
|
||||||
#include <trace/hooks/epoch.h>
|
#include <trace/hooks/epoch.h>
|
||||||
#include <trace/hooks/cpufreq.h>
|
#include <trace/hooks/cpufreq.h>
|
||||||
|
#include <trace/hooks/fs.h>
|
||||||
#include <trace/hooks/mm.h>
|
#include <trace/hooks/mm.h>
|
||||||
#include <trace/hooks/preemptirq.h>
|
#include <trace/hooks/preemptirq.h>
|
||||||
#include <trace/hooks/ftrace_dump.h>
|
#include <trace/hooks/ftrace_dump.h>
|
||||||
@ -220,3 +221,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_typec_tcpci_chk_contaminant);
|
|||||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_typec_tcpci_get_vbus);
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_typec_tcpci_get_vbus);
|
||||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_account_task_time);
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_account_task_time);
|
||||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gpio_block_read);
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gpio_block_read);
|
||||||
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ep_create_wakeup_source);
|
||||||
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_timerfd_create);
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
#include <linux/rculist.h>
|
#include <linux/rculist.h>
|
||||||
#include <net/busy_poll.h>
|
#include <net/busy_poll.h>
|
||||||
|
|
||||||
|
#include <trace/hooks/fs.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* LOCKING:
|
* LOCKING:
|
||||||
* There are three level of locking required by epoll :
|
* There are three level of locking required by epoll :
|
||||||
@ -1451,15 +1453,20 @@ static int ep_create_wakeup_source(struct epitem *epi)
|
|||||||
{
|
{
|
||||||
struct name_snapshot n;
|
struct name_snapshot n;
|
||||||
struct wakeup_source *ws;
|
struct wakeup_source *ws;
|
||||||
|
char ws_name[64];
|
||||||
|
|
||||||
|
strlcpy(ws_name, "eventpoll", sizeof(ws_name));
|
||||||
|
trace_android_vh_ep_create_wakeup_source(ws_name, sizeof(ws_name));
|
||||||
if (!epi->ep->ws) {
|
if (!epi->ep->ws) {
|
||||||
epi->ep->ws = wakeup_source_register(NULL, "eventpoll");
|
epi->ep->ws = wakeup_source_register(NULL, ws_name);
|
||||||
if (!epi->ep->ws)
|
if (!epi->ep->ws)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
take_dentry_name_snapshot(&n, epi->ffd.file->f_path.dentry);
|
take_dentry_name_snapshot(&n, epi->ffd.file->f_path.dentry);
|
||||||
ws = wakeup_source_register(NULL, n.name.name);
|
strlcpy(ws_name, n.name.name, sizeof(ws_name));
|
||||||
|
trace_android_vh_ep_create_wakeup_source(ws_name, sizeof(ws_name));
|
||||||
|
ws = wakeup_source_register(NULL, ws_name);
|
||||||
release_dentry_name_snapshot(&n);
|
release_dentry_name_snapshot(&n);
|
||||||
|
|
||||||
if (!ws)
|
if (!ws)
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#include <linux/rcupdate.h>
|
#include <linux/rcupdate.h>
|
||||||
#include <linux/time_namespace.h>
|
#include <linux/time_namespace.h>
|
||||||
|
|
||||||
|
#include <trace/hooks/fs.h>
|
||||||
|
|
||||||
struct timerfd_ctx {
|
struct timerfd_ctx {
|
||||||
union {
|
union {
|
||||||
struct hrtimer tmr;
|
struct hrtimer tmr;
|
||||||
@ -391,6 +393,7 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
|
|||||||
{
|
{
|
||||||
int ufd;
|
int ufd;
|
||||||
struct timerfd_ctx *ctx;
|
struct timerfd_ctx *ctx;
|
||||||
|
char file_name_buf[32];
|
||||||
|
|
||||||
/* Check the TFD_* constants for consistency. */
|
/* Check the TFD_* constants for consistency. */
|
||||||
BUILD_BUG_ON(TFD_CLOEXEC != O_CLOEXEC);
|
BUILD_BUG_ON(TFD_CLOEXEC != O_CLOEXEC);
|
||||||
@ -427,7 +430,9 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
|
|||||||
|
|
||||||
ctx->moffs = ktime_mono_to_real(0);
|
ctx->moffs = ktime_mono_to_real(0);
|
||||||
|
|
||||||
ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx,
|
strlcpy(file_name_buf, "[timerfd]", sizeof(file_name_buf));
|
||||||
|
trace_android_vh_timerfd_create(file_name_buf, sizeof(file_name_buf));
|
||||||
|
ufd = anon_inode_getfd(file_name_buf, &timerfd_fops, ctx,
|
||||||
O_RDWR | (flags & TFD_SHARED_FCNTL_FLAGS));
|
O_RDWR | (flags & TFD_SHARED_FCNTL_FLAGS));
|
||||||
if (ufd < 0)
|
if (ufd < 0)
|
||||||
kfree(ctx);
|
kfree(ctx);
|
||||||
@ -435,7 +440,7 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
|
|||||||
return ufd;
|
return ufd;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_timerfd_settime(int ufd, int flags,
|
static int do_timerfd_settime(int ufd, int flags,
|
||||||
const struct itimerspec64 *new,
|
const struct itimerspec64 *new,
|
||||||
struct itimerspec64 *old)
|
struct itimerspec64 *old)
|
||||||
{
|
{
|
||||||
|
23
include/trace/hooks/fs.h
Normal file
23
include/trace/hooks/fs.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-2.0 */
|
||||||
|
#undef TRACE_SYSTEM
|
||||||
|
#define TRACE_SYSTEM fs
|
||||||
|
|
||||||
|
#undef TRACE_INCLUDE_PATH
|
||||||
|
#define TRACE_INCLUDE_PATH trace/hooks
|
||||||
|
|
||||||
|
#if !defined(_TRACE_HOOK_FS_H) || defined(TRACE_HEADER_MULTI_READ)
|
||||||
|
#define _TRACE_HOOK_FS_H
|
||||||
|
|
||||||
|
#include <linux/tracepoint.h>
|
||||||
|
#include <trace/hooks/vendor_hooks.h>
|
||||||
|
DECLARE_HOOK(android_vh_ep_create_wakeup_source,
|
||||||
|
TP_PROTO(char *name, int len),
|
||||||
|
TP_ARGS(name, len));
|
||||||
|
|
||||||
|
DECLARE_HOOK(android_vh_timerfd_create,
|
||||||
|
TP_PROTO(char *name, int len),
|
||||||
|
TP_ARGS(name, len));
|
||||||
|
#endif /* _TRACE_HOOK_FS_H */
|
||||||
|
|
||||||
|
/* This part must be outside protection */
|
||||||
|
#include <trace/define_trace.h>
|
Loading…
Reference in New Issue
Block a user