From nobody Tue Feb 10 01:32:33 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 1B12F4317E for ; Fri, 27 Dec 2024 09:28:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735291691; cv=none; b=fAhJYFymawa+8f4yjBDUF7KyntGLbl1V7Nd2j2ddlT0WJR6vRGYDqA5vtb9gvo/5ds9kch21c4bOkina817ThUVjGWeo6BuyHbk/CDjl4Hf9uZ3KXH8WRbVdLk/Y2weX0eOEtMJsTV+CJ/tn/X/jQQJhq4LWLaictR9Kfw9ydAU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735291691; c=relaxed/simple; bh=Ze63/noVNbcYeAXiesSgMneOby6dKyMfICNMTFX56Jo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:To:CC; b=jI6ply8XMcU2e7Dbxwiy4SVM7YL0AypmAEajU+mhiCtGAPSXsTYiZtNUaKe/sOQqXUs1/a8YD1mMxt/xPO+0UHy2X2x0GoT9a08wOID4w9VXag8vTn14uY9lshZXoll8JVQsYZQGHVq9vBW4hVMrB3Hl6wPOzNKxjQwnIg8FYlQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=bwazMnc7; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="bwazMnc7" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BR9M0bE027035; Fri, 27 Dec 2024 09:27:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=/IEogVBWXWn2bi4PRfhsmf q6mYeT2801DPVg4QoKcyw=; b=bwazMnc70ymGf1zoCLMhb95alh97KgGmgRa1iM m4L1gEg3TxtmaZ/NsS+9gXEN86mdCwBI4HnnZAA+gjtSdapHcS3k09QU3WfdEXPk 1zQYZo9SbS22zmnoBeFjiqKSxiV1vTiCbpOrifs/BAxPeY1A+lfzmFNrVWsPzSxt vWNSltBACmgehwFgqkarhITcuAGsDfjs50wk7EXc4pnF+MpTndG9+fHr0ddD58Di 84gTYzYhOaNzGyEjA3fXALSFR9joe5kN5aTQcNRgEaxt6zoYam8KT7CqeuNPucRC /3YyuxNP//RGYdHXIWwksBj2AVVHTsyL5hTbMpsKe8wPYpbA== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 43sshpg1be-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 27 Dec 2024 09:27:41 +0000 (GMT) Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA02.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 4BR9Rebi025407 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 27 Dec 2024 09:27:40 GMT Received: from aiquny2-gv.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Fri, 27 Dec 2024 01:27:34 -0800 From: Maria Yu Date: Fri, 27 Dec 2024 17:27:10 +0800 Subject: [PATCH] sched: Use printk_deferred_once() instead of WARN_ONCE() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20241227-sched-use-printk_deferred_once-v1-1-5da85cb38da2@quicinc.com> X-B4-Tracking: v=1; b=H4sIAO5ybmcC/x3NQQqDQAxG4atI1gZq2qnQqxQRO/NbQ2GURKUg3 r1Dl9/mvYMcpnB6VAcZdnWdc0FTVxSnIb/BmopJLnJrRO7scULizcGLaV4/fcIIM6R+zhEs0ob XdZDQBlCJLIZRv//BszvPHzv5DXVwAAAA X-Change-ID: 20241226-sched-use-printk_deferred_once-2275b3a2575e To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , "Mel Gorman" , Valentin Schneider CC: Ingo Molnar , , , Maria Yu X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=ed25519-sha256; t=1735291654; l=2362; i=quic_aiquny@quicinc.com; s=20240827; h=from:subject:message-id; bh=Ze63/noVNbcYeAXiesSgMneOby6dKyMfICNMTFX56Jo=; b=S7M9+dY9PC2Ar+Vf+B4zWtodTvND2Y6tcDEqq5w0AGGfkaHF5P9ViS+qsQGxvXBAHp7RwwAhc JTmltpmhpWmCYgbXpH4rqHQq9G59jMQIQtWrpVh/nW/GTjBKC3ZsEev X-Developer-Key: i=quic_aiquny@quicinc.com; a=ed25519; pk=w3csYrSQYa80T5pm2vrYYXdqoTAMJWQOYfsGU3GVZ6s= X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: LFu-jHQWyWPjdo9TpB7deffcRktKshk1 X-Proofpoint-ORIG-GUID: LFu-jHQWyWPjdo9TpB7deffcRktKshk1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxlogscore=999 mlxscore=0 impostorscore=0 clxscore=1011 adultscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 spamscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412270078 A deadlock is observed when WARN_ONCE() uses printk() inside the scheduler logic. printk_deferred_once() is a WARN_ONCE() similar special printk facility for the scheduler to avoid unnecessary deadlocks. One of the deadlock stacks looks like this: queued_spin_lock_slowpath() -- //waiting on uart_port_lock which is already hold by current cpu queued_spin_lock(inline) do_raw_spin_lock(inline) __raw_spin_lock_irqsave(inline) _raw_spin_lock_irqsave() qcom_geni_serial_console_write() call_console_driver(inline) console_emit_next_record() console_flush_all(inline) console_unlock() vprintk_emit() vprintk_default() vprintk() _printk() __warn_printk() rq_pin_lock(inline) rq_lock_irqsave(inline) =2E wake_up_process(inline) wake_up_worker(inline) insert_work(inline) __queue_work() queue_work_on() queue_work(inline) tty_flip_buffer_push() handle_rx_console() qcom_geni_serial_handle_rx(inline) qcom_geni_serial_isr() -- //acquired uart_port_lock __handle_irq_event_percpu() handle_irq_event_percpu(inline) handle_irq_event() =2E After the change, the SCHED_WARN_ON(x) printout appears as follows: [ x.xxxxxx] WARNING: ------------[ cut here ]------------ [ x.xxxxxx] WARNING: x Fixes: 9148a3a10e0b ("sched/debug: Add SCHED_WARN_ON()") Signed-off-by: Maria Yu --- kernel/sched/sched.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index aef716c41edba8a6ec7d88db121fe0a9934b5264..863004630ad793c21272566f186= d2fbee7fcc95b 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -92,7 +92,16 @@ struct cpuidle_state; #include "cpudeadline.h" =20 #ifdef CONFIG_SCHED_DEBUG -# define SCHED_WARN_ON(x) WARN_ONCE(x, #x) +# define deferred_warn_on(fmt, ...) \ + printk_deferred_once(KERN_WARNING "WARNING: " fmt, ##__VA_ARGS__) +# define SCHED_WARN_ON(x) ({\ + int __ret_warn_on =3D !!(x); \ + if (unlikely(__ret_warn_on)) { \ + deferred_warn_on(CUT_HERE); \ + deferred_warn_on(#x); \ + } \ + unlikely(__ret_warn_on); \ +}) #else # define SCHED_WARN_ON(x) ({ (void)(x), 0; }) #endif --- base-commit: af98d8a36a963e758e84266d152b92c7b51d4ecb change-id: 20241226-sched-use-printk_deferred_once-2275b3a2575e Best regards, --=20 Maria Yu