Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp344172pxa; Fri, 14 Aug 2020 06:05:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuXSwtzsDNUwDq4lHdiH2Il04FnyRZZGvgxHtypDYYbFkyEn1TXBSydsT/Ie+my7JL2lLK X-Received: by 2002:aa7:da8c:: with SMTP id q12mr2209714eds.126.1597410316120; Fri, 14 Aug 2020 06:05:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597410316; cv=none; d=google.com; s=arc-20160816; b=dgthc2LyZGxDGby+Ub+/j35i4UxArEADRVNHaK/Nx2YwOxUTrDfAr7dn3hSBVLQ7If Wn36UpgDyPp1pKcnrjaxbHf1xgDGHCd924LSIqTrb3z+AE7+dMj+8rErNkkPwgz+LvRV 7CzKAjMwvJeNvOF04IZoT1K/0V2E5uspo6IWwmwpR34DSsXxHn3fIxR/hvkkiOJOT2uN nCgUtGRvQN2dmgw80Ow1G5q1Di7slVpIUrpGkfLHYV6RvjiAcaW7ijC9DEtlRs2WdFvF c/rdERc36gIvcix1+y8CDO1dWwd5Ym90m8oeTfaFNngVuCrFhfaZfqJjVsBFToLujtJd W+cg== 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=oNrJofI4VSIM1YMzNApXQ6u0hlAa3YOeI7FwPv0W0xo=; b=BYZ485XXlt3awFebAkTajS1Qf87asEpkjKdYEjvlH8O2SbQCZaHIE+RfEeGgAg1/Eg pEkPKHINW1UAAzCrqFpTIpF2OmlmdQxL4FqF57qjBrYwwQmTRCzQ/qXFpHkxtsr8kQbQ MpznzXihJRGJ7DpzvBnlkryBdVpZF6ghUXCgLklwZd2LYgFXeZnln827ScgXwGhSHprK 0lM71JvApwMQhdSXx7ZvmV9dKJXyyG2iUoogUdXd2D2GOmI3z2vsyUJIeHTfclsRLcjS KKzGMmecPmozZZoeC3ftWcSXEL0qNtOA8/Gk4O8RBuKCN5DIX+K+Vg4NdcEMyqq5gV3y 3W5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dRkTj42r; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r18si5302515edo.272.2020.08.14.06.04.52; Fri, 14 Aug 2020 06:05:16 -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=@linaro.org header.s=google header.b=dRkTj42r; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728061AbgHNMuU (ORCPT + 99 others); Fri, 14 Aug 2020 08:50:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726690AbgHNMuS (ORCPT ); Fri, 14 Aug 2020 08:50:18 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 754B2C061385 for ; Fri, 14 Aug 2020 05:50:18 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id i10so9812939ljn.2 for ; Fri, 14 Aug 2020 05:50:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oNrJofI4VSIM1YMzNApXQ6u0hlAa3YOeI7FwPv0W0xo=; b=dRkTj42r1ORWNCi0KwgABypOpxNH2YfxXSplKDrbKISe72oY7nKYANmkrXI7TtKY3n FWkBYRoaG+R3/7Eh6gST6LtxiWqxoQ1nnN/qdQ9Knst1jUzHDduf2/YG0bhDHTtvLjkS DBtUfpz7eYBCI85lLB3Rw7TkYRda85x+si9K8QaSMd4wEoLUDF/zI32+bvFkkArZLn2b lZ0LOGC3YD0UVakzKaVLrc7hDjHoQc8aEgGCpfrRHGeL+cc/bztqeYVArmzbPYRg/pBR wmtPaXdqENs54CoXQf69SlfWc9fyGj+wCEIJ0Ft9yWLyfQq98qCaRGUS6iUCHvOBLvZY YI2g== 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=oNrJofI4VSIM1YMzNApXQ6u0hlAa3YOeI7FwPv0W0xo=; b=fgvTWDGC26W85mMhSKLEE+b1GqfcWAPPP5VtiSMWKocVb9SqObJKYeh3tpgobdibI8 SDrDaEV13eJO39EBswUVkSNC2qVQeWOs8a0snid9/ujMkw1+nejL2oTsUJummls/ROY3 F4d/lVid41euJqJijHQj/9lrLJpI6+BxLaW29a5SMAT3JuF7r6Y0IrXoG4U9dyBtUQPx SFIZWMYWut14q4BlaII2uYzHn5EE3yr5NTO4DqcZ4Gef1Tx9k7qshQkNq3YvjtXLtmnL Zlot4xra1ySF1dsONHGgIXJi7fpAhrYtUnIYgLO3Q1/Bb2ScqwJTDvKnvS/G7+D/45Pw JNzg== X-Gm-Message-State: AOAM531py9DeBKYskgtYMtveH8uzcrDAFr+LO35+ikRZ3htlpKwpTiIM n33Pz9E7HzZFPNiE8gPjo2ii4OAbwTzeu54UrF1zYw== X-Received: by 2002:a2e:b8cb:: with SMTP id s11mr1353447ljp.110.1597409416937; Fri, 14 Aug 2020 05:50:16 -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: Sumit Garg Date: Fri, 14 Aug 2020 18:20:05 +0530 Message-ID: Subject: Re: [RFC 0/5] Introduce NMI aware serial drivers To: Doug Anderson 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 On Thu, 13 Aug 2020 at 20:56, Doug Anderson wrote: > > 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. > Your idea sounds interesting. I think where we are reaching is to have an ever active listener to serial port that can be scheduled to any random active CPU. And to keep its CPU overhead negligible, it can sleep and only wake-up and listen once every 500 ms or 1 second (configurable). I will try to think more about it and probably give it a try with a PoC. -Sumit > > > > 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