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]
Message-Id: <1428218636-3780-4-git-send-email-hofrat@osadl.org>
Date:	Sun,  5 Apr 2015 09:23:56 +0200
From:	Nicholas Mc Guire <hofrat@...dl.org>
To:	Michal Marek <mmarek@...e.cz>
Cc:	Masahiro Yamada <yamada.m@...panasonic.com>,
	Sam Ravnborg <sam@...nborg.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	"H. Peter Alvin" <hpa@...or.com>, Joe Perches <joe@...ches.com>,
	John Stultz <john.stultz@...aro.org>,
	Andrew Hunter <ahh@...gle.com>, Paul Turner <pjt@...gle.com>,
	linux-kernel@...r.kernel.org, Nicholas Mc Guire <hofrat@...dl.org>
Subject: [PATCH 3/3] time: update msecs_to_jiffies doc and move to kernel-doc format

update the documentation of msecs_to_jiffies and move to kernel-doc format

Signed-off-by: Nicholas Mc Guire <hofrat@...dl.org>
---

Patch was compile with x86_64_defconfig

Patch is against 4.0-rc6 (localversion-next is -next-20150402)

 include/linux/jiffies.h |   23 +++++++++++++++++++++++
 kernel/time/time.c      |   19 ++++++++++---------
 2 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index dcd8ba5..a75158e 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -290,6 +290,29 @@ static inline u64 jiffies_to_nsecs(const unsigned long j)
 }
 
 extern unsigned long __msecs_to_jiffies(const unsigned int m);
+
+/**
+ * msecs_to_jiffies: - convert milliseconds to jiffies
+ * @m:	time in millisecons 
+ *
+ * conversion is done as follows:
+ *
+ * - negative values mean 'infinite timeout' (MAX_JIFFY_OFFSET)
+ *
+ * - 'too large' values [that would result in larger than
+ *   MAX_JIFFY_OFFSET values] mean 'infinite timeout' too.
+ *
+ * - all other values are converted to jiffies by either multiplying
+ *   the input value by a factor or dividing it with a factor and 
+ *   handling any 32-bit overflows.
+ *   for the details see __msecs_to_jiffies()
+ *
+ * msecs_to_jiffies() checks for the passed in value being a constant 
+ * via __builtin_constant_p() allowing gcc to eliminate most of the 
+ * code, __msecs_to_jiffies() is called if the value passed does not
+ * allow constant folding and the actual conversion must be done at
+ * runtime.
+ */
 static inline unsigned long msecs_to_jiffies(const unsigned int m)
 {
 	/*
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 3797540..5d97610 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -483,22 +483,23 @@ struct timespec64 ns_to_timespec64(const s64 nsec)
 }
 EXPORT_SYMBOL(ns_to_timespec64);
 #endif
-/*
- * When we convert to jiffies then we interpret incoming values
- * the following way:
+
+/**
+ * __msecs_to_jiffies: - convert milliseconds to jiffies
+ * @m:	time in millisecons 
  *
- * - negative values mean 'infinite timeout' (MAX_JIFFY_OFFSET)
- *   negative values are handled in msecs_to_jiffies in 
- *   include/linux/jiffies.h
+ * conversion is done as follows:
  *
  * - 'too large' values [that would result in larger than
  *   MAX_JIFFY_OFFSET values] mean 'infinite timeout' too.
  *
  * - all other values are converted to jiffies by either multiplying
- *   the input value by a factor or dividing it with a factor
- *
- * We must also be careful about 32-bit overflows.
+ *   the input value by a factor or dividing it with a factor and 
+ *   handling any 32-bit overflows.
  *
+ * __msecs_to_jiffies() is called if the value passed to 
+ * msecs_to_jiffies() does not allow constant folding and the actual
+ * conversion must be done at runtime. 
  */
 unsigned long __msecs_to_jiffies(const unsigned int m)
 {
-- 
1.7.10.4

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