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 778FEC83F18 for ; Sun, 27 Aug 2023 21:47:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230379AbjH0VrA (ORCPT ); Sun, 27 Aug 2023 17:47:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230371AbjH0Vqd (ORCPT ); Sun, 27 Aug 2023 17:46:33 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAAC5119 for ; Sun, 27 Aug 2023 14:46:30 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-792979d4cb5so36086839f.2 for ; Sun, 27 Aug 2023 14:46:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1693172790; x=1693777590; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EOVv5jytzvUysYuiOU5na6ju5GFr2D3rnZDe2oaI3wE=; b=LWnCDndyxijVL6m9XTaHolTRGKyhlh1Tqy8oXCQ+HmoSqGjhXv+HRqVlWVJ0WyMD2R ebGOexZUZm3j1L4LsWqKNhYf3KjnKXIO8gT7bSl8RMahake/AfwJkB6ys8DMFClZJoMD FrFKaCR41sGFexh8cPNIFQN/QxiSWMXzOQ54g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693172790; x=1693777590; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EOVv5jytzvUysYuiOU5na6ju5GFr2D3rnZDe2oaI3wE=; b=LtFgviuyx5DkYMV5hlIn3y/jJY7i7kLIXk4N/UTaYUnkm6BCVS7hGibwdqNu0tvy5u Mxn41Na0rOcwx4l3RJt0sLcGQxATwmusRlRpktqfokk1wEJDZGro7Op+3PqmtOMWQdzg kN8xKuLWkIF2R3wLfCwpjjad0eRDiEDF/i920spPo+15iTeFwA6OHXHA3fNhK2e+DSPA EcIoMM9BFqOfzL/CpAOqaTZXpOCOoF2AcB66JhqA8hYx6S8Ang9IBGsZOrpnK0zD7wzg Qq4PrPBHWsLTjUHBiWVoNNtyi03tGB66FEtVHq2pm/97olV5l9Ebtav4SWL0P/8GEwaA r3Ag== X-Gm-Message-State: AOJu0YyRaX/hbxEI1zPU9lmMrdj9+iYKVj4wcSicfQ5HmKQLNGJ8Q4eA RaWsTz2fO2m5cVZjEi/iBtbPwA== X-Google-Smtp-Source: AGHT+IGOxnQO6va/2JkAqJJhnNkpAcdZqRJekTFUkO5JXnXKKoR4610962OnVgcKGga5zxGpuViZpw== X-Received: by 2002:a5d:8550:0:b0:787:ff98:c38c with SMTP id b16-20020a5d8550000000b00787ff98c38cmr15962029ios.10.1693172790194; Sun, 27 Aug 2023 14:46:30 -0700 (PDT) Received: from joelboxx5.c.googlers.com.com (156.190.123.34.bc.googleusercontent.com. [34.123.190.156]) by smtp.gmail.com with ESMTPSA id d13-20020a02a48d000000b0042b1cd4c096sm1992515jam.74.2023.08.27.14.46.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Aug 2023 14:46:29 -0700 (PDT) From: "Joel Fernandes (Google)" To: stable@vger.kernel.org, "Paul E. McKenney" , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5.10 2/2] rcu: Prevent expedited GP from enabling tick on offline CPU Date: Sun, 27 Aug 2023 21:46:21 +0000 Message-ID: <20230827214622.240001-2-joel@joelfernandes.org> X-Mailer: git-send-email 2.42.0.rc1.204.g551eb34607-goog In-Reply-To: <20230827214622.240001-1-joel@joelfernandes.org> References: <20230827214622.240001-1-joel@joelfernandes.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Paul E. McKenney" [ Upstream commit 147f04b14adde831eb4a0a1e378667429732f9e8 ] If an RCU expedited grace period starts just when a CPU is in the process of going offline, so that the outgoing CPU has completed its pass through stop-machine but has not yet completed its final dive into the idle loop, RCU will attempt to enable that CPU's scheduling-clock tick via a call to tick_dep_set_cpu(). For this to happen, that CPU has to have been online when the expedited grace period completed its CPU-selection phase. This is pointless: The outgoing CPU has interrupts disabled, so it cannot take a scheduling-clock tick anyway. In addition, the tick_dep_set_cpu() function's eventual call to irq_work_queue_on() will splat as follows: smpboot: CPU 1 is now offline WARNING: CPU: 6 PID: 124 at kernel/irq_work.c:95 +irq_work_queue_on+0x57/0x60 Modules linked in: CPU: 6 PID: 124 Comm: kworker/6:2 Not tainted 5.15.0-rc1+ #3 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS +rel-1.14.0-0-g155821a-rebuilt.opensuse.org 04/01/2014 Workqueue: rcu_gp wait_rcu_exp_gp RIP: 0010:irq_work_queue_on+0x57/0x60 Code: 8b 05 1d c7 ea 62 a9 00 00 f0 00 75 21 4c 89 ce 44 89 c7 e8 +9b 37 fa ff ba 01 00 00 00 89 d0 c3 4c 89 cf e8 3b ff ff ff eb ee <0f> 0b eb b7 +0f 0b eb db 90 48 c7 c0 98 2a 02 00 65 48 03 05 91 6f RSP: 0000:ffffb12cc038fe48 EFLAGS: 00010282 RAX: 0000000000000001 RBX: 0000000000005208 RCX: 0000000000000020 RDX: 0000000000000001 RSI: 0000000000000001 RDI: ffff9ad01f45a680 RBP: 000000000004c990 R08: 0000000000000001 R09: ffff9ad01f45a680 R10: ffffb12cc0317db0 R11: 0000000000000001 R12: 00000000fffecee8 R13: 0000000000000001 R14: 0000000000026980 R15: ffffffff9e53ae00 FS: 0000000000000000(0000) GS:ffff9ad01f580000(0000) +knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 000000000de0c000 CR4: 00000000000006e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: tick_nohz_dep_set_cpu+0x59/0x70 rcu_exp_wait_wake+0x54e/0x870 ? sync_rcu_exp_select_cpus+0x1fc/0x390 process_one_work+0x1ef/0x3c0 ? process_one_work+0x3c0/0x3c0 worker_thread+0x28/0x3c0 ? process_one_work+0x3c0/0x3c0 kthread+0x115/0x140 ? set_kthread_struct+0x40/0x40 ret_from_fork+0x22/0x30 ---[ end trace c5bf75eb6aa80bc6 ]--- This commit therefore avoids invoking tick_dep_set_cpu() on offlined CPUs to limit both futility and false-positive splats. Signed-off-by: Paul E. McKenney Signed-off-by: Joel Fernandes (Google) --- kernel/rcu/tree_exp.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h index 401c1f331caf..07a284a18645 100644 --- a/kernel/rcu/tree_exp.h +++ b/kernel/rcu/tree_exp.h @@ -507,7 +507,10 @@ static void synchronize_rcu_expedited_wait(void) if (rdp->rcu_forced_tick_exp) continue; rdp->rcu_forced_tick_exp = true; - tick_dep_set_cpu(cpu, TICK_DEP_BIT_RCU_EXP); + preempt_disable(); + if (cpu_online(cpu)) + tick_dep_set_cpu(cpu, TICK_DEP_BIT_RCU_EXP); + preempt_enable(); } } j = READ_ONCE(jiffies_till_first_fqs); -- 2.42.0.rc1.204.g551eb34607-goog