Commit 961f65fc41cdc1f9099a6075258816c0db98e390

Authored by David S. Miller
1 parent 9076d0e7e0

sparc: Size mondo queues more sanely.

There is currently no upper limit on the mondo queue sizes we'll use,
which guarentees that we'll eventually his page allocation limits, and
thus allocation failures, due to MAX_ORDER.

Cap the sizes sanely, current limits are:

CPU  MONDO	2 * max_possible_cpus
DEV  MONDO	256 (basically NR_IRQS)
RES  MONDO	128
NRES MONDO	4

Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 23 additions and 7 deletions Side-by-side Diff

arch/sparc/kernel/mdesc.c
... ... @@ -508,6 +508,8 @@
508 508 }
509 509 EXPORT_SYMBOL(mdesc_node_name);
510 510  
  511 +static u64 max_cpus = 64;
  512 +
511 513 static void __init report_platform_properties(void)
512 514 {
513 515 struct mdesc_handle *hp = mdesc_grab();
... ... @@ -543,8 +545,10 @@
543 545 if (v)
544 546 printk("PLATFORM: watchdog-max-timeout [%llu ms]\n", *v);
545 547 v = mdesc_get_property(hp, pn, "max-cpus", NULL);
546   - if (v)
547   - printk("PLATFORM: max-cpus [%llu]\n", *v);
  548 + if (v) {
  549 + max_cpus = *v;
  550 + printk("PLATFORM: max-cpus [%llu]\n", max_cpus);
  551 + }
548 552  
549 553 #ifdef CONFIG_SMP
550 554 {
... ... @@ -715,7 +719,7 @@
715 719 }
716 720  
717 721 static void __cpuinit get_one_mondo_bits(const u64 *p, unsigned int *mask,
718   - unsigned char def)
  722 + unsigned long def, unsigned long max)
719 723 {
720 724 u64 val;
721 725  
... ... @@ -726,6 +730,9 @@
726 730 if (!val || val >= 64)
727 731 goto use_default;
728 732  
  733 + if (val > max)
  734 + val = max;
  735 +
729 736 *mask = ((1U << val) * 64U) - 1U;
730 737 return;
731 738  
732 739  
733 740  
734 741  
735 742  
... ... @@ -736,19 +743,28 @@
736 743 static void __cpuinit get_mondo_data(struct mdesc_handle *hp, u64 mp,
737 744 struct trap_per_cpu *tb)
738 745 {
  746 + static int printed;
739 747 const u64 *val;
740 748  
741 749 val = mdesc_get_property(hp, mp, "q-cpu-mondo-#bits", NULL);
742   - get_one_mondo_bits(val, &tb->cpu_mondo_qmask, 7);
  750 + get_one_mondo_bits(val, &tb->cpu_mondo_qmask, 7, ilog2(max_cpus * 2));
743 751  
744 752 val = mdesc_get_property(hp, mp, "q-dev-mondo-#bits", NULL);
745   - get_one_mondo_bits(val, &tb->dev_mondo_qmask, 7);
  753 + get_one_mondo_bits(val, &tb->dev_mondo_qmask, 7, 8);
746 754  
747 755 val = mdesc_get_property(hp, mp, "q-resumable-#bits", NULL);
748   - get_one_mondo_bits(val, &tb->resum_qmask, 6);
  756 + get_one_mondo_bits(val, &tb->resum_qmask, 6, 7);
749 757  
750 758 val = mdesc_get_property(hp, mp, "q-nonresumable-#bits", NULL);
751   - get_one_mondo_bits(val, &tb->nonresum_qmask, 2);
  759 + get_one_mondo_bits(val, &tb->nonresum_qmask, 2, 2);
  760 + if (!printed++) {
  761 + pr_info("SUN4V: Mondo queue sizes "
  762 + "[cpu(%u) dev(%u) r(%u) nr(%u)]\n",
  763 + tb->cpu_mondo_qmask + 1,
  764 + tb->dev_mondo_qmask + 1,
  765 + tb->resum_qmask + 1,
  766 + tb->nonresum_qmask + 1);
  767 + }
752 768 }
753 769  
754 770 static void * __cpuinit mdesc_iterate_over_cpus(void *(*func)(struct mdesc_handle *, u64, int, void *), void *arg, cpumask_t *mask)