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:	Tue, 19 May 2015 07:03:58 -0700
From:	Joe Perches <joe@...ches.com>
To:	yamada.m@...panasonic.com, linux-kernel@...r.kernel.org,
	sam@...nborg.org, hpa@...or.com, john.stultz@...aro.org,
	mmarek@...e.cz, hofrat@...dl.org, tglx@...utronix.de,
	mingo@...nel.org, joe@...ches.com, pjt@...gle.com, ahh@...gle.com
Subject: Re: [tip:timers/core] time: Refactor msecs_to_jiffies

On Tue, 2015-05-19 at 06:36 -0700, tip-bot for Nicholas Mc Guire wrote:
> Refactor the msecs_to_jiffies conditional code part in time.c and 
> jiffies.h putting it into conditional functions rather than #ifdefs
> to improve readability.
[]
> diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
[]
> +static inline unsigned long _msecs_to_jiffies(const unsigned int m)
> +{
> +		return (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ);
> +}
> +#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC)
> +/*
> + * HZ is larger than 1000, and HZ is a nice round multiple of 1000 -
> + * simply multiply with the factor between them.
> + *
> + * But first make sure the multiplication result cannot overflow:
> + */
> +static inline unsigned long _msecs_to_jiffies(const unsigned int m)
> +{
> +		if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET))
> +			return MAX_JIFFY_OFFSET;
> +		return m * (HZ / MSEC_PER_SEC);
> +}
> +#else
> +/*
> + * Generic case - multiply, round and divide. But first check that if
> + * we are doing a net multiplication, that we wouldn't overflow:
> + */
> +static inline unsigned long _msecs_to_jiffies(const unsigned int m)
> +{
> +		if (HZ > MSEC_PER_SEC && m > jiffies_to_msecs(MAX_JIFFY_OFFSET))
> +			return MAX_JIFFY_OFFSET;
> +
> +		return (MSEC_TO_HZ_MUL32 * m + MSEC_TO_HZ_ADJ32)
> +			>> MSEC_TO_HZ_SHR32;
> +}
> +#endif

It'd be nicer to remove 1 level of unnecessary tab indentation in
all the _msecs_to_jiffies functions here.


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