Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1319543rdb; Fri, 1 Dec 2023 12:49:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IEzM9JmyRDtlBIdirKJT74GZjCusZu10qJurwZWuKHRILdHmHIYA6EaYbyIwYHHk6ML4HKt X-Received: by 2002:a17:902:e807:b0:1d0:6ffd:ceb2 with SMTP id u7-20020a170902e80700b001d06ffdceb2mr81471plg.107.1701463763940; Fri, 01 Dec 2023 12:49:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701463763; cv=none; d=google.com; s=arc-20160816; b=GOI1iJtqhJvVK4q+tSNB5R7yKek9DKWABrg72yOJiUMnZ+v8aYBATl8+lKPh+/7Z16 DeQ2LPrNXoj7Mxx6M6M1YvJSLP0VUZr1TcczxyFH2dvrAfGZnF+8Ilmf1oEnxV9ENtRP wqrGCEpcsBFdD2XiPFPBNLcEUoG3AUWGWvDLq0nEqXyelPCDUaP4Ja8cgvCxI4adV8hF QffPCVCcvHZY49Aab3mvyyrgeGSyBB3OQVzncxE126yFJ9W5IynCOXF3EoJgkbX7z0+j /C6UELPqjkt3YmTeLnqTeSrc9DgG818BnTAHavMvJx1ovhJmmnuryIIPWECjUYgCAVpW ZUgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:subject:cc:to:from:date; bh=nfF063jJRpVE53MH6ecf/Jze5TVd5m94kqXoqeCkJL8=; fh=7piaXXqFrdylso55bRAOdaQ8fp0BNpZGnXG8XqKBgE8=; b=UvU+QKz6oqaqQrHVdq8BgC2inHpcAPLOTlIMEig73QS5HzjkTb3Fl3ZrVBT2+k82Ro zWx3JWWgdofXcjbRQvj9YfPqwTP1ZPqu7sctQS3eYY6bHnglnqWtRe0CIbx2MJj5tUrT hMATqth9GJCCfKoLC2HuXEJSdpAoaLeG9by7yC7eG4L53pATSWorQP28lFqZOxRFUazx DTuBcfhy8jN4X6X+cbFIc7VbOv1280rHipa+7wUn+Z8Qkp4JbyEiAGuxi+nAPFYNH+/p rczOtVhdA/sPfmWRMR3TQcEEfr4UKysmMSwbCMYxKG+8E4u1U1NYAIbNcV4Ao/UDxH5I gUGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id s14-20020a170902ea0e00b001cfd24c7b81si4082501plg.216.2023.12.01.12.49.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 12:49:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 077488263EA5; Fri, 1 Dec 2023 12:49:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230456AbjLAUtG (ORCPT + 99 others); Fri, 1 Dec 2023 15:49:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbjLAUtF (ORCPT ); Fri, 1 Dec 2023 15:49:05 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 758E810D for ; Fri, 1 Dec 2023 12:49:11 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5ECFFC433C7; Fri, 1 Dec 2023 20:49:10 +0000 (UTC) Date: Fri, 1 Dec 2023 15:49:32 -0500 From: Steven Rostedt To: "Paul E. McKenney" Cc: LKML , rcu@vger.kernel.org, Frederic Weisbecker , Joel Fernandes , Mathieu Desnoyers Subject: [RCU] rcu_tasks_trace_qs(): trc_reader_special.b.need_qs value incorrect likely()? Message-ID: <20231201154932.468d088b@gandalf.local.home> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 01 Dec 2023 12:49:21 -0800 (PST) Paul, I just started running my branch tracer (that checks all branches and also gives likely and unlikely correctness). And I found this: correct incorrect % Function File Line ------- --------- - -------- ---- ---- 0 1217713 100 rcu_softirq_qs tree.c 247 Which comes down to this: # define rcu_tasks_trace_qs(t) \ do { \ int ___rttq_nesting = READ_ONCE((t)->trc_reader_nesting); \ \ if (likely(!READ_ONCE((t)->trc_reader_special.b.need_qs)) && \ likely(!___rttq_nesting)) { \ rcu_trc_cmpxchg_need_qs((t), 0, TRC_NEED_QS_CHECKED); \ } else if (___rttq_nesting && ___rttq_nesting != INT_MIN && \ !READ_ONCE((t)->trc_reader_special.b.blocked)) { \ rcu_tasks_trace_qs_blkd(t); \ } \ } while (0) I added just before the likely/unlikely to my test box and I see this: trace_printk("need qs? %d %d\n", READ_ONCE((t)->trc_reader_special.b.need_qs), ___rttq_nesting); \ -0 [005] d.h1. 2.482412: rcu_sched_clock_irq: need qs? 2 0 -0 [002] d.h1. 2.482464: rcu_sched_clock_irq: need qs? 2 0 -0 [000] d.h1. 2.482766: rcu_sched_clock_irq: need qs? 2 0 -0 [001] d.h1. 2.482951: rcu_sched_clock_irq: need qs? 2 0 -0 [007] d.h1. 2.482958: rcu_sched_clock_irq: need qs? 2 0 -0 [005] d.h1. 2.483600: rcu_sched_clock_irq: need qs? 2 0 -0 [002] d.h1. 2.483624: rcu_sched_clock_irq: need qs? 2 0 -0 [000] d.h1. 2.483927: rcu_sched_clock_irq: need qs? 2 0 -0 [007] d.h1. 2.484068: rcu_sched_clock_irq: need qs? 2 0 -0 [001] d.h1. 2.484127: rcu_sched_clock_irq: need qs? 2 0 -0 [002] d.h1. 2.484723: rcu_sched_clock_irq: need qs? 2 0 -0 [005] d.h1. 2.484745: rcu_sched_clock_irq: need qs? 2 0 -0 [000] d.h1. 2.485015: rcu_sched_clock_irq: need qs? 2 0 -0 [007] d.h1. 2.485202: rcu_sched_clock_irq: need qs? 2 0 -0 [001] d.h1. 2.485258: rcu_sched_clock_irq: need qs? 2 0 -0 [002] d.h1. 2.485818: rcu_sched_clock_irq: need qs? 2 0 -0 [005] d.h1. 2.485929: rcu_sched_clock_irq: need qs? 2 0 -0 [000] d.h1. 2.486224: rcu_sched_clock_irq: need qs? 2 0 -0 [007] d.h1. 2.486370: rcu_sched_clock_irq: need qs? 2 0 -0 [001] d.h1. 2.486399: rcu_sched_clock_irq: need qs? 2 0 -0 [002] d.h1. 2.486895: rcu_sched_clock_irq: need qs? 2 0 -0 [005] d.h1. 2.487049: rcu_sched_clock_irq: need qs? 2 0 -0 [000] d.h1. 2.487318: rcu_sched_clock_irq: need qs? 2 0 -0 [007] d.h1. 2.487472: rcu_sched_clock_irq: need qs? 2 0 -0 [001] d.h1. 2.487522: rcu_sched_clock_irq: need qs? 2 0 -0 [002] d.h1. 2.488034: rcu_sched_clock_irq: need qs? 2 0 -0 [005] d.h1. 2.488220: rcu_sched_clock_irq: need qs? 2 0 Note, that "2" is the READ_ONCE() without the "!" to it. Thus: if (likely(!READ_ONCE((t)->trc_reader_special.b.need_qs)) && \ Is unlikely to be true. Was this supposed to be: if (!likely(READ_ONCE((t)->trc_reader_special.b.need_qs)) && \ Or could it be converted to: if (unlikely(!READ_ONCE((t)->trc_reader_special.b.need_qs)) && \ ? Note, the unlikely tracing is running on my production server v6.6.3. The above trace is from my test box with latest Linus's tree. -- Steve