kernel/dma/map_benchmark.c
Source file repositories/reference/linux-study-clean/kernel/dma/map_benchmark.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/dma/map_benchmark.c- Extension
.c- Size
- 14332 bytes
- Lines
- 579
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/cleanup.hlinux/debugfs.hlinux/delay.hlinux/device.hlinux/dma-mapping.hlinux/kernel.hlinux/kthread.hlinux/math64.hlinux/module.hlinux/pci.hlinux/platform_device.hlinux/scatterlist.hlinux/slab.hlinux/timekeeping.huapi/linux/map_benchmark.h
Detected Declarations
struct map_benchmark_datastruct map_benchmark_opsstruct dma_single_map_paramstruct dma_sg_map_paramfunction dma_single_map_benchmark_unpreparefunction dma_single_map_benchmark_initialize_datafunction dma_single_map_benchmark_do_mapfunction dma_single_map_benchmark_do_unmapfunction for_each_sgtable_sgfunction dma_sg_map_benchmark_unpreparefunction dma_sg_map_benchmark_initialize_datafunction dma_sg_map_benchmark_do_mapfunction dma_sg_map_benchmark_do_unmapfunction map_benchmark_threadfunction do_map_benchmarkfunction map_benchmark_ioctlfunction map_benchmark_remove_debugfsfunction __map_benchmark_probefunction map_benchmark_platform_probefunction map_benchmark_pci_probefunction map_benchmark_initfunction map_benchmark_cleanupmodule init map_benchmark_init
Annotated Snippet
static const struct file_operations map_benchmark_fops = {
.open = simple_open,
.unlocked_ioctl = map_benchmark_ioctl,
};
static void map_benchmark_remove_debugfs(void *data)
{
struct map_benchmark_data *map = (struct map_benchmark_data *)data;
debugfs_remove(map->debugfs);
}
static int __map_benchmark_probe(struct device *dev)
{
struct dentry *entry;
struct map_benchmark_data *map;
int ret;
map = devm_kzalloc(dev, sizeof(*map), GFP_KERNEL);
if (!map)
return -ENOMEM;
map->dev = dev;
ret = devm_add_action(dev, map_benchmark_remove_debugfs, map);
if (ret) {
pr_err("Can't add debugfs remove action\n");
return ret;
}
/*
* we only permit a device bound with this driver, 2nd probe
* will fail
*/
entry = debugfs_create_file("dma_map_benchmark", 0600, NULL, map,
&map_benchmark_fops);
if (IS_ERR(entry))
return PTR_ERR(entry);
map->debugfs = entry;
return 0;
}
static int map_benchmark_platform_probe(struct platform_device *pdev)
{
return __map_benchmark_probe(&pdev->dev);
}
static struct platform_driver map_benchmark_platform_driver = {
.driver = {
.name = "dma_map_benchmark",
},
.probe = map_benchmark_platform_probe,
};
static int
map_benchmark_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
return __map_benchmark_probe(&pdev->dev);
}
static struct pci_driver map_benchmark_pci_driver = {
.name = "dma_map_benchmark",
.probe = map_benchmark_pci_probe,
};
static int __init map_benchmark_init(void)
{
int ret;
ret = pci_register_driver(&map_benchmark_pci_driver);
if (ret)
return ret;
ret = platform_driver_register(&map_benchmark_platform_driver);
if (ret) {
pci_unregister_driver(&map_benchmark_pci_driver);
return ret;
}
return 0;
}
static void __exit map_benchmark_cleanup(void)
{
platform_driver_unregister(&map_benchmark_platform_driver);
pci_unregister_driver(&map_benchmark_pci_driver);
}
module_init(map_benchmark_init);
module_exit(map_benchmark_cleanup);
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/debugfs.h`, `linux/delay.h`, `linux/device.h`, `linux/dma-mapping.h`, `linux/kernel.h`, `linux/kthread.h`, `linux/math64.h`.
- Detected declarations: `struct map_benchmark_data`, `struct map_benchmark_ops`, `struct dma_single_map_param`, `struct dma_sg_map_param`, `function dma_single_map_benchmark_unprepare`, `function dma_single_map_benchmark_initialize_data`, `function dma_single_map_benchmark_do_map`, `function dma_single_map_benchmark_do_unmap`, `function for_each_sgtable_sg`, `function dma_sg_map_benchmark_unprepare`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.