From: Thomas Gleixner <tglx@linutronix.de>
To: Daniel Church <dchurch@andplus.com>
Cc: linux-kernel@vger.kernel.org, libc-alpha@sourceware.org
Subject: Re: [PATCH v2 1/2] posix-timers: Prevents overrun counter overflow
Date: Sat, 24 Jan 2015 20:14:45 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.11.1501242004430.5526@nanos> (raw)
In-Reply-To: <1422121737-3686-2-git-send-email-dchurch@andplus.com>
On Sat, 24 Jan 2015, Daniel Church wrote:
> +/*
> + * Updates a timer's overrun count while capping it to delaytimer_max
> + */
> +static void posix_timer_update_overrun_count(struct k_itimer *timer,
> + unsigned int overruns)
> +{
> + const bool newOverrunsAboveMax = overruns >= delaytimer_max;
> + const bool totalOverrunsAboveMax =
> + timer->it_overrun >= 0 &&
> + timer->it_overrun >= delaytimer_max - overruns;
No CaMelCaSe please. And the const here is pointless.
Aside of that in a function like this we really want short local
variables so we can avoid the horrible to read multi line code.
> + if (newOverrunsAboveMax || totalOverrunsAboveMax) {
> + timer->it_overrun = delaytimer_max;
> + } else {
> + timer->it_overrun += overruns;
> + }
> +}
> +
> /* Get clock_realtime */
> static int posix_clock_realtime_get(clockid_t which_clock, struct timespec *tp)
> {
> @@ -350,14 +370,17 @@ __initcall(init_posix_timers);
>
> static void schedule_next_timer(struct k_itimer *timr)
> {
> + unsigned int overruns;
> struct hrtimer *timer = &timr->it.real.timer;
>
> if (timr->it.real.interval.tv64 == 0)
> return;
>
> - timr->it_overrun += (unsigned int) hrtimer_forward(timer,
> - timer->base->get_time(),
> - timr->it.real.interval);
> + overruns = (unsigned int) hrtimer_forward(timer,
> + timer->base->get_time(),
> + timr->it.real.interval);
Why not:
posix_timer_forward(struct hrtimer *hrt, struct k_itimer *tmr)
and doing the forward there as well? The now optimization in
common_timer_get is not that important and if we really want to keep
it, we can hand in a pointer and read the time in the function if the
pointer is NULL.
Thanks,
tglx
next prev parent reply other threads:[~2015-01-24 19:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <[PATCH 0/2] posix-timers: Prevents overrun counter overflow, adds DELAYTIMER_MAX>
2015-01-24 17:48 ` [PATCH v2 0/2] posix-timers: Prevents overrun counter overflow, adds DELAYTIMER_MAX Daniel Church
2015-01-24 17:48 ` [PATCH v2 1/2] posix-timers: Prevents overrun counter overflow Daniel Church
2015-01-24 18:17 ` Richard Cochran
2015-01-24 19:14 ` Thomas Gleixner [this message]
2015-01-24 19:37 ` Carlos O'Donell
2015-01-24 17:48 ` [PATCH v2 2/2] posix-timers: Exposes DELAYTIMER_MAX constant used to govern overruns Daniel Church
2015-01-24 19:20 ` Thomas Gleixner
2015-01-24 19:36 ` Carlos O'Donell
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=alpine.DEB.2.11.1501242004430.5526@nanos \
--to=tglx@linutronix.de \
--cc=dchurch@andplus.com \
--cc=libc-alpha@sourceware.org \
--cc=linux-kernel@vger.kernel.org \
/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®