1 /* 2 * SPDX-FileCopyrightText: Copyright (c) 2015-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 * SPDX-License-Identifier: MIT 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in 13 * all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 */ 23 24 /*! 25 * This file defines the internal interfaces to the NUMA allocator component, 26 * used by parent module PMA. 27 * 28 * All interfaces here should only be used on PowerPC 9 systems with NUMA 29 * mode enabled, where GPU's framebuffer memory is onlined to the Linux kernel. 30 * 31 * Therefore, PMA just needs to sub-allocate from the Linux kernel for most 32 * allocation requests. However, PMA does keep states in order to support 33 * eviction and GPU scrubber. Please see below for more details. 34 */ 35 36 #ifndef NUMA_H 37 #define NUMA_H 38 39 #include "nvport/nvport.h" 40 #include "phys_mem_allocator.h" 41 #include "nvmisc.h" 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 48 /*! 49 * @brief Handles NUMA allocation by calling kernel APIs 50 * 51 * This function will implement a mixture of pass-through memory allocation 52 * from the Linux kernel as well as eviction from UVM if the Linux kernel 53 * does not have any free memory. 54 * 55 * From a high level, PMA keep a bitmap for all UVM unpinned (evictable) 56 * allocations and PMA will decide to kick off eviction based on the bitmap. 57 * 58 * Please note that GPU scrubber is used for any memory evicted and CPU scrubber 59 * is used for allocations coming from the Linux kernel. 60 * The perf implication is under further study. See bug #1999793. 61 */ 62 NV_STATUS pmaNumaAllocate(PMA *pPma, NvLength allocationCount, NvU64 pageSize, 63 PMA_ALLOCATION_OPTIONS *allocationOptions, NvU64 *pPages); 64 65 /*! 66 * @brief Frees pages on a NUMA node. 67 * This function implements pass-through free calls to the Linux kernel. 68 * For UVM allocations PMA also updates the bitmap used for eviction. 69 */ 70 void pmaNumaFreeInternal(PMA *pPma, NvU64 *pPages, NvU64 pageCount, NvU64 size, NvU32 flag); 71 72 void pmaNumaSetReclaimSkipThreshold(PMA *pPma, NvU32 skipReclaimPercent); 73 #ifdef __cplusplus 74 } 75 #endif 76 77 #endif // NUMA_H 78