Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3077647pxa; Tue, 18 Aug 2020 06:10:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxdw3gLJjPixPwXKviNYyubbcGTAZQoqVr+CLpqSTz8pfwwexR7pl80TcSEatp7tELg3hq X-Received: by 2002:a17:906:3f82:: with SMTP id b2mr20838700ejj.240.1597756226884; Tue, 18 Aug 2020 06:10:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597756226; cv=none; d=google.com; s=arc-20160816; b=F2L/Gp09JmWM3rLD/2iX1o4HN/FDhnoysWnG/LXLqAj/KFbxPWWUj518rmMaeI+OgC +r7VkaTgqrstLVIvfcWgcSeNUf8CLosUKK3uV/S8MsR2xr2QbqmETrghNM/9T+mLOx8I 12Ync9elgJ4BkmrdUdCYSoL365kD9OmP21TmKDq3SCLOxUuyBIAskX0gur8UWEPdK1QD gfgf3/U/DFP0Lbbz0FVJdweaZMdH90svjG9cDAjiQqPyJPQ5XiXQIzkBRXpsmZcOmr6c +3xxJE1FqD415rDntaR6Jlu3cmoHrOjImuVr6Ro1K4QjKbxnwMmrgxnW4szZpHFerB4g Xv/g== 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=IhGt4f9jByBxwiS5kZbnVsZb64Dpn4S8Zrl+tXBABko=; b=YSxNSQgtsji6BrEtkklckcVkOJs8k3dImIzQ4pJfLw4u7F9GGKdLx9oyLmYgJqpgJh zaAM75qr8xlkN5y2Y4t+NX3r8JhwfIcTYL5yEoG5DOnyV6cD1pXtxdc8bxCseqR7pWbu rqPPKl+4GNfwvksejDZImccPoVBzdcN0lgadXLTqJ6Vqdrrd2X3LAoHU2BydPvdV0PGd Imq0shPxs+0M4/oeDZWbQwkIF9XweOZ2MQlXgVMDwgUjFmWEIQwrZR4nNFw+eoeI3oDP Lk2TuYjOueM9wRTsBwVT4G1H7YRoaSSfEb4MJzXGFdrP//8AZYCa3K8yk/chQYvjql5E e8Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PIGPhufE; 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 rs7si14015847ejb.195.2020.08.18.06.10.01; Tue, 18 Aug 2020 06:10:26 -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=PIGPhufE; 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 S1726730AbgHRNGZ (ORCPT + 99 others); Tue, 18 Aug 2020 09:06:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726746AbgHRNGU (ORCPT ); Tue, 18 Aug 2020 09:06:20 -0400 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FB01C061342 for ; Tue, 18 Aug 2020 06:06:18 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id m15so10175231lfp.7 for ; Tue, 18 Aug 2020 06:06: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=IhGt4f9jByBxwiS5kZbnVsZb64Dpn4S8Zrl+tXBABko=; b=PIGPhufEWcQqajAr9EkyMc04aTgLdkSS0SFgGl+mr7c09WYImutC9/kVv/NW1WYO9u t0j9aC1fUyT0tLB+/4rwao9XGGpMZYNDwQgd9bh2J2lB5mIvKnxtxubZl3113WG1o0bU Cf0+cB35X6H/TCOYi5aTF4x9OshcbUZMf0VNplQRedQpYfxQzjX4fPkTU9YKpINiGQSA 87TKCNoY9QA8uzYiFI4VygCo2EsFFYVDQTOFV7uRJwuSrDNpd3nj9+1R+qFMu7g0KOXH LwnfDVY2oN1dFLbIijBZxqSJan4TwqGS6Og70I7lSjgR2lfzV9gJBaqwIn2nDf6czUe9 pHPQ== 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=IhGt4f9jByBxwiS5kZbnVsZb64Dpn4S8Zrl+tXBABko=; b=jI0Dps9IEXU0KlwcOlMjjZxurw2U3CWNx2yG7Za1Pxj20G+uVMNHM8Ow71ekxh7Y6j HSKCJJwf2RTam1IcgxGtx+1cnKNPoefLZlRnK3KN1wqbj+vEY9L8L0IXvkpfq+Tdv1y2 FhO2FpcjmPfh/fCh5EVAZsGgm3Z/cn4/+aNmJfmSfkmh4xEVkNxgXl2wLXxA3Tx13EU5 Kub+PoSN/ke508/AkxntPUPtJ5nGTmjTGiocOWQqGb7ZMVGONJbhqV1BW1bQiE4M6T6D NUzGAX/sQ8Wb0CZQD8llmdtk+rxVRrMYvjI76NjFUh3ui5fZy96GlklOXk0K4QrSdqr8 mcrw== X-Gm-Message-State: AOAM532l25Qqo3iRJpSAsDUq7daOTmIdVza17EnyyZlzoMe6v68F42e2 tk3162FCZOP1XvWqMBe9cywc3K1nO2C4BdBzLx66Zw== X-Received: by 2002:a19:803:: with SMTP id 3mr9802322lfi.15.1597755976518; Tue, 18 Aug 2020 06:06:16 -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> <20200817142846.mm46yy62illrewbq@holly.lan> In-Reply-To: <20200817142846.mm46yy62illrewbq@holly.lan> From: Sumit Garg Date: Tue, 18 Aug 2020 18:36:04 +0530 Message-ID: Subject: Re: [RFC 2/5] serial: core: Add framework to allow NMI aware serial drivers To: Daniel Thompson Cc: Doug Anderson , 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 On Mon, 17 Aug 2020 at 19:58, Daniel Thompson wrote: > > On Mon, Aug 17, 2020 at 05:57:03PM +0530, Sumit Garg wrote: > > On Fri, 14 Aug 2020 at 19:43, Daniel Thompson > > wrote: > > > On Fri, Aug 14, 2020 at 04:47:11PM +0530, Sumit Garg wrote: > > > Does it look better if you create a new type to map the two structures > > > together. Alternatively are there enough existing use-cases to want to > > > extend irq_work_queue() with irq_work_schedule() or something similar? > > > > > > > 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); > > + > > This is irredeemably broken. > > Even if we didn't care about dropping events (which we do) then when you > overwrite irq_work_sched with a copy of another work_struct, either of > which could currently be enqueued somewhere, then you will cause some > very nasty corruption. > Okay, I see your point. I think there isn't a way to avoid caller specific struct such as: struct nmi_queuable_work_struct { struct work_struct work; struct irq_work iw; }; So in that case will shift to approach as suggested by Doug to rather have a new nmi_schedule_work() API. -Sumit > > Daniel.