From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org, shawn@churchofgit.com,
akpm@linux-foundation.org, avagin@openvz.org,
xemul@parallels.com, vdavydov@parallels.com
Subject: Re: [patch 1/3] timerfd: Implement show_fdinfo method
Date: Thu, 22 May 2014 01:54:09 +0400 [thread overview]
Message-ID: <20140521215409.GG12819@moon> (raw)
In-Reply-To: <alpine.DEB.2.02.1405220641240.9695@ionos.tec.linutronix.de>
[-- Attachment #1: Type: text/plain, Size: 429 bytes --]
On Thu, May 22, 2014 at 06:41:57AM +0900, Thomas Gleixner wrote:
>
> Shouldn't this depend on CONFIG_PROCFS?
>
> > static const struct file_operations timerfd_fops = {
> > .release = timerfd_release,
> > .poll = timerfd_poll,
> > .read = timerfd_read,
> > .llseek = noop_llseek,
> > + .show_fdinfo = timerfd_show,
> > };
> >
> > static int timerfd_fget(int fd, struct fd *p)
yeah, good point, thanks! Updated.
[-- Attachment #2: timerfd-show-fdinfo-4 --]
[-- Type: text/plain, Size: 3185 bytes --]
From: Cyrill Gorcunov <gorcunov@openvz.org>
Subject: timerfd: Implement show_fdinfo method
For checkpoint/restore of timerfd files we need to know how exactly
the timer were armed to be able to handle it. Thus implement show_fdinfo
method which provides enough information for timer re-creation.
One of significant changes I think is addition of
timerfd_ctx::settime_flags member. Currently there are
two flags TFD_TIMER_ABSTIME and TFD_TIMER_CANCEL_ON_SET,
and the second can be found from @might_cancel variable
but in case if the flags will be extended in future we
most probably will have to somehow remember them explicitly
anyway so I guss doing that right now won't hurt.
To not bloat the timerfd_ctx structure I've converted
@expired to short integer and defined @settime_flags
as short as well.
v2 (by avagin@, vdavydov@ and tglx@):
- Add it_value/it_interval fields
- Save flags being used in timerfd_setup in context
v3 (by tglx@):
- don't forget to use CONFIG_PROC_FS
CC: Shawn Landden <shawn@churchofgit.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Andrey Vagin <avagin@openvz.org>
CC: Pavel Emelyanov <xemul@parallels.com>
CC: Vladimir Davydov <vdavydov@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
fs/timerfd.c | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
Index: linux-2.6.git/fs/timerfd.c
===================================================================
--- linux-2.6.git.orig/fs/timerfd.c
+++ linux-2.6.git/fs/timerfd.c
@@ -35,8 +35,9 @@ struct timerfd_ctx {
ktime_t moffs;
wait_queue_head_t wqh;
u64 ticks;
- int expired;
int clockid;
+ short unsigned expired;
+ short unsigned settime_flags; /* to show in fdinfo */
struct rcu_head rcu;
struct list_head clist;
bool might_cancel;
@@ -196,6 +197,8 @@ static int timerfd_setup(struct timerfd_
if (timerfd_canceled(ctx))
return -ECANCELED;
}
+
+ ctx->settime_flags = flags & TFD_SETTIME_FLAGS;
return 0;
}
@@ -284,11 +287,40 @@ static ssize_t timerfd_read(struct file
return res;
}
+#ifdef CONFIG_PROC_FS
+static int timerfd_show(struct seq_file *m, struct file *file)
+{
+ struct timerfd_ctx *ctx = file->private_data;
+ struct itimerspec t;
+
+ spin_lock_irq(&ctx->wqh.lock);
+ t.it_value = ktime_to_timespec(timerfd_get_remaining(ctx));
+ t.it_interval = ktime_to_timespec(ctx->tintv);
+ spin_unlock_irq(&ctx->wqh.lock);
+
+ return seq_printf(m,
+ "clockid: %d\n"
+ "ticks: %llu\n"
+ "settime flags: 0%o\n"
+ "it_value: (%llu, %llu)\n"
+ "it_interval: (%llu, %llu)\n",
+ ctx->clockid, (unsigned long long)ctx->ticks,
+ ctx->settime_flags,
+ (unsigned long long)t.it_value.tv_sec,
+ (unsigned long long)t.it_value.tv_nsec,
+ (unsigned long long)t.it_interval.tv_sec,
+ (unsigned long long)t.it_interval.tv_nsec);
+}
+#endif
+
static const struct file_operations timerfd_fops = {
.release = timerfd_release,
.poll = timerfd_poll,
.read = timerfd_read,
.llseek = noop_llseek,
+#ifdef CONFIG_PROC_FS
+ .show_fdinfo = timerfd_show,
+#endif
};
static int timerfd_fget(int fd, struct fd *p)
next prev parent reply other threads:[~2014-05-21 21:54 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-28 21:25 [patch 0/3] timerfd -- implement missing parts to checkpoint and restore timerfd state, v3 Cyrill Gorcunov
2014-04-28 21:25 ` [patch 1/3] timerfd: Implement show_fdinfo method Cyrill Gorcunov
2014-05-21 21:41 ` Thomas Gleixner
2014-05-21 21:54 ` Cyrill Gorcunov [this message]
2014-04-28 21:25 ` [patch 2/3] docs: procfs -- Document timerfd output Cyrill Gorcunov
2014-04-28 21:25 ` [patch 3/3] timerfd: Implement write method Cyrill Gorcunov
2014-05-21 21:43 ` Thomas Gleixner
2014-05-21 21:57 ` Cyrill Gorcunov
2014-05-21 22:12 ` Thomas Gleixner
2014-05-21 22:35 ` Cyrill Gorcunov
2014-05-21 23:30 ` Thomas Gleixner
2014-05-22 5:31 ` Cyrill Gorcunov
2014-05-22 6:32 ` Michael Kerrisk
[not found] ` <CAHO5Pa3NFndwZUKGdEt8AYnYLXvd4aJB1RdWOQ-Kcht+Y0WEyA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-22 7:03 ` Cyrill Gorcunov
2014-05-22 7:03 ` Cyrill Gorcunov
[not found] ` <alpine.DEB.2.02.1405220643170.9695@ionos.tec.linutronix.de>
2014-05-21 21:58 ` Thomas Gleixner
2014-06-10 16:35 ` Cyrill Gorcunov
2014-06-10 20:03 ` Michael Kerrisk (man-pages)
2014-06-10 20:03 ` Michael Kerrisk (man-pages)
2014-06-10 20:05 ` Andy Lutomirski
2014-06-10 20:22 ` Cyrill Gorcunov
2014-06-11 7:27 ` Andrew Vagin
2014-06-11 7:51 ` Cyrill Gorcunov
2014-06-11 9:09 ` Andrew Vagin
2014-06-11 9:52 ` Cyrill Gorcunov
2014-06-11 12:43 ` Cyrill Gorcunov
2014-05-21 10:03 ` [patch 0/3] timerfd -- implement missing parts to checkpoint and restore timerfd state, v3 Cyrill Gorcunov
-- strict thread matches above, loose matches on Subject: below --
2014-04-07 17:47 [patch 0/3] timerfd -- implement missing parts to checkpoint and restore timerfd state, v2 Cyrill Gorcunov
2014-04-07 17:47 ` [patch 1/3] timerfd: Implement show_fdinfo method Cyrill Gorcunov
2014-04-08 6:17 ` Vladimir Davydov
2014-04-08 6:42 ` Cyrill Gorcunov
2014-04-08 6:54 ` Vladimir Davydov
2014-04-08 7:10 ` Cyrill Gorcunov
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=20140521215409.GG12819@moon \
--to=gorcunov@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=avagin@openvz.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shawn@churchofgit.com \
--cc=tglx@linutronix.de \
--cc=vdavydov@parallels.com \
--cc=xemul@parallels.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.