From nobody Mon Nov 25 17:22:23 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 E7BE415383F; Fri, 25 Oct 2024 14:54:00 +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=1729868043; cv=none; b=CvVq1Kq6mvoxqGO5gESPRBwivKPSEEVY2D8Bl7Klu1aKsFmro15XHRq80trF3AxjGMqJmrlfjqOWkoq71UfYl9S6JgrmFkuxZXf/+gHrjtTrtIPtJJDa1rifxGS02kAxZTgmxZ+0CpW9aHFdfk4kGUdEJ3vxtQ1Dmg7XN3quPbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729868043; c=relaxed/simple; bh=6PrOZAzB8xH/ZanfVbTcknJJnN4yTTOkFHka+glKbBE=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=nN3ASSyvpSG8bVasHnR6JmYMygKX+zHWtFZ7YZ2OeCdsz1o+77NjW3MEmw4MoRyhQ8fA5wQ+VjeIelzZDb5wjsDyl/rkGx7BumNbbMp628ja2Be4QOSk2cknuWhDRipuILH3gYBPrCuvP4mLqANdZ7u7f8XnzeamWnSHGDHIUtg= 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=ynIXkPdD; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=BQEgdshB; 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="ynIXkPdD"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="BQEgdshB" Date: Fri, 25 Oct 2024 14:53:58 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1729868039; 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=zbgayfJ1uIvilPUerlIUWl38rn27BFQrZG2PA9/aN88=; b=ynIXkPdDGeOu3FUvPSYpCYJHg3BnjWPwk8xEIiEAg9FeHB/moHmM3fUWt7Dd1pjDXxq1jT Idt21R9FK+WwGczc227a1cA0ZvL71HLBtmWzaLvoxJwXvJGXh/2V4gKKXYXMB1ypGMU4/c zy2G1Hpi4mfxO5Lh+1+y3yBJgdgsCafH+KOSs9Cur6mMsd+C3SOSgyHwGoNTVYsFjeiwpe /v3vU2yLKkVt5zGpGzoJ8kSQU/Ir+Hgwd8xvW63y/mRuTrB+k4dOMkZ+OHTR3ZVNhrrxGZ 0A8cYrGbbUSa9srGqp0bS9W28EOx0Ap17MZMeIllf/+o+MgKPMXbgmHuo8FSDg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1729868039; 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=zbgayfJ1uIvilPUerlIUWl38rn27BFQrZG2PA9/aN88=; b=BQEgdshB493O9c5vDrE6+uhz9CkKOOeCP297KaT5xaiCdIAczZgMPlBVFO0T0sK/aGkDr5 GLYm7HjLPXIKRVAw== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] timekeeping: Abort clocksource change in case of failure Cc: Thomas Gleixner , "Anna-Maria Behnsen" , 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-4-554456a44a15=40linutronix=2Ede=3E?= References: =?utf-8?q?=3C20241009-devel-anna-maria-b4-timers-ptp-timekeeping?= =?utf-8?q?-v2-4-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: <172986803886.1442.12084874719782440417.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: f837b757c3b192b51b658dd6a0804e2c693222cd Gitweb: https://git.kernel.org/tip/f837b757c3b192b51b658dd6a0804e2c6= 93222cd Author: Thomas Gleixner AuthorDate: Wed, 09 Oct 2024 10:28:57 +02:00 Committer: Thomas Gleixner CommitterDate: Fri, 25 Oct 2024 16:41:11 +02:00 timekeeping: Abort clocksource change in case of failure From: Thomas Gleixner There is no point to go through a full timekeeping update when acquiring a module reference or enabling the new clocksource fails. Signed-off-by: Thomas Gleixner 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-4-554456a44a15@linutronix.de --- kernel/time/timekeeping.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 14aaa44..a9550f6 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1608,33 +1608,29 @@ static void __timekeeping_set_tai_offset(struct tim= ekeeper *tk, s32 tai_offset) static int change_clocksource(void *data) { struct timekeeper *tk =3D &tk_core.timekeeper; - struct clocksource *new, *old =3D NULL; + struct clocksource *new =3D data, *old =3D NULL; unsigned long flags; - bool change =3D false; - - new =3D (struct clocksource *) data; =20 /* - * If the cs is in module, get a module reference. Succeeds - * for built-in code (owner =3D=3D NULL) as well. + * If the clocksource is in a module, get a module reference. + * Succeeds for built-in code (owner =3D=3D NULL) as well. Abort if the + * reference can't be acquired. */ - if (try_module_get(new->owner)) { - if (!new->enable || new->enable(new) =3D=3D 0) - change =3D true; - else - module_put(new->owner); + if (!try_module_get(new->owner)) + return 0; + + /* Abort if the device can't be enabled */ + if (new->enable && new->enable(new) !=3D 0) { + module_put(new->owner); + return 0; } =20 raw_spin_lock_irqsave(&timekeeper_lock, flags); write_seqcount_begin(&tk_core.seq); =20 timekeeping_forward_now(tk); - - if (change) { - old =3D tk->tkr_mono.clock; - tk_setup_internals(tk, new); - } - + old =3D tk->tkr_mono.clock; + tk_setup_internals(tk, new); timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); =20 write_seqcount_end(&tk_core.seq); @@ -1643,7 +1639,6 @@ static int change_clocksource(void *data) if (old) { if (old->disable) old->disable(old); - module_put(old->owner); }