Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp46559rdb; Wed, 23 Aug 2023 20:55:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHS//kCJnuLpIlmGO977NRsp+gBdEM0tBq5D+5tRVufaiEX95OQQBrXRUD3DB1N02Vgx02T X-Received: by 2002:a17:906:5daa:b0:99d:d4ec:6c5d with SMTP id n10-20020a1709065daa00b0099dd4ec6c5dmr10774869ejv.73.1692849324910; Wed, 23 Aug 2023 20:55:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692849324; cv=none; d=google.com; s=arc-20160816; b=hE4qEEnmDRmXiAuSh8esK/lLmA4VgXQfeJyPuPigSuCXHH1Ag/fROQJVgT7/SAhkCe UdUJ7aZtA1Oh6DV86nZZkJaZkZFQC/Q/tNcavI+vcVg8cU2vqEHz6q9PGDAS/7OThfiA +aCGU0a79KtYPd75ppnH0VfOsmMkCfU5GGcWgads+X0cIkycge6EjzTPTSc08tvo677g +s69/v6UgYlZH72Ab39gEzrfKvLzzx0/SbtQJG1Tfheox6cqX8sQ9Iuqm3Prq0tOA6ef 0kD3f7Q/Xnlis9GZO9emAnJ0STi7FpwpHmRUqzS1+EYqAZY9aDPcZQA+C/Ef1JCLDVqD yBlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=2cYT35BVhYnlfeWZ8at2stePk34UrQIFIGAWM5ubrhc=; fh=27qK38eVr4a2QBwyFuDqBWE5l+s9EdH8asNhBpr+ytQ=; b=yylier7uIDEO2MG3EnrX4RfyLfUQYJp3C4gxXI3/QTbCWDS6sLQ0iRrf/bCboHKq1m fori4F67TYsjmXVHoRm2QEKok7DW5HKwOCpV4yarvZFKrw7SeHtCfp066zwevrroKqHw wwz0UWYi3tbhRzW7rJH1ebwZ8MlpfaDubFxfgakyUp+8YMOv6G/dRjABZrjPVnPSRrmO 6PMtKy19ZZyRw3BSKb/iapNsKcJz1i+T81ael6o4PtfZAocVK9nreOhGSs+pHALCbe9Z Xj/AVBrnz1D607CRzeBCMEphLlpKgX4jp+0GokkJzmRQPElquUUAQ7u6Rj2zte1jvyjW GHPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GrZ+jz76; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bg22-20020a170906a05600b009930d1379a0si8994532ejb.885.2023.08.23.20.54.59; Wed, 23 Aug 2023 20:55:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GrZ+jz76; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236324AbjHXCvY (ORCPT + 99 others); Wed, 23 Aug 2023 22:51:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230119AbjHXCu6 (ORCPT ); Wed, 23 Aug 2023 22:50:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC841198; Wed, 23 Aug 2023 19:50:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6BB25614AC; Thu, 24 Aug 2023 02:50:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBC6CC433CD; Thu, 24 Aug 2023 02:50:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692845455; bh=FBVROIY3T0LPqE0Yehq9z3S9IR6oyeROYOJKahC5BwI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=GrZ+jz76BK/FKydLtTKBa/2pRoj8lrN0ZhE8cm0OLfSflLsnE+EyK/3nChEmd3PNY mIFXusZKQXkOZ3b9yO3DNYsKxIJ+b7uHMlPYxCjqArfH4Dc0ZftVm7viWVsU6DqlCR 4QivCfu8ifC+PdQSiVCJm/lstus+XGNbqniQ/acrEs0wLuiqpMq1OOS1T6Ybv0j4p/ Gs5uX/EVmpSa7IcJaw/f1bSQrG1f6BGl2NB4XVD4Y696IHhSOg7bfEbEDs0kQ+ZiPV uxRsEKMi6wdwvA8Oj3KB7jIogLSH89uCGQDKJwtT/45xhfKD5dl9VnfZGaYwANTq6V oeUfD4BnQW9vQ== Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-52557cc5e7bso7963855a12.0; Wed, 23 Aug 2023 19:50:55 -0700 (PDT) X-Gm-Message-State: AOJu0Yx6s6pj7ZsROxkiiHpSOyOfwvX50715Dsxd+jKbBgacituLxBSo aG5fa+qPn3/4RTLpgqeTLuV+WVzCQP2XNbNFkZo= X-Received: by 2002:aa7:d058:0:b0:523:d1ab:b2ed with SMTP id n24-20020aa7d058000000b00523d1abb2edmr11344547edo.29.1692845453993; Wed, 23 Aug 2023 19:50:53 -0700 (PDT) MIME-Version: 1.0 References: <5777BD82-2C8D-4BAB-BDD3-C2C003DC57FB@joelfernandes.org> <87ttspct76.ffs@tglx> <03fe7084-0509-45fa-87ee-8f8705a221a6@paulmck-laptop> In-Reply-To: <03fe7084-0509-45fa-87ee-8f8705a221a6@paulmck-laptop> From: Huacai Chen Date: Thu, 24 Aug 2023 10:50:41 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH V4 2/2] rcu: Update jiffies in rcu_cpu_stall_reset() To: paulmck@kernel.org Cc: Thomas Gleixner , Joel Fernandes , Z qiang , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Paul, On Thu, Aug 24, 2023 at 6:41=E2=80=AFAM Paul E. McKenney wrote: > > On Thu, Aug 24, 2023 at 12:03:25AM +0200, Thomas Gleixner wrote: > > 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. > > Just for completeness, another approach, with its own advantages > and disadvantage, is to add something like ULONG_MAX/4 to > rcu_state.jiffies_stall, but also set a counter indicating that this > has been done. Then RCU's force-quiescent processing could decrement > that counter (if non-zero) and reset rcu_state.jiffies_stall when it > does reach zero. > > Setting the counter to three should cover most cases, but "live by the > heuristic, die by the heuristic". ;-) > > It would be good to have some indication when gdb exited, but things > like the gdb "next" command can make that "interesting" when applied to > a long-running function. The original code is adding ULONG_MAX/2, so adding ULONG_MAX/4 may make no much difference? The simplest way is adding 300*HZ, but Joel dislikes that. Huacai > > Thanx, Paul > > > 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; > > > > +unsigned long tick_estimate_stale_jiffies(void) > > +{ > > + ktime_t delta =3D ktime_get_mono_fast_ns() - READ_ONCE(last_jiffi= es_update); > > + > > + return delta < 0 ? 0 : div_s64(delta, TICK_NSEC); > > +} > > + > > /* > > * Must be called with interrupts disabled ! > > */ > > > >