Files
laptops-kernel/include/linux/cgroup_rdma.h
Jiri PirkoandLeon Romanovsky c4ef67e5aa RDMA/cgroup: Disambiguate devices across net namespaces
RDMA device names are unique only within a network namespace, but an
RDMA cgroup can account resources for devices from multiple namespaces.
Duplicate names therefore make cgroup output ambiguous and can cause
limit writes to select the wrong device.

Use the system-wide RDMA device index to distinguish duplicate names
while preserving the existing UAPI for unique names. Reject ambiguous
name-only writes with -ENOTUNIQ and expose a complete device view to
administrators.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Link: https://patch.msgid.link/20260716132316.1495242-9-jiri@resnulli.us
Signed-off-by: Leon Romanovsky <leon@kernel.org>
2026-07-26 03:11:00 -04:00

56 lines
1.3 KiB
C

/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (C) 2016 Parav Pandit <pandit.parav@gmail.com>
*/
#ifndef _CGROUP_RDMA_H
#define _CGROUP_RDMA_H
#include <linux/cgroup.h>
enum rdmacg_resource_type {
RDMACG_RESOURCE_HCA_HANDLE,
RDMACG_RESOURCE_HCA_OBJECT,
RDMACG_RESOURCE_MAX,
};
#ifdef CONFIG_CGROUP_RDMA
struct rdma_cgroup {
struct cgroup_subsys_state css;
/*
* head to keep track of all resource pools
* that belongs to this cgroup.
*/
struct list_head rpools;
/* Handles for rdma.events[.local] */
struct cgroup_file events_file;
struct cgroup_file events_local_file;
};
struct rdmacg_device {
struct list_head dev_node;
struct list_head rpools;
char *name;
u32 index;
};
/*
* APIs for RDMA/IB stack to publish when a device wants to
* participate in resource accounting
*/
void rdmacg_register_device(struct rdmacg_device *device);
void rdmacg_unregister_device(struct rdmacg_device *device);
/* APIs for RDMA/IB stack to charge/uncharge pool specific resources */
int rdmacg_try_charge(struct rdma_cgroup **rdmacg,
struct rdmacg_device *device,
enum rdmacg_resource_type index);
void rdmacg_uncharge(struct rdma_cgroup *cg,
struct rdmacg_device *device,
enum rdmacg_resource_type index);
#endif /* CONFIG_CGROUP_RDMA */
#endif /* _CGROUP_RDMA_H */