drivers/ntb/test/ntb_perf.c
Source file repositories/reference/linux-study-clean/drivers/ntb/test/ntb_perf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ntb/test/ntb_perf.c- Extension
.c- Size
- 39447 bytes
- Lines
- 1566
- Domain
- Driver Families
- Bucket
- drivers/ntb
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/init.hlinux/kernel.hlinux/module.hlinux/sched.hlinux/wait.hlinux/dma-mapping.hlinux/dmaengine.hlinux/pci.hlinux/ktime.hlinux/slab.hlinux/delay.hlinux/sizes.hlinux/workqueue.hlinux/debugfs.hlinux/random.hlinux/ntb.h
Detected Declarations
struct perf_ctxstruct perf_peerstruct perf_threadstruct perf_ctxenum perf_cmdfunction perf_link_is_upfunction perf_spad_cmd_sendfunction perf_spad_cmd_recvfunction perf_msg_cmd_sendfunction perf_msg_cmd_recvfunction perf_cmd_sendfunction perf_cmd_execfunction perf_cmd_recvfunction perf_link_eventfunction test_and_clear_bitfunction perf_db_eventfunction perf_msg_eventfunction perf_free_outbuffunction perf_setup_outbuffunction perf_free_inbuffunction perf_setup_inbuffunction perf_service_workfunction perf_init_servicefunction perf_enable_servicefunction perf_disable_servicefunction perf_dma_copy_callbackfunction perf_copy_chunkfunction perf_dma_filterfunction perf_init_testfunction perf_run_testfunction perf_sync_testfunction perf_clear_testfunction perf_thread_workfunction perf_set_tcntfunction perf_terminate_testfunction perf_submit_testfunction perf_read_statsfunction perf_init_threadsfunction perf_clear_threadsfunction perf_dbgfs_read_infofunction perf_dbgfs_read_runfunction perf_dbgfs_write_runfunction perf_dbgfs_read_tcntfunction perf_dbgfs_write_tcntfunction perf_setup_dbgfsfunction perf_clear_dbgfsfunction perf_setup_peer_mwfunction perf_init_peers
Annotated Snippet
static const struct file_operations perf_dbgfs_info = {
.open = simple_open,
.read = perf_dbgfs_read_info
};
static ssize_t perf_dbgfs_read_run(struct file *filep, char __user *ubuf,
size_t size, loff_t *offp)
{
struct perf_ctx *perf = filep->private_data;
ssize_t ret, pos = 0;
char *buf;
buf = kmalloc(PERF_BUF_LEN, GFP_KERNEL);
if (!buf)
return -ENOMEM;
ret = perf_read_stats(perf, buf, PERF_BUF_LEN, &pos);
if (ret)
goto err_free;
ret = simple_read_from_buffer(ubuf, size, offp, buf, pos);
err_free:
kfree(buf);
return ret;
}
static ssize_t perf_dbgfs_write_run(struct file *filep, const char __user *ubuf,
size_t size, loff_t *offp)
{
struct perf_ctx *perf = filep->private_data;
struct perf_peer *peer;
int pidx, ret;
ret = kstrtoint_from_user(ubuf, size, 0, &pidx);
if (ret)
return ret;
if (pidx < 0 || pidx >= perf->pcnt)
return -EINVAL;
peer = &perf->peers[pidx];
ret = perf_submit_test(peer);
if (ret)
return ret;
return size;
}
static const struct file_operations perf_dbgfs_run = {
.open = simple_open,
.read = perf_dbgfs_read_run,
.write = perf_dbgfs_write_run
};
static ssize_t perf_dbgfs_read_tcnt(struct file *filep, char __user *ubuf,
size_t size, loff_t *offp)
{
struct perf_ctx *perf = filep->private_data;
char buf[8];
ssize_t pos;
pos = scnprintf(buf, sizeof(buf), "%hhu\n", perf->tcnt);
return simple_read_from_buffer(ubuf, size, offp, buf, pos);
}
static ssize_t perf_dbgfs_write_tcnt(struct file *filep,
const char __user *ubuf,
size_t size, loff_t *offp)
{
struct perf_ctx *perf = filep->private_data;
int ret;
u8 val;
ret = kstrtou8_from_user(ubuf, size, 0, &val);
if (ret)
return ret;
ret = perf_set_tcnt(perf, val);
if (ret)
return ret;
return size;
}
static const struct file_operations perf_dbgfs_tcnt = {
.open = simple_open,
.read = perf_dbgfs_read_tcnt,
Annotation
- Immediate include surface: `linux/init.h`, `linux/kernel.h`, `linux/module.h`, `linux/sched.h`, `linux/wait.h`, `linux/dma-mapping.h`, `linux/dmaengine.h`, `linux/pci.h`.
- Detected declarations: `struct perf_ctx`, `struct perf_peer`, `struct perf_thread`, `struct perf_ctx`, `enum perf_cmd`, `function perf_link_is_up`, `function perf_spad_cmd_send`, `function perf_spad_cmd_recv`, `function perf_msg_cmd_send`, `function perf_msg_cmd_recv`.
- Atlas domain: Driver Families / drivers/ntb.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.