mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicolai Stange <nicstange@gmail.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: John Stultz <john.stultz@linaro.org>,
	linux-kernel@vger.kernel.org,
	Nicolai Stange <nicstange@gmail.com>
Subject: [RFC v8 28/28] clockevents: move non-adjustable devices to the tail of the list
Date: Sat, 19 Nov 2016 17:10:36 +0100	[thread overview]
Message-ID: <20161119161036.12679-17-nicstange@gmail.com> (raw)
In-Reply-To: <20161119160055.12491-1-nicstange@gmail.com>

clockevents_adjust_all_freqs() iterates over all devices in the
clockevent_devices list and adjusts frequencies as appropriate, skipping
over those that have either of CLOCK_EVT_FEAT_DUMMY and
CLOCK_EVT_FEAT_NO_ADJUST set or aren't oneshot capable.

This results in unnecessary memory accesses to these list members.

Avoid this by moving all such devices to the end of the clockevents_devices
list and making clockevents_adjust_all_freqs() return as soon as it
encounters the first of them.

For the list insertion part, introduce the ced_list_add() helper and
use it where appropriate.

Benchmark results:
The following measurements have been carried out on a Raspberry Pi 2B
(armv7, 4 cores, 900MHz). The adjustment process has been driven by
periodically injecting a certain offset via adjtimex(2) approximately
every 3.7h. A 'stress --vm 8 --vm-bytes 32M' was running. The runtime of
clockevents_adjust_all_freqs() has been measured.

- Before this patch:
  Mean: 6916.90+-782.63
  Quantiles:
    0%    25%    50%    75%    100%
  3072   6412   6927   7430   10989 (ns)

- After this patch:
  Mean: 6505.18+-740.85
  Quantiles:
    0%    25%    50%    75%    100%
  2708   6054   6523   6980   10885 (ns)

Signed-off-by: Nicolai Stange <nicstange@gmail.com>
---
 kernel/time/clockevents.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 6146d2f..038fa82 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -341,6 +341,22 @@ int clockevents_program_event(struct clock_event_device *dev, ktime_t expires,
 	return (rc && force) ? clockevents_program_min_delta(dev) : rc;
 }
 
+static void ced_list_add(struct clock_event_device *dev)
+{
+	/*
+	 * Insert all devices which aren't candidates for NTP
+	 * frequency adjustments at the end of the list such that
+	 * clockevents_adjust_all_freqs() can skip the tail once
+	 * encountering the first of them.
+	 */
+	if (!(dev->features & CLOCK_EVT_FEAT_ONESHOT) ||
+	    (dev->features & CLOCK_EVT_FEAT_DUMMY) ||
+	    (dev->features & CLOCK_EVT_FEAT_NO_ADJUST))
+		list_add_tail(&dev->list, &clockevent_devices);
+	else
+		list_add(&dev->list, &clockevent_devices);
+}
+
 /*
  * Called after a notify add to make devices available which were
  * released from the notifier call.
@@ -353,7 +369,7 @@ static void clockevents_notify_released(void)
 		dev = list_entry(clockevents_released.next,
 				 struct clock_event_device, list);
 		list_del(&dev->list);
-		list_add(&dev->list, &clockevent_devices);
+		ced_list_add(dev);
 		tick_check_new_device(dev);
 	}
 }
@@ -524,7 +540,7 @@ void clockevents_register_device(struct clock_event_device *dev)
 
 	raw_spin_lock_irqsave(&clockevents_lock, flags);
 
-	list_add(&dev->list, &clockevent_devices);
+	ced_list_add(dev);
 	tick_check_new_device(dev);
 	clockevents_notify_released();
 
@@ -638,7 +654,7 @@ void clockevents_adjust_all_freqs(u32 mult_cs_mono, u32 mult_cs_raw)
 		if (!(dev->features & CLOCK_EVT_FEAT_ONESHOT) ||
 		    (dev->features & CLOCK_EVT_FEAT_DUMMY) ||
 		    (dev->features & CLOCK_EVT_FEAT_NO_ADJUST))
-			continue;
+			break;
 
 		/*
 		 * The cached last_mult_adjusted is only valid if
-- 
2.10.2

      parent reply	other threads:[~2016-11-19 16:12 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-19 16:00 [RFC v8 00/28] adapt clockevents frequencies to mono clock Nicolai Stange
2016-11-19 16:00 ` [RFC v8 01/28] clocksource: sh_cmt: compute rate before registration again Nicolai Stange
2016-11-19 16:00 ` [RFC v8 02/28] clocksource: sh_tmu: " Nicolai Stange
2016-11-19 16:00 ` [RFC v8 03/28] clocksource: em_sti: split clock prepare and enable steps Nicolai Stange
2016-11-19 16:00 ` [RFC v8 04/28] clocksource: em_sti: compute rate before registration Nicolai Stange
2016-11-19 16:00 ` [RFC v8 05/28] clocksource: h8300_timer8: don't reset rate in ->set_state_oneshot() Nicolai Stange
2016-11-19 16:00 ` [RFC v8 06/28] clockevents: make clockevents_config() static Nicolai Stange
2016-11-19 16:00 ` [RFC v8 07/28] many clockevent drivers: set ->min_delta_ticks and ->max_delta_ticks Nicolai Stange
2016-11-19 16:00 ` [RFC v8 08/28] arch/s390/kernel/time: " Nicolai Stange
2016-11-19 16:00 ` [RFC v8 09/28] arch/x86/platform/uv/uv_time: " Nicolai Stange
2016-11-19 16:00 ` [RFC v8 10/28] arch/tile/kernel/time: " Nicolai Stange
2016-11-19 16:00 ` [RFC v8 11/28] clockevents: always initialize ->min_delta_ns and ->max_delta_ns Nicolai Stange
2016-11-19 16:10 ` [RFC v8 12/28] many clockevent drivers: don't set " Nicolai Stange
2016-11-19 16:10 ` [RFC v8 13/28] clockevents: do comparison of delta against minimum in terms of cycles Nicolai Stange
2016-11-19 16:10 ` [RFC v8 14/28] clockevents: clockevents_program_min_delta(): don't set ->next_event Nicolai Stange
2016-11-19 16:10 ` [RFC v8 15/28] clockevents: use ->min_delta_ticks_adjusted to program minimum delta Nicolai Stange
2016-11-19 16:10 ` [RFC v8 16/28] clockevents: min delta increment: calculate min_delta_ns from ticks Nicolai Stange
2016-11-19 16:10 ` [RFC v8 17/28] timer_list: print_tickdevice(): calculate ->min_delta_ns dynamically Nicolai Stange
2016-11-19 16:10 ` [RFC v8 18/28] clockevents: purge ->min_delta_ns Nicolai Stange
2016-11-19 16:10 ` [RFC v8 19/28] clockevents: introduce CLOCK_EVT_FEAT_NO_ADJUST flag Nicolai Stange
2016-11-19 16:10 ` [RFC v8 20/28] clockevents: degrade ->min_delta_ticks to unsigned int Nicolai Stange
2016-11-19 16:10 ` [RFC v8 21/28] clockevents: pack ->state_use_accessors and ->features together Nicolai Stange
2016-11-19 16:10 ` [RFC v8 22/28] clockevents: decouple ->max_delta_ns from ->max_delta_ticks Nicolai Stange
2016-11-19 16:10 ` [RFC v8 23/28] clockevents: initial support for mono to raw time conversion Nicolai Stange
2016-11-19 16:10 ` [RFC v8 24/28] clockevents: make setting of ->mult and ->mult_adjusted atomic Nicolai Stange
2016-11-19 16:10 ` [RFC v8 25/28] timekeeping: inform clockevents about freq adjustments Nicolai Stange
2016-11-19 16:10 ` [RFC v8 26/28] clockevents: degrade ->retries to unsigned int Nicolai Stange
2016-11-19 16:10 ` [RFC v8 27/28] clockevents: optimize struct clock_event_device layout Nicolai Stange
2016-11-19 16:10 ` Nicolai Stange [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161119161036.12679-17-nicstange@gmail.com \
    --to=nicstange@gmail.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®