From cad414d3102fc829fd5c9be73027fe6eefa7bc2d Mon Sep 17 00:00:00 2001 From: Martin Radev Date: Tue, 2 May 2023 09:49:37 +0300 Subject: [PATCH] gpu: nvgpu: Expose NUMA domain id This patch exposes the NUMA domain id for the Linux device to userspace. This information is necessary for userspace to make better utilization of physical memory allocation and CPU scheduling. Bug 3972227 Change-Id: I9ad0369076d22531e154074d616e5a23e374a7e9 Signed-off-by: Martin Radev Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2897294 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c | 2 ++ include/uapi/linux/nvgpu-ctrl.h | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c index d24449efb..ce0679dca 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c @@ -399,6 +399,8 @@ static long gk20a_ctrl_ioctl_gpu_characteristics( gpu.device_instance_id = priv->device_instance_id; #endif + gpu.numa_domain_id = dev_to_node(dev_from_gk20a(g)); + gpu.L2_cache_size = g->ops.ltc.determine_L2_size_bytes(g); gpu.on_board_video_memory_size = 0; /* integrated GPU */ diff --git a/include/uapi/linux/nvgpu-ctrl.h b/include/uapi/linux/nvgpu-ctrl.h index c1edbbab2..dfb0a3f98 100644 --- a/include/uapi/linux/nvgpu-ctrl.h +++ b/include/uapi/linux/nvgpu-ctrl.h @@ -220,6 +220,13 @@ struct nvgpu_gpu_characteristics { __u32 rev; __u32 num_gpc; + /* + * Specifies the NUMA domain for the GPU device + * A value of "-1" specifies no NUMA domain info. + */ +#define NVGPU_GPU_CHARACTERISTICS_NO_NUMA_INFO (-1) + __s32 numa_domain_id; + __u64 L2_cache_size; /* bytes */ __u64 on_board_video_memory_size; /* bytes */