mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 10:34:43 +03:00
gpu: nvgpu: Move kmem_caches to allocator
Instead of using a single static kmem_cache for each type of data structure the allocators may want to allocate each allocator now has its own instance of the kmem_cache. This is done so that each GPU driver instance can accurately track how much memory it is using. In order to support this on older kernels a new NVGPU API has been made, nvgpu_kmem_cache_create(struct gk20a *g, size_t size) To handle the possibility that caches cannot be created with the same name. This patch also fixes numerous places where kfree() was wrongly used to free kmem_cache allocs. Bug 1799159 Bug 1823380 Change-Id: Id674f9a5445fde3f95db65ad6bf3ea990444603d Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: http://git-master/r/1283826 Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com> Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> GVS: Gerrit_Virtual_Submit
This commit is contained in:
committed by
mobile promotions
parent
24e8ee192a
commit
cf0ef133e6
40
drivers/gpu/nvgpu/include/nvgpu/kmem.h
Normal file
40
drivers/gpu/nvgpu/include/nvgpu/kmem.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NVGPU_KMEM_H
|
||||
#define NVGPU_KMEM_H
|
||||
|
||||
struct gk20a;
|
||||
|
||||
/*
|
||||
* In Linux there is support for the notion of a kmem_cache. It gives better
|
||||
* memory usage characteristics for lots of allocations of the same size. Think
|
||||
* structs that get allocated over and over. Normal kmalloc() type routines
|
||||
* typically round to the next power-of-2 since that's easy.
|
||||
*
|
||||
* But if we know the size ahead of time the packing for the allocations can be
|
||||
* much better. This is the benefit of a slab allocator. This type hides the
|
||||
* underlying kmem_cache (or absense thereof).
|
||||
*/
|
||||
struct nvgpu_kmem_cache;
|
||||
|
||||
struct nvgpu_kmem_cache *nvgpu_kmem_cache_create(struct gk20a *g, size_t size);
|
||||
void nvgpu_kmem_cache_destroy(struct nvgpu_kmem_cache *cache);
|
||||
|
||||
void *nvgpu_kmem_cache_alloc(struct nvgpu_kmem_cache *cache);
|
||||
void nvgpu_kmem_cache_free(struct nvgpu_kmem_cache *cache, void *ptr);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user