lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 22 Jul 2010 16:16:54 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Patrick Pannuto <ppannuto@...eaurora.org>
Cc:	Arjan van de Ven <arjan@...ux.intel.com>,
	linux-kernel@...r.kernel.org, tglx@...utronix.de, mingo@...e.hu,
	akinobu.mita@...il.com, sboyd@...eaurora.org
Subject: Re: [PATCH] timer: Added usleep[_range] timer

On Mon, 19 Jul 2010 15:12:34 -0700
Patrick Pannuto <ppannuto@...eaurora.org> wrote:

> Respun without interruptible...
> 

And without all the nice changelog info.  Oh well.

> usleep[_range] are finer precision implementations of msleep
> and are designed to be drop-in replacements for udelay where
> a precise sleep / busy-wait is unnecessary. They also allow
> an easy interface to specify slack when a precise (ish)
> wakeup is unnecessary to help minimize wakeups
> 
> Signed-off-by: Patrick Pannuto <ppannuto@...eaurora.org>
> ---
>  include/linux/delay.h |    6 ++++++
>  kernel/timer.c        |   22 ++++++++++++++++++++++
>  2 files changed, 28 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/delay.h b/include/linux/delay.h
> index fd832c6..0e303d1 100644
> --- a/include/linux/delay.h
> +++ b/include/linux/delay.h
> @@ -45,6 +45,12 @@ extern unsigned long lpj_fine;
>  void calibrate_delay(void);
>  void msleep(unsigned int msecs);
>  unsigned long msleep_interruptible(unsigned int msecs);
> +void usleep_range(unsigned long min, unsigned long max);
> +
> +static inline void usleep(unsigned long usecs)
> +{
> +	usleep_range(usecs, usecs);
> +}
>  
>  static inline void ssleep(unsigned int seconds)
>  {
> diff --git a/kernel/timer.c b/kernel/timer.c
> index ee305c8..4e6746f 100644
> --- a/kernel/timer.c
> +++ b/kernel/timer.c
> @@ -1750,3 +1750,25 @@ unsigned long msleep_interruptible(unsigned int msecs)
>  }
>  
>  EXPORT_SYMBOL(msleep_interruptible);
> +
> +static int __sched do_usleep_range(unsigned long min, unsigned long max)
> +{
> +	ktime_t kmin;
> +	unsigned long delta;
> +
> +	kmin = ktime_set(0, min * NSEC_PER_USEC);
> +	delta = max - min;
> +	return schedule_hrtimeout_range(&kmin, delta, HRTIMER_MODE_REL);
> +}
> +
> +/**
> + * usleep_range - Drop in replacement for udelay where wakeup is flexible
> + * @min: Minimum time in usecs to sleep
> + * @max: Maximum time in usecs to sleep
> + */
> +void usleep_range(unsigned long min, unsigned long max)
> +{
> +	__set_current_state(TASK_UNINTERRUPTIBLE);
> +	do_usleep_range(min, max);
> +}
> +EXPORT_SYMBOL(usleep_range);

Fair enough, I guess.  People can go over and look at the
schedule_hrtimeout_range() documentation to work out why on earth they
should specify a "range".  

Of course, nobody will actually think to _use_ this thing.  Someone
owes me a "usleep_range is preferred over usleep" checkpatch rule!

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ