linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Jason Andryuk <jandryuk@gmail.com>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: Calling queue_work() multiple times with the same work_struct
Date: Thu, 20 May 2021 13:01:25 -0400	[thread overview]
Message-ID: <YKaV5ej3WrUJQa7/@slm.duckdns.org> (raw)
In-Reply-To: <CAKf6xptjmd9BMuiKpRgj1YyyR97gGXKgYgj-4CKaTvBk4+FeoA@mail.gmail.com>

Hello, Jason.

On Thu, May 20, 2021 at 08:39:56AM -0400, Jason Andryuk wrote:
> 1 & 2 look supported from workqueue.h.  Is the 3rd case true and
> guaranteed?  Is it okay to re-use the same work_struct in that case

Yes.

> while it's being executed?  A work_struct function can re-queue

Yes.

> itself, so I hope #3 is supported.

Yes.

> DECLARE_WORK(argo_work, argo_work_fn);
> static struct workqueue_struct *argo_wq = alloc_workqueue("argo_wq",
>                     WQ_UNBOUND | WQ_HIGHPRI | WQ_CPU_INTENSIVE | WQ_SYSFS, 1);

I don't know what the device is but does it need both HIGHPRI and
CPU_INTENSIVE?

> static void argo_work_fn(struct work_struct *work)
> {
>     argo_interrupt_rx();  /* iterates multiple "rings" */
>     argo_notify();
> }
> 
> static irqreturn_t argo_interrupt(int irq, void *dev_id)
> {
>     queue_work(argo_wq, &argo_work);
> 
>     return IRQ_HANDLED;
> }

Yeah, the above will guarantee that the work function would run at least
once since the last invocation of argo_interrupt().

Thanks.

-- 
tejun

  reply	other threads:[~2021-05-20 17:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-20 12:39 Calling queue_work() multiple times with the same work_struct Jason Andryuk
2021-05-20 17:01 ` Tejun Heo [this message]
2021-05-20 17:31   ` Jason Andryuk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YKaV5ej3WrUJQa7/@slm.duckdns.org \
    --to=tj@kernel.org \
    --cc=jandryuk@gmail.com \
    --cc=jiangshanlai@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).