smp.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * include/asm-s390/smp.h
  3. *
  4. * S390 version
  5. * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
  6. * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
  7. * Martin Schwidefsky (schwidefsky@de.ibm.com)
  8. * Heiko Carstens (heiko.carstens@de.ibm.com)
  9. */
  10. #ifndef __ASM_SMP_H
  11. #define __ASM_SMP_H
  12. #include <linux/threads.h>
  13. #include <linux/cpumask.h>
  14. #include <linux/bitops.h>
  15. #if defined(__KERNEL__) && defined(CONFIG_SMP) && !defined(__ASSEMBLY__)
  16. #include <asm/lowcore.h>
  17. #include <asm/sigp.h>
  18. /*
  19. s390 specific smp.c headers
  20. */
  21. typedef struct
  22. {
  23. int intresting;
  24. sigp_ccode ccode;
  25. __u32 status;
  26. __u16 cpu;
  27. } sigp_info;
  28. extern void smp_setup_cpu_possible_map(void);
  29. extern int smp_call_function_on(void (*func) (void *info), void *info,
  30. int nonatomic, int wait, int cpu);
  31. #define NO_PROC_ID 0xFF /* No processor magic marker */
  32. /*
  33. * This magic constant controls our willingness to transfer
  34. * a process across CPUs. Such a transfer incurs misses on the L1
  35. * cache, and on a P6 or P5 with multiple L2 caches L2 hits. My
  36. * gut feeling is this will vary by board in value. For a board
  37. * with separate L2 cache it probably depends also on the RSS, and
  38. * for a board with shared L2 cache it ought to decay fast as other
  39. * processes are run.
  40. */
  41. #define PROC_CHANGE_PENALTY 20 /* Schedule penalty */
  42. #define raw_smp_processor_id() (S390_lowcore.cpu_data.cpu_nr)
  43. extern int smp_get_cpu(cpumask_t cpu_map);
  44. extern void smp_put_cpu(int cpu);
  45. static inline __u16 hard_smp_processor_id(void)
  46. {
  47. __u16 cpu_address;
  48. __asm__ ("stap %0\n" : "=m" (cpu_address));
  49. return cpu_address;
  50. }
  51. /*
  52. * returns 1 if cpu is in stopped/check stopped state or not operational
  53. * returns 0 otherwise
  54. */
  55. static inline int
  56. smp_cpu_not_running(int cpu)
  57. {
  58. __u32 status;
  59. switch (signal_processor_ps(&status, 0, cpu, sigp_sense)) {
  60. case sigp_order_code_accepted:
  61. case sigp_status_stored:
  62. /* Check for stopped and check stop state */
  63. if (status & 0x50)
  64. return 1;
  65. break;
  66. case sigp_not_operational:
  67. return 1;
  68. default:
  69. break;
  70. }
  71. return 0;
  72. }
  73. #define cpu_logical_map(cpu) (cpu)
  74. extern int __cpu_disable (void);
  75. extern void __cpu_die (unsigned int cpu);
  76. extern void cpu_die (void) __attribute__ ((noreturn));
  77. extern int __cpu_up (unsigned int cpu);
  78. #endif
  79. #ifndef CONFIG_SMP
  80. static inline int
  81. smp_call_function_on(void (*func) (void *info), void *info,
  82. int nonatomic, int wait, int cpu)
  83. {
  84. func(info);
  85. return 0;
  86. }
  87. #define smp_cpu_not_running(cpu) 1
  88. #define smp_get_cpu(cpu) ({ 0; })
  89. #define smp_put_cpu(cpu) ({ 0; })
  90. #define smp_setup_cpu_possible_map() do { } while (0)
  91. #endif
  92. #endif