[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1346564722-14408-2-git-send-email-anton.vorontsov@linaro.org>
Date: Sat, 1 Sep 2012 22:45:20 -0700
From: Anton Vorontsov <anton.vorontsov@...aro.org>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: Pekka Enberg <penberg@...nel.org>,
Leonid Moiseichuk <leonid.moiseichuk@...ia.com>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>,
Colin Cross <ccross@...roid.com>,
Arve Hjønnevåg <arve@...roid.com>,
Davide Libenzi <davidel@...ilserver.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Ingo Molnar <mingo@...e.hu>,
John Stultz <john.stultz@...aro.org>, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org, linaro-kernel@...ts.linaro.org,
patches@...aro.org, kernel-team@...roid.com
Subject: [PATCH 2/4] timerfd: Move repeated logic into timefd_rearm()
This patch introduces timerfd_rearm(), this small helper is used to
forward and restart the hrtimer.
This small refactoring would be also useful if/when we'll add other
backend for timerfd (like deferrable timers), so we won't need to
duplicate the code more.
Signed-off-by: Anton Vorontsov <anton.vorontsov@...aro.org>
---
fs/timerfd.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/fs/timerfd.c b/fs/timerfd.c
index dffeb37..ecfb3f3 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -178,6 +178,14 @@ static unsigned int timerfd_poll(struct file *file, poll_table *wait)
return events;
}
+static u64 timerfd_rearm(struct timerfd_ctx *ctx)
+{
+ u64 orun = hrtimer_forward_now(&ctx->tmr, ctx->tintv) - 1;
+
+ hrtimer_restart(&ctx->tmr);
+ return orun;
+}
+
static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count,
loff_t *ppos)
{
@@ -214,9 +222,7 @@ static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count,
* callback to avoid DoS attacks specifying a very
* short timer period.
*/
- ticks += hrtimer_forward_now(&ctx->tmr,
- ctx->tintv) - 1;
- hrtimer_restart(&ctx->tmr);
+ ticks += timerfd_rearm(ctx);
}
ctx->expired = 0;
ctx->ticks = 0;
@@ -355,9 +361,7 @@ SYSCALL_DEFINE2(timerfd_gettime, int, ufd, struct itimerspec __user *, otmr)
spin_lock_irq(&ctx->wqh.lock);
if (ctx->expired && ctx->tintv.tv64) {
ctx->expired = 0;
- ctx->ticks +=
- hrtimer_forward_now(&ctx->tmr, ctx->tintv) - 1;
- hrtimer_restart(&ctx->tmr);
+ ctx->ticks += timerfd_rearm(ctx);
}
kotmr.it_value = ktime_to_timespec(timerfd_get_remaining(ctx));
kotmr.it_interval = ktime_to_timespec(ctx->tintv);
--
1.7.11.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists