| 1 | /*	$OpenBSD: uvm_percpu.h,v 1.3 2024/05/01 12:54:27 mpi Exp $	*/ |
| 2 | |
| 3 | /* |
| 4 | * Copyright (c) 2024 Martin Pieuchot <mpi@openbsd.org> |
| 5 | * |
| 6 | * Permission to use, copy, modify, and distribute this software for any |
| 7 | * purpose with or without fee is hereby granted, provided that the above |
| 8 | * copyright notice and this permission notice appear in all copies. |
| 9 | * |
| 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 17 | */ |
| 18 | |
| 19 | #ifndef _UVM_UVM_PCPU_H_ |
| 20 | #define _UVM_UVM_PCPU_H_ |
| 21 | |
| 22 | struct vm_page; |
| 23 | |
| 24 | /* |
| 25 | * The number of pages per magazine should be large enough to get rid of the |
| 26 | * contention in the pmemrange allocator during concurrent page faults and |
| 27 | * small enough to limit fragmentation. |
| 28 | */ |
| 29 | #define UVM_PMR_CACHEMAGSZ 8 |
| 30 | |
| 31 | /* |
| 32 | * Magazine |
| 33 | */ |
| 34 | struct uvm_pmr_cache_item { |
| 35 | 	struct vm_page		*upci_pages[UVM_PMR_CACHEMAGSZ]; |
| 36 | 	int			 upci_npages;	/* # of pages in magazine */ |
| 37 | }; |
| 38 | |
| 39 | /* |
| 40 | * Per-CPU cache of physical pages. |
| 41 | */ |
| 42 | struct uvm_pmr_cache { |
| 43 | 	struct uvm_pmr_cache_item upc_magz[2];	/* magazines */ |
| 44 | 	int			 upc_actv;	/* index of active magazine */ |
| 45 | |
| 46 | }; |
| 47 | |
| 48 | #endif /* _UVM_UVM_PCPU_H_ */ |