From patchwork Mon Jul 22 13:37:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neeraj Upadhyay X-Patchwork-Id: 13738845 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77CA714F90; Mon, 22 Jul 2024 13:37:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721655470; cv=none; b=kGmrEsM98tSMpyx+OCoA8JNvhmir3bNnidoFvKbx+bpAcIaHE40qKU2OEyxKhYGgaEyOfFSU4uwbJjmAEN+8WNBmYU40KM//u+W4o2OHjRAnLZPls70zMSE4bxhZAj6Avrng3AdJ+OmFcps9iGoTtbfK3RqZUsuxOlTnnuIUQdI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721655470; c=relaxed/simple; bh=7DrJdi6I7WnokKKbDig2nnyz9y9HWc/n0Upi7h4kk28=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LpMqnSf+zoG478A55GAXl+/yjk/bQbB50a8ka9H7GEt3JQCYEUxduLrmumpPSss7gW+3RyyvJYicHae98iV/kjVKC7Xq1sGbK1zBjqk0WdZsZfXJD/70qK2udQaDEy+jQijX7lwX/APpWKC5gFBBsTQgfD1U2r9yLknaEU9Sxto= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WrexS/VK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WrexS/VK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43388C116B1; Mon, 22 Jul 2024 13:37:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721655470; bh=7DrJdi6I7WnokKKbDig2nnyz9y9HWc/n0Upi7h4kk28=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WrexS/VKKxlzgQu+8AncMOOnBRRQscnpqEDg8tZaTUD//0+nMHuTizOCU9+n3pefJ jQ6iCX4aMVzsbXLWzAMOQfMyuqmCzkfqXgYtH5bR3vNF0R43ClZ+zgQvBlGPl0DnS/ ttUh/VAqZ/TOmLdXls1zmFD2fnf4GogMcDl6kTQMJogIuKb/LzRtJ2DKjpvD8HSY2I zNFBION6ncdUMSVNFAItE38vEs/5UU2CSgrFNhv9QsfbefqC5q1TS5KFjIXOz/ippC GqocCkm00BIFffsHlEHu+TbNvAnovS3Dw504+wt5dLoDNADG8EG1HLNd3rsz6WxOce q9zzWrpBLbL1w== From: neeraj.upadhyay@kernel.org To: linux-kernel@vger.kernel.org Cc: rcu@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, mingo@kernel.org, peterz@infradead.org, paulmck@kernel.org, leobras@redhat.com, imran.f.khan@oracle.com, riel@surriel.com, neeraj.upadhyay@kernel.org, tglx@linutronix.de Subject: [PATCH v2 1/3] locking/csd_lock: Print large numbers as negatives Date: Mon, 22 Jul 2024 19:07:33 +0530 Message-Id: <20240722133735.667161-1-neeraj.upadhyay@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240722133559.GA667117@neeraj.linux> References: <20240722133559.GA667117@neeraj.linux> Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" The CSD-lock-hold diagnostics from CONFIG_CSD_LOCK_WAIT_DEBUG are printed in nanoseconds as unsigned long longs, which is a bit obtuse for human readers when timing bugs result in negative CSD-lock hold times. Yes, there are some people to whom it is immediately obvious that 18446744073709551615 is really -1, but for the rest of us... Therefore, print these numbers as signed long longs, making the negative hold times immediately apparent. Reported-by: Rik van Riel Signed-off-by: Paul E. McKenney Cc: Imran Khan Cc: Ingo Molnar Cc: Leonardo Bras Cc: "Peter Zijlstra (Intel)" Cc: Rik van Riel Reviewed-by: Rik van Riel Signed-off-by: Neeraj Upadhyay --- kernel/smp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/smp.c b/kernel/smp.c index f085ebcdf9e7..81f7083a53e2 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -248,8 +248,8 @@ static bool csd_lock_wait_toolong(call_single_data_t *csd, u64 ts0, u64 *ts1, in cpu_cur_csd = smp_load_acquire(&per_cpu(cur_csd, cpux)); /* Before func and info. */ /* How long since this CSD lock was stuck. */ ts_delta = ts2 - ts0; - pr_alert("csd: %s non-responsive CSD lock (#%d) on CPU#%d, waiting %llu ns for CPU#%02d %pS(%ps).\n", - firsttime ? "Detected" : "Continued", *bug_id, raw_smp_processor_id(), ts_delta, + pr_alert("csd: %s non-responsive CSD lock (#%d) on CPU#%d, waiting %lld ns for CPU#%02d %pS(%ps).\n", + firsttime ? "Detected" : "Continued", *bug_id, raw_smp_processor_id(), (s64)ts_delta, cpu, csd->func, csd->info); /* * If the CSD lock is still stuck after 5 minutes, it is unlikely From patchwork Mon Jul 22 13:37:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neeraj Upadhyay X-Patchwork-Id: 13738846 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5BFE14F90; Mon, 22 Jul 2024 13:37:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721655475; cv=none; b=MjNvh3tS3MgBWDtz385HocOLLWb82owLmAz7FuXcJJHQl22lnerV8u+tGTwfBEGYXFQ2SZrrhjkttDc7QvHwpQz3AZ3NIigNYdl2D+TQD3rv3NdD1mKbSw5IePor/UOcG7o7NOuAjsXnoFRU0VPJuBX2cx5Wv9iyD84lHENOsWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721655475; c=relaxed/simple; bh=qHJ5Vpfkh0DnkehcPl9mSnrv+0B4SLAaJxRPzc/l0Bw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=r4r36b4n02RC9eXthSbAmBksdoQhca6oZLIoS+1T7KQnHT77fsmYqljxErRZkst+q6WT4SVC1dauvZ173p6a/LMW1hQ2+qwoqWmzjfTuMDO15RanGbJNd011jPP25h/ynTwF9Q8R1mq777xAzkuTiM7gSYXtSqc3fLEU9+xQ1MQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=T4cqI4Xg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="T4cqI4Xg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80620C116B1; Mon, 22 Jul 2024 13:37:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721655475; bh=qHJ5Vpfkh0DnkehcPl9mSnrv+0B4SLAaJxRPzc/l0Bw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T4cqI4Xg9YGLTejR17bc+uvgH5KOah/fuJDZOnTGGSsqIO2c1PZDnfbGVoK5XXlin mK6B03Xp37roiIRPtKbTgJGN0UbB0Bv/d5fqZjcAvfjhAIZwQoVwaAaZjtakZidUPQ xSK/H7VH38kFXwyXbk/RNK1pfAjsTHeg/MScQneU0uk3F0KfoRUof1iHdqz7qYkpJp +Euuz1eZfKej4nXUosQ1hh/Phkv0tmk5dgC8/ONjsADux10yTTKiIQJNRxyTes2xOu suy58zm7eI3Hzz+2AUDauhS7ILYrmbTOnshsaxJx4W99UB7jfQjxfai07OCNcNKiUt cqNyITVMozNgw== From: neeraj.upadhyay@kernel.org To: linux-kernel@vger.kernel.org Cc: rcu@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, mingo@kernel.org, peterz@infradead.org, paulmck@kernel.org, leobras@redhat.com, imran.f.khan@oracle.com, riel@surriel.com, neeraj.upadhyay@kernel.org, tglx@linutronix.de Subject: [PATCH v2 2/3] locking/csd_lock: Provide an indication of ongoing CSD-lock stall Date: Mon, 22 Jul 2024 19:07:34 +0530 Message-Id: <20240722133735.667161-2-neeraj.upadhyay@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240722133559.GA667117@neeraj.linux> References: <20240722133559.GA667117@neeraj.linux> Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" If a CSD-lock stall goes on long enough, it will cause an RCU CPU stall warning. This additional warning provides much additional console-log traffic and little additional information. Therefore, provide a new csd_lock_is_stuck() function that returns true if there is an ongoing CSD-lock stall. This function will be used by the RCU CPU stall warnings to provide a one-line indication of the stall when this function returns true. [ neeraj.upadhyay: Apply Rik van Riel feedback. ] Signed-off-by: Paul E. McKenney Cc: Imran Khan Cc: Ingo Molnar Cc: Leonardo Bras Cc: "Peter Zijlstra (Intel)" Cc: Rik van Riel Signed-off-by: Neeraj Upadhyay --- include/linux/smp.h | 6 ++++++ kernel/smp.c | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/linux/smp.h b/include/linux/smp.h index fcd61dfe2af3..3871bd32018f 100644 --- a/include/linux/smp.h +++ b/include/linux/smp.h @@ -294,4 +294,10 @@ int smpcfd_prepare_cpu(unsigned int cpu); int smpcfd_dead_cpu(unsigned int cpu); int smpcfd_dying_cpu(unsigned int cpu); +#ifdef CONFIG_CSD_LOCK_WAIT_DEBUG +bool csd_lock_is_stuck(void); +#else +static inline bool csd_lock_is_stuck(void) { return false; } +#endif + #endif /* __LINUX_SMP_H */ diff --git a/kernel/smp.c b/kernel/smp.c index 81f7083a53e2..9385cc05de53 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -207,6 +207,19 @@ static int csd_lock_wait_getcpu(call_single_data_t *csd) return -1; } +static atomic_t n_csd_lock_stuck; + +/** + * csd_lock_is_stuck - Has a CSD-lock acquisition been stuck too long? + * + * Returns @true if a CSD-lock acquisition is stuck and has been stuck + * long enough for a "non-responsive CSD lock" message to be printed. + */ +bool csd_lock_is_stuck(void) +{ + return !!atomic_read(&n_csd_lock_stuck); +} + /* * Complain if too much time spent waiting. Note that only * the CSD_TYPE_SYNC/ASYNC types provide the destination CPU, @@ -228,6 +241,7 @@ static bool csd_lock_wait_toolong(call_single_data_t *csd, u64 ts0, u64 *ts1, in cpu = csd_lock_wait_getcpu(csd); pr_alert("csd: CSD lock (#%d) got unstuck on CPU#%02d, CPU#%02d released the lock.\n", *bug_id, raw_smp_processor_id(), cpu); + atomic_dec(&n_csd_lock_stuck); return true; } @@ -251,6 +265,8 @@ static bool csd_lock_wait_toolong(call_single_data_t *csd, u64 ts0, u64 *ts1, in pr_alert("csd: %s non-responsive CSD lock (#%d) on CPU#%d, waiting %lld ns for CPU#%02d %pS(%ps).\n", firsttime ? "Detected" : "Continued", *bug_id, raw_smp_processor_id(), (s64)ts_delta, cpu, csd->func, csd->info); + if (firsttime) + atomic_inc(&n_csd_lock_stuck); /* * If the CSD lock is still stuck after 5 minutes, it is unlikely * to become unstuck. Use a signed comparison to avoid triggering From patchwork Mon Jul 22 13:37:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neeraj Upadhyay X-Patchwork-Id: 13738847 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D26C14F90; Mon, 22 Jul 2024 13:38:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721655480; cv=none; b=cW5O4S/E5lMp4w7oqWNjxefVWjXb7IUTWZKMqZUEtVd4Y2pPO+o7breKn2TbMTvFqDf7AwKDdBCBSZ5D4a0+v4U3On2/xI55IZjImzvoi6uRVVTb9N/qnfdkgsBc/EbVm4RQHjqHzvPn+e70WFkSq3xP9rsDXKhu445KbLqrtKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721655480; c=relaxed/simple; bh=KbZ0G6tmSn77UgwcV1sEKkUrgKMBPdvgbJK/0kc7aF4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OJIRTH/StI6NXzDr4VSV2i+aDZ2vOT6iXe0F2rkLEltz60P/iDBYb6w+j65acU7cLi47VAwtnFXhUnE4cD3ps0kKBW5Vawwj/Iw5u/Bg6sVrmrwWVoMrbWNfshkC6vzGTTt6QSYPAV2suPsBA4jTu3Z6eqdZAJu8wzvnnSA4hKA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WBmv+1Tx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WBmv+1Tx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CE45C4AF0B; Mon, 22 Jul 2024 13:37:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721655480; bh=KbZ0G6tmSn77UgwcV1sEKkUrgKMBPdvgbJK/0kc7aF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WBmv+1TxMQYW+7kbUJshAnxB0gSK2IXL7c1CEeINK2BxdctfCy7a+MEJhxZoU4s1n KT9jBGjChnF79+p8/EbrEMZKkpJqMQOMaY7zs+93GZA4dXvGmI8kvRZy7o4IC2bqSa E0DMb55xSDac3crlXMO1g0z2dDKrL3hPNTlniXz7sFew2QYdoHSjsTA0LxFONkvTfk GsmeAYMLvvXOyuFB1Yy53YzLUFB2MtL+JwMh6FIcOxySGpgRvD6nQuo9SP7wevDB08 SJDmVEUFFLvdz+dZsmSn1tOxftqLowfrWn8q0yZbtPyNF1p8+VY2OD+yO0q15KPWK5 0Nmg9HflFoWVw== From: neeraj.upadhyay@kernel.org To: linux-kernel@vger.kernel.org Cc: rcu@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, mingo@kernel.org, peterz@infradead.org, paulmck@kernel.org, leobras@redhat.com, imran.f.khan@oracle.com, riel@surriel.com, neeraj.upadhyay@kernel.org, tglx@linutronix.de Subject: [PATCH v2 3/3] locking/csd-lock: Use backoff for repeated reports of same incident Date: Mon, 22 Jul 2024 19:07:35 +0530 Message-Id: <20240722133735.667161-3-neeraj.upadhyay@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240722133559.GA667117@neeraj.linux> References: <20240722133559.GA667117@neeraj.linux> Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" Currently, the CSD-lock diagnostics in CONFIG_CSD_LOCK_WAIT_DEBUG=y kernels are emitted at five-second intervals. Although this has proven to be a good time interval for the first diagnostic, if the target CPU keeps interrupts disabled for way longer than five seconds, the ratio of useful new information to pointless repetition increases considerably. Therefore, back off the time period for repeated reports of the same incident, increasing linearly with the number of reports and logarithmicly with the number of online CPUs. [ paulmck: Apply Dan Carpenter feedback. ] Signed-off-by: Paul E. McKenney Cc: Imran Khan Cc: Ingo Molnar Cc: Leonardo Bras Cc: "Peter Zijlstra (Intel)" Cc: Rik van Riel Reviewed-by: Rik van Riel Signed-off-by: Neeraj Upadhyay --- kernel/smp.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kernel/smp.c b/kernel/smp.c index 9385cc05de53..dfcde438ef63 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -225,7 +225,7 @@ bool csd_lock_is_stuck(void) * the CSD_TYPE_SYNC/ASYNC types provide the destination CPU, * so waiting on other types gets much less information. */ -static bool csd_lock_wait_toolong(call_single_data_t *csd, u64 ts0, u64 *ts1, int *bug_id) +static bool csd_lock_wait_toolong(call_single_data_t *csd, u64 ts0, u64 *ts1, int *bug_id, unsigned long *nmessages) { int cpu = -1; int cpux; @@ -248,7 +248,9 @@ static bool csd_lock_wait_toolong(call_single_data_t *csd, u64 ts0, u64 *ts1, in ts2 = sched_clock(); /* How long since we last checked for a stuck CSD lock.*/ ts_delta = ts2 - *ts1; - if (likely(ts_delta <= csd_lock_timeout_ns || csd_lock_timeout_ns == 0)) + if (likely(ts_delta <= csd_lock_timeout_ns * (*nmessages + 1) * + (!*nmessages ? 1 : (ilog2(num_online_cpus()) / 2 + 1)) || + csd_lock_timeout_ns == 0)) return false; firsttime = !*bug_id; @@ -265,6 +267,7 @@ static bool csd_lock_wait_toolong(call_single_data_t *csd, u64 ts0, u64 *ts1, in pr_alert("csd: %s non-responsive CSD lock (#%d) on CPU#%d, waiting %lld ns for CPU#%02d %pS(%ps).\n", firsttime ? "Detected" : "Continued", *bug_id, raw_smp_processor_id(), (s64)ts_delta, cpu, csd->func, csd->info); + (*nmessages)++; if (firsttime) atomic_inc(&n_csd_lock_stuck); /* @@ -305,12 +308,13 @@ static bool csd_lock_wait_toolong(call_single_data_t *csd, u64 ts0, u64 *ts1, in */ static void __csd_lock_wait(call_single_data_t *csd) { + unsigned long nmessages = 0; int bug_id = 0; u64 ts0, ts1; ts1 = ts0 = sched_clock(); for (;;) { - if (csd_lock_wait_toolong(csd, ts0, &ts1, &bug_id)) + if (csd_lock_wait_toolong(csd, ts0, &ts1, &bug_id, &nmessages)) break; cpu_relax(); } From patchwork Wed Jul 24 17:06:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neeraj Upadhyay X-Patchwork-Id: 13741202 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F16A156898; Wed, 24 Jul 2024 17:07:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721840836; cv=none; b=CncyXzguzsOx8w5c6WCU8n92HDj/AZrlCxKIHpsKWvYMx+wCmx8FnDXz2myyFkGWxzROyl7yiW02JCW1U3EBvxeRlomL6Y5dwa1uXQCrjAAfWAGwsbbR5fi7PNr3Xi1xkpuo849oXwm44A9+0zGB8wDpTr6YO+sJL2Ak0o0SJIs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721840836; c=relaxed/simple; bh=rPZGcmYmRSOMzLi0nNkViwAM1lDiZbC+r0BU2UMwV0g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VOxmB6V8N+xcet90FAoB2ctW0fRY5M0baaNVTLuIqVEBhsSL0i+UGVHRjS7Ys/kT1DK/0IPMU9S5Ob3U/1Jad0VJOgIpQnHUzQGyyfGMDlt1d3Kc4jCv49odkzmU3cFhGGWGt8mz99bLu7a1E8nI34t11l4X6mL7x0HgITVVPGk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UwcvV7K9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UwcvV7K9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 976FFC32781; Wed, 24 Jul 2024 17:07:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721840835; bh=rPZGcmYmRSOMzLi0nNkViwAM1lDiZbC+r0BU2UMwV0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UwcvV7K9RbblZtS62OvkhK3lz/EIvXxolad0Cknf13o7Ku/1afPWaaHiA07vlwVKq ExkFD3A+jAC+emUVzXA26uQia11CxS1YBv+DUDrh+HpKdyOEIt7OKZHUakzOS9rpiz 992llqpxhULKpj2N99tRWwzvPpc6Vp4tZjQ0LVYOeFaC3UJqOstH24HGzWYEgfvcnH yNGT27gvijLjBjtKXH6bHb4miJsXQeGWs/igpmTygqrJM7lLOacKoK17zw7ost7avV 5HHayyIYoVaq9OGbi0ca992tagp9qtW4du4tdsvXnTqMUezA0qXuPMYW7lQsqpx/2j OthMG3iyZ5LjQ== From: neeraj.upadhyay@kernel.org To: linux-kernel@vger.kernel.org Cc: rcu@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, mingo@kernel.org, peterz@infradead.org, paulmck@kernel.org, leobras@redhat.com, imran.f.khan@oracle.com, riel@surriel.com, neeraj.upadhyay@kernel.org, tglx@linutronix.de Subject: [PATCH v2 4/3] smp: print only local CPU info when sched_clock goes backward Date: Wed, 24 Jul 2024 22:36:52 +0530 Message-Id: <20240724170652.809939-1-neeraj.upadhyay@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240722133559.GA667117@neeraj.linux> References: <20240722133559.GA667117@neeraj.linux> Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Rik van Riel About 40% of all csd_lock warnings observed in our fleet appear to be due to sched_clock() going backward in time (usually only a little bit), resulting in ts0 being larger than ts2. When the local CPU is at fault, we should print out a message reflecting that, rather than trying to get the remote CPU's stack trace. Signed-off-by: Rik van Riel Tested-by: "Paul E. McKenney" Signed-off-by: Neeraj Upadhyay --- kernel/smp.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/smp.c b/kernel/smp.c index dfcde438ef63..143ae26f96a2 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -253,6 +253,14 @@ static bool csd_lock_wait_toolong(call_single_data_t *csd, u64 ts0, u64 *ts1, in csd_lock_timeout_ns == 0)) return false; + if (ts0 > ts2) { + /* Our own sched_clock went backward; don't blame another CPU. */ + ts_delta = ts0 - ts2; + pr_alert("sched_clock on CPU %d went backward by %llu ns\n", raw_smp_processor_id(), ts_delta); + *ts1 = ts2; + return false; + } + firsttime = !*bug_id; if (firsttime) *bug_id = atomic_inc_return(&csd_bug_count);