From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (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 EFBAF477995 for ; Mon, 11 May 2026 17:54:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778522098; cv=none; b=UKaVS3qvMlP7+ki1OZGcoRQkEGGDQW28LGYdAZpDIScWRerCG6DA3eHhpz6JObUJScO2GUGRgMK7NI96XLNFIl0eEHVZ7BlMd26eaVLONVIdxUhAE+h6q7nKERdc1xmVJfejcXJ/RxrXAjjEQRjU0MjRRUimw/J9Cbb1Xr4lGIQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778522098; c=relaxed/simple; bh=1gqbdSXuc2lYJ9G7B+thJWtUos0MtzF5jgiSQKynjWQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X+FmmFDsjFbccbj5OnhCa2b+Vvw6Zr6kR0X3ddKIJ8+/9e1YIaCALGXu9Yvu//WMdMEPlYj6YD4Ac3hk5sqOMnmwhNCyOBZ1S4ZJyt8KrMd+KIzloFmVwHzwf77tTxRBc1LT/5Fh6Z8Xo7qznzOkMnIbiBK6HIn7RybiBFsuC/I= 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=PgcOubl6; arc=none smtp.client-ip=209.85.208.181 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="PgcOubl6" Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-39380e79936so58239481fa.2 for ; Mon, 11 May 2026 10:54:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778522094; x=1779126894; 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=wHIDhlOJb8urKkomAEMs1m87rndRxl/f43Adb3lInY4=; b=PgcOubl6Y/FdPFWtoCtspYmTpt260eQBD/YoQvixSBdvJhjja3XhD+WUtzXcnE4Ihw 8UG87PXYxIYEBm0DUjnyslA6y0n7HCWecYVByFldaC6H7Ca/I+FUdBfjq40iV+VjPyc2 tMLZWj2E3bKYT125PhjGt/RTsraRBvQZaKmxu+m+/R6Phlgtd4ot+gdCdvbb4pGgxtTF NVhgb7X5OYEW3ikLcJyWCqjgEZqZYjOoE9K+atx3b+mCIQE8vZpdf/p0i2JlxEZP5Cvq cCAMMRBPOC8JbZn9Co2hi2Jalqc6bnPZvr9VkpA8CHrjBhASjLimIwWehm4NX+77kUKB I2vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778522094; x=1779126894; 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=wHIDhlOJb8urKkomAEMs1m87rndRxl/f43Adb3lInY4=; b=UmWIrtvfb4WeJCRz2q+roZJKrXHA7LQ8LVNHK8p9gsc0ZIfBf1DgozuYQi5qhIqfFx f2p+ROfEnvmKtSIyFYg8libFEZAFMFJK0AhZKbYZzbvFu0ivZ5PyveOLwrJwa//IHvHs 8RxWqhOxmT4xUd5PjBiytvp5aK1LRb66dcIShOYviwIK3ciyLo+FLfKSzkjosRpX+T2m 4H58tlv8poy8ung1KSAL1qkZCoPXkKtHE/INVTbI7IdMufYoZF8pTLp0nPoPa5sAo2Nq y5SgCL1OHT+h9yBcBu6tRLXfNBH3zNflvS+mpsduy3lyqj6Uzf3FjbSYIM7Xt7iTzngN /t2g== X-Forwarded-Encrypted: i=1; AFNElJ/sHK4k9FaebqSEQlqAMQtobty/vs5eNkpR4PoS9Hz6KI4Bi69oElJUJdzjh5EUkKOfJsb8a9yjERbPAT4=@vger.kernel.org X-Gm-Message-State: AOJu0YxsKp82K9iXzeEek4En1LjBzlXHIOeyKvnuFDEV8/WCLEbiIqGJ jdM1ynCFc/+Ny+KIs/tl4xr9s4+149FRcS6jPgVV5UnWD27Q7UScwHDT X-Gm-Gg: Acq92OHIjRCOQAOdxufPRTs5JSOE2LMjA10LwUPrFsc5l66VxV3TkavUyVcWN4KJTD8 V9ZW2VhgyE+miXTVe+LR40p8bodaI2AptAtlLlrDE7E0OZpHV/13Jfl/Eyb8mlsytyqYZUluLpF /mTAvaKC44eGlzm0Oww4rqmDODGLzkFxdVjOTRRSiKvGN6xU0KqJoj1X+1WkVukEg1GITLCatdI IIvm+imbhYYlEgSk8aMuV+cCBFg9C0gW9MP86zmDj5Zvt7xJe707acGTXDlcPCvKdZn2SDxKaxc N6E+3ZifW95yaiJTOLpmfjsM0q+C3l/Cfv/ZuIH5aVatVFJ61Qn20CPw+m37niTq6IBWcVEChUf hLr3Bk6pM4YN9IgiNc0N9Ykf9VxwZ6HFV2eWBk4iLT4zhPfXHru2/iaeR0R1ZwkEYLSqE3zYlbB dwfFjjO03Yr3iG2x0= X-Received: by 2002:a2e:9783:0:b0:393:903c:225b with SMTP id 38308e7fff4ca-393c4338719mr65673121fa.31.1778522094076; Mon, 11 May 2026 10:54:54 -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.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 10:54:53 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: "Paul E . McKenney" , Joel Fernandes , Frederic Weisbecker , Boqun Feng Cc: RCU , LKML , Uladzislau Rezki , Vasily Gorbik , Samir , Shrikanth Hegde , Tejun Heo Subject: [PATCH -next v1 05/12] srcu: Don't queue workqueue handlers to never-online CPUs Date: Mon, 11 May 2026 19:54:41 +0200 Message-ID: <20260511175448.153326-6-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: "Paul E. McKenney" While an srcu_struct structure is in the midst of switching from CPU-0 to all-CPUs state, it can attempt to invoke callbacks for CPUs that have never been online. Worse yet, it can attempt in invoke callbacks for CPUs that never will be online, even including imaginary CPUs not in cpu_possible_mask. This can cause hangs on s390, which is not set up to deal with workqueue handlers being scheduled on such CPUs. This commit therefore causes Tree SRCU to refrain from queueing workqueue handlers on CPUs that have not yet (and might never) come online. Because callbacks are not invoked on CPUs that have not been online, it is an error to invoke call_srcu(), synchronize_srcu(), or synchronize_srcu_expedited() on a CPU that is not yet fully online. However, it turns out to be less code to redirect the callbacks from too-early invocations of call_srcu() than to warn about such invocations. This commit therefore also redirects callbacks queued on not-yet-fully-online CPUs to the boot CPU. Reported-by: Vasily Gorbik Fixes: 61bbcfb50514 ("srcu: Push srcu_node allocation to GP when non-preemptible") Signed-off-by: Paul E. McKenney Tested-by: Vasily Gorbik Tested-by: Samir Reviewed-by: Shrikanth Hegde Cc: Tejun Heo Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/srcutree.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c index 0d01cd8c4b4a..7c2f7cc131f7 100644 --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -897,11 +897,9 @@ static void srcu_schedule_cbs_snp(struct srcu_struct *ssp, struct srcu_node *snp { int cpu; - for (cpu = snp->grplo; cpu <= snp->grphi; cpu++) { - if (!(mask & (1UL << (cpu - snp->grplo)))) - continue; - srcu_schedule_cbs_sdp(per_cpu_ptr(ssp->sda, cpu), delay); - } + for (cpu = snp->grplo; cpu <= snp->grphi; cpu++) + if ((mask & (1UL << (cpu - snp->grplo))) && rcu_cpu_beenfullyonline(cpu)) + srcu_schedule_cbs_sdp(per_cpu_ptr(ssp->sda, cpu), delay); } /* @@ -1322,7 +1320,9 @@ static unsigned long srcu_gp_start_if_needed(struct srcu_struct *ssp, */ idx = __srcu_read_lock_nmisafe(ssp); ss_state = smp_load_acquire(&ssp->srcu_sup->srcu_size_state); - if (ss_state < SRCU_SIZE_WAIT_CALL) + // If !rcu_cpu_beenfullyonline(), interrupts are still disabled, + // so no migration is possible in either direction from this CPU. + if (ss_state < SRCU_SIZE_WAIT_CALL || !rcu_cpu_beenfullyonline(raw_smp_processor_id())) sdp = per_cpu_ptr(ssp->sda, get_boot_cpu_id()); else sdp = raw_cpu_ptr(ssp->sda); -- 2.47.3