Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2324026pxa; Mon, 17 Aug 2020 07:01:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwF+9zGeLYX7qy+WufmJQsPOhxr55KVyFRch/Fi5aOUyx5vLl8ENrJTArxUzdFCRySbmPIJ X-Received: by 2002:a50:e70e:: with SMTP id a14mr14641459edn.93.1597672882795; Mon, 17 Aug 2020 07:01:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597672882; cv=none; d=google.com; s=arc-20160816; b=OE+nUioWLY7av6HABRQlrdTACVr+j2ZAAdg9FWu1UQxjJ9/2bxBN0WlcNSfFv/HWR9 9Z/LRTjn/xOzP1dp9DsT3zaflJwQ4vEyeQadMhXm1Y8VcrKF1HM6PFObkd59KQUmnajA V6Q4f9lFEu9DE2+478zSBlRUpFXkjnJBwdLoRNbJu3QKqZArqLdUYnDUOqAPGFQHMTD9 nojwqZXyC8QZx0p1M3DY+6zMTPPW4l94CgKcYvRSm07qnozFSPbqbJthds3ja+7sOKQA 2Gi6FDprogNAHNmo5Yy+DLEjAqn1aXyhxw8mZ5lwjO96z4ja4lbC5KK919XZt2nJP+kq 1Jnw== 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=xdKYrohN8OlGDXEszWS+Ec7t39VpiibXfsuU/BXESmU=; b=GcCa82xFnAm9lAAag9ekbaAh5Ng1wrNS9pCUm5+UFITD7ZghJIWbuQSGHogAHPgTLW 7/lNiq8ThS1MbSGaSUVTZWKR1/l7Heo4rL4iUnmUfUmMUpBgrbqXvy+0wy0jFxiyBqOI hHMe0suJyZBEaVWQ3zb3Q2tn8cGvCuAla8NMSqzP2szw0eqAjaizHJl9MgIp8HFUBmuq foJP13+YJ2Zd1WXi0aNmHS/8mc+JhX4OFjCRSy6JuS5V/hfg//7FuHzcRyZJNZmAZTRH A8s8LYB4Z10OmFO8rmOLLKtNOVA0tQPcWFRasZH0rX9HIF130Hymept4yxdHUGYuDuI8 lQXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="ZKT/oHgX"; 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 t4si11067172ejt.506.2020.08.17.07.00.58; Mon, 17 Aug 2020 07:01:22 -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="ZKT/oHgX"; 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 S1728686AbgHQN5l (ORCPT + 99 others); Mon, 17 Aug 2020 09:57:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728585AbgHQN5j (ORCPT ); Mon, 17 Aug 2020 09:57:39 -0400 Received: from mail-vk1-xa42.google.com (mail-vk1-xa42.google.com [IPv6:2607:f8b0:4864:20::a42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 589A1C061342 for ; Mon, 17 Aug 2020 06:57:39 -0700 (PDT) Received: by mail-vk1-xa42.google.com with SMTP id x2so3541950vkd.8 for ; Mon, 17 Aug 2020 06:57:39 -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=xdKYrohN8OlGDXEszWS+Ec7t39VpiibXfsuU/BXESmU=; b=ZKT/oHgXJeLaz2zSrpCOpcciOR4Mu1pqaSQj+Y449pXWXd5zG14b92RWlkzZCxWBO7 yME6N7qJVHxW7bemEEpv63eiFnQiLjA0UKyEvL6CwHme89gvtDcenUq5X9ku6kYABH4m ad78O5beq8PPyCpELu1KKVgY+uZ0KpO9XYRLE= 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=xdKYrohN8OlGDXEszWS+Ec7t39VpiibXfsuU/BXESmU=; b=kHVOLKJukQOyP6/53lLCd4o4DtGkgIGLuxPIvkIDbisrL2xB+ifkbr7ADi5p2/jkP2 Y5uxa/NARB9qePBBGUi7+NClxIVlvEYgpt7STPjUqBr5HuzCZM61AcQjc02cjnOVJ62X uMaiUwub49FJ0RoJqP7PLW2IysqSSd6H88H64KSvyB4GC4zzE7ftNRfZLVKp/JXuQOUt Zt5h/WE1qhSvtL4NvAoHb3Cl8E4HuJlVqNTFgGm1oFSns/KSjeja3M7NEsXimgevuVkl ujpV5ddmwQYzrR2tl4/QHO2rNPdHGns8aJj8RdWKpaWhJfAQ7STmZQaa4nG9Qzxp29XG bUng== X-Gm-Message-State: AOAM533kOJkWEUPjnk1yuRXId4xqP9ga1wrOSCbxYLynVFxz6AbupxRL f/PUiS1ai2euazGu+mlO5WOZgTN0snrt1Q== X-Received: by 2002:a1f:a094:: with SMTP id j142mr8008466vke.7.1597672655950; Mon, 17 Aug 2020 06:57:35 -0700 (PDT) Received: from mail-vs1-f49.google.com (mail-vs1-f49.google.com. [209.85.217.49]) by smtp.gmail.com with ESMTPSA id x25sm2629655ual.2.2020.08.17.06.57.34 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Aug 2020 06:57:34 -0700 (PDT) Received: by mail-vs1-f49.google.com with SMTP id o184so8307226vsc.0 for ; Mon, 17 Aug 2020 06:57:34 -0700 (PDT) X-Received: by 2002:a67:fd67:: with SMTP id h7mr7276952vsa.121.1597672654168; Mon, 17 Aug 2020 06:57:34 -0700 (PDT) MIME-Version: 1.0 References: <1595333413-30052-1-git-send-email-sumit.garg@linaro.org> <1595333413-30052-3-git-send-email-sumit.garg@linaro.org> <20200814141322.lffebtamfjt2qrym@holly.lan> In-Reply-To: From: Doug Anderson Date: Mon, 17 Aug 2020 06:57:22 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC 2/5] serial: core: Add framework to allow NMI aware serial drivers To: Sumit Garg Cc: Daniel Thompson , Greg Kroah-Hartman , linux-serial@vger.kernel.org, kgdb-bugreport@lists.sourceforge.net, Jiri Slaby , Russell King - ARM Linux , Jason Wessel , LKML , Linux ARM 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 Mon, Aug 17, 2020 at 5:27 AM Sumit Garg wrote: > > Thanks for your suggestion, irq_work_schedule() looked even better > without any overhead, see below: > > diff --git a/include/linux/irq_work.h b/include/linux/irq_work.h > index 3082378..1eade89 100644 > --- a/include/linux/irq_work.h > +++ b/include/linux/irq_work.h > @@ -3,6 +3,7 @@ > #define _LINUX_IRQ_WORK_H > > #include > +#include > > /* > * An entry can be in one of four states: > @@ -24,6 +25,11 @@ struct irq_work { > void (*func)(struct irq_work *); > }; > > +struct irq_work_schedule { > + struct irq_work work; > + struct work_struct *sched_work; > +}; > + > static inline > void init_irq_work(struct irq_work *work, void (*func)(struct irq_work *)) > { > { > @@ -39,6 +45,7 @@ void init_irq_work(struct irq_work *work, void > (*func)(struct irq_work *)) > > bool irq_work_queue(struct irq_work *work); > bool irq_work_queue_on(struct irq_work *work, int cpu); > +bool irq_work_schedule(struct work_struct *sched_work); > > void irq_work_tick(void); > void irq_work_sync(struct irq_work *work); > diff --git a/kernel/irq_work.c b/kernel/irq_work.c > index eca8396..3880316 100644 > --- a/kernel/irq_work.c > +++ b/kernel/irq_work.c > @@ -24,6 +24,8 @@ > static DEFINE_PER_CPU(struct llist_head, raised_list); > static DEFINE_PER_CPU(struct llist_head, lazy_list); > > +static struct irq_work_schedule irq_work_sched; > + > /* > * Claim the entry so that no one else will poke at it. > */ > @@ -79,6 +81,25 @@ bool irq_work_queue(struct irq_work *work) > } > EXPORT_SYMBOL_GPL(irq_work_queue); > > +static void irq_work_schedule_fn(struct irq_work *work) > +{ > + struct irq_work_schedule *irq_work_sched = > + container_of(work, struct irq_work_schedule, work); > + > + if (irq_work_sched->sched_work) > + schedule_work(irq_work_sched->sched_work); > +} > + > +/* Schedule work via irq work queue */ > +bool irq_work_schedule(struct work_struct *sched_work) > +{ > + init_irq_work(&irq_work_sched.work, irq_work_schedule_fn); > + irq_work_sched.sched_work = sched_work; > + > + return irq_work_queue(&irq_work_sched.work); > +} > +EXPORT_SYMBOL_GPL(irq_work_schedule); Wait, howzat work? There's a single global variable that you stash the "sched_work" into with no locking? What if two people schedule work at the same time? -Doug