srat.c (6cec9cad762b6476313fb1f8e931a1647822db6b) | srat.c (fc4f524a6e105aff3689eaa5aa29b90709ba0674) |
---|---|
1/*- 2 * Copyright (c) 2010 Advanced Computing Technologies LLC 3 * Written by: John H. Baldwin <jhb@FreeBSD.org> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 48 unchanged lines hidden (view full) --- 57} cpus[MAX_APIC_ID + 1]; 58 59struct mem_affinity mem_info[VM_PHYSSEG_MAX + 1]; 60int num_mem; 61 62static ACPI_TABLE_SRAT *srat; 63static vm_paddr_t srat_physaddr; 64 | 1/*- 2 * Copyright (c) 2010 Advanced Computing Technologies LLC 3 * Written by: John H. Baldwin <jhb@FreeBSD.org> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 48 unchanged lines hidden (view full) --- 57} cpus[MAX_APIC_ID + 1]; 58 59struct mem_affinity mem_info[VM_PHYSSEG_MAX + 1]; 60int num_mem; 61 62static ACPI_TABLE_SRAT *srat; 63static vm_paddr_t srat_physaddr; 64 |
65static int vm_domains[VM_PHYSSEG_MAX]; 66 |
|
65static void srat_walk_table(acpi_subtable_handler *handler, void *arg); 66 67/* 68 * Returns true if a memory range overlaps with at least one range in 69 * phys_avail[]. 70 */ 71static int 72overlaps_phys_avail(vm_paddr_t start, vm_paddr_t end) --- 169 unchanged lines hidden (view full) --- 242 243/* 244 * Renumber the memory domains to be compact and zero-based if not 245 * already. Returns an error if there are too many domains. 246 */ 247static int 248renumber_domains(void) 249{ | 67static void srat_walk_table(acpi_subtable_handler *handler, void *arg); 68 69/* 70 * Returns true if a memory range overlaps with at least one range in 71 * phys_avail[]. 72 */ 73static int 74overlaps_phys_avail(vm_paddr_t start, vm_paddr_t end) --- 169 unchanged lines hidden (view full) --- 244 245/* 246 * Renumber the memory domains to be compact and zero-based if not 247 * already. Returns an error if there are too many domains. 248 */ 249static int 250renumber_domains(void) 251{ |
250 int domains[VM_PHYSSEG_MAX]; | |
251 int i, j, slot; 252 253 /* Enumerate all the domains. */ 254 vm_ndomains = 0; 255 for (i = 0; i < num_mem; i++) { 256 /* See if this domain is already known. */ 257 for (j = 0; j < vm_ndomains; j++) { | 252 int i, j, slot; 253 254 /* Enumerate all the domains. */ 255 vm_ndomains = 0; 256 for (i = 0; i < num_mem; i++) { 257 /* See if this domain is already known. */ 258 for (j = 0; j < vm_ndomains; j++) { |
258 if (domains[j] >= mem_info[i].domain) | 259 if (vm_domains[j] >= mem_info[i].domain) |
259 break; 260 } | 260 break; 261 } |
261 if (j < vm_ndomains && domains[j] == mem_info[i].domain) | 262 if (j < vm_ndomains && vm_domains[j] == mem_info[i].domain) |
262 continue; 263 264 /* Insert the new domain at slot 'j'. */ 265 slot = j; 266 for (j = vm_ndomains; j > slot; j--) | 263 continue; 264 265 /* Insert the new domain at slot 'j'. */ 266 slot = j; 267 for (j = vm_ndomains; j > slot; j--) |
267 domains[j] = domains[j - 1]; 268 domains[slot] = mem_info[i].domain; | 268 vm_domains[j] = vm_domains[j - 1]; 269 vm_domains[slot] = mem_info[i].domain; |
269 vm_ndomains++; 270 if (vm_ndomains > MAXMEMDOM) { 271 vm_ndomains = 1; 272 printf("SRAT: Too many memory domains\n"); 273 return (EFBIG); 274 } 275 } 276 277 /* Renumber each domain to its index in the sorted 'domains' list. */ 278 for (i = 0; i < vm_ndomains; i++) { 279 /* 280 * If the domain is already the right value, no need 281 * to renumber. 282 */ | 270 vm_ndomains++; 271 if (vm_ndomains > MAXMEMDOM) { 272 vm_ndomains = 1; 273 printf("SRAT: Too many memory domains\n"); 274 return (EFBIG); 275 } 276 } 277 278 /* Renumber each domain to its index in the sorted 'domains' list. */ 279 for (i = 0; i < vm_ndomains; i++) { 280 /* 281 * If the domain is already the right value, no need 282 * to renumber. 283 */ |
283 if (domains[i] == i) | 284 if (vm_domains[i] == i) |
284 continue; 285 286 /* Walk the cpu[] and mem_info[] arrays to renumber. */ 287 for (j = 0; j < num_mem; j++) | 285 continue; 286 287 /* Walk the cpu[] and mem_info[] arrays to renumber. */ 288 for (j = 0; j < num_mem; j++) |
288 if (mem_info[j].domain == domains[i]) | 289 if (mem_info[j].domain == vm_domains[i]) |
289 mem_info[j].domain = i; 290 for (j = 0; j <= MAX_APIC_ID; j++) | 290 mem_info[j].domain = i; 291 for (j = 0; j <= MAX_APIC_ID; j++) |
291 if (cpus[j].enabled && cpus[j].domain == domains[i]) | 292 if (cpus[j].enabled && cpus[j].domain == vm_domains[i]) |
292 cpus[j].domain = i; 293 } 294 KASSERT(vm_ndomains > 0, 295 ("renumber_domains: invalid final vm_ndomains setup")); 296 297 return (0); 298} 299 --- 63 unchanged lines hidden (view full) --- 363 pc->pc_apic_id); 364 pc->pc_domain = cpu->domain; 365 if (bootverbose) 366 printf("SRAT: CPU %u has memory domain %d\n", i, 367 cpu->domain); 368 } 369} 370SYSINIT(srat_set_cpus, SI_SUB_CPU, SI_ORDER_ANY, srat_set_cpus, NULL); | 293 cpus[j].domain = i; 294 } 295 KASSERT(vm_ndomains > 0, 296 ("renumber_domains: invalid final vm_ndomains setup")); 297 298 return (0); 299} 300 --- 63 unchanged lines hidden (view full) --- 364 pc->pc_apic_id); 365 pc->pc_domain = cpu->domain; 366 if (bootverbose) 367 printf("SRAT: CPU %u has memory domain %d\n", i, 368 cpu->domain); 369 } 370} 371SYSINIT(srat_set_cpus, SI_SUB_CPU, SI_ORDER_ANY, srat_set_cpus, NULL); |
372 373/* 374 * Map a _PXM value to a VM domain ID. 375 * 376 * Returns the domain ID, or -1 if no domain ID was found. 377 */ 378int 379acpi_map_pxm_to_vm_domainid(int pxm) 380{ 381 int i; 382 383 for (i = 0; i < vm_ndomains; i++) { 384 if (vm_domains[i] == pxm) 385 return (i); 386 } 387 388 return (-1); 389} 390 |
|
371#endif /* MAXMEMDOM > 1 */ | 391#endif /* MAXMEMDOM > 1 */ |