Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1887026lqp; Tue, 16 Apr 2024 00:05:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWoM+hmYM8hrhFGKEcN09qoi3TZtvlJ9vACcI4QnofZHzg0yG5txPjXGlMxbptnrx4Tg9ETC+nvaMobNnhYXH6cqteqXJWs7pkrr5Pyjg== X-Google-Smtp-Source: AGHT+IF5mOr8vF3dHSZz6BKr04yxKIcKpaPBZdLdcTMMLC+8KaNXgE3qmA5BO3vFradGRbHo/a3N X-Received: by 2002:a05:6a21:670b:b0:1a9:a820:c604 with SMTP id wh11-20020a056a21670b00b001a9a820c604mr13672870pzb.48.1713251114882; Tue, 16 Apr 2024 00:05:14 -0700 (PDT) Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id m13-20020aa78a0d000000b006ed0c9751d3si9150194pfa.324.2024.04.16.00.05.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 00:05:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146377-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; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-146377-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146377-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 DADF9B22460 for ; Tue, 16 Apr 2024 07:05:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F22574421; Tue, 16 Apr 2024 07:05:04 +0000 (UTC) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 DFFEF38FA1; Tue, 16 Apr 2024 07:05:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713251103; cv=none; b=EGNj6VCdfvNywEhMD9IfVG3TPJiqHwu3gg3DuO6KoFqys2bdExYDTZzrKmXPZbASzgm4tldNSsHZPPZITAzgjbEPZvJ9dFGqGGgnIdnbAyma7TiSWWgrdcUDx3Xv2D/nJJqUOczIYdNjodqJny3YTat5AJvRy+C2sZXEoNzLwaU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713251103; c=relaxed/simple; bh=ndGLAr2AF7IFyaoZXHY3CTyQTRVAXE7lvX+9Y+E1qOY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=lMF3gQkgjr/bMVrwUSfCMyKz1wgvEgKZ11ZFdWm62L0QHbVX1/lBpA/0I5/W34SPF2qln5jiI2Ly4KHNzPG+QIeQOkV/TLwSmmcwjUHQmdPjehD5NuZy2xGFfn44cOaIcwCIa4+WEOYigk1qv2/VK4L8nipDonNJq81R13s1YuY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-417f5268b12so35568045e9.1; Tue, 16 Apr 2024 00:05:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713251100; x=1713855900; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=jz8xW0hkNFPg+LOM+BMDp3CRmgqid89xE+lYmINvP6g=; b=SppUcMjWNjamUEM/+BLvjz6j8RyG6v6POKCK15K6u+zJK0ORyC6NWiznMwFtePsvGd 7Vp4SKTXifx25N7jmFt89xVa69LiD3ueVg5+5KmMLAxtx0T1+mpmV21/06J/lxeAPR/U EePz+1yEQlIxXCQiVBaZjPkfNgnM/L6i11ljRKJW4kgMU47LD6mUx4e0AHBNFhvvLvE7 K3z33ZztYFJXSugX2fpDlaPd/2q4VYSrPAX+YMZd4udjGeTC4wRUiZtKnisFgZigm/Hm Swdex9R+0dbfdNcLf3xIwxmVzbngvyhGdZ8Oq1lcfRe91zEpcWvprvn5i/tefYEQc4RY yE+w== X-Forwarded-Encrypted: i=1; AJvYcCXJvvLrB9r5sSIQtGMXB138ZN2iusYY5z8VsPZbo9Rr6We2j6kuhVD1o3ltAUZRTWmvujxEM0IwpjCRhqxNXnsfgoQVlIaYY6diAmUOTllWXrtfebrdT0pl4ScngFdUvoFk7aHKXlFNFoOv X-Gm-Message-State: AOJu0YwTYCQRKnaDUPq02JmXImKLvslsAL0mt90EuQaBqv6qdd1q5YWy x4grTwOsLn1ntm80zYxolBiviia5PwEEhRYzBgb4h349Vqp6hMnz X-Received: by 2002:a05:600c:19cc:b0:416:4973:4d87 with SMTP id u12-20020a05600c19cc00b0041649734d87mr11228590wmq.3.1713251099929; Tue, 16 Apr 2024 00:04:59 -0700 (PDT) Received: from ?IPV6:2a0b:e7c0:0:107::aaaa:69? ([2a0b:e7c0:0:107::aaaa:69]) by smtp.gmail.com with ESMTPSA id h15-20020adff4cf000000b003432ffc3aeasm13953280wrp.56.2024.04.16.00.04.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Apr 2024 00:04:59 -0700 (PDT) Message-ID: Date: Tue, 16 Apr 2024 09:04:56 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 12/15] tty: serial: switch from circ_buf to kfifo To: Pengfei Xu Cc: gregkh@linuxfoundation.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Al Cooper , Matthias Brugger , AngeloGioacchino Del Regno , Kumaravel Thiagarajan , Tharun Kumar P , Russell King , Vineet Gupta , Richard Genoud , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Alexander Shiyan , Baruch Siach , "Maciej W. Rozycki" , Shawn Guo , Sascha Hauer , Fabio Estevam , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Taichi Sugaya , Takao Orito , Bjorn Andersson , Konrad Dybcio , =?UTF-8?Q?Pali_Roh=C3=A1r?= , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Manivannan Sadhasivam , Krzysztof Kozlowski , Alim Akhtar , Laxman Dewangan , Thierry Reding , Jonathan Hunter , Orson Zhai , Baolin Wang , Chunyan Zhang , Patrice Chotard , Maxime Coquelin , Alexandre Torgue , "David S. Miller" , Hammer Hsieh , Peter Korsgaard , Timur Tabi , Michal Simek , Sumit Semwal , =?UTF-8?Q?Christian_K=C3=B6nig?= References: <20240405060826.2521-1-jirislaby@kernel.org> <20240405060826.2521-13-jirislaby@kernel.org> Content-Language: en-US From: Jiri Slaby Autocrypt: addr=jirislaby@kernel.org; keydata= xsFNBE6S54YBEACzzjLwDUbU5elY4GTg/NdotjA0jyyJtYI86wdKraekbNE0bC4zV+ryvH4j rrcD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ABEBAAHCwV8EGAECAAkFAk6S 54YCGwwACgkQvSWxBAa0cEk3tRAAgO+DFpbyIa4RlnfpcW17AfnpZi9VR5+zr496n2jH/1ld wRO/S+QNSA8qdABqMb9WI4BNaoANgcg0AS429Mq0taaWKkAjkkGAT7mD1Q5PiLr06Y/+Kzdr 90eUVneqM2TUQQbK+Kh7JwmGVrRGNqQrDk+gRNvKnGwFNeTkTKtJ0P8jYd7P1gZb9Fwj9YLx jhn/sVIhNmEBLBoI7PL+9fbILqJPHgAwW35rpnq4f/EYTykbk1sa13Tav6btJ+4QOgbcezWI wZ5w/JVfEJW9JXp3BFAVzRQ5nVrrLDAJZ8Y5ioWcm99JtSIIxXxt9FJaGc1Bgsi5K/+dyTKL wLMJgiBzbVx8G+fCJJ9YtlNOPWhbKPlrQ8+AY52Aagi9WNhe6XfJdh5g6ptiOILm330mkR4g W6nEgZVyIyTq3ekOuruftWL99qpP5zi+eNrMmLRQx9iecDNgFr342R9bTDlb1TLuRb+/tJ98 f/bIWIr0cqQmqQ33FgRhrG1+Xml6UXyJ2jExmlO8JljuOGeXYh6ZkIEyzqzffzBLXZCujlYQ DFXpyMNVJ2ZwPmX2mWEoYuaBU0JN7wM+/zWgOf2zRwhEuD3A2cO2PxoiIfyUEfB9SSmffaK/ S4xXoB6wvGENZ85Hg37C7WDNdaAt6Xh2uQIly5grkgvWppkNy4ZHxE+jeNsU7tg= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, On 16. 04. 24, 5:24, Pengfei Xu wrote: > On 2024-04-05 at 08:08:23 +0200, Jiri Slaby (SUSE) wrote: >> Switch from struct circ_buf to proper kfifo. kfifo provides much better >> API, esp. when wrap-around of the buffer needs to be taken into account. >> Look at pl011_dma_tx_refill() or cpm_uart_tx_pump() changes for example. .. > Greeting! > I used syzkaller and Internal v6.9-rc4 kernel which include Linux next kernel, > and found deadlock in console_flush_all issue, bisected the commit is: > " > 1788cf6a91d9 tty: serial: switch from circ_buf to kfifo > " .. > [ 17.841628] ====================================================== > [ 17.841631] WARNING: possible circular locking dependency detected > [ 17.841632] 6.9.0-rc4-df0b4fecf9eb+ #1 Not tainted > [ 17.841636] ------------------------------------------------------ > [ 17.841638] repro/726 is trying to acquire lock: > [ 17.841641] ffffffff86d6da80 (console_owner){....}-{0:0}, at: console_flush_all+0x51a/0xc40 > [ 17.841665] > [ 17.841665] but task is already holding lock: > [ 17.841667] ffffffff89aa52b8 (&port_lock_key){-...}-{2:2}, at: uart_put_char+0x118/0x510 > [ 17.841684] > [ 17.841684] which lock already depends on the new lock. .. > [ 17.842133] stack backtrace: .. > [ 17.842461] handle_bug+0xa2/0x130 > [ 17.842469] exc_invalid_op+0x3c/0x80 > [ 17.842479] asm_exc_invalid_op+0x1f/0x30 > [ 17.842487] RIP: 0010:uart_put_char+0x3ac/0x510 So you hit a "WARNING" (see below). And printing pretty much anything (like the WARNING report) from this point inside uart_put_char() will lead to this deadlock. .. > [ 17.879899] WARNING: CPU: 0 PID: 726 at drivers/tty/serial/serial_core.c:561 uart_put_char+0x3ac/0x510 This is the real thing/root cause of the above. WARN_ON_ONCE(!state->port.xmit_buf)) was hit in uart_put_char(). Let me see how kfifo changed xmit_buf handling. > Hope reproduced code and bisection is helpful. Thanks, let me investigate. -- js suse labs