From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 529C0C7113B for ; Wed, 23 Aug 2023 22:04:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235458AbjHWWDo (ORCPT ); Wed, 23 Aug 2023 18:03:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238450AbjHWWD3 (ORCPT ); Wed, 23 Aug 2023 18:03:29 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BD49E6D; Wed, 23 Aug 2023 15:03:27 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1692828205; h=from:from: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=Y/NSbqLkBcAVkR1qAY36zcRsKaJY0QWO48cvwI3jfDY=; b=ztwmMeP/9aQCODsq7WUmsVCTa+n+ylmuicZXzJxuVnSSinQXhG6iXsRuRHPmzokznMfaAM rw7D27568+nSskl1b+cuOkf/kHHWxSSDUM3cF44TyHbImhqZLNF3fWJSgynnTaDDSTf+/1 /mxc3pKe7ksKNv67fwnwmoy5h1+wTswVDovvt5sSwOOh1Z69XpDF6Q+4EMKLmMD+km757t +9Zw8FtbP81rau3eoCwM9eoVk/tF3yJglgLsqZHrFnb9eaQp3Y0BS35hpQ7oWwtKCiVWDv XCaUAu08SCMhFaHseuRDkVh53dDrg3hwqmCnKgBaF1NeMIahU6/lWpFcRsJiMw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1692828205; h=from:from: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=Y/NSbqLkBcAVkR1qAY36zcRsKaJY0QWO48cvwI3jfDY=; b=2HX5OKtmZOUAQoSsbLqZmxLXrxZKOK65yYZ7oS0DRtKK5lQ4Q1o9jgyxLnnSV8EmAMRdZB +yFIsGoQuIMah2Dg== To: Huacai Chen , Joel Fernandes Cc: Z qiang , paulmck@kernel.org, Huacai Chen , Frederic Weisbecker , Neeraj Upadhyay , Josh Triplett , Boqun Feng , Ingo Molnar , John Stultz , Stephen Boyd , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Sergey Senozhatsky , rcu@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Binbin Zhou Subject: Re: [PATCH V4 2/2] rcu: Update jiffies in rcu_cpu_stall_reset() In-Reply-To: References: <5777BD82-2C8D-4BAB-BDD3-C2C003DC57FB@joelfernandes.org> Date: Thu, 24 Aug 2023 00:03:25 +0200 Message-ID: <87ttspct76.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Thu, Aug 17 2023 at 16:06, Huacai Chen wrote: > On Thu, Aug 17, 2023 at 3:27=E2=80=AFAM Joel Fernandes wrote: >> > If do_update_jiffies_64() cannot be used in NMI context, >> >> Can you not make the jiffies update conditional on whether it is >> called within NMI context? Which solves what? If KGDB has a breakpoint in the jiffies lock held region then you still dead lock. >> I dislike that.. > Is this acceptable? > > void rcu_cpu_stall_reset(void) > { > unsigned long delta; > > delta =3D nsecs_to_jiffies(ktime_get_ns() - ktime_get_coarse_ns()= ); > > WRITE_ONCE(rcu_state.jiffies_stall, > jiffies + delta + rcu_jiffies_till_stall_check()); > } > > This can update jiffies_stall without updating jiffies (but has the > same effect). Now you traded the potential dead lock on jiffies lock for a potential live lock vs. tk_core.seq. Not really an improvement, right? The only way you can do the above is something like the incomplete and uncompiled below. NMI safe and therefore livelock proof time interfaces exist for a reason. Thanks, tglx --- --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -51,6 +51,13 @@ struct tick_sched *tick_get_tick_sched(i */ static ktime_t last_jiffies_update; =20 +unsigned long tick_estimate_stale_jiffies(void) +{ + ktime_t delta =3D ktime_get_mono_fast_ns() - READ_ONCE(last_jiffies_updat= e); + + return delta < 0 ? 0 : div_s64(delta, TICK_NSEC); +} + /* * Must be called with interrupts disabled ! */