Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp287202lqp; Thu, 21 Mar 2024 00:38:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV3gTmkSthus8im72aB7AUvZvEsdmiB/sPO/hakQf9CiwUXKnsQ+36m58kvjj63gcdKjOUEd/OJBh/s5bscxQ37vvhUbMvZOKIQmotHbQ== X-Google-Smtp-Source: AGHT+IEnBMaN7GCG+mL5f9YMMemIPXxUKK4sUOsBCyP4eTuTTjTNRWUrBaqI6rYXQkb0+u/WOpCO X-Received: by 2002:a05:6359:2d02:b0:17f:16d8:277c with SMTP id rl2-20020a0563592d0200b0017f16d8277cmr5292375rwb.14.1711006698821; Thu, 21 Mar 2024 00:38:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711006698; cv=pass; d=google.com; s=arc-20160816; b=VAQqcHGWK+h7Q0J+TSnI1Ol/VGEBEPY0L4uHzlBuFdlcHnxmoy4a28SKjbMtsaekXB cqASirpuiCxo1RYgNP9WRn0fTEitp4LIorC63TNkGO6S1A4Axwm9QHB1f42nZNMvQslk p56AF2AV5rR/2UPHcAyZ1Oi5Vhtm9jm2da40Ko8WPK92DOPJh4cNcYZGJ2JthtaaoNpJ Wx6hxYRMlw75Ya+JPtmQEAtbkgmuNSyoCJwmBLIMqQl+WPy/1VhwZ0eCwdsR53xIKvJ4 zZJbXOAW8wK14Q4T5/ufRIHcCmFabV6thHkbZ8zyM5rfBYTg22/kKxWXYp0UKytEbp/R VlIg== 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=4YCbD7hnRuEloQElRYK84GXNjnMU5CZZGqCbe5W2znI=; fh=98f+TDkh5a5XYNhapIPmENUx4tNfqsdVnppqIkUZLKk=; b=CwvBxq0GLPaPjmwTha8XtCK1QYZqcdWBNBkwYRqhfLmr0qbk1sHBHGX2Ho59Fi+bQa l5Qjw57CNG5F2qKhM3zv36ekj+nvkSdk5hIQ9zdpTm5ilsiv7tXQWhBApMxjzMWmIegB I568nYCwnfNecHbxdigqhvVHoWNYPTRMi7CE7FMN52yEM1A140BkOUNEW2QzKkxfpbux 4XJW5zkPKhjfBrIGfq1o4yZX3C7i5KaxFidDVswx88FIlzK5R0xGNw+DpbTs/FThuQEh KxgXEb6jjQw9vwbHuZHhahoZEN8jlBLI+rjrvRHICYCqtIVBGQGAkC389sSufYs5zhy2 5l6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jAV3qku2; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-109734-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109734-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id c5-20020a63ef45000000b005dc956c2c15si13653048pgk.70.2024.03.21.00.38.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 00:38:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109734-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=@linuxfoundation.org header.s=korg header.b=jAV3qku2; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-109734-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109734-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 9A1A0B214FA for ; Thu, 21 Mar 2024 07:38:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0B35C58121; Thu, 21 Mar 2024 07:38:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="jAV3qku2" 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 D19948F5D; Thu, 21 Mar 2024 07:38:04 +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=1711006685; cv=none; b=k8g3WgyEmCgOd4WyCQguZPvbqjyZ2lrWbIknLLqTbufg9f3nVA18ZBW6eQ8xE1sw5iuq0eDI3ibpVV0/YXurbBSVd5fT6YAjoexOiSi9DZD80Aq4OefmsHIRK9m/7gXinzPe6fpCWFz+2tqhjOfJSzf5E+C/sp97XWSKeNtn7U4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711006685; c=relaxed/simple; bh=r5tQxRIoGQ31YekqFLxmrVDnCnZskKiy+nmyBJ0P9Mc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QXwBhLZUxwSROALCbI/YLf2qBJDd3FpW9gkSINYE64wcJqyek63I+xSa8eI/B3c7hfmV5soPXtPktanxmZdHwY598s7gOcXcpNCkNjX2AWejtxaqdTZgyVSn161TLM4jbI8SbIPB03ANvmDC6KTuJYEtjJgYLQaJ8m+JplqrEPQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=jAV3qku2; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4FB7C433F1; Thu, 21 Mar 2024 07:38:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1711006684; bh=r5tQxRIoGQ31YekqFLxmrVDnCnZskKiy+nmyBJ0P9Mc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jAV3qku2vdq7slWqkOit85k4p8LiqknT2EUeqJ36paO2XEvzH/+gTyg46bTnLNN6G cTvjqqEB8fBHJ2HLdS+//Yl/FJEzhYoJdjoZUhIWw/WeWkytytkJEZOYpBJd2pk98p +mTLBUJf0x9PHmMZKU7xnYfNf8oLThBOAktYSbo8= Date: Thu, 21 Mar 2024 08:38:00 +0100 From: Greg KH To: liu.yec@h3c.com Cc: daniel.thompson@linaro.org, dianders@chromium.org, jason.wessel@windriver.com, jirislaby@kernel.org, kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: Re: [PATCH V3] kdb: Fix the deadlock issue in KDB debugging. Message-ID: <2024032137-parrot-sandbank-ab29@gregkh> References: <20240320162802.GA22198@aspen.lan> <20240321022604.4088438-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: <20240321022604.4088438-1-liu.yec@h3c.com> On Thu, Mar 21, 2024 at 10:26:04AM +0800, liu.yec@h3c.com wrote: > From: LiuYe > > Currently, if CONFIG_KDB_KEYBOARD is enabled, then kgdboc will > attempt to use schedule_work() to provoke a keyboard reset when > transitioning out of the debugger and back to normal operation. > This can cause deadlock because schedule_work() is not NMI-safe. > > The stack trace below shows an example of the problem. In this > case the master cpu is not running from NMI but it has parked > the slave CPUs using an NMI and the parked CPUs is holding > spinlocks needed by schedule_work(). > > example: > BUG: spinlock lockup suspected on CPU#0, namex/10450 > lock: 0xffff881ffe823980, .magic: dead4ead, .owner: namexx/21888, .owner_cpu: 1 > ffff881741d00000 ffff881741c01000 0000000000000000 0000000000000000 > ffff881740f58e78 ffff881741cffdd0 ffffffff8147a7fc ffff881740f58f20 > Call Trace: > [] ? __schedule+0x16d/0xac0 > [] ? schedule+0x3c/0x90 > [] ? schedule_hrtimeout_range_clock+0x10a/0x120 > [] ? mutex_unlock+0xe/0x10 > [] ? ep_scan_ready_list+0x1db/0x1e0 > [] ? schedule_hrtimeout_range+0x13/0x20 > [] ? ep_poll+0x27a/0x3b0 > [] ? wake_up_q+0x70/0x70 > [] ? SyS_epoll_wait+0xb8/0xd0 > [] ? entry_SYSCALL_64_fastpath+0x12/0x75 > CPU: 0 PID: 10450 Comm: namex Tainted: G O 4.4.65 #1 > Hardware name: Insyde Purley/Type2 - Board Product Name1, BIOS 05.21.51.0036 07/19/2019 > 0000000000000000 ffff881ffe813c10 ffffffff8124e883 ffff881741c01000 > ffff881ffe823980 ffff881ffe813c38 ffffffff810a7f7f ffff881ffe823980 > 000000007d2b7cd0 0000000000000001 ffff881ffe813c68 ffffffff810a80e0 > Call Trace: > <#DB> [] dump_stack+0x85/0xc2 > [] spin_dump+0x7f/0x100 > [] do_raw_spin_lock+0xa0/0x150 > [] _raw_spin_lock+0x15/0x20 > [] try_to_wake_up+0x176/0x3d0 > [] wake_up_process+0x15/0x20 > [] insert_work+0x81/0xc0 > [] __queue_work+0x135/0x390 > [] queue_work_on+0x46/0x90 > [] kgdboc_post_exp_handler+0x48/0x70 > [] kgdb_cpu_enter+0x598/0x610 > [] kgdb_handle_exception+0xf2/0x1f0 > [] __kgdb_notify+0x71/0xd0 > [] kgdb_notify+0x35/0x70 > [] notifier_call_chain+0x4a/0x70 > [] notify_die+0x3d/0x50 > [] do_int3+0x89/0x120 > [] int3+0x44/0x80 > > Signed-off-by: LiuYe > Co-authored-by: Daniel Thompson > Signed-off-by: Daniel Thompson > --- > 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); > +} > + > +static DEFINE_IRQ_WORK(kgdboc_restore_input_irq_work, kgdboc_queue_restore_input_helper); > + > static void kgdboc_restore_input(void) > { > if (likely(system_state == SYSTEM_RUNNING)) > - schedule_work(&kgdboc_restore_input_work); > + irq_work_queue(&kgdboc_restore_input_irq_work); > } > > static int kgdboc_register_kbd(char **cptr) > @@ -133,6 +141,7 @@ static void kgdboc_unregister_kbd(void) > i--; > } > } > + irq_work_sync(&kgdboc_restore_input_irq_work); > flush_work(&kgdboc_restore_input_work); > } > #else /* ! CONFIG_KDB_KEYBOARD */ > -- > 2.25.1 > > Hi, This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree. You are receiving this message because of the following common error(s) as indicated below: - This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/process/submitting-patches.rst for what needs to be done here to properly describe this. If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers. thanks, greg k-h's patch email bot