Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp218612rdb; Thu, 22 Feb 2024 01:11:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU0Ax29Choz8NBKjKbHdLOnLSNxUCUYzFs0M45KHMXvH3DV4dwf8pfyh18Qtsb3snvdLKj6hdT0VocY+5lwwhFRa+FX99pCvt773qY7jA== X-Google-Smtp-Source: AGHT+IGrff7mfi1CiEpAXk+LT0JHsxxuGo8a2gUTQ4qTyFjo4bRpFWLuJnl3VIsyJwWpdmRBV4Yp X-Received: by 2002:a05:6a00:da:b0:6e4:c5a1:e41d with SMTP id e26-20020a056a0000da00b006e4c5a1e41dmr1999660pfj.29.1708593095144; Thu, 22 Feb 2024 01:11:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708593095; cv=pass; d=google.com; s=arc-20160816; b=SLYTnVZsyh7TRSB5tyKXmC9072diZDfFFtWCzlGsz2l+6Wdqxxnj4yMDSV1coh5NcA mitNO8+Nq/gW8QCCJjVwZKm6ABuIDaPVMoroln6Sn6AHMEYhNKth6EDaTrGY7/uy3dYJ UtjvIqNg2QSlkBee6i9S3EwgwLQbQof15IhJ2cpbrwfYfxG/J8cRbV4IVw+0sSv0KYEm n/cEp268oV9N1kww6432nkPGoLoD3MqNDZ7elC5Hc9T2ajWKG4fWoKurWsV1QmLoIwib QcGIvPqjZr+mrbrICzt2EjrXPyNLZye13Xvp0GEXFmzJqSD2BmpwMbms9HUA3hCNB1gO O3XQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=b7MKLBW4+oeVN4wDzAN30WAcbkMR7wXtDIhD/4exjd4=; fh=5+ImABtXf26WLybeZg7EpVC/ECJzYzIURmWkqvfulAw=; b=U6ddUaww47dT94sUAY/8xt4NuirkO+V/DqDeBkQs2eOuIDSpHpqXjMl62ny1/6fGO5 Uyxa9y0RUvaa0ciaxSOkxRWV/Bb5AeBiT2KXweoxrHAVydlE0FF8KdeJh2HC5qxIsfdE FH2E/Fe4Qurb4b66rmvgRkqxdaFyjQQTyrUywVic4sxQ2m8WOd0Zxhlx1OwV/7+15rRx CRPp5n0hQpIxElnlKkN8C5wjSfR9dMtVGu+Kv0JHSwEDzIDYbV2N5/+hPh2gx5NTcYhr 6+KB8MJymIGTZHpWJJzmPfxQQdkZbqWNEtl7Ug5i498dT2L+5BRwEV0lqhSczV5oCIuU lCXQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=YVIstuwt; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-76180-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76180-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id n51-20020a056a000d7300b006e396759fa7si8632562pfv.172.2024.02.22.01.11.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 01:11:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76180-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=YVIstuwt; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-76180-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76180-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 85164B26757 for ; Thu, 22 Feb 2024 09:06:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0449217994; Thu, 22 Feb 2024 09:06:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="YVIstuwt" 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 70160182D2 for ; Thu, 22 Feb 2024 09:06:12 +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=1708592774; cv=none; b=HZoTN5i1VXGsgbsfOGc2ZJmj+ynzaf21gPIL07VsRG/rDjiVCW5IkkqOw3hdAzsW3R4DXvFLiiIaEiHh75LylznZ9qVJFD+6Bv9IN7JuQOhKCJ2LHtRFDwVfe2UVdDFhAaZB84DtxxkXVaVI/ov79IlzqytSNF5baLofQ3PgCTk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708592774; c=relaxed/simple; bh=8c/Xh5sRpC4JqMGbwZlEN2x9qcwZFAlKpVkj5lFERAo=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=XQsSt5LRvR7XUgee42XFpw6pQ0ms0h+uQS03MHPTfQ9Slv9gCbw/v2KzJIDSGRdiXqaYToFq/v8ptIjY6TSPgIOwouGWVg6DFDXQRUZxrc3eKVd8A0GOKJZnsMkf5HbjvgLgF89v5CBd5PuTwcfN2Pyu50R7I4z1Y7o2qM2h/7c= 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=YVIstuwt; 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 Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41M6mhop019458; Thu, 22 Feb 2024 09:05:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=qcppdkim1; bh=b7MKLBW 4+oeVN4wDzAN30WAcbkMR7wXtDIhD/4exjd4=; b=YVIstuwtn/vitABEqDTJki2 aRlRB8Otas4WX55YjnfBq/cyRdIrRl252rNd7gqOo9L0iI0Pq3rsrvM3qEp/+FBh brCLG7SXnMrn0AK6wXUBr9avlGs8zbwLBRMw0drvVlvAWNNurk+yuP2U6h4JXty4 09+of8onv4gGZeor2WtMDGPa4bLIr7FSsyxNIt4ShmLgwvcapilcxtFUQHX3Asdu HPZNG0CDQvaQeVV87z4w57zom5X/qxcn0H9qqewIShK0ehYO9GspGyDF8j6YHavu +xrLB/Qr9wvWpvOWJuypn2Mvy8lb/yZUY7vZf60ItDz47Rle/YqpbnR1sm9lbEQ= = Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3we1b0gf0r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 22 Feb 2024 09:05:57 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41M95vR1027616 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 22 Feb 2024 09:05:57 GMT Received: from hu-mojha-hyd.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 22 Feb 2024 01:05:55 -0800 From: Mukesh Ojha To: , , , CC: , Mukesh Ojha Subject: [PATCH] printk: Add atomic context check inside console_unlock() Date: Thu, 22 Feb 2024 14:35:38 +0530 Message-ID: <20240222090538.23017-1-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.43.0.254.ga26002b62827 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 2cY2Txy475aLHp0j55uuqHQs-E4pPdlS X-Proofpoint-GUID: 2cY2Txy475aLHp0j55uuqHQs-E4pPdlS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-22_06,2024-02-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2402220071 Situation of schedule while atomic context can happen in a scenario if CPU-Y executing a async probe of ufs and while printing a line it is started spinning for console lock after preemption disable on CPU-Y and later it got the handover of console lock from CPU-X and in console_unlock() it get schedule with preempt disable as console_may_schedule was one and due to which do_cond_resched was one. CPU-X CPU-Y worker_thread process_one_work async_run_entry_fn ufshcd_async_scan ufshcd_device_init really_probe+0x1c8 ufshcd_probe_hba platform_probe+0xc0 ufshcd_config_mcq qcom_geni_serial_probe+0x374 _dev_info uart_add_one_port+0x10 __dev_printk serial_ctrl_register_port+0x10 dev_printk_emit serial_core_register_port+0x5dc dev_vprintk_emit register_console+0x284 vprintk_emit console_init_seq() preempt_disable(); console_trylock_spinning() console_lock(); console_flush_all() Hand over of console lock happen from CPU-X to CPU-Y console_unlock() console_lock+0x74 console_flush_all down[jt]+0x40 __might_resched __down+0x18 __down_common+0x68 ___down_common+0xdc schedule_timeout+0x4c schedule+0x78 __schedule+0x6c0 Signed-off-by: Mukesh Ojha --- kernel/printk/printk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index f2444b581e16..8b666feff65d 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3028,7 +3028,7 @@ void console_unlock(void) * messages practically incapacitating the system. Therefore, create * a local to use for the printing loop. */ - do_cond_resched = console_may_schedule; + do_cond_resched = in_atomic() || console_may_schedule; do { console_may_schedule = 0; -- 2.43.0.254.ga26002b62827