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: <20161119161036.12679-4-nicstange@gmail.com>
Date:   Sat, 19 Nov 2016 17:10:23 +0100
From:   Nicolai Stange <nicstange@...il.com>
To:     Thomas Gleixner <tglx@...utronix.de>
Cc:     John Stultz <john.stultz@...aro.org>, linux-kernel@...r.kernel.org,
        Nicolai Stange <nicstange@...il.com>
Subject: [RFC v8 15/28] clockevents: use ->min_delta_ticks_adjusted to program minimum delta

The use of a clockevent device's ->min_delta_ns in the event programming
path hinders upcoming changes to the clockevent core making it NTP
correction aware: both, ->mult and ->min_delta_ns would need to get
updated as well as consumed atomically and we'd rather like to avoid any
locking here.

We already have got ->min_delta_ticks_adjusted which
- resembles the value of ->min_delta_ns
- and is guaranteed to be always >= the hardware's hard limit
  ->min_delta_ticks and thus, can be used w/o locking as we don't care
  for small deviations.

In both implementations of clockevents_program_min_delta(),
don't calculate the event's deadline from ->min_delta_ns, but use its
drop-in replacement ->min_delta_ticks_adjusted.

Signed-off-by: Nicolai Stange <nicstange@...il.com>
---
 kernel/time/clockevents.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 8d32c2c..74b05dd 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -243,19 +243,14 @@ static int clockevents_increase_min_delta(struct clock_event_device *dev)
  */
 static int clockevents_program_min_delta(struct clock_event_device *dev)
 {
-	unsigned long long clc;
-	int64_t delta;
 	int i;
 
 	for (i = 0;;) {
-		delta = dev->min_delta_ns;
-
 		if (clockevent_state_shutdown(dev))
 			return 0;
 
 		dev->retries++;
-		clc = ((unsigned long long) delta * dev->mult) >> dev->shift;
-		if (dev->set_next_event((unsigned long) clc, dev) == 0)
+		if (!dev->set_next_event(dev->min_delta_ticks_adjusted, dev))
 			return 0;
 
 		if (++i > 2) {
@@ -281,17 +276,11 @@ static int clockevents_program_min_delta(struct clock_event_device *dev)
  */
 static int clockevents_program_min_delta(struct clock_event_device *dev)
 {
-	unsigned long long clc;
-	int64_t delta;
-
-	delta = dev->min_delta_ns;
-
 	if (clockevent_state_shutdown(dev))
 		return 0;
 
 	dev->retries++;
-	clc = ((unsigned long long) delta * dev->mult) >> dev->shift;
-	return dev->set_next_event((unsigned long) clc, dev);
+	return dev->set_next_event(dev->min_delta_ticks_adjusted, dev);
 }
 
 #endif /* CONFIG_GENERIC_CLOCKEVENTS_MIN_ADJUST */
-- 
2.10.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ