|
|
Log in / Subscribe / Register

Running work in hardware interrupt context

By Jonathan Corbet
October 26, 2010
As a general rule, kernel developers work to avoid running code in hardware interrupt context; there is a whole array of mechanisms by which interrupt-driven work can be deferred to less pressing times. Apparently, however, there is an occasional need to run arbitrary code in the hardware interrupt context - and there is no hardware conveniently signaling interrupts at the time. To enable the running of code in hardware interrupt context, a new API has been added to 2.6.37.

The first step is to fill in an irq_work structure:

    #include <linux/irq_work.h>

    struct irq_work my_work;

    init_irq_work(struct irq_work *entry, void (*func)(struct irq_work *func));

There is then a fairly familiar pair of functions for running the work indicated by this structure:

    bool irq_work_queue(struct irq_work *entry);
    void irq_work_sync(struct irq_work *entry);

The intended area of use is apparently code running from non-maskable interrupts which needs to be able to interact with the rest of the system. One should assume that just about any other use of this feature is likely to be scrutinized closely.


to post comments

Running work in hardware interrupt context

Posted Oct 28, 2010 6:12 UTC (Thu) by zenaan (guest, #3778) [Link]

"One should assume that just about any other use of this feature is likely to be scrutinized closely."
++ Quote of the week.

Running work in hardware interrupt context

Posted Oct 28, 2010 8:39 UTC (Thu) by mlankhorst (subscriber, #52260) [Link] (1 responses)

Why would you want to sync work in irq context?

Running work in hardware interrupt context

Posted Oct 9, 2018 5:49 UTC (Tue) by changbin (guest, #87107) [Link]

Sometimes, you may want code be NMI safe. So you can move code from NMI context to hardirq context.


Copyright © 2010, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds