topology.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright IBM Corp. 2007, 2011
  4. */
  5. #define KMSG_COMPONENT "cpu"
  6. #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
  7. #include <linux/workqueue.h>
  8. #include <linux/memblock.h>
  9. #include <linux/uaccess.h>
  10. #include <linux/sysctl.h>
  11. #include <linux/cpuset.h>
  12. #include <linux/device.h>
  13. #include <linux/export.h>
  14. #include <linux/kernel.h>
  15. #include <linux/sched.h>
  16. #include <linux/sched/topology.h>
  17. #include <linux/delay.h>
  18. #include <linux/init.h>
  19. #include <linux/slab.h>
  20. #include <linux/cpu.h>
  21. #include <linux/smp.h>
  22. #include <linux/mm.h>
  23. #include <linux/nodemask.h>
  24. #include <linux/node.h>
  25. #include <asm/hiperdispatch.h>
  26. #include <asm/sysinfo.h>
  27. #define PTF_HORIZONTAL (0UL)
  28. #define PTF_VERTICAL (1UL)
  29. #define PTF_CHECK (2UL)
  30. enum {
  31. TOPOLOGY_MODE_HW,
  32. TOPOLOGY_MODE_SINGLE,
  33. TOPOLOGY_MODE_PACKAGE,
  34. TOPOLOGY_MODE_UNINITIALIZED
  35. };
  36. struct mask_info {
  37. struct mask_info *next;
  38. unsigned char id;
  39. cpumask_t mask;
  40. };
  41. static int topology_mode = TOPOLOGY_MODE_UNINITIALIZED;
  42. static void set_topology_timer(void);
  43. static void topology_work_fn(struct work_struct *work);
  44. static struct sysinfo_15_1_x *tl_info;
  45. static int cpu_management;
  46. static DECLARE_WORK(topology_work, topology_work_fn);
  47. /*
  48. * Socket/Book linked lists and cpu_topology updates are
  49. * protected by "sched_domains_mutex".
  50. */
  51. static struct mask_info socket_info;
  52. static struct mask_info book_info;
  53. static struct mask_info drawer_info;
  54. struct cpu_topology_s390 cpu_topology[NR_CPUS];
  55. EXPORT_SYMBOL_GPL(cpu_topology);
  56. static void cpu_group_map(cpumask_t *dst, struct mask_info *info, unsigned int cpu)
  57. {
  58. static cpumask_t mask;
  59. cpumask_clear(&mask);
  60. if (!cpumask_test_cpu(cpu, &cpu_setup_mask))
  61. goto out;
  62. cpumask_set_cpu(cpu, &mask);
  63. switch (topology_mode) {
  64. case TOPOLOGY_MODE_HW:
  65. while (info) {
  66. if (cpumask_test_cpu(cpu, &info->mask)) {
  67. cpumask_copy(&mask, &info->mask);
  68. break;
  69. }
  70. info = info->next;
  71. }
  72. break;
  73. case TOPOLOGY_MODE_PACKAGE:
  74. cpumask_copy(&mask, cpu_present_mask);
  75. break;
  76. default:
  77. fallthrough;
  78. case TOPOLOGY_MODE_SINGLE:
  79. break;
  80. }
  81. cpumask_and(&mask, &mask, &cpu_setup_mask);
  82. out:
  83. cpumask_copy(dst, &mask);
  84. }
  85. static void cpu_thread_map(cpumask_t *dst, unsigned int cpu)
  86. {
  87. static cpumask_t mask;
  88. unsigned int max_cpu;
  89. cpumask_clear(&mask);
  90. if (!cpumask_test_cpu(cpu, &cpu_setup_mask))
  91. goto out;
  92. cpumask_set_cpu(cpu, &mask);
  93. if (topology_mode != TOPOLOGY_MODE_HW)
  94. goto out;
  95. cpu -= cpu % (smp_cpu_mtid + 1);
  96. max_cpu = min(cpu + smp_cpu_mtid, nr_cpu_ids - 1);
  97. for (; cpu <= max_cpu; cpu++) {
  98. if (cpumask_test_cpu(cpu, &cpu_setup_mask))
  99. cpumask_set_cpu(cpu, &mask);
  100. }
  101. out:
  102. cpumask_copy(dst, &mask);
  103. }
  104. #define TOPOLOGY_CORE_BITS 64
  105. static void add_cpus_to_mask(struct topology_core *tl_core,
  106. struct mask_info *drawer,
  107. struct mask_info *book,
  108. struct mask_info *socket)
  109. {
  110. struct cpu_topology_s390 *topo;
  111. unsigned int core;
  112. for_each_set_bit(core, &tl_core->mask, TOPOLOGY_CORE_BITS) {
  113. unsigned int max_cpu, rcore;
  114. int cpu;
  115. rcore = TOPOLOGY_CORE_BITS - 1 - core + tl_core->origin;
  116. cpu = smp_find_processor_id(rcore << smp_cpu_mt_shift);
  117. if (cpu < 0)
  118. continue;
  119. max_cpu = min(cpu + smp_cpu_mtid, nr_cpu_ids - 1);
  120. for (; cpu <= max_cpu; cpu++) {
  121. topo = &cpu_topology[cpu];
  122. topo->drawer_id = drawer->id;
  123. topo->book_id = book->id;
  124. topo->socket_id = socket->id;
  125. topo->core_id = rcore;
  126. topo->thread_id = cpu;
  127. topo->dedicated = tl_core->d;
  128. cpumask_set_cpu(cpu, &drawer->mask);
  129. cpumask_set_cpu(cpu, &book->mask);
  130. cpumask_set_cpu(cpu, &socket->mask);
  131. smp_cpu_set_polarization(cpu, tl_core->pp);
  132. smp_cpu_set_capacity(cpu, CPU_CAPACITY_HIGH);
  133. }
  134. }
  135. }
  136. static void clear_masks(void)
  137. {
  138. struct mask_info *info;
  139. info = &socket_info;
  140. while (info) {
  141. cpumask_clear(&info->mask);
  142. info = info->next;
  143. }
  144. info = &book_info;
  145. while (info) {
  146. cpumask_clear(&info->mask);
  147. info = info->next;
  148. }
  149. info = &drawer_info;
  150. while (info) {
  151. cpumask_clear(&info->mask);
  152. info = info->next;
  153. }
  154. }
  155. static union topology_entry *next_tle(union topology_entry *tle)
  156. {
  157. if (!tle->nl)
  158. return (union topology_entry *)((struct topology_core *)tle + 1);
  159. return (union topology_entry *)((struct topology_container *)tle + 1);
  160. }
  161. static void tl_to_masks(struct sysinfo_15_1_x *info)
  162. {
  163. struct mask_info *socket = &socket_info;
  164. struct mask_info *book = &book_info;
  165. struct mask_info *drawer = &drawer_info;
  166. union topology_entry *tle, *end;
  167. clear_masks();
  168. tle = info->tle;
  169. end = (union topology_entry *)((unsigned long)info + info->length);
  170. while (tle < end) {
  171. switch (tle->nl) {
  172. case 3:
  173. drawer = drawer->next;
  174. drawer->id = tle->container.id;
  175. break;
  176. case 2:
  177. book = book->next;
  178. book->id = tle->container.id;
  179. break;
  180. case 1:
  181. socket = socket->next;
  182. socket->id = tle->container.id;
  183. break;
  184. case 0:
  185. add_cpus_to_mask(&tle->cpu, drawer, book, socket);
  186. break;
  187. default:
  188. clear_masks();
  189. return;
  190. }
  191. tle = next_tle(tle);
  192. }
  193. }
  194. static void topology_update_polarization_simple(void)
  195. {
  196. int cpu;
  197. for_each_possible_cpu(cpu)
  198. smp_cpu_set_polarization(cpu, POLARIZATION_HRZ);
  199. }
  200. static int ptf(unsigned long fc)
  201. {
  202. int rc;
  203. asm volatile(
  204. " .insn rre,0xb9a20000,%1,%1\n"
  205. " ipm %0\n"
  206. " srl %0,28\n"
  207. : "=d" (rc)
  208. : "d" (fc) : "cc");
  209. return rc;
  210. }
  211. int topology_set_cpu_management(int fc)
  212. {
  213. int cpu, rc;
  214. if (!MACHINE_HAS_TOPOLOGY)
  215. return -EOPNOTSUPP;
  216. if (fc)
  217. rc = ptf(PTF_VERTICAL);
  218. else
  219. rc = ptf(PTF_HORIZONTAL);
  220. if (rc)
  221. return -EBUSY;
  222. for_each_possible_cpu(cpu)
  223. smp_cpu_set_polarization(cpu, POLARIZATION_UNKNOWN);
  224. return rc;
  225. }
  226. void update_cpu_masks(void)
  227. {
  228. struct cpu_topology_s390 *topo, *topo_package, *topo_sibling;
  229. int cpu, sibling, pkg_first, smt_first, id;
  230. for_each_possible_cpu(cpu) {
  231. topo = &cpu_topology[cpu];
  232. cpu_thread_map(&topo->thread_mask, cpu);
  233. cpu_group_map(&topo->core_mask, &socket_info, cpu);
  234. cpu_group_map(&topo->book_mask, &book_info, cpu);
  235. cpu_group_map(&topo->drawer_mask, &drawer_info, cpu);
  236. topo->booted_cores = 0;
  237. if (topology_mode != TOPOLOGY_MODE_HW) {
  238. id = topology_mode == TOPOLOGY_MODE_PACKAGE ? 0 : cpu;
  239. topo->thread_id = cpu;
  240. topo->core_id = cpu;
  241. topo->socket_id = id;
  242. topo->book_id = id;
  243. topo->drawer_id = id;
  244. }
  245. }
  246. hd_reset_state();
  247. for_each_online_cpu(cpu) {
  248. topo = &cpu_topology[cpu];
  249. pkg_first = cpumask_first(&topo->core_mask);
  250. topo_package = &cpu_topology[pkg_first];
  251. if (cpu == pkg_first) {
  252. for_each_cpu(sibling, &topo->core_mask) {
  253. topo_sibling = &cpu_topology[sibling];
  254. smt_first = cpumask_first(&topo_sibling->thread_mask);
  255. if (sibling == smt_first) {
  256. topo_package->booted_cores++;
  257. hd_add_core(sibling);
  258. }
  259. }
  260. } else {
  261. topo->booted_cores = topo_package->booted_cores;
  262. }
  263. }
  264. }
  265. void store_topology(struct sysinfo_15_1_x *info)
  266. {
  267. stsi(info, 15, 1, topology_mnest_limit());
  268. }
  269. static void __arch_update_dedicated_flag(void *arg)
  270. {
  271. if (topology_cpu_dedicated(smp_processor_id()))
  272. set_cpu_flag(CIF_DEDICATED_CPU);
  273. else
  274. clear_cpu_flag(CIF_DEDICATED_CPU);
  275. }
  276. static int __arch_update_cpu_topology(void)
  277. {
  278. struct sysinfo_15_1_x *info = tl_info;
  279. int rc, hd_status;
  280. hd_status = 0;
  281. rc = 0;
  282. mutex_lock(&smp_cpu_state_mutex);
  283. if (MACHINE_HAS_TOPOLOGY) {
  284. rc = 1;
  285. store_topology(info);
  286. tl_to_masks(info);
  287. }
  288. update_cpu_masks();
  289. if (!MACHINE_HAS_TOPOLOGY)
  290. topology_update_polarization_simple();
  291. if (cpu_management == 1)
  292. hd_status = hd_enable_hiperdispatch();
  293. mutex_unlock(&smp_cpu_state_mutex);
  294. if (hd_status == 0)
  295. hd_disable_hiperdispatch();
  296. return rc;
  297. }
  298. int arch_update_cpu_topology(void)
  299. {
  300. int rc;
  301. rc = __arch_update_cpu_topology();
  302. on_each_cpu(__arch_update_dedicated_flag, NULL, 0);
  303. return rc;
  304. }
  305. static void topology_work_fn(struct work_struct *work)
  306. {
  307. rebuild_sched_domains();
  308. }
  309. void topology_schedule_update(void)
  310. {
  311. schedule_work(&topology_work);
  312. }
  313. static void topology_flush_work(void)
  314. {
  315. flush_work(&topology_work);
  316. }
  317. static void topology_timer_fn(struct timer_list *unused)
  318. {
  319. if (ptf(PTF_CHECK))
  320. topology_schedule_update();
  321. set_topology_timer();
  322. }
  323. static struct timer_list topology_timer;
  324. static atomic_t topology_poll = ATOMIC_INIT(0);
  325. static void set_topology_timer(void)
  326. {
  327. if (atomic_add_unless(&topology_poll, -1, 0))
  328. mod_timer(&topology_timer, jiffies + msecs_to_jiffies(100));
  329. else
  330. mod_timer(&topology_timer, jiffies + msecs_to_jiffies(60 * MSEC_PER_SEC));
  331. }
  332. void topology_expect_change(void)
  333. {
  334. if (!MACHINE_HAS_TOPOLOGY)
  335. return;
  336. /* This is racy, but it doesn't matter since it is just a heuristic.
  337. * Worst case is that we poll in a higher frequency for a bit longer.
  338. */
  339. if (atomic_read(&topology_poll) > 60)
  340. return;
  341. atomic_add(60, &topology_poll);
  342. set_topology_timer();
  343. }
  344. static int set_polarization(int polarization)
  345. {
  346. int rc = 0;
  347. cpus_read_lock();
  348. mutex_lock(&smp_cpu_state_mutex);
  349. if (cpu_management == polarization)
  350. goto out;
  351. rc = topology_set_cpu_management(polarization);
  352. if (rc)
  353. goto out;
  354. cpu_management = polarization;
  355. topology_expect_change();
  356. out:
  357. mutex_unlock(&smp_cpu_state_mutex);
  358. cpus_read_unlock();
  359. return rc;
  360. }
  361. static ssize_t dispatching_show(struct device *dev,
  362. struct device_attribute *attr,
  363. char *buf)
  364. {
  365. ssize_t count;
  366. mutex_lock(&smp_cpu_state_mutex);
  367. count = sprintf(buf, "%d\n", cpu_management);
  368. mutex_unlock(&smp_cpu_state_mutex);
  369. return count;
  370. }
  371. static ssize_t dispatching_store(struct device *dev,
  372. struct device_attribute *attr,
  373. const char *buf,
  374. size_t count)
  375. {
  376. int val, rc;
  377. char delim;
  378. if (sscanf(buf, "%d %c", &val, &delim) != 1)
  379. return -EINVAL;
  380. if (val != 0 && val != 1)
  381. return -EINVAL;
  382. rc = set_polarization(val);
  383. return rc ? rc : count;
  384. }
  385. static DEVICE_ATTR_RW(dispatching);
  386. static ssize_t cpu_polarization_show(struct device *dev,
  387. struct device_attribute *attr, char *buf)
  388. {
  389. int cpu = dev->id;
  390. ssize_t count;
  391. mutex_lock(&smp_cpu_state_mutex);
  392. switch (smp_cpu_get_polarization(cpu)) {
  393. case POLARIZATION_HRZ:
  394. count = sprintf(buf, "horizontal\n");
  395. break;
  396. case POLARIZATION_VL:
  397. count = sprintf(buf, "vertical:low\n");
  398. break;
  399. case POLARIZATION_VM:
  400. count = sprintf(buf, "vertical:medium\n");
  401. break;
  402. case POLARIZATION_VH:
  403. count = sprintf(buf, "vertical:high\n");
  404. break;
  405. default:
  406. count = sprintf(buf, "unknown\n");
  407. break;
  408. }
  409. mutex_unlock(&smp_cpu_state_mutex);
  410. return count;
  411. }
  412. static DEVICE_ATTR(polarization, 0444, cpu_polarization_show, NULL);
  413. static struct attribute *topology_cpu_attrs[] = {
  414. &dev_attr_polarization.attr,
  415. NULL,
  416. };
  417. static struct attribute_group topology_cpu_attr_group = {
  418. .attrs = topology_cpu_attrs,
  419. };
  420. static ssize_t cpu_dedicated_show(struct device *dev,
  421. struct device_attribute *attr, char *buf)
  422. {
  423. int cpu = dev->id;
  424. ssize_t count;
  425. mutex_lock(&smp_cpu_state_mutex);
  426. count = sprintf(buf, "%d\n", topology_cpu_dedicated(cpu));
  427. mutex_unlock(&smp_cpu_state_mutex);
  428. return count;
  429. }
  430. static DEVICE_ATTR(dedicated, 0444, cpu_dedicated_show, NULL);
  431. static struct attribute *topology_extra_cpu_attrs[] = {
  432. &dev_attr_dedicated.attr,
  433. NULL,
  434. };
  435. static struct attribute_group topology_extra_cpu_attr_group = {
  436. .attrs = topology_extra_cpu_attrs,
  437. };
  438. int topology_cpu_init(struct cpu *cpu)
  439. {
  440. int rc;
  441. rc = sysfs_create_group(&cpu->dev.kobj, &topology_cpu_attr_group);
  442. if (rc || !MACHINE_HAS_TOPOLOGY)
  443. return rc;
  444. rc = sysfs_create_group(&cpu->dev.kobj, &topology_extra_cpu_attr_group);
  445. if (rc)
  446. sysfs_remove_group(&cpu->dev.kobj, &topology_cpu_attr_group);
  447. return rc;
  448. }
  449. static const struct cpumask *cpu_thread_mask(int cpu)
  450. {
  451. return &cpu_topology[cpu].thread_mask;
  452. }
  453. const struct cpumask *cpu_coregroup_mask(int cpu)
  454. {
  455. return &cpu_topology[cpu].core_mask;
  456. }
  457. static const struct cpumask *cpu_book_mask(int cpu)
  458. {
  459. return &cpu_topology[cpu].book_mask;
  460. }
  461. static const struct cpumask *cpu_drawer_mask(int cpu)
  462. {
  463. return &cpu_topology[cpu].drawer_mask;
  464. }
  465. static struct sched_domain_topology_level s390_topology[] = {
  466. { cpu_thread_mask, cpu_smt_flags, SD_INIT_NAME(SMT) },
  467. { cpu_coregroup_mask, cpu_core_flags, SD_INIT_NAME(MC) },
  468. { cpu_book_mask, SD_INIT_NAME(BOOK) },
  469. { cpu_drawer_mask, SD_INIT_NAME(DRAWER) },
  470. { cpu_cpu_mask, SD_INIT_NAME(PKG) },
  471. { NULL, },
  472. };
  473. static void __init alloc_masks(struct sysinfo_15_1_x *info,
  474. struct mask_info *mask, int offset)
  475. {
  476. int i, nr_masks;
  477. nr_masks = info->mag[TOPOLOGY_NR_MAG - offset];
  478. for (i = 0; i < info->mnest - offset; i++)
  479. nr_masks *= info->mag[TOPOLOGY_NR_MAG - offset - 1 - i];
  480. nr_masks = max(nr_masks, 1);
  481. for (i = 0; i < nr_masks; i++) {
  482. mask->next = memblock_alloc(sizeof(*mask->next), 8);
  483. if (!mask->next)
  484. panic("%s: Failed to allocate %zu bytes align=0x%x\n",
  485. __func__, sizeof(*mask->next), 8);
  486. mask = mask->next;
  487. }
  488. }
  489. void __init topology_init_early(void)
  490. {
  491. struct sysinfo_15_1_x *info;
  492. set_sched_topology(s390_topology);
  493. if (topology_mode == TOPOLOGY_MODE_UNINITIALIZED) {
  494. if (MACHINE_HAS_TOPOLOGY)
  495. topology_mode = TOPOLOGY_MODE_HW;
  496. else
  497. topology_mode = TOPOLOGY_MODE_SINGLE;
  498. }
  499. if (!MACHINE_HAS_TOPOLOGY)
  500. goto out;
  501. tl_info = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
  502. if (!tl_info)
  503. panic("%s: Failed to allocate %lu bytes align=0x%lx\n",
  504. __func__, PAGE_SIZE, PAGE_SIZE);
  505. info = tl_info;
  506. store_topology(info);
  507. pr_info("The CPU configuration topology of the machine is: %d %d %d %d %d %d / %d\n",
  508. info->mag[0], info->mag[1], info->mag[2], info->mag[3],
  509. info->mag[4], info->mag[5], info->mnest);
  510. alloc_masks(info, &socket_info, 1);
  511. alloc_masks(info, &book_info, 2);
  512. alloc_masks(info, &drawer_info, 3);
  513. out:
  514. cpumask_set_cpu(0, &cpu_setup_mask);
  515. __arch_update_cpu_topology();
  516. __arch_update_dedicated_flag(NULL);
  517. }
  518. static inline int topology_get_mode(int enabled)
  519. {
  520. if (!enabled)
  521. return TOPOLOGY_MODE_SINGLE;
  522. return MACHINE_HAS_TOPOLOGY ? TOPOLOGY_MODE_HW : TOPOLOGY_MODE_PACKAGE;
  523. }
  524. static inline int topology_is_enabled(void)
  525. {
  526. return topology_mode != TOPOLOGY_MODE_SINGLE;
  527. }
  528. static int __init topology_setup(char *str)
  529. {
  530. bool enabled;
  531. int rc;
  532. rc = kstrtobool(str, &enabled);
  533. if (rc)
  534. return rc;
  535. topology_mode = topology_get_mode(enabled);
  536. return 0;
  537. }
  538. early_param("topology", topology_setup);
  539. static int topology_ctl_handler(const struct ctl_table *ctl, int write,
  540. void *buffer, size_t *lenp, loff_t *ppos)
  541. {
  542. int enabled = topology_is_enabled();
  543. int new_mode;
  544. int rc;
  545. struct ctl_table ctl_entry = {
  546. .procname = ctl->procname,
  547. .data = &enabled,
  548. .maxlen = sizeof(int),
  549. .extra1 = SYSCTL_ZERO,
  550. .extra2 = SYSCTL_ONE,
  551. };
  552. rc = proc_douintvec_minmax(&ctl_entry, write, buffer, lenp, ppos);
  553. if (rc < 0 || !write)
  554. return rc;
  555. mutex_lock(&smp_cpu_state_mutex);
  556. new_mode = topology_get_mode(enabled);
  557. if (topology_mode != new_mode) {
  558. topology_mode = new_mode;
  559. topology_schedule_update();
  560. }
  561. mutex_unlock(&smp_cpu_state_mutex);
  562. topology_flush_work();
  563. return rc;
  564. }
  565. static int polarization_ctl_handler(const struct ctl_table *ctl, int write,
  566. void *buffer, size_t *lenp, loff_t *ppos)
  567. {
  568. int polarization;
  569. int rc;
  570. struct ctl_table ctl_entry = {
  571. .procname = ctl->procname,
  572. .data = &polarization,
  573. .maxlen = sizeof(int),
  574. .extra1 = SYSCTL_ZERO,
  575. .extra2 = SYSCTL_ONE,
  576. };
  577. polarization = cpu_management;
  578. rc = proc_douintvec_minmax(&ctl_entry, write, buffer, lenp, ppos);
  579. if (rc < 0 || !write)
  580. return rc;
  581. return set_polarization(polarization);
  582. }
  583. static struct ctl_table topology_ctl_table[] = {
  584. {
  585. .procname = "topology",
  586. .mode = 0644,
  587. .proc_handler = topology_ctl_handler,
  588. },
  589. {
  590. .procname = "polarization",
  591. .mode = 0644,
  592. .proc_handler = polarization_ctl_handler,
  593. },
  594. };
  595. static int __init topology_init(void)
  596. {
  597. struct device *dev_root;
  598. int rc = 0;
  599. timer_setup(&topology_timer, topology_timer_fn, TIMER_DEFERRABLE);
  600. if (MACHINE_HAS_TOPOLOGY)
  601. set_topology_timer();
  602. else
  603. topology_update_polarization_simple();
  604. if (IS_ENABLED(CONFIG_SCHED_TOPOLOGY_VERTICAL))
  605. set_polarization(1);
  606. register_sysctl("s390", topology_ctl_table);
  607. dev_root = bus_get_dev_root(&cpu_subsys);
  608. if (dev_root) {
  609. rc = device_create_file(dev_root, &dev_attr_dispatching);
  610. put_device(dev_root);
  611. }
  612. return rc;
  613. }
  614. device_initcall(topology_init);