aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-10-25 23:21:16 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-25 23:21:16 -0400
commit9f4c7ac227423eb4a514ce0bbd3a884a26541e63 (patch)
tree8f2d8cdebfe87f11e0e7f14c789f807dbf0bec5d /arch
parent8c8a0eab988c94294adbbb4fe955bba7d8ebddcf (diff)
parent70a0a5357db20c291d46c04011d646d5d84c868c (diff)
Merge branch 'for-linus' of git://one.firstfloor.org/home/andi/git/linux-2.6
* 'for-linus' of git://one.firstfloor.org/home/andi/git/linux-2.6: [PATCH] x86-64: Only look at per_cpu data for online cpus. [PATCH] x86-64: Simplify the vector allocator.
Diffstat (limited to 'arch')
-rw-r--r--arch/x86_64/kernel/io_apic.c62
-rw-r--r--arch/x86_64/kernel/smpboot.c7
2 files changed, 50 insertions, 19 deletions
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
index b000017e4b5d..fe429e5d6b29 100644
--- a/arch/x86_64/kernel/io_apic.c
+++ b/arch/x86_64/kernel/io_apic.c
@@ -63,7 +63,7 @@ int timer_over_8254 __initdata = 1;
63static struct { int pin, apic; } ioapic_i8259 = { -1, -1 }; 63static struct { int pin, apic; } ioapic_i8259 = { -1, -1 };
64 64
65static DEFINE_SPINLOCK(ioapic_lock); 65static DEFINE_SPINLOCK(ioapic_lock);
66static DEFINE_SPINLOCK(vector_lock); 66DEFINE_SPINLOCK(vector_lock);
67 67
68/* 68/*
69 * # of IRQ routing registers 69 * # of IRQ routing registers
@@ -612,15 +612,15 @@ static int __assign_irq_vector(int irq, cpumask_t mask, cpumask_t *result)
612 * Also, we've got to be careful not to trash gate 612 * Also, we've got to be careful not to trash gate
613 * 0x80, because int 0x80 is hm, kind of importantish. ;) 613 * 0x80, because int 0x80 is hm, kind of importantish. ;)
614 */ 614 */
615 static struct { 615 static int current_vector = FIRST_DEVICE_VECTOR, current_offset = 0;
616 int vector;
617 int offset;
618 } pos[NR_CPUS] = { [ 0 ... NR_CPUS - 1] = {FIRST_DEVICE_VECTOR, 0} };
619 int old_vector = -1; 616 int old_vector = -1;
620 int cpu; 617 int cpu;
621 618
622 BUG_ON((unsigned)irq >= NR_IRQ_VECTORS); 619 BUG_ON((unsigned)irq >= NR_IRQ_VECTORS);
623 620
621 /* Only try and allocate irqs on cpus that are present */
622 cpus_and(mask, mask, cpu_online_map);
623
624 if (irq_vector[irq] > 0) 624 if (irq_vector[irq] > 0)
625 old_vector = irq_vector[irq]; 625 old_vector = irq_vector[irq];
626 if (old_vector > 0) { 626 if (old_vector > 0) {
@@ -630,15 +630,15 @@ static int __assign_irq_vector(int irq, cpumask_t mask, cpumask_t *result)
630 } 630 }
631 631
632 for_each_cpu_mask(cpu, mask) { 632 for_each_cpu_mask(cpu, mask) {
633 cpumask_t domain; 633 cpumask_t domain, new_mask;
634 int first, new_cpu; 634 int new_cpu;
635 int vector, offset; 635 int vector, offset;
636 636
637 domain = vector_allocation_domain(cpu); 637 domain = vector_allocation_domain(cpu);
638 first = first_cpu(domain); 638 cpus_and(new_mask, domain, cpu_online_map);
639 639
640 vector = pos[first].vector; 640 vector = current_vector;
641 offset = pos[first].offset; 641 offset = current_offset;
642next: 642next:
643 vector += 8; 643 vector += 8;
644 if (vector >= FIRST_SYSTEM_VECTOR) { 644 if (vector >= FIRST_SYSTEM_VECTOR) {
@@ -646,24 +646,24 @@ next:
646 offset = (offset + 1) % 8; 646 offset = (offset + 1) % 8;
647 vector = FIRST_DEVICE_VECTOR + offset; 647 vector = FIRST_DEVICE_VECTOR + offset;
648 } 648 }
649 if (unlikely(pos[first].vector == vector)) 649 if (unlikely(current_vector == vector))
650 continue; 650 continue;
651 if (vector == IA32_SYSCALL_VECTOR) 651 if (vector == IA32_SYSCALL_VECTOR)
652 goto next; 652 goto next;
653 for_each_cpu_mask(new_cpu, domain) 653 for_each_cpu_mask(new_cpu, new_mask)
654 if (per_cpu(vector_irq, new_cpu)[vector] != -1) 654 if (per_cpu(vector_irq, new_cpu)[vector] != -1)
655 goto next; 655 goto next;
656 /* Found one! */ 656 /* Found one! */
657 for_each_cpu_mask(new_cpu, domain) { 657 current_vector = vector;
658 pos[new_cpu].vector = vector; 658 current_offset = offset;
659 pos[new_cpu].offset = offset;
660 }
661 if (old_vector >= 0) { 659 if (old_vector >= 0) {
660 cpumask_t old_mask;
662 int old_cpu; 661 int old_cpu;
663 for_each_cpu_mask(old_cpu, irq_domain[irq]) 662 cpus_and(old_mask, irq_domain[irq], cpu_online_map);
663 for_each_cpu_mask(old_cpu, old_mask)
664 per_cpu(vector_irq, old_cpu)[old_vector] = -1; 664 per_cpu(vector_irq, old_cpu)[old_vector] = -1;
665 } 665 }
666 for_each_cpu_mask(new_cpu, domain) 666 for_each_cpu_mask(new_cpu, new_mask)
667 per_cpu(vector_irq, new_cpu)[vector] = irq; 667 per_cpu(vector_irq, new_cpu)[vector] = irq;
668 irq_vector[irq] = vector; 668 irq_vector[irq] = vector;
669 irq_domain[irq] = domain; 669 irq_domain[irq] = domain;
@@ -684,6 +684,32 @@ static int assign_irq_vector(int irq, cpumask_t mask, cpumask_t *result)
684 return vector; 684 return vector;
685} 685}
686 686
687void __setup_vector_irq(int cpu)
688{
689 /* Initialize vector_irq on a new cpu */
690 /* This function must be called with vector_lock held */
691 unsigned long flags;
692 int irq, vector;
693
694
695 /* Mark the inuse vectors */
696 for (irq = 0; irq < NR_IRQ_VECTORS; ++irq) {
697 if (!cpu_isset(cpu, irq_domain[irq]))
698 continue;
699 vector = irq_vector[irq];
700 per_cpu(vector_irq, cpu)[vector] = irq;
701 }
702 /* Mark the free vectors */
703 for (vector = 0; vector < NR_VECTORS; ++vector) {
704 irq = per_cpu(vector_irq, cpu)[vector];
705 if (irq < 0)
706 continue;
707 if (!cpu_isset(cpu, irq_domain[irq]))
708 per_cpu(vector_irq, cpu)[vector] = -1;
709 }
710}
711
712
687extern void (*interrupt[NR_IRQS])(void); 713extern void (*interrupt[NR_IRQS])(void);
688 714
689static struct irq_chip ioapic_chip; 715static struct irq_chip ioapic_chip;
diff --git a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c
index 7b7a6870288a..62c2e747af58 100644
--- a/arch/x86_64/kernel/smpboot.c
+++ b/arch/x86_64/kernel/smpboot.c
@@ -581,12 +581,16 @@ void __cpuinit start_secondary(void)
581 * smp_call_function(). 581 * smp_call_function().
582 */ 582 */
583 lock_ipi_call_lock(); 583 lock_ipi_call_lock();
584 spin_lock(&vector_lock);
584 585
586 /* Setup the per cpu irq handling data structures */
587 __setup_vector_irq(smp_processor_id());
585 /* 588 /*
586 * Allow the master to continue. 589 * Allow the master to continue.
587 */ 590 */
588 cpu_set(smp_processor_id(), cpu_online_map); 591 cpu_set(smp_processor_id(), cpu_online_map);
589 per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE; 592 per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
593 spin_unlock(&vector_lock);
590 unlock_ipi_call_lock(); 594 unlock_ipi_call_lock();
591 595
592 cpu_idle(); 596 cpu_idle();
@@ -799,7 +803,6 @@ static int __cpuinit do_boot_cpu(int cpu, int apicid)
799 cpu, node); 803 cpu, node);
800 } 804 }
801 805
802
803 alternatives_smp_switch(1); 806 alternatives_smp_switch(1);
804 807
805 c_idle.idle = get_idle_for_cpu(cpu); 808 c_idle.idle = get_idle_for_cpu(cpu);
@@ -1246,8 +1249,10 @@ int __cpu_disable(void)
1246 local_irq_disable(); 1249 local_irq_disable();
1247 remove_siblinginfo(cpu); 1250 remove_siblinginfo(cpu);
1248 1251
1252 spin_lock(&vector_lock);
1249 /* It's now safe to remove this processor from the online map */ 1253 /* It's now safe to remove this processor from the online map */
1250 cpu_clear(cpu, cpu_online_map); 1254 cpu_clear(cpu, cpu_online_map);
1255 spin_unlock(&vector_lock);
1251 remove_cpu_from_maps(); 1256 remove_cpu_from_maps();
1252 fixup_irqs(cpu_online_map); 1257 fixup_irqs(cpu_online_map);
1253 return 0; 1258 return 0;