From: Thomas Gleixner <tglx@linutronix.de>
To: Manish Varma <varmam@google.com>,
Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Manish Varma <varmam@google.com>,
Kelly Rossmoyer <krossmo@google.com>
Subject: Re: [PATCH] fs: Improve eventpoll logging to stop indicting timerfd
Date: Thu, 18 Mar 2021 14:04:01 +0100 [thread overview]
Message-ID: <87pmzw7gvy.fsf@nanos.tec.linutronix.de> (raw)
In-Reply-To: <20210302034928.3761098-1-varmam@google.com>
Manish,
On Mon, Mar 01 2021 at 19:49, Manish Varma wrote:
> All together, that will give us names like the following:
>
> 1) timerfd file descriptor: [timerfd14:system_server]
> 2) eventpoll top-level per-process wakesource: epoll:system_server
> 3) eventpoll-on-timerfd per-descriptor wakesource:
> epollitem:system_server.[timerfd14:system_server]
All together that should be splitted up into a change to eventpoll and
timerfd.
> diff --git a/fs/timerfd.c b/fs/timerfd.c
> index c5509d2448e3..4249e8c9a38c 100644
> --- a/fs/timerfd.c
> +++ b/fs/timerfd.c
> @@ -46,6 +46,8 @@ struct timerfd_ctx {
> bool might_cancel;
> };
>
> +static atomic_t instance_count = ATOMIC_INIT(0);
instance_count is misleading as it does not do any accounting of
instances as the name suggests.
> static LIST_HEAD(cancel_list);
> static DEFINE_SPINLOCK(cancel_lock);
>
> @@ -391,6 +393,9 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
> {
> int ufd;
> struct timerfd_ctx *ctx;
> + char task_comm_buf[sizeof(current->comm)];
> + char file_name_buf[32];
> + int instance;
>
> /* Check the TFD_* constants for consistency. */
> BUILD_BUG_ON(TFD_CLOEXEC != O_CLOEXEC);
> @@ -427,7 +432,11 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
>
> ctx->moffs = ktime_mono_to_real(0);
>
> - ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx,
> + instance = atomic_inc_return(&instance_count);
> + get_task_comm(task_comm_buf, current);
How is current->comm supposed to be unique? And with a wrapping counter
like the above you can end up with identical file descriptor names.
What's wrong with simply using the PID which is guaranteed to be unique
for the life time of a process/task?
> + snprintf(file_name_buf, sizeof(file_name_buf), "[timerfd%d:%s]",
> + instance, task_comm_buf);
> + ufd = anon_inode_getfd(file_name_buf, &timerfd_fops, ctx,
> O_RDWR | (flags & TFD_SHARED_FCNTL_FLAGS));
> if (ufd < 0)
> kfree(ctx);
I actually wonder, whether this should be part of anon_inode_get*().
Aside of that this is a user space visible change both for eventpoll and
timerfd.
Have you carefully investigated whether there is existing user space
which might depend on the existing naming conventions?
The changelog is silent about this...
Thanks,
tglx
next prev parent reply other threads:[~2021-03-18 13:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-02 3:49 Manish Varma
2021-03-18 13:04 ` Thomas Gleixner [this message]
2021-03-22 17:15 ` Manish Varma
2021-03-22 21:40 ` Thomas Gleixner
2021-03-25 5:18 ` Manish Varma
2021-03-25 7:06 ` Thomas Gleixner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pmzw7gvy.fsf@nanos.tec.linutronix.de \
--to=tglx@linutronix.de \
--cc=krossmo@google.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=varmam@google.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®