2002-12-13 01:34:07

by Zwane Mwaikambo

[permalink] [raw]
Subject: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit

Hi,
I've got an 32x SMP system which has an xAPIC but utilises flat
addressing. This patch is to rename what was formerly x86_summit to
x86_xapic (just to avoid confusion) and then select mask depending on
that.

Untested/uncompiled patch

Index: linux-2.5.51/include/asm-i386/apic.h
===================================================================
RCS file: /build/cvsroot/linux-2.5.51/include/asm-i386/apic.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 apic.h
--- linux-2.5.51/include/asm-i386/apic.h 10 Dec 2002 12:47:44 -0000 1.1.1.1
+++ linux-2.5.51/include/asm-i386/apic.h 12 Dec 2002 17:10:51 -0000
@@ -90,6 +90,7 @@
extern int check_nmi_watchdog (void);
extern void enable_NMI_through_LVT0 (void * dummy);

+extern int x86_xapic;
extern unsigned int nmi_watchdog;
#define NMI_NONE 0
#define NMI_IO_APIC 1
Index: linux-2.5.51/include/asm-i386/apicdef.h
===================================================================
RCS file: /build/cvsroot/linux-2.5.51/include/asm-i386/apicdef.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 apicdef.h
--- linux-2.5.51/include/asm-i386/apicdef.h 10 Dec 2002 12:47:44 -0000 1.1.1.1
+++ linux-2.5.51/include/asm-i386/apicdef.h 12 Dec 2002 03:22:59 -0000
@@ -9,10 +9,11 @@
*/

#define APIC_DEFAULT_PHYS_BASE 0xfee00000
-
+extern int x86_xapic;
+#define APIC_BROADCAST_ID (x86_xapic ? 0xFF : 0x0F)
#define APIC_ID 0x20
-#define APIC_ID_MASK (0x0F<<24)
-#define GET_APIC_ID(x) (((x)>>24)&0x0F)
+#define APIC_ID_MASK (APIC_BROADCAST_ID<<24)
+#define GET_APIC_ID(x) (((x)>>24)&APIC_BROADCAST_ID)
#define APIC_LVR 0x30
#define APIC_LVR_MASK 0xFF00FF
#define GET_APIC_VERSION(x) ((x)&0xFF)
Index: linux-2.5.51/arch/i386/kernel/apic.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.51/arch/i386/kernel/apic.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 apic.c
--- linux-2.5.51/arch/i386/kernel/apic.c 10 Dec 2002 12:46:46 -0000 1.1.1.1
+++ linux-2.5.51/arch/i386/kernel/apic.c 12 Dec 2002 17:08:26 -0000
@@ -33,6 +33,8 @@
#include <asm/arch_hooks.h>
#include "mach_apic.h"

+int x86_xapic;
+
void __init apic_intr_init(void)
{
#ifdef CONFIG_SMP
Index: linux-2.5.51/arch/i386/kernel/io_apic.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.51/arch/i386/kernel/io_apic.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 io_apic.c
--- linux-2.5.51/arch/i386/kernel/io_apic.c 10 Dec 2002 12:46:46 -0000 1.1.1.1
+++ linux-2.5.51/arch/i386/kernel/io_apic.c 12 Dec 2002 16:08:04 -0000
@@ -1147,7 +1147,7 @@

if (clustered_apic_mode)
/* We don't have a good way to do this yet - hack */
- phys_id_present_map = (u_long) 0xf;
+ phys_id_present_map = (u_long) APIC_BROADCAST_ID;
/*
* Set the IOAPIC ID to the value stored in the MPC table.
*/
@@ -1177,10 +1177,10 @@
mp_ioapics[apic].mpc_apicid)) {
printk(KERN_ERR "BIOS bug, IO-APIC#%d ID %d is already used!...\n",
apic, mp_ioapics[apic].mpc_apicid);
- for (i = 0; i < 0xf; i++)
+ for (i = 0; i < APIC_BROADCAST_ID; i++)
if (!(phys_id_present_map & (1 << i)))
break;
- if (i >= 0xf)
+ if (i >= APIC_BROADCAST_ID)
panic("Max APIC ID exceeded!\n");
printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n",
i);
Index: linux-2.5.51/arch/i386/kernel/mpparse.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.51/arch/i386/kernel/mpparse.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 mpparse.c
--- linux-2.5.51/arch/i386/kernel/mpparse.c 10 Dec 2002 12:46:46 -0000 1.1.1.1
+++ linux-2.5.51/arch/i386/kernel/mpparse.c 12 Dec 2002 17:07:39 -0000
@@ -67,10 +67,9 @@
/* Internal processor count */
static unsigned int __initdata num_processors;

-/* Bitmask of physically existing CPUs */
+/* Bitmask of physically present CPUs and IOAPICs */
unsigned long phys_cpu_present_map;

-int summit_x86 = 0;
u8 raw_phys_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID };

/*
@@ -394,7 +393,7 @@
str[12]=0;
printk("Product ID: %s ",str);

- summit_check(oem, str);
+ smp_hardware_check(oem, str);

printk("APIC at: 0x%lX\n",mpc->mpc_lapic);

Index: linux-2.5.51/arch/i386/mach-generic/mach_apic.h
===================================================================
RCS file: /build/cvsroot/linux-2.5.51/arch/i386/mach-generic/mach_apic.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 mach_apic.h
--- linux-2.5.51/arch/i386/mach-generic/mach_apic.h 10 Dec 2002 12:46:46 -0000 1.1.1.1
+++ linux-2.5.51/arch/i386/mach-generic/mach_apic.h 12 Dec 2002 03:49:07 -0000
@@ -17,11 +17,15 @@
#define TARGET_CPUS 0x01
#endif

-#define APIC_BROADCAST_ID 0x0F
#define check_apicid_used(bitmap, apicid) (bitmap & (1 << apicid))

-static inline void summit_check(char *oem, char *productid)
+static inline void smp_hardware_check(char *oem, char *productid)
{
+ unsigned long ver, reg = apic_read(APIC_LVR);
+
+ ver = GET_APIC_VERSION(reg);
+ if (ver == 0x14)
+ x86_xapic = 1;
}

static inline void clustered_apic_check(void)
Index: linux-2.5.51/arch/i386/mach-summit/mach_apic.h
===================================================================
RCS file: /build/cvsroot/linux-2.5.51/arch/i386/mach-summit/mach_apic.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 mach_apic.h
--- linux-2.5.51/arch/i386/mach-summit/mach_apic.h 10 Dec 2002 12:46:46 -0000 1.1.1.1
+++ linux-2.5.51/arch/i386/mach-summit/mach_apic.h 12 Dec 2002 03:49:20 -0000
@@ -1,8 +1,6 @@
#ifndef __ASM_MACH_APIC_H
#define __ASM_MACH_APIC_H

-extern int x86_summit;
-
#define XAPIC_DEST_CPUS_MASK 0x0Fu
#define XAPIC_DEST_CLUSTER_MASK 0xF0u

@@ -13,34 +11,33 @@
{
unsigned long id;

- if (x86_summit)
+ if (x86_xapic)
id = xapic_phys_to_log_apicid(hard_smp_processor_id());
else
id = 1UL << smp_processor_id();
return ((old & ~APIC_LDR_MASK) | SET_APIC_LOGICAL_ID(id));
}

-#define APIC_DFR_VALUE (x86_summit ? APIC_DFR_CLUSTER : APIC_DFR_FLAT)
-#define TARGET_CPUS (x86_summit ? XAPIC_DEST_CPUS_MASK : cpu_online_map)
+#define APIC_DFR_VALUE (x86_xapic ? APIC_DFR_CLUSTER : APIC_DFR_FLAT)
+#define TARGET_CPUS (x86_xapic ? XAPIC_DEST_CPUS_MASK : cpu_online_map)

-#define APIC_BROADCAST_ID (x86_summit ? 0xFF : 0x0F)
#define check_apicid_used(bitmap, apicid) (0)

-static inline void summit_check(char *oem, char *productid)
+static inline void smp_hardware_check(char *oem, char *productid)
{
if (!strncmp(oem, "IBM ENSW", 8) && !strncmp(str, "VIGIL SMP", 9))
- x86_summit = 1;
+ x86_xapic = 1;
}

static inline void clustered_apic_check(void)
{
printk("Enabling APIC mode: %s. Using %d I/O APICs\n",
- (x86_summit ? "Summit" : "Flat"), nr_ioapics);
+ (x86_xapic ? "Summit" : "Flat"), nr_ioapics);
}

static inline int cpu_present_to_apicid(int mps_cpu)
{
- if (x86_summit)
+ if (x86_xapic)
return (int) raw_phys_apicid[mps_cpu];
else
return mps_cpu;
@@ -48,7 +45,7 @@

static inline unsigned long apicid_to_phys_cpu_present(int apicid)
{
- if (x86_summit)
+ if (x86_xapic)
return (1ul << (((apicid >> 4) << 2) | (apicid & 0x3)));
else
return (1ul << apicid);


2002-12-13 02:02:19

by James Cleverdon

[permalink] [raw]
Subject: Re: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit

On Thursday 12 December 2002 05:44 pm, Zwane Mwaikambo wrote:
> Hi,
> I've got an 32x SMP system which has an xAPIC but utilises flat
> addressing. This patch is to rename what was formerly x86_summit to
> x86_xapic (just to avoid confusion) and then select mask depending on
> that.
>
> Untested/uncompiled patch

Hi Zwane,

How can you have a 32-way SMP system with flat addressing? There are only 8
bits in the destination address field. Even if you work around that by
assigning a set of CPUs to each dest addr bit, there can only be 15 physical
APIC IDs in flat mode. To get to 32 you must switch into clustered mode.

Please tell me more. I'm intrigued how this can be done.


> Index: linux-2.5.51/include/asm-i386/apic.h
> ===================================================================
> RCS file: /build/cvsroot/linux-2.5.51/include/asm-i386/apic.h,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 apic.h
> --- linux-2.5.51/include/asm-i386/apic.h 10 Dec 2002 12:47:44 -0000 1.1.1.1
> +++ linux-2.5.51/include/asm-i386/apic.h 12 Dec 2002 17:10:51 -0000
> @@ -90,6 +90,7 @@
> extern int check_nmi_watchdog (void);
> extern void enable_NMI_through_LVT0 (void * dummy);
>
> +extern int x86_xapic;
> extern unsigned int nmi_watchdog;
> #define NMI_NONE 0
> #define NMI_IO_APIC 1
> Index: linux-2.5.51/include/asm-i386/apicdef.h
> ===================================================================
> RCS file: /build/cvsroot/linux-2.5.51/include/asm-i386/apicdef.h,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 apicdef.h
> --- linux-2.5.51/include/asm-i386/apicdef.h 10 Dec 2002 12:47:44
> -0000 1.1.1.1 +++ linux-2.5.51/include/asm-i386/apicdef.h 12 Dec 2002
> 03:22:59 -0000 @@ -9,10 +9,11 @@
> */
>
> #define APIC_DEFAULT_PHYS_BASE 0xfee00000
> -
> +extern int x86_xapic;
> +#define APIC_BROADCAST_ID (x86_xapic ? 0xFF : 0x0F)
> #define APIC_ID 0x20
> -#define APIC_ID_MASK (0x0F<<24)
> -#define GET_APIC_ID(x) (((x)>>24)&0x0F)
> +#define APIC_ID_MASK (APIC_BROADCAST_ID<<24)
> +#define GET_APIC_ID(x) (((x)>>24)&APIC_BROADCAST_ID)
> #define APIC_LVR 0x30
> #define APIC_LVR_MASK 0xFF00FF
> #define GET_APIC_VERSION(x) ((x)&0xFF)
> Index: linux-2.5.51/arch/i386/kernel/apic.c
> ===================================================================
> RCS file: /build/cvsroot/linux-2.5.51/arch/i386/kernel/apic.c,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 apic.c
> --- linux-2.5.51/arch/i386/kernel/apic.c 10 Dec 2002 12:46:46 -0000 1.1.1.1
> +++ linux-2.5.51/arch/i386/kernel/apic.c 12 Dec 2002 17:08:26 -0000
> @@ -33,6 +33,8 @@
> #include <asm/arch_hooks.h>
> #include "mach_apic.h"
>
> +int x86_xapic;
> +
> void __init apic_intr_init(void)
> {
> #ifdef CONFIG_SMP
> Index: linux-2.5.51/arch/i386/kernel/io_apic.c
> ===================================================================
> RCS file: /build/cvsroot/linux-2.5.51/arch/i386/kernel/io_apic.c,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 io_apic.c
> --- linux-2.5.51/arch/i386/kernel/io_apic.c 10 Dec 2002 12:46:46
> -0000 1.1.1.1 +++ linux-2.5.51/arch/i386/kernel/io_apic.c 12 Dec 2002
> 16:08:04 -0000 @@ -1147,7 +1147,7 @@
>
> if (clustered_apic_mode)
> /* We don't have a good way to do this yet - hack */
> - phys_id_present_map = (u_long) 0xf;
> + phys_id_present_map = (u_long) APIC_BROADCAST_ID;
> /*
> * Set the IOAPIC ID to the value stored in the MPC table.
> */
> @@ -1177,10 +1177,10 @@
> mp_ioapics[apic].mpc_apicid)) {
> printk(KERN_ERR "BIOS bug, IO-APIC#%d ID %d is already used!...\n",
> apic, mp_ioapics[apic].mpc_apicid);
> - for (i = 0; i < 0xf; i++)
> + for (i = 0; i < APIC_BROADCAST_ID; i++)
> if (!(phys_id_present_map & (1 << i)))
> break;
> - if (i >= 0xf)
> + if (i >= APIC_BROADCAST_ID)
> panic("Max APIC ID exceeded!\n");
> printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n",
> i);
> Index: linux-2.5.51/arch/i386/kernel/mpparse.c
> ===================================================================
> RCS file: /build/cvsroot/linux-2.5.51/arch/i386/kernel/mpparse.c,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 mpparse.c
> --- linux-2.5.51/arch/i386/kernel/mpparse.c 10 Dec 2002 12:46:46
> -0000 1.1.1.1 +++ linux-2.5.51/arch/i386/kernel/mpparse.c 12 Dec 2002
> 17:07:39 -0000 @@ -67,10 +67,9 @@
> /* Internal processor count */
> static unsigned int __initdata num_processors;
>
> -/* Bitmask of physically existing CPUs */
> +/* Bitmask of physically present CPUs and IOAPICs */
> unsigned long phys_cpu_present_map;
>
> -int summit_x86 = 0;
> u8 raw_phys_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID };
>
> /*
> @@ -394,7 +393,7 @@
> str[12]=0;
> printk("Product ID: %s ",str);
>
> - summit_check(oem, str);
> + smp_hardware_check(oem, str);
>
> printk("APIC at: 0x%lX\n",mpc->mpc_lapic);
>
> Index: linux-2.5.51/arch/i386/mach-generic/mach_apic.h
> ===================================================================
> RCS file: /build/cvsroot/linux-2.5.51/arch/i386/mach-generic/mach_apic.h,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 mach_apic.h
> --- linux-2.5.51/arch/i386/mach-generic/mach_apic.h 10 Dec 2002 12:46:46
> -0000 1.1.1.1 +++ linux-2.5.51/arch/i386/mach-generic/mach_apic.h 12 Dec
> 2002 03:49:07 -0000 @@ -17,11 +17,15 @@
> #define TARGET_CPUS 0x01
> #endif
>
> -#define APIC_BROADCAST_ID 0x0F
> #define check_apicid_used(bitmap, apicid) (bitmap & (1 << apicid))
>
> -static inline void summit_check(char *oem, char *productid)
> +static inline void smp_hardware_check(char *oem, char *productid)
> {
> + unsigned long ver, reg = apic_read(APIC_LVR);
> +
> + ver = GET_APIC_VERSION(reg);
> + if (ver == 0x14)
> + x86_xapic = 1;
> }
>
> static inline void clustered_apic_check(void)
> Index: linux-2.5.51/arch/i386/mach-summit/mach_apic.h
> ===================================================================
> RCS file: /build/cvsroot/linux-2.5.51/arch/i386/mach-summit/mach_apic.h,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 mach_apic.h
> --- linux-2.5.51/arch/i386/mach-summit/mach_apic.h 10 Dec 2002 12:46:46
> -0000 1.1.1.1 +++ linux-2.5.51/arch/i386/mach-summit/mach_apic.h 12 Dec
> 2002 03:49:20 -0000 @@ -1,8 +1,6 @@
> #ifndef __ASM_MACH_APIC_H
> #define __ASM_MACH_APIC_H
>
> -extern int x86_summit;
> -
> #define XAPIC_DEST_CPUS_MASK 0x0Fu
> #define XAPIC_DEST_CLUSTER_MASK 0xF0u
>
> @@ -13,34 +11,33 @@
> {
> unsigned long id;
>
> - if (x86_summit)
> + if (x86_xapic)
> id = xapic_phys_to_log_apicid(hard_smp_processor_id());
> else
> id = 1UL << smp_processor_id();
> return ((old & ~APIC_LDR_MASK) | SET_APIC_LOGICAL_ID(id));
> }
>
> -#define APIC_DFR_VALUE (x86_summit ? APIC_DFR_CLUSTER : APIC_DFR_FLAT)
> -#define TARGET_CPUS (x86_summit ? XAPIC_DEST_CPUS_MASK : cpu_online_map)
> +#define APIC_DFR_VALUE (x86_xapic ? APIC_DFR_CLUSTER : APIC_DFR_FLAT)
> +#define TARGET_CPUS (x86_xapic ? XAPIC_DEST_CPUS_MASK : cpu_online_map)
>
> -#define APIC_BROADCAST_ID (x86_summit ? 0xFF : 0x0F)
> #define check_apicid_used(bitmap, apicid) (0)
>
> -static inline void summit_check(char *oem, char *productid)
> +static inline void smp_hardware_check(char *oem, char *productid)
> {
> if (!strncmp(oem, "IBM ENSW", 8) && !strncmp(str, "VIGIL SMP", 9))
> - x86_summit = 1;
> + x86_xapic = 1;
> }
>
> static inline void clustered_apic_check(void)
> {
> printk("Enabling APIC mode: %s. Using %d I/O APICs\n",
> - (x86_summit ? "Summit" : "Flat"), nr_ioapics);
> + (x86_xapic ? "Summit" : "Flat"), nr_ioapics);
> }
>
> static inline int cpu_present_to_apicid(int mps_cpu)
> {
> - if (x86_summit)
> + if (x86_xapic)
> return (int) raw_phys_apicid[mps_cpu];
> else
> return mps_cpu;
> @@ -48,7 +45,7 @@
>
> static inline unsigned long apicid_to_phys_cpu_present(int apicid)
> {
> - if (x86_summit)
> + if (x86_xapic)
> return (1ul << (((apicid >> 4) << 2) | (apicid & 0x3)));
> else
> return (1ul << apicid);
> -


--
James Cleverdon
IBM xSeries Linux Solutions
{jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot com

2002-12-13 02:11:19

by Zwane Mwaikambo

[permalink] [raw]
Subject: Re: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit

On Thu, 12 Dec 2002, James Cleverdon wrote:

> On Thursday 12 December 2002 05:44 pm, Zwane Mwaikambo wrote:
> > Hi,
> > I've got an 32x SMP system which has an xAPIC but utilises flat
> > addressing. This patch is to rename what was formerly x86_summit to
> > x86_xapic (just to avoid confusion) and then select mask depending on
> > that.
> >
> > Untested/uncompiled patch
>
> Hi Zwane,
>
> How can you have a 32-way SMP system with flat addressing? There are only 8
> bits in the destination address field. Even if you work around that by
> assigning a set of CPUs to each dest addr bit, there can only be 15 physical
> APIC IDs in flat mode. To get to 32 you must switch into clustered mode.
>
> Please tell me more. I'm intrigued how this can be done.

Hi James,
with the xAPIC we can use the 8bit address space everywhere in
physical destination mode. For example the ICR now has an 8bit space for
destination.

"Specifies the target processor or processors. This field is only used
when the destination shorthand field is set to 00B. If the destination
mode is set to physical, then bits 56 through 59 contain the APIC ID of
the target processor for Pentium and P6 family processors and bits 56
through 63 contain the APIC ID of the target processor the for Pentium 4
and Intel Xeon processors. If the destination mode is set to logical, the
interpretation of the 8-bit destination field depends on the settings of
the DFR and LDR registers of the local APICs in all the processors in the
system (see Section 8.6.2., Determining IPI Destination )."
- System Developer's Manual vol3 p291

Regards,
Zwane
--
function.linuxpower.ca

2002-12-13 02:35:13

by James Cleverdon

[permalink] [raw]
Subject: Re: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit

On Thursday 12 December 2002 06:21 pm, Zwane Mwaikambo wrote:
> On Thu, 12 Dec 2002, James Cleverdon wrote:
> > On Thursday 12 December 2002 05:44 pm, Zwane Mwaikambo wrote:
> > > Hi,
> > > I've got an 32x SMP system which has an xAPIC but utilises flat
> > > addressing. This patch is to rename what was formerly x86_summit to
> > > x86_xapic (just to avoid confusion) and then select mask depending on
> > > that.
> > >
> > > Untested/uncompiled patch
> >
> > Hi Zwane,
> >
> > How can you have a 32-way SMP system with flat addressing? There are
> > only 8 bits in the destination address field. Even if you work around
> > that by assigning a set of CPUs to each dest addr bit, there can only be
> > 15 physical APIC IDs in flat mode. To get to 32 you must switch into
> > clustered mode.
> >
> > Please tell me more. I'm intrigued how this can be done.
>
> Hi James,
> with the xAPIC we can use the 8bit address space everywhere in
> physical destination mode. For example the ICR now has an 8bit space for
> destination.
>
> "Specifies the target processor or processors. This field is only used
> when the destination shorthand field is set to 00B. If the destination
> mode is set to physical, then bits 56 through 59 contain the APIC ID of
> the target processor for Pentium and P6 family processors and bits 56
> through 63 contain the APIC ID of the target processor the for Pentium 4
> and Intel Xeon processors. If the destination mode is set to logical, the
> interpretation of the 8-bit destination field depends on the settings of
> the DFR and LDR registers of the local APICs in all the processors in the
> system (see Section 8.6.2., Determining IPI Destination )."
> - System Developer's Manual vol3 p291
>
> Regards,
> Zwane

Sure you can physically address them, if you assign IDs using Intel's official
xAPIC numbering scheme (which must be clustered for more than 7 CPUs). But,
you still don't have enough destination address bits to go around. In flat
mode, the kernel assumes you have one bit per CPU and phys IDs will be < 0xF.

Bill tells me that you may be doing this for an emulator. Why not emulate
clusered APIC mode, like the real hardware uses?

I know the name x86_summit doesn't really fit. The summit patch should work
for any xAPIC box that uses the system bus for interrupt delivery and has
multiple APIC clusters. Is that what you're working towards?

--
James Cleverdon
IBM xSeries Linux Solutions
{jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot com

2002-12-13 02:57:52

by Nakajima, Jun

[permalink] [raw]
Subject: RE: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit

BTW, we are working on a xAPIC patch that supports more than 8 CPUs in a
generic fashion (don't use hardcode OEM checking). We already tested it on
two OEM systems with 16 CPUs.
- It uses clustered mode. We don't want to use physical mode because it does
not support lowest priority delivery mode.
- We also check the version of the local APIC if it's xAPIC or not. It's
possible that some other x86 architecture (other than P4P) uses xAPIC.

Stay tuned.

Jun
> -----Original Message-----
> From: James Cleverdon [mailto:[email protected]]
> Sent: Thursday, December 12, 2002 6:42 PM
> To: Zwane Mwaikambo
> Cc: Martin Bligh; John Stultz; Linux Kernel
> Subject: Re: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit
>
> On Thursday 12 December 2002 06:21 pm, Zwane Mwaikambo wrote:
> > On Thu, 12 Dec 2002, James Cleverdon wrote:
> > > On Thursday 12 December 2002 05:44 pm, Zwane Mwaikambo wrote:
> > > > Hi,
> > > > I've got an 32x SMP system which has an xAPIC but utilises
> flat
> > > > addressing. This patch is to rename what was formerly x86_summit to
> > > > x86_xapic (just to avoid confusion) and then select mask depending
> on
> > > > that.
> > > >
> > > > Untested/uncompiled patch
> > >
> > > Hi Zwane,
> > >
> > > How can you have a 32-way SMP system with flat addressing? There are
> > > only 8 bits in the destination address field. Even if you work around
> > > that by assigning a set of CPUs to each dest addr bit, there can only
> be
> > > 15 physical APIC IDs in flat mode. To get to 32 you must switch into
> > > clustered mode.
> > >
> > > Please tell me more. I'm intrigued how this can be done.
> >
> > Hi James,
> > with the xAPIC we can use the 8bit address space everywhere in
> > physical destination mode. For example the ICR now has an 8bit space for
> > destination.
> >
> > "Specifies the target processor or processors. This field is only used
> > when the destination shorthand field is set to 00B. If the destination
> > mode is set to physical, then bits 56 through 59 contain the APIC ID of
> > the target processor for Pentium and P6 family processors and bits 56
> > through 63 contain the APIC ID of the target processor the for Pentium 4
> > and Intel Xeon processors. If the destination mode is set to logical,
> the
> > interpretation of the 8-bit destination field depends on the settings of
> > the DFR and LDR registers of the local APICs in all the processors in
> the
> > system (see Section 8.6.2., Determining IPI Destination )."
> > - System Developer's Manual vol3 p291
> >
> > Regards,
> > Zwane
>
> Sure you can physically address them, if you assign IDs using Intel's
> official
> xAPIC numbering scheme (which must be clustered for more than 7 CPUs).
> But,
> you still don't have enough destination address bits to go around. In
> flat
> mode, the kernel assumes you have one bit per CPU and phys IDs will be <
> 0xF.
>
> Bill tells me that you may be doing this for an emulator. Why not emulate
> clusered APIC mode, like the real hardware uses?
>
> I know the name x86_summit doesn't really fit. The summit patch should
> work
> for any xAPIC box that uses the system bus for interrupt delivery and has
> multiple APIC clusters. Is that what you're working towards?
>
> --
> James Cleverdon
> IBM xSeries Linux Solutions
> {jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot com
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2002-12-13 03:00:48

by Zwane Mwaikambo

[permalink] [raw]
Subject: Re: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit

On Thu, 12 Dec 2002, James Cleverdon wrote:

> Sure you can physically address them, if you assign IDs using Intel's official
> xAPIC numbering scheme (which must be clustered for more than 7 CPUs). But,
> you still don't have enough destination address bits to go around. In flat
> mode, the kernel assumes you have one bit per CPU and phys IDs will be < 0xF.
>
> Bill tells me that you may be doing this for an emulator. Why not emulate
> clusered APIC mode, like the real hardware uses?
>
> I know the name x86_summit doesn't really fit. The summit patch should work
> for any xAPIC box that uses the system bus for interrupt delivery and has
> multiple APIC clusters. Is that what you're working towards?

Hmm although i could then skip the logical destination mode and stick to
physical destination mode. This would greatly simplify my code paths since
i could almost use the same code for both normal SMP and this larger sim.
Debugging would then be somewhat simpler. My target doesn't have multiple
APIC clusters and all are addressable via a 0xff broadcast.

Thanks,
Zwane
--
function.linuxpower.ca

2002-12-13 03:15:42

by Zwane Mwaikambo

[permalink] [raw]
Subject: RE: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit

On Thu, 12 Dec 2002, Nakajima, Jun wrote:

> BTW, we are working on a xAPIC patch that supports more than 8 CPUs in a
> generic fashion (don't use hardcode OEM checking). We already tested it on
> two OEM systems with 16 CPUs.
> - It uses clustered mode. We don't want to use physical mode because it does
> not support lowest priority delivery mode.

Wouldn't that only be for all including self? Or is the documentation
incorrect?

Thanks,
Zwane
--
function.linuxpower.ca

2002-12-13 03:14:52

by James Cleverdon

[permalink] [raw]
Subject: Re: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit

On Thursday 12 December 2002 07:05 pm, Nakajima, Jun wrote:
> BTW, we are working on a xAPIC patch that supports more than 8 CPUs in a
> generic fashion (don't use hardcode OEM checking). We already tested it on
> two OEM systems with 16 CPUs.
> - It uses clustered mode. We don't want to use physical mode because it
> does not support lowest priority delivery mode.
> - We also check the version of the local APIC if it's xAPIC or not. It's
> possible that some other x86 architecture (other than P4P) uses xAPIC.
>
> Stay tuned.
>
> Jun

See my 2.5 summit patch for one that uses logical mode and lowest priority
delivery. I haven't submitted that for 2.4 because the physical patch has
the most run time on it, both in Alan's tree and SuSE 8.0+.

The hardcoded OEM checking was necessary because the Summit I/O APICs were
still using the older version number. (The HW folks claim that Intel didn't
specify the new number soon enough for them.)

I'm hesitant to key xAPIC vs. flat off the local APIC version number because
it's possible to build a flat system out of P4 CPUs. I/O APIC version
numbers combined with the parallel vs. serial bit would be safer (except for
the Summit problem above). I've also tried checking all the CPU's physical
APIC IDs to see if they use multiple APIC clusters.

> > -----Original Message-----
> > From: James Cleverdon [mailto:[email protected]]
> > Sent: Thursday, December 12, 2002 6:42 PM
> > To: Zwane Mwaikambo
> > Cc: Martin Bligh; John Stultz; Linux Kernel
> > Subject: Re: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit
> >
> > On Thursday 12 December 2002 06:21 pm, Zwane Mwaikambo wrote:
> > > On Thu, 12 Dec 2002, James Cleverdon wrote:
> > > > On Thursday 12 December 2002 05:44 pm, Zwane Mwaikambo wrote:
> > > > > Hi,
> > > > > I've got an 32x SMP system which has an xAPIC but utilises
> >
> > flat
> >
> > > > > addressing. This patch is to rename what was formerly x86_summit to
> > > > > x86_xapic (just to avoid confusion) and then select mask depending
> >
> > on
> >
> > > > > that.
> > > > >
> > > > > Untested/uncompiled patch
> > > >
> > > > Hi Zwane,
> > > >
> > > > How can you have a 32-way SMP system with flat addressing? There are
> > > > only 8 bits in the destination address field. Even if you work
> > > > around that by assigning a set of CPUs to each dest addr bit, there
> > > > can only
> >
> > be
> >
> > > > 15 physical APIC IDs in flat mode. To get to 32 you must switch into
> > > > clustered mode.
> > > >
> > > > Please tell me more. I'm intrigued how this can be done.
> > >
> > > Hi James,
> > > with the xAPIC we can use the 8bit address space everywhere in
> > > physical destination mode. For example the ICR now has an 8bit space
> > > for destination.
> > >
> > > "Specifies the target processor or processors. This field is only used
> > > when the destination shorthand field is set to 00B. If the destination
> > > mode is set to physical, then bits 56 through 59 contain the APIC ID of
> > > the target processor for Pentium and P6 family processors and bits 56
> > > through 63 contain the APIC ID of the target processor the for Pentium
> > > 4 and Intel Xeon processors. If the destination mode is set to logical,
> >
> > the
> >
> > > interpretation of the 8-bit destination field depends on the settings
> > > of the DFR and LDR registers of the local APICs in all the processors
> > > in
> >
> > the
> >
> > > system (see Section 8.6.2., Determining IPI Destination )."
> > > - System Developer's Manual vol3 p291
> > >
> > > Regards,
> > > Zwane
> >
> > Sure you can physically address them, if you assign IDs using Intel's
> > official
> > xAPIC numbering scheme (which must be clustered for more than 7 CPUs).
> > But,
> > you still don't have enough destination address bits to go around. In
> > flat
> > mode, the kernel assumes you have one bit per CPU and phys IDs will be <
> > 0xF.
> >
> > Bill tells me that you may be doing this for an emulator. Why not
> > emulate clusered APIC mode, like the real hardware uses?
> >
> > I know the name x86_summit doesn't really fit. The summit patch should
> > work
> > for any xAPIC box that uses the system bus for interrupt delivery and has
> > multiple APIC clusters. Is that what you're working towards?
> >
> > --
> > James Cleverdon
> > IBM xSeries Linux Solutions
> > {jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot com


--
James Cleverdon
IBM xSeries Linux Solutions
{jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot com

2002-12-13 03:13:07

by Nakajima, Jun

[permalink] [raw]
Subject: RE: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit

The clustering mode we are talking about is part of xAPIC functionality, not
a NUMA (or Multi-Quad) thing. Even a non-NUMA system, it's available if it
has xAPICs.

Jun

> -----Original Message-----
> From: Zwane Mwaikambo [mailto:[email protected]]
> Sent: Thursday, December 12, 2002 7:11 PM
> To: James Cleverdon
> Cc: Martin Bligh; John Stultz; Linux Kernel
> Subject: Re: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit
>
> On Thu, 12 Dec 2002, James Cleverdon wrote:
>
> > Sure you can physically address them, if you assign IDs using Intel's
> official
> > xAPIC numbering scheme (which must be clustered for more than 7 CPUs).
> But,
> > you still don't have enough destination address bits to go around. In
> flat
> > mode, the kernel assumes you have one bit per CPU and phys IDs will be <
> 0xF.
> >
> > Bill tells me that you may be doing this for an emulator. Why not
> emulate
> > clusered APIC mode, like the real hardware uses?
> >
> > I know the name x86_summit doesn't really fit. The summit patch should
> work
> > for any xAPIC box that uses the system bus for interrupt delivery and
> has
> > multiple APIC clusters. Is that what you're working towards?
>
> Hmm although i could then skip the logical destination mode and stick to
> physical destination mode. This would greatly simplify my code paths since
> i could almost use the same code for both normal SMP and this larger sim.
> Debugging would then be somewhat simpler. My target doesn't have multiple
> APIC clusters and all are addressable via a 0xff broadcast.
>
> Thanks,
> Zwane
> --
> function.linuxpower.ca
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2002-12-13 03:24:46

by James Cleverdon

[permalink] [raw]
Subject: Re: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit

On Thursday 12 December 2002 07:26 pm, Zwane Mwaikambo wrote:
> On Thu, 12 Dec 2002, Nakajima, Jun wrote:
> > BTW, we are working on a xAPIC patch that supports more than 8 CPUs in a
> > generic fashion (don't use hardcode OEM checking). We already tested it
> > on two OEM systems with 16 CPUs.
> > - It uses clustered mode. We don't want to use physical mode because it
> > does not support lowest priority delivery mode.
>
> Wouldn't that only be for all including self? Or is the documentation
> incorrect?
>
> Thanks,
> Zwane

I'm not sure I understand your question. Lowest Priority delivery mode only
works with logical interrupts. (I've tried it with physical intrs. It fails
miserably.) The "all including self" and "all excluding self" destination
shorthands don't do lowest priority arbitration. They always deliver the
interrupt to the CPUs mentioned in the shortand.

Lowest priority delivery mode isn't _too_ useful in Linux yet. It would be
nice to preferentially target idle CPUs with interrupts in real time. That
means changing each CPU's Task Priority Register (TPR) to represent how busy
it is. I've got some patches to do that, but haven't posted them as anything
more than a RFC.

--
James Cleverdon
IBM xSeries Linux Solutions
{jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot com

2002-12-13 05:45:19

by Steffen Persvold

[permalink] [raw]
Subject: Re: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit

On Thu, 12 Dec 2002, James Cleverdon wrote:

> On Thursday 12 December 2002 07:26 pm, Zwane Mwaikambo wrote:
> > On Thu, 12 Dec 2002, Nakajima, Jun wrote:
> > > BTW, we are working on a xAPIC patch that supports more than 8 CPUs in a
> > > generic fashion (don't use hardcode OEM checking). We already tested it
> > > on two OEM systems with 16 CPUs.
> > > - It uses clustered mode. We don't want to use physical mode because it
> > > does not support lowest priority delivery mode.
> >
> > Wouldn't that only be for all including self? Or is the documentation
> > incorrect?
> >
> > Thanks,
> > Zwane
>
> I'm not sure I understand your question. Lowest Priority delivery mode only
> works with logical interrupts. (I've tried it with physical intrs. It fails
> miserably.) The "all including self" and "all excluding self" destination
> shorthands don't do lowest priority arbitration. They always deliver the
> interrupt to the CPUs mentioned in the shortand.
>
> Lowest priority delivery mode isn't _too_ useful in Linux yet. It would be
> nice to preferentially target idle CPUs with interrupts in real time. That
> means changing each CPU's Task Priority Register (TPR) to represent how busy
> it is. I've got some patches to do that, but haven't posted them as anything
> more than a RFC.
>

Hmm, I though the APIC routing patch found in the LSE project
(http://sourceforge.net/projects/lse/) did this already. Atleast I've
tested this patch on a couple of Dual E7500 Xeon boxes (kernel 2.4.20) and
it distributes interrupts nicely.

However with the patch enabled, the interrupt latency on for example the
Intel GbE 82544GC devices increased a fraction with this patch (a
microsecond or two).

Regards,
--
Steffen Persvold | Scali AS
mailto:[email protected] | http://www.scali.com
Tel: (+47) 2262 8950 | Olaf Helsets vei 6
Fax: (+47) 2262 8951 | N0621 Oslo, NORWAY

2002-12-13 15:35:38

by Nakajima, Jun

[permalink] [raw]
Subject: RE: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit

I/O APIC? I'm talking about xAPIC, i.e. local APIC which is part of the
chip. Also note that I/O subsystem can generate interrupts (e.g. MSI,
Message Signaled Interrupt), bypassing I/O APICs.

Jun

> -----Original Message-----
> From: James Cleverdon [mailto:[email protected]]
> Sent: Thursday, December 12, 2002 7:22 PM
> To: Nakajima, Jun; Zwane Mwaikambo
> Cc: Martin Bligh; John Stultz; Linux Kernel
> Subject: Re: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit
>
> On Thursday 12 December 2002 07:05 pm, Nakajima, Jun wrote:
> > BTW, we are working on a xAPIC patch that supports more than 8 CPUs in a
> > generic fashion (don't use hardcode OEM checking). We already tested it
> on
> > two OEM systems with 16 CPUs.
> > - It uses clustered mode. We don't want to use physical mode because it
> > does not support lowest priority delivery mode.
> > - We also check the version of the local APIC if it's xAPIC or not. It's
> > possible that some other x86 architecture (other than P4P) uses xAPIC.
> >
> > Stay tuned.
> >
> > Jun
>
> See my 2.5 summit patch for one that uses logical mode and lowest priority
> delivery. I haven't submitted that for 2.4 because the physical patch has
> the most run time on it, both in Alan's tree and SuSE 8.0+.
>
> The hardcoded OEM checking was necessary because the Summit I/O APICs were
> still using the older version number. (The HW folks claim that Intel
> didn't
> specify the new number soon enough for them.)
>
> I'm hesitant to key xAPIC vs. flat off the local APIC version number
> because
> it's possible to build a flat system out of P4 CPUs. I/O APIC version
> numbers combined with the parallel vs. serial bit would be safer (except
> for
> the Summit problem above). I've also tried checking all the CPU's
> physical
> APIC IDs to see if they use multiple APIC clusters.
>
> > > -----Original Message-----
> > > From: James Cleverdon [mailto:[email protected]]
> > > Sent: Thursday, December 12, 2002 6:42 PM
> > > To: Zwane Mwaikambo
> > > Cc: Martin Bligh; John Stultz; Linux Kernel
> > > Subject: Re: [PATCH][2.5][RFC] Using xAPIC apic address space on
> !Summit
> > >
> > > On Thursday 12 December 2002 06:21 pm, Zwane Mwaikambo wrote:
> > > > On Thu, 12 Dec 2002, James Cleverdon wrote:
> > > > > On Thursday 12 December 2002 05:44 pm, Zwane Mwaikambo wrote:
> > > > > > Hi,
> > > > > > I've got an 32x SMP system which has an xAPIC but utilises
> > >
> > > flat
> > >
> > > > > > addressing. This patch is to rename what was formerly x86_summit
> to
> > > > > > x86_xapic (just to avoid confusion) and then select mask
> depending
> > >
> > > on
> > >
> > > > > > that.
> > > > > >
> > > > > > Untested/uncompiled patch
> > > > >
> > > > > Hi Zwane,
> > > > >
> > > > > How can you have a 32-way SMP system with flat addressing? There
> are
> > > > > only 8 bits in the destination address field. Even if you work
> > > > > around that by assigning a set of CPUs to each dest addr bit,
> there
> > > > > can only
> > >
> > > be
> > >
> > > > > 15 physical APIC IDs in flat mode. To get to 32 you must switch
> into
> > > > > clustered mode.
> > > > >
> > > > > Please tell me more. I'm intrigued how this can be done.
> > > >
> > > > Hi James,
> > > > with the xAPIC we can use the 8bit address space everywhere
in
> > > > physical destination mode. For example the ICR now has an 8bit space
> > > > for destination.
> > > >
> > > > "Specifies the target processor or processors. This field is only
> used
> > > > when the destination shorthand field is set to 00B. If the
> destination
> > > > mode is set to physical, then bits 56 through 59 contain the APIC ID
> of
> > > > the target processor for Pentium and P6 family processors and bits
> 56
> > > > through 63 contain the APIC ID of the target processor the for
> Pentium
> > > > 4 and Intel Xeon processors. If the destination mode is set to
> logical,
> > >
> > > the
> > >
> > > > interpretation of the 8-bit destination field depends on the
> settings
> > > > of the DFR and LDR registers of the local APICs in all the
> processors
> > > > in
> > >
> > > the
> > >
> > > > system (see Section 8.6.2., Determining IPI Destination )."
> > > > - System Developer's Manual vol3 p291
> > > >
> > > > Regards,
> > > > Zwane
> > >
> > > Sure you can physically address them, if you assign IDs using Intel's
> > > official
> > > xAPIC numbering scheme (which must be clustered for more than 7 CPUs).
> > > But,
> > > you still don't have enough destination address bits to go around. In
> > > flat
> > > mode, the kernel assumes you have one bit per CPU and phys IDs will be
> <
> > > 0xF.
> > >
> > > Bill tells me that you may be doing this for an emulator. Why not
> > > emulate clusered APIC mode, like the real hardware uses?
> > >
> > > I know the name x86_summit doesn't really fit. The summit patch
> should
> > > work
> > > for any xAPIC box that uses the system bus for interrupt delivery and
> has
> > > multiple APIC clusters. Is that what you're working towards?
> > >
> > > --
> > > James Cleverdon
> > > IBM xSeries Linux Solutions
> > > {jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot com
>
>
> --
> James Cleverdon
> IBM xSeries Linux Solutions
> {jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot com

2002-12-13 19:26:50

by James Cleverdon

[permalink] [raw]
Subject: Re: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit

On Thursday 12 December 2002 09:53 pm, Steffen Persvold wrote:
> On Thu, 12 Dec 2002, James Cleverdon wrote:
> > On Thursday 12 December 2002 07:26 pm, Zwane Mwaikambo wrote:
> > > On Thu, 12 Dec 2002, Nakajima, Jun wrote:
> > > > BTW, we are working on a xAPIC patch that supports more than 8 CPUs
> > > > in a generic fashion (don't use hardcode OEM checking). We already
> > > > tested it on two OEM systems with 16 CPUs.
> > > > - It uses clustered mode. We don't want to use physical mode because
> > > > it does not support lowest priority delivery mode.
> > >
> > > Wouldn't that only be for all including self? Or is the documentation
> > > incorrect?
> > >
> > > Thanks,
> > > Zwane
> >
> > I'm not sure I understand your question. Lowest Priority delivery mode
> > only works with logical interrupts. (I've tried it with physical intrs.
> > It fails miserably.) The "all including self" and "all excluding self"
> > destination shorthands don't do lowest priority arbitration. They always
> > deliver the interrupt to the CPUs mentioned in the shortand.
> >
> > Lowest priority delivery mode isn't _too_ useful in Linux yet. It would
> > be nice to preferentially target idle CPUs with interrupts in real time.
> > That means changing each CPU's Task Priority Register (TPR) to represent
> > how busy it is. I've got some patches to do that, but haven't posted
> > them as anything more than a RFC.
>
> Hmm, I though the APIC routing patch found in the LSE project
> (http://sourceforge.net/projects/lse/) did this already. Atleast I've
> tested this patch on a couple of Dual E7500 Xeon boxes (kernel 2.4.20) and
> it distributes interrupts nicely.
>
> However with the patch enabled, the interrupt latency on for example the
> Intel GbE 82544GC devices increased a fraction with this patch (a
> microsecond or two).
>
> Regards,

Sure, Dave Olien's patch adjusted the TPR. However, he wrote that for the
classic APIC; it does most of the priority adjustments in the lower nibble of
the TPR's value. xAPIC routing is done via HW in the PCI-to-host bridge
chips. There they keep a copy of each CPU's TPR value in eight XTPR
registers for lowest priority interrupt routing -- but only the TPR's upper
nibble. So, Dave's patch is less useful on xAPIC systems.

I came up with something simpler. Just 2 lines added to idle_cpu() and
do_IRQ respectively. It's a hack but it seemed useful.

Interesting that it would be a microsecond slower. Maybe that's the time it
takes to adjust the TPR. One more reason to keep those adjustments as simple
as possible.

--
James Cleverdon
IBM xSeries Linux Solutions
{jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot com

2002-12-13 19:33:36

by James Cleverdon

[permalink] [raw]
Subject: Re: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit

On Friday 13 December 2002 07:43 am, Nakajima, Jun wrote:
> I/O APIC? I'm talking about xAPIC, i.e. local APIC which is part of the
> chip. Also note that I/O subsystem can generate interrupts (e.g. MSI,
> Message Signaled Interrupt), bypassing I/O APICs.
>
> Jun

Part of the "x" in xAPIC is that it can communicate over the classic 2 data /
1 clock serial bus or send interrupts over the system bus. If operating in
serial mode, the old priority arbitration protocol works just fine. It's
parallel mode where we have problems. All the I/O interrupts tend to hit CPU
0, thanks to the XTPR HW's tie-breaker logic.

Intel has added a new register to I/O APICs that tells whether they're
operating in serial or parallel mode. It may be useful to read that bit
before activating some of the code in my patches.

I've never worked on a system that tries to use MSIs. Do they use lowest
priority delivery?

(FYI, Summit boxes are hardwired into parallel mode. There's no provision for
a serial APIC bus connecting the PCI expansion box to the CPUs.)

> > -----Original Message-----
> > From: James Cleverdon [mailto:[email protected]]
> > Sent: Thursday, December 12, 2002 7:22 PM
> > To: Nakajima, Jun; Zwane Mwaikambo
> > Cc: Martin Bligh; John Stultz; Linux Kernel
> > Subject: Re: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit
> >
> > On Thursday 12 December 2002 07:05 pm, Nakajima, Jun wrote:
> > > BTW, we are working on a xAPIC patch that supports more than 8 CPUs in
> > > a generic fashion (don't use hardcode OEM checking). We already tested
> > > it
> >
> > on
> >
> > > two OEM systems with 16 CPUs.
> > > - It uses clustered mode. We don't want to use physical mode because it
> > > does not support lowest priority delivery mode.
> > > - We also check the version of the local APIC if it's xAPIC or not.
> > > It's possible that some other x86 architecture (other than P4P) uses
> > > xAPIC.
> > >
> > > Stay tuned.
> > >
> > > Jun
> >
> > See my 2.5 summit patch for one that uses logical mode and lowest
> > priority delivery. I haven't submitted that for 2.4 because the physical
> > patch has the most run time on it, both in Alan's tree and SuSE 8.0+.
> >
> > The hardcoded OEM checking was necessary because the Summit I/O APICs
> > were still using the older version number. (The HW folks claim that
> > Intel didn't
> > specify the new number soon enough for them.)
> >
> > I'm hesitant to key xAPIC vs. flat off the local APIC version number
> > because
> > it's possible to build a flat system out of P4 CPUs. I/O APIC version
> > numbers combined with the parallel vs. serial bit would be safer (except
> > for
> > the Summit problem above). I've also tried checking all the CPU's
> > physical
> > APIC IDs to see if they use multiple APIC clusters.
> >
> > > > -----Original Message-----
> > > > From: James Cleverdon [mailto:[email protected]]
> > > > Sent: Thursday, December 12, 2002 6:42 PM
> > > > To: Zwane Mwaikambo
> > > > Cc: Martin Bligh; John Stultz; Linux Kernel
> > > > Subject: Re: [PATCH][2.5][RFC] Using xAPIC apic address space on
> >
> > !Summit
> >
> > > > On Thursday 12 December 2002 06:21 pm, Zwane Mwaikambo wrote:
> > > > > On Thu, 12 Dec 2002, James Cleverdon wrote:
> > > > > > On Thursday 12 December 2002 05:44 pm, Zwane Mwaikambo wrote:
> > > > > > > Hi,
> > > > > > > I've got an 32x SMP system which has an xAPIC but utilises
> > > >
> > > > flat
> > > >
> > > > > > > addressing. This patch is to rename what was formerly
> > > > > > > x86_summit
> >
> > to
> >
> > > > > > > x86_xapic (just to avoid confusion) and then select mask
> >
> > depending
> >
> > > > on
> > > >
> > > > > > > that.
> > > > > > >
> > > > > > > Untested/uncompiled patch
> > > > > >
> > > > > > Hi Zwane,
> > > > > >
> > > > > > How can you have a 32-way SMP system with flat addressing? There
> >
> > are
> >
> > > > > > only 8 bits in the destination address field. Even if you work
> > > > > > around that by assigning a set of CPUs to each dest addr bit,
> >
> > there
> >
> > > > > > can only
> > > >
> > > > be
> > > >
> > > > > > 15 physical APIC IDs in flat mode. To get to 32 you must switch
> >
> > into
> >
> > > > > > clustered mode.
> > > > > >
> > > > > > Please tell me more. I'm intrigued how this can be done.
> > > > >
> > > > > Hi James,
> > > > > with the xAPIC we can use the 8bit address space everywhere
>
> in
>
> > > > > physical destination mode. For example the ICR now has an 8bit
> > > > > space for destination.
> > > > >
> > > > > "Specifies the target processor or processors. This field is only
> >
> > used
> >
> > > > > when the destination shorthand field is set to 00B. If the
> >
> > destination
> >
> > > > > mode is set to physical, then bits 56 through 59 contain the APIC
> > > > > ID
> >
> > of
> >
> > > > > the target processor for Pentium and P6 family processors and bits
> >
> > 56
> >
> > > > > through 63 contain the APIC ID of the target processor the for
> >
> > Pentium
> >
> > > > > 4 and Intel Xeon processors. If the destination mode is set to
> >
> > logical,
> >
> > > > the
> > > >
> > > > > interpretation of the 8-bit destination field depends on the
> >
> > settings
> >
> > > > > of the DFR and LDR registers of the local APICs in all the
> >
> > processors
> >
> > > > > in
> > > >
> > > > the
> > > >
> > > > > system (see Section 8.6.2., Determining IPI Destination )."
> > > > > - System Developer's Manual vol3 p291
> > > > >
> > > > > Regards,
> > > > > Zwane
> > > >
> > > > Sure you can physically address them, if you assign IDs using Intel's
> > > > official
> > > > xAPIC numbering scheme (which must be clustered for more than 7
> > > > CPUs). But,
> > > > you still don't have enough destination address bits to go around.
> > > > In flat
> > > > mode, the kernel assumes you have one bit per CPU and phys IDs will
> > > > be
> >
> > <
> >
> > > > 0xF.
> > > >
> > > > Bill tells me that you may be doing this for an emulator. Why not
> > > > emulate clusered APIC mode, like the real hardware uses?
> > > >
> > > > I know the name x86_summit doesn't really fit. The summit patch
> >
> > should
> >
> > > > work
> > > > for any xAPIC box that uses the system bus for interrupt delivery and
> >
> > has
> >
> > > > multiple APIC clusters. Is that what you're working towards?
> > > >
> > > > --
> > > > James Cleverdon
> > > > IBM xSeries Linux Solutions
> > > > {jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot com
> >
> > --
> > James Cleverdon
> > IBM xSeries Linux Solutions
> > {jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot com

--
James Cleverdon
IBM xSeries Linux Solutions
{jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot com

2002-12-13 20:34:08

by Nakajima, Jun

[permalink] [raw]
Subject: RE: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit

Do you have performance data when you program TPR? Today, in 2.5, for
example, we are distributing interrupts among CPUs with Ingo's patch in
software. Doing that in software is fine because it's relatively simple, but
the chipset has more information on the on-going interrupt activities. So
using TPR might work better in general.

One issue with lowest priority delivery mode (as well as Ingo's) is that it
could have negative impacts on L2 caches (actually we saw such instances).
So we also have a patch to balance interrupts load (using statistic data)
without moving them around frequently (mostly static) and I think we can
combine that patch and lowest priority delivery mode.

Jun

> -----Original Message-----
> From: James Cleverdon [mailto:[email protected]]
> Sent: Thursday, December 12, 2002 7:32 PM
> To: Zwane Mwaikambo; Nakajima, Jun
> Cc: Martin Bligh; John Stultz; Linux Kernel
> Subject: Re: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit
>
> On Thursday 12 December 2002 07:26 pm, Zwane Mwaikambo wrote:
> > On Thu, 12 Dec 2002, Nakajima, Jun wrote:
> > > BTW, we are working on a xAPIC patch that supports more than 8 CPUs in
> a
> > > generic fashion (don't use hardcode OEM checking). We already tested
> it
> > > on two OEM systems with 16 CPUs.
> > > - It uses clustered mode. We don't want to use physical mode because
> it
> > > does not support lowest priority delivery mode.
> >
> > Wouldn't that only be for all including self? Or is the documentation
> > incorrect?
> >
> > Thanks,
> > Zwane
>
> I'm not sure I understand your question. Lowest Priority delivery mode
> only
> works with logical interrupts. (I've tried it with physical intrs. It
> fails
> miserably.) The "all including self" and "all excluding self" destination
> shorthands don't do lowest priority arbitration. They always deliver the
> interrupt to the CPUs mentioned in the shortand.
>
> Lowest priority delivery mode isn't _too_ useful in Linux yet. It would
> be
> nice to preferentially target idle CPUs with interrupts in real time.
> That
> means changing each CPU's Task Priority Register (TPR) to represent how
> busy
> it is. I've got some patches to do that, but haven't posted them as
> anything
> more than a RFC.
>
> --
> James Cleverdon
> IBM xSeries Linux Solutions
> {jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot com

2002-12-17 02:22:39

by Nakajima, Jun

[permalink] [raw]
Subject: RE: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit

> I've never worked on a system that tries to use MSIs. Do they use lowest
> priority delivery?

They should provide lowest priority delivery as well as direct.

Jun


> -----Original Message-----
> From: James Cleverdon [mailto:[email protected]]
> Sent: Friday, December 13, 2002 11:40 AM
> To: Nakajima, Jun; Zwane Mwaikambo
> Cc: Martin Bligh; John Stultz; Linux Kernel
> Subject: Re: [PATCH][2.5][RFC] Using xAPIC apic address space on !Summit
>
> On Friday 13 December 2002 07:43 am, Nakajima, Jun wrote:
> > I/O APIC? I'm talking about xAPIC, i.e. local APIC which is part of the
> > chip. Also note that I/O subsystem can generate interrupts (e.g. MSI,
> > Message Signaled Interrupt), bypassing I/O APICs.
> >
> > Jun
>
> Part of the "x" in xAPIC is that it can communicate over the classic 2
> data /
> 1 clock serial bus or send interrupts over the system bus. If operating
> in
> serial mode, the old priority arbitration protocol works just fine. It's
> parallel mode where we have problems. All the I/O interrupts tend to hit
> CPU
> 0, thanks to the XTPR HW's tie-breaker logic.
>
> Intel has added a new register to I/O APICs that tells whether they're
> operating in serial or parallel mode. It may be useful to read that bit
> before activating some of the code in my patches.
>
> I've never worked on a system that tries to use MSIs. Do they use lowest
> priority delivery?
>
> (FYI, Summit boxes are hardwired into parallel mode. There's no provision
> for
> a serial APIC bus connecting the PCI expansion box to the CPUs.)
>
> > > -----Original Message-----
> > > From: James Cleverdon [mailto:[email protected]]
> > > Sent: Thursday, December 12, 2002 7:22 PM
> > > To: Nakajima, Jun; Zwane Mwaikambo
> > > Cc: Martin Bligh; John Stultz; Linux Kernel
> > > Subject: Re: [PATCH][2.5][RFC] Using xAPIC apic address space on
> !Summit
> > >
> > > On Thursday 12 December 2002 07:05 pm, Nakajima, Jun wrote:
> > > > BTW, we are working on a xAPIC patch that supports more than 8 CPUs
> in
> > > > a generic fashion (don't use hardcode OEM checking). We already
> tested
> > > > it
> > >
> > > on
> > >
> > > > two OEM systems with 16 CPUs.
> > > > - It uses clustered mode. We don't want to use physical mode because
> it
> > > > does not support lowest priority delivery mode.
> > > > - We also check the version of the local APIC if it's xAPIC or not.
> > > > It's possible that some other x86 architecture (other than P4P) uses
> > > > xAPIC.
> > > >
> > > > Stay tuned.
> > > >
> > > > Jun
> > >
> > > See my 2.5 summit patch for one that uses logical mode and lowest
> > > priority delivery. I haven't submitted that for 2.4 because the
> physical
> > > patch has the most run time on it, both in Alan's tree and SuSE 8.0+.
> > >
> > > The hardcoded OEM checking was necessary because the Summit I/O APICs
> > > were still using the older version number. (The HW folks claim that
> > > Intel didn't
> > > specify the new number soon enough for them.)
> > >
> > > I'm hesitant to key xAPIC vs. flat off the local APIC version number
> > > because
> > > it's possible to build a flat system out of P4 CPUs. I/O APIC version
> > > numbers combined with the parallel vs. serial bit would be safer
> (except
> > > for
> > > the Summit problem above). I've also tried checking all the CPU's
> > > physical
> > > APIC IDs to see if they use multiple APIC clusters.
> > >
> > > > > -----Original Message-----
> > > > > From: James Cleverdon [mailto:[email protected]]
> > > > > Sent: Thursday, December 12, 2002 6:42 PM
> > > > > To: Zwane Mwaikambo
> > > > > Cc: Martin Bligh; John Stultz; Linux Kernel
> > > > > Subject: Re: [PATCH][2.5][RFC] Using xAPIC apic address space on
> > >
> > > !Summit
> > >
> > > > > On Thursday 12 December 2002 06:21 pm, Zwane Mwaikambo wrote:
> > > > > > On Thu, 12 Dec 2002, James Cleverdon wrote:
> > > > > > > On Thursday 12 December 2002 05:44 pm, Zwane Mwaikambo wrote:
> > > > > > > > Hi,
> > > > > > > > I've got an 32x SMP system which has an xAPIC but
> utilises
> > > > >
> > > > > flat
> > > > >
> > > > > > > > addressing. This patch is to rename what was formerly
> > > > > > > > x86_summit
> > >
> > > to
> > >
> > > > > > > > x86_xapic (just to avoid confusion) and then select mask
> > >
> > > depending
> > >
> > > > > on
> > > > >
> > > > > > > > that.
> > > > > > > >
> > > > > > > > Untested/uncompiled patch
> > > > > > >
> > > > > > > Hi Zwane,
> > > > > > >
> > > > > > > How can you have a 32-way SMP system with flat addressing?
> There
> > >
> > > are
> > >
> > > > > > > only 8 bits in the destination address field. Even if you
> work
> > > > > > > around that by assigning a set of CPUs to each dest addr bit,
> > >
> > > there
> > >
> > > > > > > can only
> > > > >
> > > > > be
> > > > >
> > > > > > > 15 physical APIC IDs in flat mode. To get to 32 you must
> switch
> > >
> > > into
> > >
> > > > > > > clustered mode.
> > > > > > >
> > > > > > > Please tell me more. I'm intrigued how this can be done.
> > > > > >
> > > > > > Hi James,
> > > > > > with the xAPIC we can use the 8bit address space everywhere
> >
> > in
> >
> > > > > > physical destination mode. For example the ICR now has an 8bit
> > > > > > space for destination.
> > > > > >
> > > > > > "Specifies the target processor or processors. This field is
> only
> > >
> > > used
> > >
> > > > > > when the destination shorthand field is set to 00B. If the
> > >
> > > destination
> > >
> > > > > > mode is set to physical, then bits 56 through 59 contain the
> APIC
> > > > > > ID
> > >
> > > of
> > >
> > > > > > the target processor for Pentium and P6 family processors and
> bits
> > >
> > > 56
> > >
> > > > > > through 63 contain the APIC ID of the target processor the for
> > >
> > > Pentium
> > >
> > > > > > 4 and Intel Xeon processors. If the destination mode is set to
> > >
> > > logical,
> > >
> > > > > the
> > > > >
> > > > > > interpretation of the 8-bit destination field depends on the
> > >
> > > settings
> > >
> > > > > > of the DFR and LDR registers of the local APICs in all the
> > >
> > > processors
> > >
> > > > > > in
> > > > >
> > > > > the
> > > > >
> > > > > > system (see Section 8.6.2., Determining IPI Destination )."
> > > > > > - System Developer's Manual vol3 p291
> > > > > >
> > > > > > Regards,
> > > > > > Zwane
> > > > >
> > > > > Sure you can physically address them, if you assign IDs using
> Intel's
> > > > > official
> > > > > xAPIC numbering scheme (which must be clustered for more than 7
> > > > > CPUs). But,
> > > > > you still don't have enough destination address bits to go around.
> > > > > In flat
> > > > > mode, the kernel assumes you have one bit per CPU and phys IDs
> will
> > > > > be
> > >
> > > <
> > >
> > > > > 0xF.
> > > > >
> > > > > Bill tells me that you may be doing this for an emulator. Why not
> > > > > emulate clusered APIC mode, like the real hardware uses?
> > > > >
> > > > > I know the name x86_summit doesn't really fit. The summit patch
> > >
> > > should
> > >
> > > > > work
> > > > > for any xAPIC box that uses the system bus for interrupt delivery
> and
> > >
> > > has
> > >
> > > > > multiple APIC clusters. Is that what you're working towards?
> > > > >
> > > > > --
> > > > > James Cleverdon
> > > > > IBM xSeries Linux Solutions
> > > > > {jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot com
> > >
> > > --
> > > James Cleverdon
> > > IBM xSeries Linux Solutions
> > > {jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot com
>
> --
> James Cleverdon
> IBM xSeries Linux Solutions
> {jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot com