Re: [PATCH] futex: Consolidate duplicated timer setup code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux