kernel/cgroup/rdma.c
Source file repositories/reference/linux-study-clean/kernel/cgroup/rdma.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/cgroup/rdma.c- Extension
.c- Size
- 20760 bytes
- Lines
- 790
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration 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.
- 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/bitops.hlinux/limits.hlinux/slab.hlinux/seq_file.hlinux/cgroup.hlinux/parser.hlinux/cgroup_rdma.h
Detected Declarations
struct rdmacg_resourcestruct rdmacg_resource_poolenum rdmacg_limit_tokensenum rdmacg_file_typefunction set_resource_limitfunction set_all_resource_max_limitfunction free_cg_rpool_lockedfunction rpool_has_persistent_statefunction find_cg_rpool_lockedfunction get_cg_rpool_lockedfunction uncharge_cg_lockedfunction cgroup_file_notifyfunction rdmacg_uncharge_hierarchyfunction rdmacg_unchargefunction rdmacg_try_chargefunction rdmacg_register_devicefunction rdmacg_register_devicefunction rdmacg_resource_set_maxfunction print_rpool_valuesfunction rdmacg_resource_readfunction list_for_each_entryfunction rdmacg_events_showfunction list_for_each_entryfunction rdmacg_events_local_showfunction list_for_each_entryfunction rdmacg_css_allocfunction rdmacg_css_freefunction rdmacg_css_offlineexport rdmacg_unchargeexport rdmacg_try_chargeexport rdmacg_register_deviceexport rdmacg_unregister_device
Annotated Snippet
struct rdmacg_resource {
int max;
int usage;
int peak;
};
/*
* resource pool object which represents per cgroup, per device
* resources. There are multiple instances of this object per cgroup,
* therefore it cannot be embedded within rdma_cgroup structure. It
* is maintained as list.
*/
struct rdmacg_resource_pool {
struct rdmacg_device *device;
struct rdmacg_resource resources[RDMACG_RESOURCE_MAX];
struct list_head cg_node;
struct list_head dev_node;
/* count active user tasks of this pool */
u64 usage_sum;
/* total number counts which are set to max */
int num_max_cnt;
/* per-resource event counters */
u64 events_max[RDMACG_RESOURCE_MAX];
u64 events_alloc_fail[RDMACG_RESOURCE_MAX];
u64 events_local_max[RDMACG_RESOURCE_MAX];
u64 events_local_alloc_fail[RDMACG_RESOURCE_MAX];
};
static struct rdma_cgroup *css_rdmacg(struct cgroup_subsys_state *css)
{
return container_of(css, struct rdma_cgroup, css);
}
static struct rdma_cgroup *parent_rdmacg(struct rdma_cgroup *cg)
{
return css_rdmacg(cg->css.parent);
}
static inline struct rdma_cgroup *get_current_rdmacg(void)
{
return css_rdmacg(task_get_css(current, rdma_cgrp_id));
}
static void set_resource_limit(struct rdmacg_resource_pool *rpool,
int index, int new_max)
{
if (new_max == S32_MAX) {
if (rpool->resources[index].max != S32_MAX)
rpool->num_max_cnt++;
} else {
if (rpool->resources[index].max == S32_MAX)
rpool->num_max_cnt--;
}
rpool->resources[index].max = new_max;
}
static void set_all_resource_max_limit(struct rdmacg_resource_pool *rpool)
{
int i;
for (i = 0; i < RDMACG_RESOURCE_MAX; i++)
set_resource_limit(rpool, i, S32_MAX);
}
static void free_cg_rpool_locked(struct rdmacg_resource_pool *rpool)
{
lockdep_assert_held(&rdmacg_mutex);
list_del(&rpool->cg_node);
list_del(&rpool->dev_node);
kfree(rpool);
}
static bool rpool_has_persistent_state(struct rdmacg_resource_pool *rpool)
{
int i;
/*
* Keep the rpool alive if any peak value is non-zero,
* so that rdma.peak persists as a historical high-
* watermark even after all resources are freed.
*/
for (i = 0; i < RDMACG_RESOURCE_MAX; i++) {
if (rpool->resources[i].peak ||
rpool->events_max[i] ||
rpool->events_local_max[i] ||
rpool->events_alloc_fail[i] ||
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/limits.h`, `linux/slab.h`, `linux/seq_file.h`, `linux/cgroup.h`, `linux/parser.h`, `linux/cgroup_rdma.h`.
- Detected declarations: `struct rdmacg_resource`, `struct rdmacg_resource_pool`, `enum rdmacg_limit_tokens`, `enum rdmacg_file_type`, `function set_resource_limit`, `function set_all_resource_max_limit`, `function free_cg_rpool_locked`, `function rpool_has_persistent_state`, `function find_cg_rpool_locked`, `function get_cg_rpool_locked`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- 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.