Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1219007rbb; Mon, 26 Feb 2024 02:34:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVkqeCLoU/LqRKe9bPhunBctgeGLQqrCLXZ/cMk8tGVA59yIe/kN8AKuf+DRbcrFmq9UdRGdH77MHcYg/YVPY2yQb8T6DhGHjmcrjnSaA== X-Google-Smtp-Source: AGHT+IGbIHCGezfWAjRCU8pc9YtFLwe5gcaSzwWpNmqV9UDcHHwA03GnkLoU1BCBJ7eNowzgRL4L X-Received: by 2002:a05:6808:1302:b0:3c1:827c:3dba with SMTP id y2-20020a056808130200b003c1827c3dbamr8566248oiv.6.1708943645562; Mon, 26 Feb 2024 02:34:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708943645; cv=pass; d=google.com; s=arc-20160816; b=zf2J2XghB0LNxV+B/DOxfGuMOz3xhRsevBRSL/3UDTPwsxxolZfYH/mdRjL7yPe1P3 JvjAhQi3HJ3oSlrjX32+ZnFRxvdtkMLr+9RTLUbWroyueJiU4ep0vEV/sDILb/mJJx8X ty/+OTeWWZO/c+dISWvE8HWwL1ChQDja9rl8gUgVjS0G8po7fSaNT52tMDkiZYfdhDWY BUcGxg0G6SA/NoIseTRR/t3VdNzX9Igf320zwGQe3UmrfXX9YM3ZRu+Stp+wbvB+WPSB mXln32PUWRZ3n9yJZ8PLmatpwvpthHo0zQ368PeUeL8hv0GWzkUV7ceCiT2DQCzfPf0h FnDA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=O2DE/nIvS1ODn/CemR0wgKU5W8KOvSU+fm4XqxrMHec=; fh=LjVi734VKTr/n/Ixf6FmjQD3h1llszLBsOxS1D8DbcI=; b=HScxDvSKI+zprptLeH0K2SfCy6jvbPb/rfEIi40JsoxiAo2aNW6NRBmcQqHtrTyNbl GNuWkxVhkJfcn3rkq/7ZCrw5xJN7z4/nSmMI49AougbOZIbLS2LsAuzmhOni9YSvrYdR NpQUs+F8v//7dk8ZtA4o3xIct/aGEbbcIXYVUisxH/XeNkE+0xDl3sZiazBd0fas1bhn kg6V9SOGxhVuVU1/IvkICAV8jGhOFvIF19Vi0Nva2bBDlyWYStoqYkawjSPztXqpXiwx 4IEMlT5XEDcpg2uW9yi5N7Jq2QCOyj6DK+GBPogiivi3QqYvKQ6Jd37eNZZ1pFPyZroM FeLg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=cFIEi9BN; 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-81151-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81151-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d10-20020ac8534a000000b0042e7de4d4besi2851238qto.422.2024.02.26.02.34.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 02:34:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81151-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=cFIEi9BN; 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-81151-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81151-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 4AE421C28075 for ; Mon, 26 Feb 2024 10:33:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D88E3208A0; Mon, 26 Feb 2024 10:18:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="cFIEi9BN" 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 9310D1CFBE for ; Mon, 26 Feb 2024 10:18:42 +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=1708942724; cv=none; b=hPJmE6nZb4po5/H/CKzQG0G4u92Z5Gb7k7dq8sWlBCQsd8EfgdQqqElpiAWkOU4g/F5wmfO2bikDXHGVHWfxRsuNJX9Q41ezOzV7J1zmA0X4/sRHxwEmcHq6ktA7j9I/E0AEiQucKhGBequVVAjyLnyNsQiOWhwBrh6lKfGwPoM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708942724; c=relaxed/simple; bh=3dY9v8pzYytwG1dhDWUFwhk6KVuyvtvg0hRzpm2/Tjs=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=EpM1Hlr9dQJ2dhoRjHJcs8ubBCgIEkc4zmCoWPj+q85QlK2BMGw/oiiJYdjMtZbWjbvoE67c+vQ0Pvv709+b+ZbpMuoWufshAyVuejlVe2RMVS0uMf0w6djKiGTMto2OIJV1EQiblQNL/BVNAef+lhTHm3j3T06nw8YwKDb/RGM= 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=cFIEi9BN; 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 41Q5dJPw011612; Mon, 26 Feb 2024 10:18:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= qcppdkim1; bh=O2DE/nIvS1ODn/CemR0wgKU5W8KOvSU+fm4XqxrMHec=; b=cF IEi9BN+DOccfzhedeCDBq6iogDL+oKI2f6dPou1pKel0osuznVYAR/1pia5oaXeI w2pSpGGd5S/r00B2jEMypKLeWRgIEDMf4kyNMhn00nn2XZLPK1cdwxd958Kvq7nL OBXxCVWwMvu5+yAb3OnFvKI3uV4/uRlM41uCchqXUtkoeLDGXreu12Gy+iH3tHbb kzO6EecwYdPx/HnMX+kAC6zx7hG51peyDWo8WUA+d8t8XSy9hLuIjB1AwgUKP7fT AcA3XI3/Jct+28T+pQ1swj/w4LBRWpWN7LA0Y3Kie78qu7dMF3nd4MH+NCLsftnd vFORyuNNHtIzvEbudlLQ== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3wgkxngk40-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 10:18:24 +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 41QAIO07010807 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 10:18:24 GMT Received: from [10.214.66.81] (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; Mon, 26 Feb 2024 02:18:21 -0800 Message-ID: Date: Mon, 26 Feb 2024 15:47:47 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] printk: Add atomic context check inside console_unlock() Content-Language: en-US To: John Ogness , , , CC: References: <20240222090538.23017-1-quic_mojha@quicinc.com> <87plwo5z4k.fsf@jogness.linutronix.de> From: Mukesh Ojha In-Reply-To: <87plwo5z4k.fsf@jogness.linutronix.de> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit 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: lzNiT9SrsIx7z_LR_XkQc73CMGh9MF2q X-Proofpoint-GUID: lzNiT9SrsIx7z_LR_XkQc73CMGh9MF2q 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-26_07,2024-02-23_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 mlxscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2402260078 On 2/22/2024 8:23 PM, John Ogness wrote: > On 2024-02-22, Mukesh Ojha wrote: >> 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. > > Nice catch. But I think the below patch is the appropriate fix: Thanks for the change @john, would you be sending this as proper patch. -Mukesh > > John Ogness > > -------8<-------- > Subject: [PATCH] printk: Update @console_may_schedule in > console_trylock_spinning() > > console_trylock_spinning() may takeover the console lock from a > scheduable context. Update @console_may_schedule to make sure it > reflects a trylock acquire. > > Reported-by: Mukesh Ojha > Link: https://lore.kernel.org/lkml/20240222090538.23017-1-quic_mojha@quicinc.com > Signed-off-by: John Ogness > --- > kernel/printk/printk.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > index 1685a71f3f71..1612b50b2374 100644 > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -2020,6 +2020,12 @@ static int console_trylock_spinning(void) > */ > mutex_acquire(&console_lock_dep_map, 0, 1, _THIS_IP_); > > + /* > + * Update @console_may_schedule for trylock because the previous > + * owner may have been scheduable. > + */ > + console_may_schedule = 0; > + > return 1; > } > > > base-commit: e7081d5a9d976b84f61f497316d7c940a4a2e67a