kernel/irq/irq_test.c
Source file repositories/reference/linux-study-clean/kernel/irq/irq_test.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/irq/irq_test.c- Extension
.c- Size
- 5720 bytes
- Lines
- 237
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/cleanup.hlinux/cpu.hlinux/cpumask.hlinux/interrupt.hlinux/irq.hlinux/irqdesc.hlinux/irqdomain.hlinux/nodemask.hkunit/test.hinternals.h
Detected Declarations
function noop_handlerfunction noopfunction noop_affinityfunction irq_test_setup_fake_irqfunction irq_disable_depth_testfunction irq_free_disabled_testfunction irq_shutdown_depth_testfunction irq_cpuhotplug_test
Annotated Snippet
static void noop(struct irq_data *data) { }
static unsigned int noop_ret(struct irq_data *data) { return 0; }
static int noop_affinity(struct irq_data *data, const struct cpumask *dest,
bool force)
{
irq_data_update_effective_affinity(data, dest);
return 0;
}
static struct irq_chip fake_irq_chip = {
.name = "fake",
.irq_startup = noop_ret,
.irq_shutdown = noop,
.irq_enable = noop,
.irq_disable = noop,
.irq_ack = noop,
.irq_mask = noop,
.irq_unmask = noop,
.irq_set_affinity = noop_affinity,
.flags = IRQCHIP_SKIP_SET_WAKE,
};
static int irq_test_setup_fake_irq(struct kunit *test, struct irq_affinity_desc *affd)
{
struct irq_desc *desc;
int virq;
virq = irq_domain_alloc_descs(-1, 1, 0, NUMA_NO_NODE, affd);
KUNIT_ASSERT_GE(test, virq, 0);
irq_set_chip_and_handler(virq, &fake_irq_chip, handle_simple_irq);
desc = irq_to_desc(virq);
KUNIT_ASSERT_PTR_NE(test, desc, NULL);
/* On some architectures, IRQs are NOREQUEST | NOPROBE by default. */
irq_settings_clr_norequest(desc);
return virq;
}
static void irq_disable_depth_test(struct kunit *test)
{
struct irq_desc *desc;
int virq, ret;
virq = irq_test_setup_fake_irq(test, NULL);
desc = irq_to_desc(virq);
KUNIT_ASSERT_PTR_NE(test, desc, NULL);
ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
KUNIT_ASSERT_EQ(test, ret, 0);
KUNIT_EXPECT_EQ(test, desc->depth, 0);
disable_irq(virq);
KUNIT_EXPECT_EQ(test, desc->depth, 1);
enable_irq(virq);
KUNIT_EXPECT_EQ(test, desc->depth, 0);
free_irq(virq, NULL);
}
static void irq_free_disabled_test(struct kunit *test)
{
struct irq_desc *desc;
int virq, ret;
virq = irq_test_setup_fake_irq(test, NULL);
desc = irq_to_desc(virq);
KUNIT_ASSERT_PTR_NE(test, desc, NULL);
ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
KUNIT_ASSERT_EQ(test, ret, 0);
KUNIT_EXPECT_EQ(test, desc->depth, 0);
disable_irq(virq);
KUNIT_EXPECT_EQ(test, desc->depth, 1);
free_irq(virq, NULL);
KUNIT_EXPECT_GE(test, desc->depth, 1);
ret = request_irq(virq, noop_handler, 0, "test_irq", NULL);
KUNIT_ASSERT_EQ(test, ret, 0);
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/cpu.h`, `linux/cpumask.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/irqdesc.h`, `linux/irqdomain.h`, `linux/nodemask.h`.
- Detected declarations: `function noop_handler`, `function noop`, `function noop_affinity`, `function irq_test_setup_fake_irq`, `function irq_disable_depth_test`, `function irq_free_disabled_test`, `function irq_shutdown_depth_test`, `function irq_cpuhotplug_test`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.