From nobody Mon Nov 25 15:47:17 2024 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE15C20BB5C; Fri, 25 Oct 2024 18:01:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729879281; cv=none; b=FMeEz6YfQstmCMxJuTjVF7B52Wslf/GgKt1B/G0hH7vxxJ2KXVkUtCMyTSRlaqd373g8tnl6ABOmWr5iAUeDY9fDVDOUPE9Fe7Yo5rcRD1CB/KBPZN74uOc/hQku8oO2wKW5rxrtDX0Vg0XVs1RqPTjOZL6paLSx7y/5ABTmfnU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729879281; c=relaxed/simple; bh=6lS5GYTUpkOWKsHlMryerW/KXPrgCtP7d0ahKiSQYO0=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=MwrgLzFVuB9EbtoqNIQxGdvVmTjNy/fHzDJx89mUnvg3zuNJ0lxqcVZ/kBhpflNyTqZodRqMte4OuJcr7U3uRG6eE5GXBb4bewJcDIqLjYcONRKSveWHQ/QBZ8IEI1QiNXVSjXsB9kI5md947+FoeA/58AeaedKYDHPx5CiObDQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=xDj+GtbY; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=E8n+Y06U; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="xDj+GtbY"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="E8n+Y06U" Date: Fri, 25 Oct 2024 18:01:16 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1729879276; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Jc+XQqzgyW94TMU9vfB/naNwpGMRf+1eljQyCzT+BpM=; b=xDj+GtbYzWSOjMv/R0mKRcBo4p+yz3zabd/tYavDE51d6egfiAJX78IkccYQJXO23K0n1I QPa7A7jRYVZZkmEYiRg0nUKvmvmvMlNfSYiOQ2yPOYhMfTNUGU14AljLRofyirC78g6U/C eWKXr82kV8yQlPwJTSlqIjl5R6Xdjg27RjZqEG9szI6ZFdnPatqgxsWpvCCgInNpOW3onS q3AUVcNBJeJAPvXEYkdPmmpPk/Zln+fbpUhhCNefNDd/46Y3cT9xwvpOFc2xnoxz5Mydf3 Aa8DRnmV/XVV1lrhjw9ipmKh+r+yGidADCIqLyZGP0pblmlysOP5luiUtRKcZA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1729879276; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Jc+XQqzgyW94TMU9vfB/naNwpGMRf+1eljQyCzT+BpM=; b=E8n+Y06UO6j/+rkWY+BZCCVTCsWDGZhcCKJJhKi8UTHI9Q4i5Vk+Hs48Rt+07rbHMx/aL5 quR7qubuTSPesoDg== From: "tip-bot2 for Anna-Maria Behnsen" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] timekeeping: Rework timekeeping_resume() to use shadow_timekeeper Cc: "Anna-Maria Behnsen" , Thomas Gleixner , John Stultz , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: =?utf-8?q?=3C20241009-devel-anna-maria-b4-timers-ptp-timekeepin?= =?utf-8?q?g-v2-21-554456a44a15=40linutronix=2Ede=3E?= References: =?utf-8?q?=3C20241009-devel-anna-maria-b4-timers-ptp-timekeeping?= =?utf-8?q?-v2-21-554456a44a15=40linutronix=2Ede=3E?= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <172987927604.1442.2624338564985056515.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the timers/core branch of tip: Commit-ID: b2350d954dca14dfde95e7512ad521ccab0e4108 Gitweb: https://git.kernel.org/tip/b2350d954dca14dfde95e7512ad521cca= b0e4108 Author: Anna-Maria Behnsen AuthorDate: Wed, 09 Oct 2024 10:29:14 +02:00 Committer: Thomas Gleixner CommitterDate: Fri, 25 Oct 2024 19:49:15 +02:00 timekeeping: Rework timekeeping_resume() to use shadow_timekeeper Updates of the timekeeper can be done by operating on the shadow timekeeper and afterwards copying the result into the real timekeeper. This has the advantage, that the sequence count write protected region is kept as small as possible. While the sequence count held time is not relevant for the resume path as there is no concurrency, there is no reason to have this function different than all the other update sites. Convert timekeeping_inject_offset() to use this scheme and cleanup the variable declaration while at it. Signed-off-by: Anna-Maria Behnsen Signed-off-by: Thomas Gleixner Acked-by: John Stultz Link: https://lore.kernel.org/all/20241009-devel-anna-maria-b4-timers-ptp-t= imekeeping-v2-21-554456a44a15@linutronix.de --- kernel/time/timekeeping.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 9552bc7..94f68e7 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1943,12 +1943,12 @@ void timekeeping_inject_sleeptime64(const struct ti= mespec64 *delta) */ void timekeeping_resume(void) { - struct timekeeper *tk =3D &tk_core.timekeeper; - struct clocksource *clock =3D tk->tkr_mono.clock; - unsigned long flags; + struct timekeeper *tks =3D &tk_core.shadow_timekeeper; + struct clocksource *clock =3D tks->tkr_mono.clock; struct timespec64 ts_new, ts_delta; - u64 cycle_now, nsec; bool inject_sleeptime =3D false; + u64 cycle_now, nsec; + unsigned long flags; =20 read_persistent_clock64(&ts_new); =20 @@ -1956,7 +1956,6 @@ void timekeeping_resume(void) clocksource_resume(); =20 raw_spin_lock_irqsave(&tk_core.lock, flags); - write_seqcount_begin(&tk_core.seq); =20 /* * After system resumes, we need to calculate the suspended time and @@ -1970,7 +1969,7 @@ void timekeeping_resume(void) * The less preferred source will only be tried if there is no better * usable source. The rtc part is handled separately in rtc core code. */ - cycle_now =3D tk_clock_read(&tk->tkr_mono); + cycle_now =3D tk_clock_read(&tks->tkr_mono); nsec =3D clocksource_stop_suspend_timing(clock, cycle_now); if (nsec > 0) { ts_delta =3D ns_to_timespec64(nsec); @@ -1982,17 +1981,16 @@ void timekeeping_resume(void) =20 if (inject_sleeptime) { suspend_timing_needed =3D false; - __timekeeping_inject_sleeptime(tk, &ts_delta); + __timekeeping_inject_sleeptime(tks, &ts_delta); } =20 /* Re-base the last cycle value */ - tk->tkr_mono.cycle_last =3D cycle_now; - tk->tkr_raw.cycle_last =3D cycle_now; + tks->tkr_mono.cycle_last =3D cycle_now; + tks->tkr_raw.cycle_last =3D cycle_now; =20 - tk->ntp_error =3D 0; + tks->ntp_error =3D 0; timekeeping_suspended =3D 0; - timekeeping_update(&tk_core, tk, TK_MIRROR | TK_CLOCK_WAS_SET); - write_seqcount_end(&tk_core.seq); + timekeeping_update_from_shadow(&tk_core, TK_CLOCK_WAS_SET); raw_spin_unlock_irqrestore(&tk_core.lock, flags); =20 touch_softlockup_watchdog();