smpboot.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include <linux/init.h>
  2. #include <linux/smp.h>
  3. #ifdef CONFIG_HOTPLUG_CPU
  4. int additional_cpus __initdata = -1;
  5. static __init int setup_additional_cpus(char *s)
  6. {
  7. return s && get_option(&s, &additional_cpus) ? 0 : -EINVAL;
  8. }
  9. early_param("additional_cpus", setup_additional_cpus);
  10. /*
  11. * cpu_possible_map should be static, it cannot change as cpu's
  12. * are onlined, or offlined. The reason is per-cpu data-structures
  13. * are allocated by some modules at init time, and dont expect to
  14. * do this dynamically on cpu arrival/departure.
  15. * cpu_present_map on the other hand can change dynamically.
  16. * In case when cpu_hotplug is not compiled, then we resort to current
  17. * behaviour, which is cpu_possible == cpu_present.
  18. * - Ashok Raj
  19. *
  20. * Three ways to find out the number of additional hotplug CPUs:
  21. * - If the BIOS specified disabled CPUs in ACPI/mptables use that.
  22. * - The user can overwrite it with additional_cpus=NUM
  23. * - Otherwise don't reserve additional CPUs.
  24. * We do this because additional CPUs waste a lot of memory.
  25. * -AK
  26. */
  27. __init void prefill_possible_map(void)
  28. {
  29. int i;
  30. int possible;
  31. if (additional_cpus == -1) {
  32. if (disabled_cpus > 0)
  33. additional_cpus = disabled_cpus;
  34. else
  35. additional_cpus = 0;
  36. }
  37. possible = num_processors + additional_cpus;
  38. if (possible > NR_CPUS)
  39. possible = NR_CPUS;
  40. printk(KERN_INFO "SMP: Allowing %d CPUs, %d hotplug CPUs\n",
  41. possible, max_t(int, possible - num_processors, 0));
  42. for (i = 0; i < possible; i++)
  43. cpu_set(i, cpu_possible_map);
  44. }
  45. #endif