2.5.31 Summit NUMA patch with dynamic IRQ balancing
Quoted 13 lines
From: James Cleverdon [mailto:[email protected]]
Quoted 1 line
What happens when you use the FULL ACPI support? I suspect
that you really
Quoted 1 line
do want the interpreter, in order to evaluate
_PRTsproperly.Bingo! With full ACPI turned on, the system does indeed boot. The extra I/O
APIC entries are being programmed from the PRT.(Call chain is:
pci_acpi_init-->acpi_pci_irq_init-->mp_parse_prt-->io_apic_set_pci_routing)
Quoted 6 lines
So, given that quite a number of our customers would like to run with hyperthreading turned on, but do not want full ACPI, what is the right thing
to do in the HT-only case? Add extra code to process the PRT? Fall back on
MPS's IRQ records? Something else entirely?
The solution is ACPI. Full ACPI. What is the problem? I have devoted too much time already to make hybrid ACPI/MPS combos work, but that will never be the right solution.
Please have your customers email me privately and tell me why ~100KB of mem on a 1GB+ system is something us engineers should spend our valuable time hacking around, when the correct solution already is implemented and *works*.
Regards -- Andy
PATCH 1/1 ACPI tweak for 2.5.31 Summit NUMA patch with dynamic IRQ balancing
Quoted 1 line · Andrew
Quoted 1 line
From: James Cleverdon [mailto:[email protected]]
[ Snip discussion of full vs. HT-only ACPI support ]
This patch works together with my 2.5.31 Summit patch to boot a x440 with ACPI's CPU enumeration-only turned on.
As always, comments and corrections welcome:
arch/i386/kernel/mpparse.c renamed from arch/i386/kernel/mpparse.c.df +14 -3
@@ -240,10 +240,23 @@ } } +static int __init ioapic_dup_check (unsigned long apicaddr) +{ + registerint i; + +for (i = nr_ioapics; --i >=0 ; ) { +if (mp_ioapics[i].mpc_apicaddr == apicaddr) +return 1 ;/* Got a dup. */ + } +return 0 ;/* No dup. */ +} +static void __init MP_ioapic_info (struct mpc_config_ioapic *m) {if (!(m->mpc_flags &MPC_APIC_USABLE ))return ; +if (ioapic_dup_check (m->mpc_apicaddr)) +return ;printk ("I/O APIC #%d Version %d at 0x%lX.\n" , m->mpc_apicid, m->mpc_apicver, m->mpc_apicaddr);
@@ -691,10 +704,8 @@* ACPI supports both logical (e.g. Hyper-Threading) and physical * processors, where MPS only supports physical. */ -if (acpi_lapic && acpi_ioapic) { +if (acpi_lapic && acpi_ioapic)printk (KERN_INFO "Using ACPI (MADT) for SMP configuration information\n" ); -return ; - }else if (acpi_lapic) printk(KERN_INFO "Using ACPI for processor (LAPIC) configuration
information\n");
@@ -949,6 +960,8 @@
{
int idx = 0;
+ if (ioapic_dup_check(address))
+ return;
if (nr_ioapics >= MAX_IO_APICS) {
printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded "
"(found %d)\n", MAX_IO_APICS, nr_ioapics);
arch/i386/kernel/acpi.c renamed from arch/i386/kernel/acpi.c.df +3 -0
@@ -364,18 +368,18 @@return result; } +#ifndef CONFIG_ACPI_HT_ONLY result =acpi_table_parse_madt (ACPI_MADT_LAPIC_NMI , acpi_parse_lapic_nmi);if (result <0 ) { printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");/* TBD: Cleanup to allow fallback to MPS */ return result; } +#endif /*!CONFIG_ACPI_HT_ONLY*/ acpi_lapic =1 ;#endif /*CONFIG_X86_LOCAL_APIC*/ #ifdef CONFIG_X86_IO_APIC +#ifndef CONFIG_ACPI_HT_ONLY
/*
* I/O APIC
@@ -413,11 +420,14 @@
acpi_ioapic = 1;
+#endif /*!CONFIG_ACPI_HT_ONLY*/
#endif /*CONFIG_X86_IO_APIC*/
#ifdef CONFIG_X86_LOCAL_APIC
Signature · 3 lines
James Cleverdon
IBM xSeries Linux Solutions
{jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot comPATCH 1/1 2.5.31 Summit NUMA patch with dynamic IRQ balancing -- now with ACPI
Here's the latest iteration of my 2.5 Summit chipset patch. It contains feedback from Andi Kleen and an ACPI hack so that kernels built with ACPI's "CPU Enumeration only" hyperthread option will boot properly.
Important safety note: Since this patch should remove the need for balance_cpu on P4 systems (and no others need it), the patch deletes it and associated functions. You have been warned. Use only as directed. Actual highway mileage may vary. Batteries not included.
Signature · 3 lines
James Cleverdon
IBM xSeries Linux Solutions
{jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot comarch/i386/kernel/acpi.c +9 -1
@@ -130,6 +130,8 @@ printk(KERN_INFO PREFIX "Local APIC address 0x%08x\n", madt->lapic_address); +acpi_madt_oem_check (madt->header.oem_id, madt->header.oem_table_id); +return 0 ; }
@@ -364,18 +366,21 @@return result; } +#ifndef CONFIG_ACPI_HT_ONLY result =acpi_table_parse_madt (ACPI_MADT_LAPIC_NMI , acpi_parse_lapic_nmi);if (result <0 ) { printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n");/* TBD: Cleanup to allow fallback to MPS */ return result; } +#endif /*!CONFIG_ACPI_HT_ONLY*/ acpi_lapic =1 ;#endif /*CONFIG_X86_LOCAL_APIC*/ #ifdef CONFIG_X86_IO_APIC +#ifndef CONFIG_ACPI_HT_ONLY /* * I/O APIC
@@ -413,11 +418,14 @@ acpi_ioapic =1 ; +#endif /*!CONFIG_ACPI_HT_ONLY*/ #endif /*CONFIG_X86_IO_APIC*/ #ifdef CONFIG_X86_LOCAL_APIC -if (acpi_lapic && acpi_ioapic) +if (acpi_lapic && acpi_ioapic) { smp_found_config =1 ; +smp_cluster_apic_check (); + }#endif return 0 ;
arch/i386/kernel/apic.c +20 -8
@@ -29,6 +29,7 @@#include <asm/mtrr.h> #include <asm/mpspec.h> #include <asm/pgalloc.h> +#include <asm/smpboot.h> /* Using APIC to generate smp_local_timer_interrupt? */ int using_apic_timer =0 ;
@@ -272,6 +273,16 @@apic_write_around (APIC_LVT1 , value); } +static inline unsigned long apic_ldr_value (unsigned long value) +{ +if (clustered_apic_numaq) +return (value); +if (clustered_apic_xapic) +return (((value) & ~APIC_LDR_MASK ) | +SET_APIC_LOGICAL_ID (xapic_physical_to_logical_apicid (hard_smp_processor_id ()))); +return (((value) & ~APIC_LDR_MASK ) |SET_APIC_LOGICAL_ID (1UL <<smp_processor_id ())); +} +void __init setup_local_APIC (void ) {unsigned long value, ver, maxlvt;
@@ -304,21 +315,22 @@* document number 292116). So here it goes... */ -if (!clustered_apic_mode) { +if (!clustered_apic_numaq) {/* -* In clustered apic mode, the firmware does this for us -* Put the APIC into flat delivery mode. -* Must be "all ones" explicitly for 82489DX. +* For NUMA-Q, the firmware does this for us. Otherwise, put the APIC into clustered or flat +* +* delivery mode. Must be "all ones" explicitly for 82489DX. */ -apic_write_around (APIC_DFR ,0xffffffff ); +if (clustered_apic_mode) +apic_write_around (APIC_DFR ,APIC_DFR_CLUSTER ); +else +apic_write_around (APIC_DFR ,APIC_DFR_FLAT );/* * Set up the logical destination ID. */ value =apic_read (APIC_LDR ); - value &= ~APIC_LDR_MASK ; - value |= (1 <<(smp_processor_id ()+24 )); -apic_write_around (APIC_LDR , value); +apic_write_around (APIC_LDR ,apic_ldr_value (value)); }/*
arch/i386/kernel/io_apic.c +42 -66
185 lines not on this page · raw message
arch/i386/kernel/irq.c +2 -0
@@ -332,6 +332,7 @@irq_enter (); kstat.irqs[cpu][irq]++; +apic_adj_tpr (TPR_IRQ );spin_lock (&desc->lock); desc->handler->ack (irq);/*
@@ -389,6 +390,7 @@*/ desc->handler->end (irq);spin_unlock (&desc->lock); +apic_adj_tpr (-TPR_IRQ );irq_exit ();
arch/i386/kernel/mpparse.c +100 -20
226 lines not on this page · raw message
arch/i386/kernel/process.c +3 -1
@@ -145,7 +145,9 @@ irq_stat[smp_processor_id ()].idle_timestamp = jiffies;while (!need_resched ())idle (); +apic_set_tpr (TPR_TASK );schedule (); +apic_set_tpr (TPR_IDLE ); } }
@@ -197,7 +199,7 @@ }/* we will leave sorting out the final value when we are ready to reboot, since we might not -have set up boot_cpu_id or smp_num_cpu */ +have set up boot_cpu_physical_apicid or smp_num_cpu */ break ;#endif }
arch/i386/kernel/smpboot.c +64 -76
262 lines not on this page · raw message
arch/i386/kernel/trampoline.S +0 -2
@@ -36,9 +36,7 @@ ENTRY(trampoline_data) r_base = . -#ifdef CONFIG_MULTIQUAD wbinvd -#endif /* CONFIG_MULTIQUAD */ mov %cs, %ax # Code and data in the same place mov %ax, %ds
include/asm-i386/acpi.h +3 -0
@@ -138,6 +138,9 @@/* early initialization routine */ extern void acpi_reserve_bootmem (void ); +/* Check for special HW using OEM name lists */ +extern void acpi_madt_oem_check (char *oem_id,char *oem_table_id); +#endif /*CONFIG_ACPI_SLEEP*/ #endif /*__KERNEL__*/
include/asm-i386/apic.h +25 -0
@@ -64,6 +64,22 @@apic_write_around (APIC_EOI ,0 ); } +static inline void apic_set_tpr (unsigned long val) +{ +unsigned long value; + + value =apic_read (APIC_TASKPRI ); +apic_write_around (APIC_TASKPRI , (value & ~APIC_TPRI_MASK ) + val); +} + +static inline void apic_adj_tpr (long adj) +{ +unsigned long value; + + value =apic_read (APIC_TASKPRI ); +apic_write_around (APIC_TASKPRI , value + adj); +} +extern int get_maxlvt (void );extern void clear_local_APIC (void );extern void connect_bsp_APIC (void );
@@ -96,6 +112,15 @@#define NMI_LOCAL_APIC 2#define NMI_INVALID 3 +#else /* CONFIG_X86_LOCAL_APIC */ +#define apic_set_tpr (val) +#define apic_adj_tpr (adj)#endif /* CONFIG_X86_LOCAL_APIC */ +/* Priority values for apic_adj_tpr() and apic_set_tpr() */ +/* xAPICs only do priority comparisons on the upper nibble. */ +#define TPR_IDLE (0x00L) +#define TPR_TASK (0x10L) +#define TPR_IRQ (0x10L) +#endif /* __ASM_APIC_H */
include/asm-i386/apicdef.h +14 -3
@@ -11,8 +11,10 @@#define APIC_DEFAULT_PHYS_BASE 0xfee00000#define APIC_ID 0x20 -#define APIC_ID_MASK (0x0F<<24) -#define GET_APIC_ID (x) (((x)>>24)&0x0F) +#define APIC_ID_MASK (0xFF<<24) +#define GET_APIC_ID (x) (((x)>>24)&0xFF) +#define XAPIC_VER_LOW 0x14/* Version num range */ +#define XAPIC_VER_HIGH 0x1F#define APIC_LVR 0x30#define APIC_LVR_MASK 0xFF00FF#define GET_APIC_VERSION (x) ((x)&0xFF)
@@ -32,6 +34,8 @@#define SET_APIC_LOGICAL_ID (x) (((x)<<24))#define APIC_ALL_CPUS 0xFF#define APIC_DFR 0xE0 +#define APIC_DFR_CLUSTER 0x0FFFFFFFul/* Clustered */ +#define APIC_DFR_FLAT 0xFFFFFFFFul/* Flat mode */ #define APIC_SPIV 0xF0#define APIC_SPIV_FOCUS_DISABLED (1<<9)#define APIC_SPIV_APIC_ENABLED (1<<8)
@@ -58,6 +62,7 @@#define APIC_INT_ASSERT 0x04000#define APIC_ICR_BUSY 0x01000#define APIC_DEST_LOGICAL 0x00800 +#define APIC_DEST_PHYSICAL 0x0/* For symmetry */ #define APIC_DM_FIXED 0x00000#define APIC_DM_LOWEST 0x00100#define APIC_DM_SMI 0x00200
@@ -108,7 +113,13 @@#define APIC_BASE (fix_to_virt(FIX_APIC_BASE)) -#define MAX_IO_APICS 8 +#define MAX_IO_APICS 32/* Summit boxes can have 4*(2+3*2) I/O APICs */ + +/* +* The intr broadcast ID is 0xF for old APICs and 0xFF for xAPICs. +*/ +#define APIC_BROADCAST_ID_XAPIC 0xFF +#define APIC_BROADCAST_ID_APIC 0x0F/* * the local APIC register structure, memory mapped. Not terribly well
include/asm-i386/mpspec.h +3 -5
@@ -14,13 +14,10 @@#define SMP_MAGIC_IDENT (('_'<<24)|('P'<<16)|('M'<<8)|'_')/* -* a maximum of 16 APICs with the current APIC ID architecture. +* A maximum of 16 APICs with the classic APIC ID architecture. +* xAPICs can have up to 256. */ -#ifdef CONFIG_MULTIQUAD #define MAX_APICS 256 -#else /* !CONFIG_MULTIQUAD */ -#define MAX_APICS 16 -#endif /* CONFIG_MULTIQUAD */ #define MAX_MPC_ENTRY 1024
@@ -204,6 +201,7 @@extern int mp_bus_id_to_pci_bus [MAX_MP_BUSSES ];extern unsigned int boot_cpu_physical_apicid; +extern unsigned int boot_cpu_logical_apicid;extern unsigned long phys_cpu_present_map;extern int smp_found_config;extern void find_smp_config (void );
include/asm-i386/smp.h +50 -37
113 lines not on this page · raw message
include/asm-i386/smpboot.h +29 -49
91 lines not on this page · raw message