Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1434469pxa; Thu, 13 Aug 2020 08:27:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRfBvvVxd9dgvpd5uZbtUeJ1i8VGGFnEmwgqzhlBzeMWossqIuCqEpsg5ZWEIIPs+jj+rl X-Received: by 2002:a50:ec95:: with SMTP id e21mr5104939edr.250.1597332471577; Thu, 13 Aug 2020 08:27:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597332471; cv=none; d=google.com; s=arc-20160816; b=CbQuyMD5n7J8dXi48H8RvEJkcEOE9ejNw2boNqC9T7yZfhyfSA/IdfJviirC+MVUIQ d9HmNafb6kLSlsgpn1KIOBlE/9zoebxCP76CIOnAwpzqrMac5uoLsKQKbEFWMebZeW3T O9pMso1QcfJftD8D42ec4YPeTFbWfpW4i77yIDeICLmaCfHBHUyME2EkKhaCfxJUXi06 up2BaPwY+JOfIze0dswLAc7gwZv5lfiMGYb3Jj9rT/zZg18G4d/C0YF/jXK8M9LdZgoG OocktkB+9/zGQ6NSeE5angVgHYWp9kU+ReeGW9bY6DFaN9gryWbDW+9HNDrph0z3rK/Q lqVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=1s5slD5xTRFFbW+h5M8Mtfy1B797ut+y2+cHY1OmjLY=; b=L14bCheMfwHJiQD4NCjN/6vEB4jRNhK12NFLoCpXDRPi/uk8Z1MmZE2ATyO9lFOyEE ClzHI20qe5ActsF061F38+mKQl703oR+e6uC0gUKrJ5ZJ34Y0VFYQdju8kq6sY6FtVE9 huh7bVldVbghwmF2ClccronjwI3UBIGt34Ie3xXIfcvhxICO9naR2uzsUc26uRCSB/qz C1aIzvWgsYetfSNE6YEfCk1FHoLZrb/1HZZsuICOOyDiRHe7dWrinzNojakPLpTjak+h xh/9OohGLQUEiX2eObQxK6yWa+zEUyNWwbx3d9I776f+IxTV/mEzGWSbr5acBv26tvvf Z5OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=WHqM+7gQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lk1si3590647ejb.504.2020.08.13.08.27.27; Thu, 13 Aug 2020 08:27:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=WHqM+7gQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726249AbgHMP0x (ORCPT + 99 others); Thu, 13 Aug 2020 11:26:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726131AbgHMP0w (ORCPT ); Thu, 13 Aug 2020 11:26:52 -0400 Received: from mail-vs1-xe43.google.com (mail-vs1-xe43.google.com [IPv6:2607:f8b0:4864:20::e43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA1F7C061757 for ; Thu, 13 Aug 2020 08:26:51 -0700 (PDT) Received: by mail-vs1-xe43.google.com with SMTP id 1so3107323vsl.1 for ; Thu, 13 Aug 2020 08:26:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1s5slD5xTRFFbW+h5M8Mtfy1B797ut+y2+cHY1OmjLY=; b=WHqM+7gQMzNV59fPJeZs3rGKhbE9qM3WyS4WwK4osQC4YO4qDuGUt6LJ9FM8egQwUC VytnE4Zh2KYSkKeCXP4g/2ZrFQ0UTbqr49Ky7xXOH0E+VX1VQ7SHKP5HibHklBsLX0Lb zD8EqdHy3tjHuz3ZMqgWbofxY0x5cqC77Plqs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1s5slD5xTRFFbW+h5M8Mtfy1B797ut+y2+cHY1OmjLY=; b=MrE3iIrDw7oPfSQMdTa7LmzHpSjE51xKqpAWXW5wwMr8T3EUEuE/wZNcVxSTlRJQGl kKVnWrS1aGCG+1iQ/awRY2BHVmthEtPHf+9v2cSaLB6JG/gJ/ems7266xOkkg3laomx4 SvO+gGuHZijMjy6wriJ0Tz1lM5fhwuvlqpDR0YnMfD0IwHiiwbCO6Zp/R2D3jhqIAjGG 9aa9Xjuzbtkn6soH/IgbxjarmFoNBPzJaqnRrnO6FZKr8CPzBVIfIotafW0q7jfa7I47 8b6cuS7ycxoy9steCTbTbafKc5x0mHZ4n+mwN6vJdw1ackqrlBBdTPBw/kdRO+rHrbrO +SGA== X-Gm-Message-State: AOAM530ao3hX/4GfriRIXpRAVtIPOTN23NfHTcUstXUfAbnM+Exhe2R2 Ws3I9NumiI849sG5Uq2xoYnl+ncRQh8= X-Received: by 2002:a67:e9d6:: with SMTP id q22mr3650276vso.232.1597332410763; Thu, 13 Aug 2020 08:26:50 -0700 (PDT) Received: from mail-ua1-f52.google.com (mail-ua1-f52.google.com. [209.85.222.52]) by smtp.gmail.com with ESMTPSA id j20sm613883ual.9.2020.08.13.08.26.49 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Aug 2020 08:26:49 -0700 (PDT) Received: by mail-ua1-f52.google.com with SMTP id k18so638442uao.11 for ; Thu, 13 Aug 2020 08:26:49 -0700 (PDT) X-Received: by 2002:ab0:37d3:: with SMTP id e19mr3760000uav.64.1597332408240; Thu, 13 Aug 2020 08:26:48 -0700 (PDT) MIME-Version: 1.0 References: <1595333413-30052-1-git-send-email-sumit.garg@linaro.org> <20200811135801.GA416071@kroah.com> <20200811145816.GA424033@kroah.com> In-Reply-To: From: Doug Anderson Date: Thu, 13 Aug 2020 08:26:36 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC 0/5] Introduce NMI aware serial drivers To: Sumit Garg Cc: Greg Kroah-Hartman , Daniel Thompson , linux-serial@vger.kernel.org, kgdb-bugreport@lists.sourceforge.net, Jiri Slaby , Russell King - ARM Linux admin , Jason Wessel , Linux Kernel Mailing List , linux-arm-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Thu, Aug 13, 2020 at 2:25 AM Sumit Garg wrote: > > > One other idea occurred to me that's maybe simpler. You could in > > theory just poll the serial port periodically to accomplish. It would > > actually probably even work to call the normal serial port interrupt > > routine from any random CPU. On many serial drivers the entire > > interrupt handler is wrapped with: > > > > spin_lock_irqsave(&uap->port.lock, flags); > > ... > > spin_unlock_irqrestore(&uap->port.lock, flags); > > > > And a few (the ones I was involved in fixing) have the similar pattern > > of using uart_unlock_and_check_sysrq(). > > > > Any serial drivers following this pattern could have their interrupt > > routine called periodically just to poll for characters and it'd be > > fine, right? ...and having it take a second before a sysrq comes in > > this case is probably not the end of the world? > > > > Are you proposing to have complete RX operation in polling mode with > RX interrupt disabled (eg. using a kernel thread)? No, I'm suggesting a hybrid approach. Leave the interrupts enabled as usual, but _also_ poll every 500 ms or 1 second (maybe make it configurable?). In some serial drivers (ones that hold the lock for the whole interrupt routine) this polling function could actually be the same as the normal interrupt handler so it'd be trivially easy to implement and maintain. NOTE: This is not the same type of polling that kgdb does today. The existing polling is really only intended to work when we're dropped into the debugger. This would be more like a "poll_irq" type function that would do all the normal work the interrupt did and is really just there in the case that the CPU that the interrupt is routed to is locked up. > > One nice benefit of this is that it would actually work _better_ on > > SMP systems for any sysrqs that aren't NMI safe. Specifically with > > your patch series those would be queued with irq_work_queue() which > > means they'd be blocked if the CPU processing the NMI is stuck with > > IRQs disabled. > > Yes, the sysrq handlers which aren't NMI safe will behave similarly to > existing IRQ based sysrq handlers. > > > With the polling mechanism they'd nicely just run on a > > different CPU. > > It looks like polling would cause much CPU overhead. So I am not sure > if that is the preferred approach. Maybe now it's clearer that there should be almost no overhead. When dealing with a SYSRQ it's fine if there's a bit of a delay before it's processed, so polling every 1 second is probably fine. -Doug