public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [rfc 0/2] timerfd -- implement missing parts to checkpoint and restore timerfd state
@ 2014-03-31 17:54 Cyrill Gorcunov
  2014-03-31 17:54 ` [rfc 1/2] timerfd: Implement show_fdinfo method Cyrill Gorcunov
  2014-03-31 17:54 ` [rfc 2/2] docs: procfs -- Document timerfd output Cyrill Gorcunov
  0 siblings, 2 replies; 7+ messages in thread
From: Cyrill Gorcunov @ 2014-03-31 17:54 UTC (permalink / raw)
  To: linux-kernel; +Cc: shawn, tglx, akpm, avagin, xemul, gorcunov

Timerfd interface provides to user-space almost all data needed to checkpoint
and restore it, the only missing parts are @clockid (and while @ticks can be
read by simple read() call there is no way to write its value back). The series
exports them to userspace via /proc/pid/fdinfo/N interface and with write()
call one can setup @ticks back to a timer.

Please take a look. This is rfc to figure out if there a better way
to handle timerfds (maybe ioctls with complete timer context or somthing).
Also I'm not sure in one aspect -- if someone sets non-zero @ticks to
a timer, should I mark it as expired? Thomas, could you please give
me some advice on it?

	Cyrill

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [rfc 1/2] timerfd: Implement show_fdinfo method
  2014-03-31 17:54 [rfc 0/2] timerfd -- implement missing parts to checkpoint and restore timerfd state Cyrill Gorcunov
@ 2014-03-31 17:54 ` Cyrill Gorcunov
  2014-03-31 19:43   ` Thomas Gleixner
  2014-03-31 17:54 ` [rfc 2/2] docs: procfs -- Document timerfd output Cyrill Gorcunov
  1 sibling, 1 reply; 7+ messages in thread
From: Cyrill Gorcunov @ 2014-03-31 17:54 UTC (permalink / raw)
  To: linux-kernel; +Cc: shawn, tglx, akpm, avagin, xemul, gorcunov

[-- Attachment #1: timerfd-show-fdinfo --]
[-- Type: text/plain, Size: 1380 bytes --]

For checkpoint/restore of timerfd files we need to know the clock
type being used on timerfd creation. Thus implement show_fdinfo
method where we print out the type.

Also to minimize the number of calls print out the ticks as well
(thus one read of fdinfo entry would eliminate the need of doing
 read() over timerfd itself).

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>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
 fs/timerfd.c |    9 +++++++++
 1 file changed, 9 insertions(+)

Index: linux-2.6.git/fs/timerfd.c
===================================================================
--- linux-2.6.git.orig/fs/timerfd.c
+++ linux-2.6.git/fs/timerfd.c
@@ -284,11 +284,20 @@ static ssize_t timerfd_read(struct file
 	return res;
 }
 
+static int timerfd_show(struct seq_file *m, struct file *file)
+{
+	struct timerfd_ctx *ctx = file->private_data;
+
+	return seq_printf(m, "clockid: %d ticks: %llu\n",
+			  ctx->clockid, (unsigned long long)ctx->ticks);
+}
+
 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)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [rfc 2/2] docs: procfs -- Document timerfd output
  2014-03-31 17:54 [rfc 0/2] timerfd -- implement missing parts to checkpoint and restore timerfd state Cyrill Gorcunov
  2014-03-31 17:54 ` [rfc 1/2] timerfd: Implement show_fdinfo method Cyrill Gorcunov
@ 2014-03-31 17:54 ` Cyrill Gorcunov
  2014-03-31 18:31   ` Andrey Wagin
  1 sibling, 1 reply; 7+ messages in thread
From: Cyrill Gorcunov @ 2014-03-31 17:54 UTC (permalink / raw)
  To: linux-kernel; +Cc: shawn, tglx, akpm, avagin, xemul, gorcunov

[-- Attachment #1: timerfd-doc-fdinfo --]
[-- Type: text/plain, Size: 1121 bytes --]

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>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
 Documentation/filesystems/proc.txt |    9 +++++++++
 1 file changed, 9 insertions(+)

Index: linux-2.6.git/Documentation/filesystems/proc.txt
===================================================================
--- linux-2.6.git.orig/Documentation/filesystems/proc.txt
+++ linux-2.6.git/Documentation/filesystems/proc.txt
@@ -1741,6 +1741,15 @@ pair provide additional information part
 	While the first three lines are mandatory and always printed, the rest is
 	optional and may be omitted if no marks created yet.
 
+	Timerfd files
+	~~~~~~~~~~~~~
+	pos:	0
+	flags:	02
+	mnt_id:	9
+	clockid: 0 ticks: 0
+
+	where 'clockid' is the clock type and 'ticks' is the number of the timer expirations
+	that have occurred [see timerfd_create(2) for details].
 
 ------------------------------------------------------------------------------
 Configuring procfs


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [rfc 2/2] docs: procfs -- Document timerfd output
  2014-03-31 17:54 ` [rfc 2/2] docs: procfs -- Document timerfd output Cyrill Gorcunov
@ 2014-03-31 18:31   ` Andrey Wagin
  2014-03-31 18:43     ` Cyrill Gorcunov
  0 siblings, 1 reply; 7+ messages in thread
From: Andrey Wagin @ 2014-03-31 18:31 UTC (permalink / raw)
  To: Cyrill Gorcunov
  Cc: LKML, Shawn Landden, Thomas Gleixner, Andrew Morton,
	Павел Емельянов

2014-03-31 21:54 GMT+04:00 Cyrill Gorcunov <gorcunov@openvz.org>:
> 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>
> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
> ---
>  Documentation/filesystems/proc.txt |    9 +++++++++
>  1 file changed, 9 insertions(+)
>
> Index: linux-2.6.git/Documentation/filesystems/proc.txt
> ===================================================================
> --- linux-2.6.git.orig/Documentation/filesystems/proc.txt
> +++ linux-2.6.git/Documentation/filesystems/proc.txt
> @@ -1741,6 +1741,15 @@ pair provide additional information part
>         While the first three lines are mandatory and always printed, the rest is
>         optional and may be omitted if no marks created yet.
>
> +       Timerfd files
> +       ~~~~~~~~~~~~~
> +       pos:    0
> +       flags:  02
> +       mnt_id: 9
> +       clockid: 0 ticks: 0

I would prefer to print "tick" on a separate line.

And we can print the current setting of the timer here. It can be
useful not only for CRIU but for other users too.

it_value: (5, 149234)
it_interval: (10, 0)

> +
> +       where 'clockid' is the clock type and 'ticks' is the number of the timer expirations
> +       that have occurred [see timerfd_create(2) for details].
>
>  ------------------------------------------------------------------------------
>  Configuring procfs
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [rfc 2/2] docs: procfs -- Document timerfd output
  2014-03-31 18:31   ` Andrey Wagin
@ 2014-03-31 18:43     ` Cyrill Gorcunov
  0 siblings, 0 replies; 7+ messages in thread
From: Cyrill Gorcunov @ 2014-03-31 18:43 UTC (permalink / raw)
  To: Andrey Wagin
  Cc: LKML, Shawn Landden, Thomas Gleixner, Andrew Morton,
	Павел Емельянов

On Mon, Mar 31, 2014 at 10:31:02PM +0400, Andrey Wagin wrote:
> > +       Timerfd files
> > +       ~~~~~~~~~~~~~
> > +       pos:    0
> > +       flags:  02
> > +       mnt_id: 9
> > +       clockid: 0 ticks: 0
> 
> I would prefer to print "tick" on a separate line.

Sure, this is not a problem to make it so.

> And we can print the current setting of the timer here. It can be
> useful not only for CRIU but for other users too.
> 
> it_value: (5, 149234)
> it_interval: (10, 0)

Yeah, moreover I think this is needed because if the timer is expired
and it's interval timer the gettime method will rearm it which we
defenitely not needed. Will update, thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [rfc 1/2] timerfd: Implement show_fdinfo method
  2014-03-31 17:54 ` [rfc 1/2] timerfd: Implement show_fdinfo method Cyrill Gorcunov
@ 2014-03-31 19:43   ` Thomas Gleixner
  2014-03-31 19:51     ` Cyrill Gorcunov
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Gleixner @ 2014-03-31 19:43 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: linux-kernel, shawn, akpm, avagin, xemul

On Mon, 31 Mar 2014, Cyrill Gorcunov wrote:
> For checkpoint/restore of timerfd files we need to know the clock
> type being used on timerfd creation. Thus implement show_fdinfo
> method where we print out the type.
> 
> Also to minimize the number of calls print out the ticks as well
> (thus one read of fdinfo entry would eliminate the need of doing
>  read() over timerfd itself).
> 
> 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>
> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
> ---
>  fs/timerfd.c |    9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> Index: linux-2.6.git/fs/timerfd.c
> ===================================================================
> --- linux-2.6.git.orig/fs/timerfd.c
> +++ linux-2.6.git/fs/timerfd.c
> @@ -284,11 +284,20 @@ static ssize_t timerfd_read(struct file
>  	return res;
>  }
>  
> +static int timerfd_show(struct seq_file *m, struct file *file)
> +{
> +	struct timerfd_ctx *ctx = file->private_data;
> +
> +	return seq_printf(m, "clockid: %d ticks: %llu\n",
> +			  ctx->clockid, (unsigned long long)ctx->ticks);
> +}

And what gives you the flags which were used in timerfd_settime()
along with the remaining time to expiry and the interval?

Thanks,

	tglx



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [rfc 1/2] timerfd: Implement show_fdinfo method
  2014-03-31 19:43   ` Thomas Gleixner
@ 2014-03-31 19:51     ` Cyrill Gorcunov
  0 siblings, 0 replies; 7+ messages in thread
From: Cyrill Gorcunov @ 2014-03-31 19:51 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-kernel, shawn, akpm, avagin, xemul

On Mon, Mar 31, 2014 at 09:43:13PM +0200, Thomas Gleixner wrote:
> > Index: linux-2.6.git/fs/timerfd.c
> > ===================================================================
> > --- linux-2.6.git.orig/fs/timerfd.c
> > +++ linux-2.6.git/fs/timerfd.c
> > @@ -284,11 +284,20 @@ static ssize_t timerfd_read(struct file
> >  	return res;
> >  }
> >  
> > +static int timerfd_show(struct seq_file *m, struct file *file)
> > +{
> > +	struct timerfd_ctx *ctx = file->private_data;
> > +
> > +	return seq_printf(m, "clockid: %d ticks: %llu\n",
> > +			  ctx->clockid, (unsigned long long)ctx->ticks);
> > +}
> 
> And what gives you the flags which were used in timerfd_settime()
> along with the remaining time to expiry and the interval?

Ouch, indeed, I need to export them as well. Thanks a lot!

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-03-31 19:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-31 17:54 [rfc 0/2] timerfd -- implement missing parts to checkpoint and restore timerfd state Cyrill Gorcunov
2014-03-31 17:54 ` [rfc 1/2] timerfd: Implement show_fdinfo method Cyrill Gorcunov
2014-03-31 19:43   ` Thomas Gleixner
2014-03-31 19:51     ` Cyrill Gorcunov
2014-03-31 17:54 ` [rfc 2/2] docs: procfs -- Document timerfd output Cyrill Gorcunov
2014-03-31 18:31   ` Andrey Wagin
2014-03-31 18:43     ` Cyrill Gorcunov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox