init.c (4f2c0a4acffbec01079c28f839422e64ddeff004) | init.c (23baf831a32c04f9a968812511540b1b3e648bf5) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * KMSAN initialization routines. 4 * 5 * Copyright (C) 2017-2021 Google LLC 6 * Author: Alexander Potapenko <glider@google.com> 7 * 8 */ --- 82 unchanged lines hidden (view full) --- 91 kmsan_init_alloc_meta_for_range( 92 (void *)start_end_pairs[i].start, 93 (void *)start_end_pairs[i].end); 94} 95 96struct metadata_page_pair { 97 struct page *shadow, *origin; 98}; | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * KMSAN initialization routines. 4 * 5 * Copyright (C) 2017-2021 Google LLC 6 * Author: Alexander Potapenko <glider@google.com> 7 * 8 */ --- 82 unchanged lines hidden (view full) --- 91 kmsan_init_alloc_meta_for_range( 92 (void *)start_end_pairs[i].start, 93 (void *)start_end_pairs[i].end); 94} 95 96struct metadata_page_pair { 97 struct page *shadow, *origin; 98}; |
99static struct metadata_page_pair held_back[MAX_ORDER] __initdata; | 99static struct metadata_page_pair held_back[MAX_ORDER + 1] __initdata; |
100 101/* 102 * Eager metadata allocation. When the memblock allocator is freeing pages to 103 * pagealloc, we use 2/3 of them as metadata for the remaining 1/3. 104 * We store the pointers to the returned blocks of pages in held_back[] grouped 105 * by their order: when kmsan_memblock_free_pages() is called for the first 106 * time with a certain order, it is reserved as a shadow block, for the second 107 * time - as an origin block. On the third time the incoming block receives its --- 98 unchanged lines hidden (view full) --- 206 * - while there are >= 3 elements in @collect, do garbage collection: 207 * - pop 3 ranges from @collect; 208 * - use two of them as shadow and origin for the third one; 209 * - repeat; 210 * - split each remaining element from @collect into 2 ranges of 211 * order=N-1, 212 * - repeat. 213 */ | 100 101/* 102 * Eager metadata allocation. When the memblock allocator is freeing pages to 103 * pagealloc, we use 2/3 of them as metadata for the remaining 1/3. 104 * We store the pointers to the returned blocks of pages in held_back[] grouped 105 * by their order: when kmsan_memblock_free_pages() is called for the first 106 * time with a certain order, it is reserved as a shadow block, for the second 107 * time - as an origin block. On the third time the incoming block receives its --- 98 unchanged lines hidden (view full) --- 206 * - while there are >= 3 elements in @collect, do garbage collection: 207 * - pop 3 ranges from @collect; 208 * - use two of them as shadow and origin for the third one; 209 * - repeat; 210 * - split each remaining element from @collect into 2 ranges of 211 * order=N-1, 212 * - repeat. 213 */ |
214 collect.order = MAX_ORDER - 1; 215 for (int i = MAX_ORDER - 1; i >= 0; i--) { | 214 collect.order = MAX_ORDER; 215 for (int i = MAX_ORDER; i >= 0; i--) { |
216 if (held_back[i].shadow) 217 smallstack_push(&collect, held_back[i].shadow); 218 if (held_back[i].origin) 219 smallstack_push(&collect, held_back[i].origin); 220 held_back[i].shadow = NULL; 221 held_back[i].origin = NULL; 222 do_collection(); 223 collect_split(); --- 12 unchanged lines hidden --- | 216 if (held_back[i].shadow) 217 smallstack_push(&collect, held_back[i].shadow); 218 if (held_back[i].origin) 219 smallstack_push(&collect, held_back[i].origin); 220 held_back[i].shadow = NULL; 221 held_back[i].origin = NULL; 222 do_collection(); 223 collect_split(); --- 12 unchanged lines hidden --- |