From nobody Mon Nov 25 18:03:11 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 BD8CC163A97; Fri, 25 Oct 2024 14:53:49 +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=1729868033; cv=none; b=qGvmG2mUgBEtP+EUDm9ISQIuFYnYRm1lHFwfWvOWAROw7Jb4CAOtAboLmVaAulLNL+lio7BfpQlXYraM4d3Zf41gKnt08OSeCLyfyc96n05vjmkHAeYcme/ajydoUM3XlA6o+j/HFI8ds+zoeK3PMlPsNWTT/hdhVEXbzSz6YgU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729868033; c=relaxed/simple; bh=gwx99e7tHRRrWllWerm60uyJz4WizSdITFnb8UV/+cs=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=OrLIx1/EF6parlnEaWWDs61ARzF08pVI9yEbB2x44Zc+IpS7GejztcrG6qpNzbVjAnuUOhFvuWyvutRHyP0sl9MNN4/RoRsNZ7HcPStkY98eD4fDZ5mDVNwxF+XM9xstj8k2+6JWsEwIn32PuBPgeCiDfZ1dmKnIpFj18PgBYPQ= 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=Lt2IyfG0; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Ex6llKDy; 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="Lt2IyfG0"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Ex6llKDy" Date: Fri, 25 Oct 2024 14:53:47 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1729868028; 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=MChSoZANMU++R7+wseuB+lD1AAEjQDTAlsLNohiXTAs=; b=Lt2IyfG0rSppTrBodLUhJ9dZV0Go9u/2xiqXhcsjWp24VQ7P0iITfB7LhhzE7JKeYcgNxZ my4hNKqUuI083iAAJyt9+Z0+w60S6FfxTyY3hN8HAJH7lNXcIQdPD1FmU0zoNQoIMcOzVk yeIgaI6TUuZ6GizPemTXL99C0xTEW4PUdblyFTUyus9El1Y9AHbzLaUnj+67bSQktIpAhh ctpTqoEPLlAm9gSJtrlLdSc8to8MpPilii2SZer64Rv2lvAjyutftUa057jMav22M29Zzm VaFBKa97cK135yeQo9lBgn85000qz/p0KfuqAahs99CXXUvRdRfCI2QWdVKfiw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1729868028; 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=MChSoZANMU++R7+wseuB+lD1AAEjQDTAlsLNohiXTAs=; b=Ex6llKDyqTkyBAivu1BXPEJClNeSrpvapJ9lRKG3uLBFhp6I3OOe40UBNBWKh/rzaiVD8B cXKNgZV+g/3Qc3BQ== 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: <172986802740.1442.9533067440872609955.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: b78f15dd40628efbe0b5ac74e31af1dbda00bc35 Gitweb: https://git.kernel.org/tip/b78f15dd40628efbe0b5ac74e31af1dbd= a00bc35 Author: Anna-Maria Behnsen AuthorDate: Wed, 09 Oct 2024 10:29:14 +02:00 Committer: Thomas Gleixner CommitterDate: Fri, 25 Oct 2024 16:41:13 +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();