mirror of
https://github.com/torvalds/linux.git
synced 2024-11-18 18:11:56 +00:00
2025cf9e19
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms and conditions of the gnu general public license version 2 as published by the free software foundation this program is distributed in the hope it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 263 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Alexios Zavras <alexios.zavras@intel.com> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190529141901.208660670@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
54 lines
1.5 KiB
C
54 lines
1.5 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (C) 2016 Parav Pandit <pandit.parav@gmail.com>
|
|
*/
|
|
|
|
#include "core_priv.h"
|
|
|
|
/**
|
|
* ib_device_register_rdmacg - register with rdma cgroup.
|
|
* @device: device to register to participate in resource
|
|
* accounting by rdma cgroup.
|
|
*
|
|
* Register with the rdma cgroup. Should be called before
|
|
* exposing rdma device to user space applications to avoid
|
|
* resource accounting leak.
|
|
*/
|
|
void ib_device_register_rdmacg(struct ib_device *device)
|
|
{
|
|
device->cg_device.name = device->name;
|
|
rdmacg_register_device(&device->cg_device);
|
|
}
|
|
|
|
/**
|
|
* ib_device_unregister_rdmacg - unregister with rdma cgroup.
|
|
* @device: device to unregister.
|
|
*
|
|
* Unregister with the rdma cgroup. Should be called after
|
|
* all the resources are deallocated, and after a stage when any
|
|
* other resource allocation by user application cannot be done
|
|
* for this device to avoid any leak in accounting.
|
|
*/
|
|
void ib_device_unregister_rdmacg(struct ib_device *device)
|
|
{
|
|
rdmacg_unregister_device(&device->cg_device);
|
|
}
|
|
|
|
int ib_rdmacg_try_charge(struct ib_rdmacg_object *cg_obj,
|
|
struct ib_device *device,
|
|
enum rdmacg_resource_type resource_index)
|
|
{
|
|
return rdmacg_try_charge(&cg_obj->cg, &device->cg_device,
|
|
resource_index);
|
|
}
|
|
EXPORT_SYMBOL(ib_rdmacg_try_charge);
|
|
|
|
void ib_rdmacg_uncharge(struct ib_rdmacg_object *cg_obj,
|
|
struct ib_device *device,
|
|
enum rdmacg_resource_type resource_index)
|
|
{
|
|
rdmacg_uncharge(cg_obj->cg, &device->cg_device,
|
|
resource_index);
|
|
}
|
|
EXPORT_SYMBOL(ib_rdmacg_uncharge);
|