lib/dim/net_dim.c
Source file repositories/reference/linux-study-clean/lib/dim/net_dim.c
File Facts
- System
- Linux kernel
- Corpus path
lib/dim/net_dim.c- Extension
.c- Size
- 9438 bytes
- Lines
- 380
- Domain
- Kernel Services
- Bucket
- lib
- Inferred role
- Kernel Services: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/dim.hlinux/rtnetlink.h
Detected Declarations
function net_dim_get_rx_moderationfunction net_dim_get_def_rx_moderationfunction net_dim_get_tx_moderationfunction net_dim_get_def_tx_moderationfunction net_dim_init_irq_moderfunction net_dim_free_irq_moderfunction net_dim_settingfunction net_dim_work_cancelfunction net_dim_get_rx_irq_moderfunction net_dim_get_tx_irq_moderfunction net_dim_set_rx_modefunction net_dim_set_tx_modefunction net_dim_stepfunction net_dim_exit_parkingfunction net_dim_stats_comparefunction net_dim_decisionfunction net_dimexport net_dim_get_rx_moderationexport net_dim_get_def_rx_moderationexport net_dim_get_tx_moderationexport net_dim_get_def_tx_moderationexport net_dim_init_irq_moderexport net_dim_free_irq_moderexport net_dim_settingexport net_dim_work_cancelexport net_dim_get_rx_irq_moderexport net_dim_get_tx_irq_moderexport net_dim_set_rx_modeexport net_dim_set_tx_modeexport net_dim
Annotated Snippet
if (dim_on_top(dim)) {
dim_park_on_top(dim);
break;
}
step_res = net_dim_step(dim);
switch (step_res) {
case DIM_ON_EDGE:
dim_park_on_top(dim);
break;
case DIM_TOO_TIRED:
dim_park_tired(dim);
break;
}
break;
}
if (prev_state != DIM_PARKING_ON_TOP ||
dim->tune_state != DIM_PARKING_ON_TOP)
dim->prev_stats = *curr_stats;
return dim->profile_ix != prev_ix;
}
void net_dim(struct dim *dim, const struct dim_sample *end_sample)
{
struct dim_stats curr_stats;
u16 nevents;
switch (dim->state) {
case DIM_MEASURE_IN_PROGRESS:
nevents = BIT_GAP(BITS_PER_TYPE(u16),
end_sample->event_ctr,
dim->start_sample.event_ctr);
if (nevents < DIM_NEVENTS)
break;
if (!dim_calc_stats(&dim->start_sample, end_sample, &curr_stats))
break;
if (net_dim_decision(&curr_stats, dim)) {
dim->state = DIM_APPLY_NEW_PROFILE;
schedule_work(&dim->work);
break;
}
fallthrough;
case DIM_START_MEASURE:
dim_update_sample(end_sample->event_ctr, end_sample->pkt_ctr,
end_sample->byte_ctr, &dim->start_sample);
dim->state = DIM_MEASURE_IN_PROGRESS;
break;
case DIM_APPLY_NEW_PROFILE:
break;
}
}
EXPORT_SYMBOL(net_dim);
Annotation
- Immediate include surface: `linux/dim.h`, `linux/rtnetlink.h`.
- Detected declarations: `function net_dim_get_rx_moderation`, `function net_dim_get_def_rx_moderation`, `function net_dim_get_tx_moderation`, `function net_dim_get_def_tx_moderation`, `function net_dim_init_irq_moder`, `function net_dim_free_irq_moder`, `function net_dim_setting`, `function net_dim_work_cancel`, `function net_dim_get_rx_irq_moder`, `function net_dim_get_tx_irq_moder`.
- Atlas domain: Kernel Services / lib.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.