mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-23 07:01:23 +00:00
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 recreate it on restore stage. Thus implement show_fdinfo method which provides enough information for that. One of significant changes I think is the addition of @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 too. 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 v4 (by akpm@): -Use define timerfd_show NULL for non c/r config Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Michael Kerrisk <mtk.manpages@gmail.com> Cc: Andrey Vagin <avagin@openvz.org> Cc: Pavel Emelyanov <xemul@parallels.com> Cc: Vladimir Davydov <vdavydov@parallels.com> Link: http://lkml.kernel.org/r/20140715215703.114365649@openvz.org Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
parent
afdb094380
commit
af9c4957cf
1 changed files with 33 additions and 1 deletions
34
fs/timerfd.c
34
fs/timerfd.c
|
@ -35,8 +35,9 @@ struct timerfd_ctx {
|
||||||
ktime_t moffs;
|
ktime_t moffs;
|
||||||
wait_queue_head_t wqh;
|
wait_queue_head_t wqh;
|
||||||
u64 ticks;
|
u64 ticks;
|
||||||
int expired;
|
|
||||||
int clockid;
|
int clockid;
|
||||||
|
short unsigned expired;
|
||||||
|
short unsigned settime_flags; /* to show in fdinfo */
|
||||||
struct rcu_head rcu;
|
struct rcu_head rcu;
|
||||||
struct list_head clist;
|
struct list_head clist;
|
||||||
bool might_cancel;
|
bool might_cancel;
|
||||||
|
@ -196,6 +197,8 @@ static int timerfd_setup(struct timerfd_ctx *ctx, int flags,
|
||||||
if (timerfd_canceled(ctx))
|
if (timerfd_canceled(ctx))
|
||||||
return -ECANCELED;
|
return -ECANCELED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx->settime_flags = flags & TFD_SETTIME_FLAGS;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,11 +287,40 @@ static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count,
|
||||||
return res;
|
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);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define timerfd_show NULL
|
||||||
|
#endif
|
||||||
|
|
||||||
static const struct file_operations timerfd_fops = {
|
static const struct file_operations timerfd_fops = {
|
||||||
.release = timerfd_release,
|
.release = timerfd_release,
|
||||||
.poll = timerfd_poll,
|
.poll = timerfd_poll,
|
||||||
.read = timerfd_read,
|
.read = timerfd_read,
|
||||||
.llseek = noop_llseek,
|
.llseek = noop_llseek,
|
||||||
|
.show_fdinfo = timerfd_show,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int timerfd_fget(int fd, struct fd *p)
|
static int timerfd_fget(int fd, struct fd *p)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue