lkml.org 
[lkml]   [2021]   [Mar]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Subject[PATCH v2] fs: Improve eventpoll logging to stop indicting timerfd
From
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.

This change addresses this problem by changing the way eventpoll
wakesources are named:

1) the top-level per-process eventpoll wakesource is now named "epoll:P"
(instead of just "eventpoll"), where P, is the PID of the creating
process.
2) individual per-underlying-filedescriptor eventpoll wakesources are
now named "epollitemN:P.F", where N is a unique ID token and P is PID
of the creating process and F is the name of the underlying file
descriptor.

All together that should be splitted up into a change to eventpoll and
timerfd (or other file descriptors).

Co-developed-by: Kelly Rossmoyer <krossmo@google.com>
Signed-off-by: Kelly Rossmoyer <krossmo@google.com>
Signed-off-by: Manish Varma <varmam@google.com>
---
fs/eventpoll.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 7df8c0fa462b..8d3369a02633 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -297,6 +297,7 @@ static LIST_HEAD(tfile_check_list);

static long long_zero;
static long long_max = LONG_MAX;
+static atomic_t wakesource_create_id = ATOMIC_INIT(0);

struct ctl_table epoll_table[] = {
{
@@ -1451,15 +1452,23 @@ static int ep_create_wakeup_source(struct epitem *epi)
{
struct name_snapshot n;
struct wakeup_source *ws;
+ pid_t task_pid;
+ char buf[64];
+ int id;
+
+ task_pid = task_pid_nr(current);

if (!epi->ep->ws) {
- epi->ep->ws = wakeup_source_register(NULL, "eventpoll");
+ snprintf(buf, sizeof(buf), "epoll:%d", task_pid);
+ epi->ep->ws = wakeup_source_register(NULL, buf);
if (!epi->ep->ws)
return -ENOMEM;
}

+ id = atomic_inc_return(&wakesource_create_id);
take_dentry_name_snapshot(&n, epi->ffd.file->f_path.dentry);
- ws = wakeup_source_register(NULL, n.name.name);
+ snprintf(buf, sizeof(buf), "epollitem%d:%d.%s", id, task_pid, n.name.name);
+ ws = wakeup_source_register(NULL, buf);
release_dentry_name_snapshot(&n);

if (!ws)
--
2.31.0.291.g576ba9dcdaf-goog
\
 
 \ /
  Last update: 2021-04-01 04:18    [W:0.158 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site