From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F05E83128B2 for ; Mon, 11 May 2026 17:55:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778522103; cv=none; b=jmFGJW3+m/K5T1i2M7uBepvvuCTkXtAVftJuNGjgCUNPg3d9dk2M0V9YL3djfQtLLhA22+DindxVWjgyJ2sstdQLGG2hb5MPSmO9g/3NxtfCegLEhf3fhj3OWjMH1gxCBblQljcxK9vqc+riAmUoMUKH7JNd2cx9/aDA5JyEDD0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778522103; c=relaxed/simple; bh=aGn8oFIeADYd9zR2os0KsYgOWUkPHLyy0V9cTn+474I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V2ggztHYrHYYVwdudAAlsPB9I6U3P7yH+710HsNoFdDBWc2pePE0moYPQR3vo1wUmALbqAoFDelVXRfdbz/RBaXne868SbbFXVyI4hDXQOKLe8V3xdX8wUH0WadzzMfuyll3lF70Y6MKTPlad1cps0XQkpyjVjnyCGP9KwJyj0s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Q0FMVz/D; arc=none smtp.client-ip=209.85.208.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q0FMVz/D" Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-39394e1e8f3so38980101fa.1 for ; Mon, 11 May 2026 10:55:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778522099; x=1779126899; darn=vger.kernel.org; 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=jgAUP6OLEyhflkklRcpo72fjxpM93txMmwPi2+jDRTQ=; b=Q0FMVz/DfjFpaoRaB0RxYuo7jZdhUPrwfuiFUnINQLvMVeocPjBfJBp+9eXeYUd3TW cNFJhpPsbm1a6g5AQWuQItnND0ASh0jolLw5CcetOTnb0eJNjIEibZjo0OdhSANmMj3A j2qyzRfqLQ9huM9GgSeVjeDL0O/AcN5ZTJF5P/8vD9thqNWfYqK3ovH9Hzk3w/svsuiZ IIlrfUyFeQ+CxBrAOFBdDeSUuFA0i2TRE9k7QWRcQXeWkAz34x9KefOKiSV9KpNqnNFJ AZqmEDb+G1SpBUNmQpDrFJFG96OnFavuGz8bzxrlorI8KxioRIktsR52vGVf1JFUSXTk kmaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778522099; x=1779126899; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=jgAUP6OLEyhflkklRcpo72fjxpM93txMmwPi2+jDRTQ=; b=l2KEFugx8Eoa62pGlBUPnTx/zLEpULRZo5kQKUVwbD/T9kyeGJZFxYe+14eBnKeKDY /s2+5WOyH78u+qg/leUCTmNJBkmrgx5sIR8gdhk+Jhpm2KlJFM+zMvAmX/4ZHgToNAtd 7Pshwyxrk7FMRFMy29sfqLdArxSjLIVz574/OFzONN/+CFPjxvlpFymoPTiJSNF/kYMG Bz2YUVG7aUKHrm9JhZXGcE88gv+Tj64O3VTZzxhU6sDDiRINdJT5fzOqGX+QtJiYy7x3 WOR86KltxBhQjN/TafaWOsCKn16kdMPiPnnuL4G96obB+SBB/AeDpqzcXN6oIQAv5g2O WBtg== X-Forwarded-Encrypted: i=1; AFNElJ8mzzUm8aeSG7K8HU/h/VKWHXsqCrjTHVs9jKUZDnVgd9qNp1IamWAJGqlqNHRJ9IFLWO5jpaoUVtJzVyc=@vger.kernel.org X-Gm-Message-State: AOJu0Yw+rarMdif6Xpx0V38RLvuFN76HqXoI0BqIo3bvSzL0BTt+RVR9 ghjGocEx6eb6Y1oLs4xLZQqeWlvKm4RmxOluup3AKj0qlw5KNrhmZPn/ X-Gm-Gg: Acq92OH6YMKaYxGSl6dUr2dpnC4hYaRW485Dshpm/iQLgcaiXBO3R4V1fAXy7+hpuHF hRaEOY1K8T+nVsJ7zzdNxbVBW8pBHPF3gPJ6A5FQgqsqqBpGQC9C5OiB05u19hru8SVSieA1wYr 2WXSBjeW291IZCoqe0R2P74R/G5rKfdNw/yjh/ddSiA8P2G5QYB8mVnQ4DlCod2jtIV3yeVHv2K dq3pO1LwJf/LiSy7mMlET83gp7aNWu0tf9T7ec54j9H+IHXfq1uP+itVVk9NIWQ3cziHtQotuAU Phk5eI/ZTa4cYLkaz++Fw83LxPxVSvZlByjJgTC8Y9uxs4gYTe5g8Ln/HcONUat5JZOEiHwpzz5 k15j+H/ZwFbnmV1UZh6KabBWY6MAMmaaxVYTCSzfAs1QPH57SElpxPUxjteLNfASiOQN2tv1UI2 lMJ7hpZ3T+Xwpt4Hw= X-Received: by 2002:a05:6512:6d0:b0:5a8:74c3:5d9b with SMTP id 2adb3069b0e04-5a8b6c5f46fmr3217767e87.0.1778522098929; Mon, 11 May 2026 10:54:58 -0700 (PDT) Received: from localhost.localdomain ([2001:9b1:d5a0:a500::24b]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-393f614a5f4sm28968891fa.33.2026.05.11.10.54.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 10:54:58 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: "Paul E . McKenney" , Joel Fernandes , Frederic Weisbecker , Boqun Feng Cc: RCU , LKML , Uladzislau Rezki , Zqiang Subject: [PATCH -next v1 12/12] rcu-tasks: Fix possible boot-time tests failed for the call_rcu_tasks() Date: Mon, 11 May 2026 19:54:48 +0200 Message-ID: <20260511175448.153326-13-urezki@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260511175448.153326-1-urezki@gmail.com> References: <20260511175448.153326-1-urezki@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Zqiang The following scenarios will cause the call_rcu_tasks() boot-time tests failed: CPU0 CPU1 rcu_init_tasks_generic() ->rcu_tasks_initiate_self_tests() ->call_rcu_tasks_trace(&tests[1].rh, test_rcu_tasks_callback) ->call_rcu_tasks_generic() ->havekthread = smp_load_acquire(&rtp->kthread_ptr) "The havekthread is false" .... rcu_tasks_kthread() ->smp_store_release(&rtp->kthread_ptr, current) ->rcu_tasks_one_gp() ->rcuwait_wait_event() ->rcu_tasks_need_gpcb() ->for (cpu = 0; cpu < dequeue_limit; cpu++) ->rcu_segcblist_n_cbs(&rtpcp->cblist) == 0 ->schedule() ->raw_spin_trylock_rcu_node() ->needwake = (func == wakeme_after_rcu) || (rcu_segcblist_n_cbs(&rtpcp->cblist) == rcu_task_lazy_lim) "the rcu_task_lazy_lim default value is 32, and the func pointer is test_rcu_tasks_callback, lead to needwake is false." ->if (havekthread && !needwake && !timer_pending(&rtpcp->lazy_timer)) "the havekthread is false, will not enter here." .... "the needwake is false lead to rtp_irq_work can not queue, even if the rtp->kthread_ptr already exists at this point." ->if (needwake && READ_ONCE(rtp->kthread_ptr)) ->irq_work_queue(&rtpcp->rtp_irq_work) For the above scenarios, if the call_rcu_tasks() is not called again afterward, the rcu_tasks_kthread will not have a chance to be wakeup, the test_rcu_tasks_callback() will never be called, the boot-time tests failed can happen, this commit therefore check havekthread variable, if it's false and the rtpcp->cblist is empty, set needwake variable is true, if the rtp->kthread_ptr exist, the rtpcp->rtp_irq_work can be queued to wakeup rcu_tasks_kthread. Signed-off-by: Zqiang Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/tasks.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h index 48f0d803c8e2..f4da5fad70f5 100644 --- a/kernel/rcu/tasks.h +++ b/kernel/rcu/tasks.h @@ -373,7 +373,8 @@ static void call_rcu_tasks_generic(struct rcu_head *rhp, rcu_callback_t func, // Queuing callbacks before initialization not yet supported. if (WARN_ON_ONCE(!rcu_segcblist_is_enabled(&rtpcp->cblist))) rcu_segcblist_init(&rtpcp->cblist); - needwake = (func == wakeme_after_rcu) || + needwake = (!havekthread && rcu_segcblist_empty(&rtpcp->cblist)) || + (func == wakeme_after_rcu) || (rcu_segcblist_n_cbs(&rtpcp->cblist) == rcu_task_lazy_lim); if (havekthread && !needwake && !timer_pending(&rtpcp->lazy_timer)) { if (rtp->lazy_jiffies) -- 2.47.3