Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3173404lqp; Tue, 26 Mar 2024 01:23:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW2IGfmUJY7OQWjLW6edr5WD0WI3isIyuXrm0YV55jQ6Yd1X/DQoQ1gWt0e6IiO4+e63kFAYHy5GicQqDyCpiGDkI+Z+UIku/6uPg0fVA== X-Google-Smtp-Source: AGHT+IGzBgrJJyJ/nyEHQmaTsJn+SMEMGsgK6yFtJ9O+EuR0hL08+3iI4JUCq7htKEW789u14OmX X-Received: by 2002:a05:6830:455:b0:6e4:cd4f:b67 with SMTP id d21-20020a056830045500b006e4cd4f0b67mr9861916otc.5.1711441389078; Tue, 26 Mar 2024 01:23:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711441389; cv=pass; d=google.com; s=arc-20160816; b=Oebx5AHR8Fwnff5C5PZy8SwGY8HSJUakp9X6O+KuTseW6+rMC3C2vxM0VjIKwzvItL ZjAgnICGqJaGF7Xe7K+dwIotaCYKHyY5I3ilEVsrKk+ghRoAIbqLEYy0W9bSj+chs8lJ gwmWo8+XtlA2PNE8GK1+sFuww+1bEvi59+tUHbPeelER68+HYX+zzHXfTJnUR4igwDO0 aRqsipW4HZIj4oyIlMiwxUYjEWhYApiKvjrQetVINIa21xlDG5aikvwnJ6g3oe38/Dli RXVwBWrhpKMsjkNTiZrhBwbz1EC6G+McjxVq+SPrcN9kTrn4O7DMR+pZwm2GShYg4n64 OhKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=zPGq9QAfs5yblIrjHBOytvOonJf9qJcXr2vlXfvH/I8=; fh=M5m9ml/dsdIZurK9p8a8rAm6KBsmcH9Rvc4uWu29DZ8=; b=jb8w142KnDE1bLOESDUnasiZx4C2oXZ/1JCYOl2laPE5BgsUtuLZ6Tg060Ca8vG887 x5QAPZb7ynv+QJNLW+X/W92IBUZxUhMzE6ijHL4sMgGygg5qeKSOSpAQSUDAHRroqFv5 E8mUer/5ZGXe3w9KBM9k0ayHE1jQhHxbOanRuXLnHymzhHn0YwNvhz0FiiQUNENH1+PV e7Yt1UTTD7e2u6v3Vjku6FPqNKMe2cXg8oepEpur7NUiyFicePz996irEs4A8gzBNS30 cp4gp0IYe3V2Cu5xbQiAm9i5dEKuCzzURzeJ/cJ4OKlx0+03+HZzDHhCmDPbM84JxOz5 1L5Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RJQoui9W; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-118529-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118529-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u15-20020a63470f000000b005dbd4cf445csi9072016pga.35.2024.03.26.01.23.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 01:23:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-118529-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RJQoui9W; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-118529-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118529-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7FFCC2E1144 for ; Tue, 26 Mar 2024 08:23:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1CC9B13341C; Tue, 26 Mar 2024 08:23:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="RJQoui9W" 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 28BD81CAA2; Tue, 26 Mar 2024 08:23:01 +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=1711441382; cv=none; b=SPSXQA4xe0UeTrK37YmF5QpzOzoaAWwZWx7nZCI34iZ1G0bYHVd3eJ2hdmElUJqaFzWbayMn35cOTelU6Dg+LMERDcmyYrZ3rHJTu2hQgFo73uF3IEsrx+LfVxXL0PxRmXCU1EZdGFjSO9zM6zLeFg6EMD9LeUHKGTOR+tqqirg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711441382; c=relaxed/simple; bh=hwm0DgownOe+a+wofavFrRbBxRMYeIjoVarruVwkAp8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iBfZezmEoiBnOGv2dwTUnPFb2aOBozS+Ut273fc7liOtYCL4xwwvjHd2k8B52Q5nkxUEKBU1bjJuJmnzNRntLfqw7WCrVLstQbqUH25VyEia1mCuEFcAfw3rPyKIk5pFbdXdn0pHEIttc28bPN1JfAv6V8mFQbQL07JQR9srauM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=RJQoui9W; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECBC1C433F1; Tue, 26 Mar 2024 08:23:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1711441381; bh=hwm0DgownOe+a+wofavFrRbBxRMYeIjoVarruVwkAp8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RJQoui9Wv8kNVDt2z9iBQZygQxlmX8aSnUITgrc3cyQw4pnhb+7i74VCqYXCe8lJy qKZwtCfRkdoc+PcDT45tR9DmH8PAr/1CIaBuR5suhR929+L/UJUwSCe01Ri4Yns4B5 QS79pRCAD50jqWIOcKlqq+4Jg6aajCVTkyrriolw= Date: Tue, 26 Mar 2024 09:22:57 +0100 From: Greg KH To: liu.yec@h3c.com Cc: daniel.thompson@linaro.org, jirislaby@kernel.org, dianders@chromium.org, jason.wessel@windriver.com, kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: Re: [PATCH V6] kdb: Fix the deadlock issue in KDB debugging. Message-ID: <2024032630-croon-consuming-6ef9@gregkh> References: <20240325165436.GA485978@aspen.lan> <20240326074014.1905023-1-liu.yec@h3c.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240326074014.1905023-1-liu.yec@h3c.com> On Tue, Mar 26, 2024 at 03:40:14PM +0800, liu.yec@h3c.com wrote: > Note that we still need to a workqueue since we cannot resync > the keyboard state from the hardirq context provided by irq_work. I think you are missing a word between "to" and "a", right? > That must be done from task context for the calls into the input > subystem. Hence we must defer the work twice. First to safely > switch from the debug trap (NMI-like context) to hardirq and > then, secondly, to get from hardirq to the system workqueue. > > Signed-off-by: LiuYe > Co-authored-by: Daniel Thompson > Signed-off-by: Daniel Thompson > > --- > V5 -> V6: Replace with a more professional and accurate answer. > V4 -> V5: Answer why schedule another work in the irq_work and not do the job directly. > V3 -> V4: Add changelogs > V2 -> V3: Add description information > V1 -> V2: using irq_work to solve this properly. > --- > --- > drivers/tty/serial/kgdboc.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c > index 7ce7bb164..161b25ecc 100644 > --- a/drivers/tty/serial/kgdboc.c > +++ b/drivers/tty/serial/kgdboc.c > @@ -22,6 +22,7 @@ > #include > #include > #include > +#include > > #define MAX_CONFIG_LEN 40 > > @@ -99,10 +100,17 @@ static void kgdboc_restore_input_helper(struct work_struct *dummy) > > static DECLARE_WORK(kgdboc_restore_input_work, kgdboc_restore_input_helper); > > +static void kgdboc_queue_restore_input_helper(struct irq_work *unused) > +{ > + schedule_work(&kgdboc_restore_input_work); As this is a "two stage deferment" or something like that, it should be documented in the code exactly why this is needed and what is happening, otherwise it looks very odd. thanks, greg k-h