block/bfq-cgroup.c
Source file repositories/reference/linux-study-clean/block/bfq-cgroup.c
File Facts
- System
- Linux kernel
- Corpus path
block/bfq-cgroup.c- Extension
.c- Size
- 38365 bytes
- Lines
- 1449
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: implementation source
- Status
- source implementation candidate
Why This File Exists
Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- 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/module.hlinux/slab.hlinux/blkdev.hlinux/cgroup.hlinux/ktime.hlinux/rbtree.hlinux/ioprio.hlinux/sbitmap.hlinux/delay.helevator.hbfq-iosched.h
Detected Declarations
enum bfqg_stats_flagsfunction bfq_stat_initfunction bfq_stat_exitfunction bfq_stat_addfunction bfq_stat_readfunction bfq_stat_resetfunction bfq_stat_add_auxfunction blkg_prfill_statfunction bfqg_stats_update_group_wait_timefunction bfqg_stats_set_start_group_wait_timefunction bfqg_stats_end_empty_timefunction bfqg_stats_update_dequeuefunction bfqg_stats_set_start_empty_timefunction bfqg_stats_update_idle_timefunction bfqg_stats_set_start_idle_timefunction bfqg_stats_update_avg_queue_sizefunction bfqg_stats_update_io_addfunction bfqg_stats_update_io_removefunction bfqg_stats_update_io_mergedfunction bfqg_stats_update_completionfunction bfqg_stats_update_io_removefunction bfqg_stats_exitfunction bfqg_getfunction bfqg_putfunction bfqg_and_blkg_getfunction bfqg_and_blkg_putfunction bfqg_stats_update_legacy_iofunction bfqg_stats_resetfunction bfqg_stats_add_auxfunction bfqg_stats_xfer_deadfunction bfq_init_entityfunction bfqg_stats_initfunction bfq_cpd_freefunction bfq_pd_initfunction bfq_pd_freefunction bfq_pd_reset_statsfunction bfq_group_set_parentfunction bfq_link_bfqgfunction bfq_bfqq_movefunction bfq_sync_bfqq_movefunction callfunction bfq_bic_update_cgroupfunction bfq_flush_idle_treefunction bfq_reparent_leaf_entityfunction bfq_reparent_active_queuesfunction bfq_pd_offlinefunction bfq_end_wr_asyncfunction list_for_each_entry
Annotated Snippet
void bfqg_stats_update_io_remove(struct bfq_group *bfqg, blk_opf_t opf) { }
void bfqg_stats_update_io_merged(struct bfq_group *bfqg, blk_opf_t opf) { }
void bfqg_stats_update_completion(struct bfq_group *bfqg, u64 start_time_ns,
u64 io_start_time_ns, blk_opf_t opf) { }
void bfqg_stats_update_dequeue(struct bfq_group *bfqg) { }
void bfqg_stats_set_start_idle_time(struct bfq_group *bfqg) { }
#endif /* CONFIG_BFQ_CGROUP_DEBUG */
#ifdef CONFIG_BFQ_GROUP_IOSCHED
/*
* blk-cgroup policy-related handlers
* The following functions help in converting between blk-cgroup
* internal structures and BFQ-specific structures.
*/
static struct bfq_group *pd_to_bfqg(struct blkg_policy_data *pd)
{
return pd ? container_of(pd, struct bfq_group, pd) : NULL;
}
struct blkcg_gq *bfqg_to_blkg(struct bfq_group *bfqg)
{
return pd_to_blkg(&bfqg->pd);
}
static struct bfq_group *blkg_to_bfqg(struct blkcg_gq *blkg)
{
return pd_to_bfqg(blkg_to_pd(blkg, &blkcg_policy_bfq));
}
/*
* bfq_group handlers
* The following functions help in navigating the bfq_group hierarchy
* by allowing to find the parent of a bfq_group or the bfq_group
* associated to a bfq_queue.
*/
static struct bfq_group *bfqg_parent(struct bfq_group *bfqg)
{
struct blkcg_gq *pblkg = bfqg_to_blkg(bfqg)->parent;
return pblkg ? blkg_to_bfqg(pblkg) : NULL;
}
static void bfqg_stats_exit(struct bfqg_stats *stats)
{
blkg_rwstat_exit(&stats->bytes);
blkg_rwstat_exit(&stats->ios);
#ifdef CONFIG_BFQ_CGROUP_DEBUG
blkg_rwstat_exit(&stats->merged);
blkg_rwstat_exit(&stats->service_time);
blkg_rwstat_exit(&stats->wait_time);
blkg_rwstat_exit(&stats->queued);
bfq_stat_exit(&stats->time);
bfq_stat_exit(&stats->avg_queue_size_sum);
bfq_stat_exit(&stats->avg_queue_size_samples);
bfq_stat_exit(&stats->dequeue);
bfq_stat_exit(&stats->group_wait_time);
bfq_stat_exit(&stats->idle_time);
bfq_stat_exit(&stats->empty_time);
#endif
}
struct bfq_group *bfqq_group(struct bfq_queue *bfqq)
{
struct bfq_entity *group_entity = bfqq->entity.parent;
return group_entity ? container_of(group_entity, struct bfq_group,
entity) :
bfqq->bfqd->root_group;
}
/*
* The following two functions handle get and put of a bfq_group by
* wrapping the related blk-cgroup hooks.
*/
static void bfqg_get(struct bfq_group *bfqg)
{
refcount_inc(&bfqg->ref);
}
static void bfqg_put(struct bfq_group *bfqg)
{
if (refcount_dec_and_test(&bfqg->ref)) {
bfqg_stats_exit(&bfqg->stats);
kfree(bfqg);
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/blkdev.h`, `linux/cgroup.h`, `linux/ktime.h`, `linux/rbtree.h`, `linux/ioprio.h`, `linux/sbitmap.h`.
- Detected declarations: `enum bfqg_stats_flags`, `function bfq_stat_init`, `function bfq_stat_exit`, `function bfq_stat_add`, `function bfq_stat_read`, `function bfq_stat_reset`, `function bfq_stat_add_aux`, `function blkg_prfill_stat`, `function bfqg_stats_update_group_wait_time`, `function bfqg_stats_set_start_group_wait_time`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: source 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.