Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp126640rdb; Thu, 24 Aug 2023 00:43:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUBIvAT0ingSj8qdQhGcRl7KSYbzvZIDw7QluJsn675LS4KOzA7AvWsBHmLKkddEiZGUbx X-Received: by 2002:a17:907:7891:b0:99b:5445:10d5 with SMTP id ku17-20020a170907789100b0099b544510d5mr11878248ejc.51.1692863036220; Thu, 24 Aug 2023 00:43:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692863036; cv=none; d=google.com; s=arc-20160816; b=c1f/Wmgtvwme/byF+V5OuQVmptZ7fWCl1OeYNiBpXfCjVgKOxpYXzZUAaSqG3vzpRR PNDI9cc5nMa0YTGEMG9JeZH+LXSZLnwGWuNRjFONzl8yYVIy5yHUt4nQeqER/jk8/hEH anMzNRskn77KP9vM4pKbBHSBzkzAR22HY5pgLDLPoSx15Coi+3whDI0+vFMvo4rSwNYE WB2hab8sugOaS77lnFUs9dJzjaSL4rLgSd777aoPYSuBQY9LZwmgLxNo1yRUFOr0gclA TdS42C+7bgXMomX3iBiREENMBID1gAgA5BPAlO6drMuJbJX5T5MsnhjTAMOt1lOeX/ps kHzg== 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=eVGF+HQG9byoVcmw8G76pRCQ1T3LXA/AI/buBKDDDYw=; fh=b9YN613uZ6WNEfrKVHStQ5CMjECETNuskWvwrxtCXh4=; b=CIwGSLNlaGJOFVzG5mTy+NwfvF+52j3bkgkMDLvWfrvhGtrTbP6S3dpTS0PjfeN6Bt +wkEXYHVoruQhc8dnorZWX0KfVz/nNWz1mieYp5vEme92hyZAeTBe47ngqaAPK3uivDX glIqSyHLln0mymrI3nraqnj0tXsQ791A9uHe7vrcTV1/cJ2fqpunsi2jM0JbpnhJldWk 8bX2VP74Dv5GPCL1WYEDKltqHCsQodUxc5XCkWOWCyQKg79SFNm3zhkbI4iMDHfnv3+z 4wIbYXNglayfkJZly5Eba/g3S5Dr2TE2lTGIsigdw3a01JZi1w3Vy7MY5jX14qqO9xk4 3WrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SInx7YxB; 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 17-20020a170906059100b00992aa293be8si9015457ejn.204.2023.08.24.00.43.26; Thu, 24 Aug 2023 00:43:56 -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=SInx7YxB; 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 S239387AbjHXCsJ (ORCPT + 99 others); Wed, 23 Aug 2023 22:48:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239366AbjHXCrt (ORCPT ); Wed, 23 Aug 2023 22:47:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43079198; Wed, 23 Aug 2023 19:47:48 -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 D628F632E9; Thu, 24 Aug 2023 02:47:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D01EC433C9; Thu, 24 Aug 2023 02:47:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692845265; bh=7PBy+Refm2RRnKJWoTExxPu62p0WpFG8uVlZZkXh0xI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=SInx7YxBx2W+8zAR+OJPWRrvknl/TERlYQH6atyjZN8Ip2rJjL6ManClVGh/JGPlZ FJD0q4ZrcXF9dzRHjQvLrINfIrLg6R2LXhCR/tRzIrX7jvlB0TnDmBiOMVFfEUH3ZF BX45B9IIOHVcy1/RznJGW/0QJr7e+Y3lFmlt380LSsRBxqVKXYMZ1CdktrdOqhIK60 NorsfON4QhicAJ3dfH0k20dsZjgVNjKThmOFAp9KaxyBntBfSmkLcgD39DXhRUKGkU BZzApGCmZ6Jfr9dlQ9K4Qf3Y1n/A05+sTTxF3bY5QOTGxXC6ZQgKj79af+41ZRe0MS bzAR0QKhyEWxg== Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-51bece5d935so7937998a12.1; Wed, 23 Aug 2023 19:47:45 -0700 (PDT) X-Gm-Message-State: AOJu0YyiE+FAmOCfhM8OTu6kJXT55HU4SzR4FQ18JAFPY2MOR60CvXdF g7+ryYZZFL4lQUTxTfjJa7aQFFFYASikd21zSrM= X-Received: by 2002:a05:6402:2051:b0:525:469a:fc49 with SMTP id bc17-20020a056402205100b00525469afc49mr10849489edb.17.1692845263397; Wed, 23 Aug 2023 19:47:43 -0700 (PDT) MIME-Version: 1.0 References: <5777BD82-2C8D-4BAB-BDD3-C2C003DC57FB@joelfernandes.org> <87ttspct76.ffs@tglx> In-Reply-To: <87ttspct76.ffs@tglx> From: Huacai Chen Date: Thu, 24 Aug 2023 10:47:30 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH V4 2/2] rcu: Update jiffies in rcu_cpu_stall_reset() To: Thomas Gleixner Cc: Joel Fernandes , 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 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, Thomas, On Thu, Aug 24, 2023 at 6:03=E2=80=AFAM 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. > > 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 ! > */ Thank you for your advice, now the latest proposal is here [1], this is very similar to your diff, please take a look. [1] https://lore.kernel.org/rcu/CAAhV-H5mePbbF8Y3t-JfV+PNP8BEcjKtX4UokzL_vD= zyw+2BRg@mail.gmail.com/T/#t Huacai > >