lkml.org 
[lkml]   [2019]   [Apr]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] futex: Consolidate duplicated timer setup code
On Wed, Apr 24, 2019 at 11:36:51AM -0400, Waiman Long wrote:
> +static inline struct hrtimer_sleeper *
> +futex_setup_timer(ktime_t *time, struct hrtimer_sleeper *timeout,
> + int flags, u64 range_ns)
> +{
> + if (!time)
> + return NULL;
> +
> + hrtimer_init_on_stack(&timeout->timer, (flags & FLAGS_CLOCKRT) ?
> + CLOCK_REALTIME : CLOCK_MONOTONIC,
> + HRTIMER_MODE_ABS);
> + hrtimer_init_sleeper(timeout, current);
> + if (range_ns)
> + hrtimer_set_expires_range_ns(&timeout->timer, *time, range_ns);
> + else
> + hrtimer_set_expires(&timeout->timer, *time);

That can be an unconditinoal:

hrtimer_set_expires_range_ns(&timeout->timer, *time, range_ns);

See how:

timer->node.expires = ktime_add_safe(time, ns_to_ktime(delta));

is the same as:

timer->node.expires = time;

when !delta.

> +
> + return timeout;
> +}

Anyway, looks good otherwise.

\
 
 \ /
  Last update: 2019-04-24 18:11    [W:0.036 / U:1.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site