Skip to contentSkip to conversation

linux-2.6.3-rc2_ia64-cyclone_A0

RFC PATCH In review john stultz 4 participants 16 messages Feb 12, 2004 – Feb 23, 2004

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 linux-2.6.3-rc2_ia64-cyclone_A0

All,
This patch provides access to the cyclone time source found on IBM EXA
based systems (x450 and x455). This is needed on multi-node systems where the CPU ITCs are not synchronized, causing possible time inconsistencies.

I tried my best to properly follow the time_interpolator interface, but please let me know if you see any mistakes.

Any comments or suggestions would be greatly appreciated.

thanks
-john

arch/ia64/Kconfig +6 -0
diff -Nru a/arch/ia64/Kconfig b/arch/ia64/Kconfig
@@ -245,6 +245,12 @@
 	  Say Y here to enable machine check support for IA-64.  If you're
 	  unsure, answer Y.
 
+config IA64_CYCLONE
+	bool "Support Cyclone(EXA) Time Source"
+	help
+		Say Y here to enable support for IBM EXA Cyclone time source.
+		If you're unsure, answer N.
+	
 config PM
 	bool "Power Management support"
 	depends on IA64_GENERIC || IA64_DIG || IA64_HP_ZX1
arch/ia64/kernel/Makefile +1 -0
diff -Nru a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile
@@ -18,6 +18,7 @@
 obj-$(CONFIG_MODULES)		+= module.o
 obj-$(CONFIG_SMP)		+= smp.o smpboot.o
 obj-$(CONFIG_PERFMON)		+= perfmon_default_smpl.o
+obj-$(CONFIG_IA64_CYCLONE)	+= cyclone.o
 
 # The gate DSO image is built using a special linker script.
 targets += gate.so gate-syms.o
arch/ia64/kernel/acpi.c +14 -0
diff -Nru a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
@@ -49,6 +49,7 @@
 #include <asm/page.h>
 #include <asm/system.h>
 #include <asm/numa.h>
+#include <asm/cyclone.h>
 
 
 #define PREFIX			"ACPI: "
@@ -304,6 +305,15 @@
 	return 0;
 }
 
+/* Hook from generic ACPI tables.c */
+void __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
+{
+	if (!strncmp(oem_id, "IBM", 3) &&
+	    (!strncmp(oem_table_id, "SERMOW", 6))){
+		/*Start cyclone clock*/
+		cyclone_setup(0);
+	}
+}
 
 static int __init
 acpi_parse_madt (unsigned long phys_addr, unsigned long size)
@@ -327,6 +337,10 @@
 		ipi_base_addr = (unsigned long) ioremap(acpi_madt->lapic_address, 0);
 
 	printk(KERN_INFO PREFIX "Local APIC address 0x%lx\n", ipi_base_addr);
+
+	acpi_madt_oem_check(acpi_madt->header.oem_id, 
+		acpi_madt->header.oem_table_id);
+
 	return 0;
 }
 
arch/ia64/kernel/cyclone.c new file +155 -0

155 lines not on this page · raw message

include/asm-ia64/cyclone.h new file +15 -0
diff -Nru a/include/asm-ia64/cyclone.h b/include/asm-ia64/cyclone.h
@@ -0,0 +1,15 @@
+#ifndef ASM_IA64_CYCLONE_H
+#define ASM_IA64_CYCLONE_H
+
+#ifdef	CONFIG_IA64_CYCLONE
+extern int use_cyclone;
+extern int __init cyclone_setup(char*);
+#else	/* CONFIG_IA64_CYCLONE */
+#define use_cyclone 0
+static inline void cyclone_setup(char* s) 
+{
+	printk(KERN_ERR "Cyclone Counter: System not configured"
+					" w/ CONFIG_IA64_CYCLONE.\n");
+}
+#endif	/* CONFIG_IA64_CYCLONE */
+#endif	/* !ASM_IA64_CYCLONE_H */
#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · john stultz

John> All, This patch provides access to the cyclone time source John> found on IBM EXA based systems (x450 and x455). This is needed John> on multi-node systems where the CPU ITCs are not synchronized, John> causing possible time inconsistencies.

John> I tried my best to properly follow the time_interpolator John> interface, but please let me know if you see any mistakes.

John> Any comments or suggestions would be greatly appreciated.

It looks mostly OK to me. Some comments:

- It seems to me cyclone.c should check whether the SAL ITCdrift flag is on and register the cyclone time-interpolator only if it is turned on.

- When accessing iomemory space, please use readX()/writeX(). For example:

+ offset = cyclone_timer[0];

should be:

	offset = readl (cyclone_timer);

- The formatting is a bit weird. You can format it for 100 columns wide and it would be nice if you could drop all the trailing whitespace.

- This:

+	u32 offset;
	  [snip]

+ offset = (offset*NSEC_PER_SEC)/CYCLONE_TIMER_FREQ;
will overflow in about 4.3 seconds. Not likely to happen but it might be safer to declare "offset" as "u64".

	--david
#2 lore raw
In reply to john stultz
Quoted 10 lines · David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · john stultz

John> All, This patch provides access to the cyclone time source John> found on IBM EXA based systems (x450 and x455). This is needed John> on multi-node systems where the CPU ITCs are not synchronized, John> causing possible time inconsistencies.

John> I tried my best to properly follow the time_interpolator John> interface, but please let me know if you see any mistakes.

Quoted 7 lines

John> Any comments or suggestions would be greatly appreciated.

It looks mostly OK to me. Some comments:

- It seems to me cyclone.c should check whether the SAL ITCdrift flag is on and register the cyclone time-interpolator only if it is turned on.

Hmm. As cyclone is only enabled for x450/x455 systems, I'm not sure if that additional check is necessary, but I'll try to look into that.

Quoted 8 lines

- When accessing iomemory space, please use readX()/writeX(). For example:

+ offset = cyclone_timer[0];

   should be:

	offset = readl (cyclone_timer);

Ok, will fix.

Quoted 3 lines

- The formatting is a bit weird. You can format it for 100 columns wide and it would be nice if you could drop all the trailing whitespace.

Gah! Sorry, I'm terrible w/ whitespace.

arch/ia64/kernel/cyclone.c

Quoted 6 lines

- This:

arch/ia64/kernel/cyclone.c new file +2 -0
+	u32 offset;
[snip]
+	offset = (offset*NSEC_PER_SEC)/CYCLONE_TIMER_FREQ;
   will overflow in about 4.3 seconds.  Not likely to happen but
   it might be safer to declare "offset" as "u64".

Yep, I caught that right after I sent out the patch.

Thanks so much for the review! I'll apply your suggestions and resend.

thanks again,
-john

#3 lore raw
In reply to john stultz
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · john stultz

John> Hmm. As cyclone is only enabled for x450/x455 systems, I'm not John> sure if that additional check is necessary, but I'll try to John> look into that.

At the very least, verify that the SAL ITCdrift bit is turned on by the firmware. Otherwise, the lightweight handler of gettimeofday() will still use ITC-based interpolation.

	--david
#4 lore raw
In reply to john stultz
Quoted 6 lines · David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · john stultz

John> Hmm. As cyclone is only enabled for x450/x455 systems, I'm not John> sure if that additional check is necessary, but I'll try to John> look into that.

Quoted 6 lines

At the very least, verify that the SAL ITCdrift bit is turned on by the firmware. Otherwise, the lightweight handler of gettimeofday() will still use ITC-based interpolation.

	--david

-

David,

The x450/x455 doesn't set/implement the SAL ITC drift bit. Could you point us to where this is documentated? The latest SAL spec (Dec 2003) didn't have reference to this flag being implemented in the Platform Features Descriptor Entry in the SST.

thanks,

Signature · 5 lines
-chris

Chris McDermott
IBM Linux Technology Center (LTC)
xSeries Platform Enablement
#5 lore raw
In reply to john stultz
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Chris McDermott

Chris> The x450/x455 doesn't set/implement the SAL ITC drift Chris> bit. Could you point us to where this is documentated? The Chris> latest SAL spec (Dec 2003) didn't have reference to this flag Chris> being implemented in the Platform Features Descriptor Entry Chris> in the SST.

Hmmh, you're right: I don't see it either in the public documentation. I got confirmation from Intel on 8 Nov 2001 that bit 3 of the platform-feature vector will be defined as the ITC_DRIFT bit and the SAL documentation was supposed to have been updated Q1 2002. Looks to me like something got lost along the way. Can someone from Intel clarify?

	--david
#6 lore raw
In reply to john stultz
Quoted 9 lines · David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · john stultz

John> Hmm. As cyclone is only enabled for x450/x455 systems, I'm not John> sure if that additional check is necessary, but I'll try to John> look into that.

At the very least, verify that the SAL ITCdrift bit is turned on by the firmware. Otherwise, the lightweight handler of gettimeofday() will still use ITC-based interpolation.

I'm not sure I see how gettimeofday will use ITC based interpolation if the ITCdrift is off. Sure, the ITC will register a timesource, but init_cyclone_clock runs after time_init and has a negative drift value, so on the x450/x455 the cyclone interpolator will be used.

Am I missing something?

thanks
-john

#7 lore raw
In reply to john stultz
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · john stultz

John> I'm not sure I see how gettimeofday will use ITC based John> interpolation if the ITCdrift is off. Sure, the ITC will John> register a timesource, but init_cyclone_clock runs after John> time_init and has a negative drift value, so on the x450/x455 John> the cyclone interpolator will be used.

John> Am I missing something?

Yes: it's the _lightweight_ gettimeofday() handler that will get you. See arch/ia64/kernel/fsys.S:fsys_gettimeofday().

To date no distribution ships with light-weight syscall supported enabled, but the support is in the current glibc, so it's only a matter of time before this would start to bite.

	--david
#8 lore raw
In reply to john stultz
Quoted 7 lines

Hmmh, you're right: I don't see it either in the public documentation. I got confirmation from Intel on 8 Nov 2001 that bit 3 of the platform-feature vector will be defined as the ITC_DRIFT bit and the SAL documentation was supposed to have been updated Q1 2002. Looks to me like something got lost along the way. Can someone from Intel clarify?

We are checking with the SAL spec owners and let you know. Thanks,
Asit

#9 lore raw
In reply to john stultz
Quoted 8 lines · David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · john stultz

John> I'm not sure I see how gettimeofday will use ITC based John> interpolation if the ITCdrift is off. Sure, the ITC will John> register a timesource, but init_cyclone_clock runs after John> time_init and has a negative drift value, so on the x450/x455 John> the cyclone interpolator will be used.

Quoted 8 lines

John> Am I missing something?

Yes: it's the _lightweight_ gettimeofday() handler that will get you. See arch/ia64/kernel/fsys.S:fsys_gettimeofday().

To date no distribution ships with light-weight syscall supported enabled, but the support is in the current glibc, so it's only a matter of time before this would start to bite.

Ah! Thanks for the pointer! I wouldn't have caught that otherwise.

So, as it seems the hardware currently doesn't set the ITCdrift flag, should I then set it in my init code? Or is there some other way of disabling fsys support, possibly on a per-syscall basis?

thanks
-john

#10 lore raw
In reply to john stultz
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · john stultz

John> So, as it seems the hardware currently doesn't set the John> ITCdrift flag, should I then set it in my init code?

As a temporary workaround, that seems like a reasonable solution.

John> Or is there some other way of disabling fsys support, possibly John> on a per-syscall basis?

You can't disable fsys-support itself, but you can turn off the use of light-weight handlers by booting the kernel with option "nolwsys". I wouldn't recommend that though because it's a sledgehammer and will disable all other lightweight syscalls as well (getpid, getppid, set_tid_address, and sigprocmask, for now).

	--david
#11 lore raw

RFC PATCH 1/1 linux-2.6.3-rc2_ia64-cyclone_A1

In reply to john stultz

All,
This patch provides access to the cyclone time source found on
IBM EXA based systems (x450 and x455). This is needed on multi-node systems where the CPU ITCs are not synchronized, causing possible time inconsistencies.

Since the last release, I've implemented a number of suggested cleanups and fixes, but please let me know if you have any additional suggestions or comments.

thanks
-john

arch/ia64/Kconfig +6 -0
diff -Nru a/arch/ia64/Kconfig b/arch/ia64/Kconfig
@@ -245,6 +245,12 @@
 	  Say Y here to enable machine check support for IA-64.  If you're
 	  unsure, answer Y.
 
+config IA64_CYCLONE
+	bool "Support Cyclone(EXA) Time Source"
+	help
+		Say Y here to enable support for IBM EXA Cyclone time source.
+		If you're unsure, answer N.
+	
 config PM
 	bool "Power Management support"
 	depends on IA64_GENERIC || IA64_DIG || IA64_HP_ZX1
arch/ia64/kernel/Makefile +1 -0
diff -Nru a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile
@@ -18,6 +18,7 @@
 obj-$(CONFIG_MODULES)		+= module.o
 obj-$(CONFIG_SMP)		+= smp.o smpboot.o
 obj-$(CONFIG_PERFMON)		+= perfmon_default_smpl.o
+obj-$(CONFIG_IA64_CYCLONE)	+= cyclone.o
 
 # The gate DSO image is built using a special linker script.
 targets += gate.so gate-syms.o
arch/ia64/kernel/acpi.c +22 -0
diff -Nru a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
@@ -49,6 +49,8 @@
 #include <asm/page.h>
 #include <asm/system.h>
 #include <asm/numa.h>
+#include <asm/sal.h>
+#include <asm/cyclone.h>
 
 
 #define PREFIX			"ACPI: "
@@ -304,6 +306,22 @@
 	return 0;
 }
 
+/* Hook from generic ACPI tables.c */
+void __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
+{
+	if (!strncmp(oem_id, "IBM", 3) &&
+	    (!strncmp(oem_table_id, "SERMOW", 6))){
+
+		/* Unfortunatly ITC_DRIFT is not yet part of the
+		 * official SAL spec, so the ITC_DRIFT bit is not
+		 * set by the BIOS on this hardware.
+		 */
+		sal_platform_features |= IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT;
+		
+		/*Start cyclone clock*/
+		cyclone_setup(0);
+	}
+}
 
 static int __init
 acpi_parse_madt (unsigned long phys_addr, unsigned long size)
@@ -327,6 +345,10 @@
 		ipi_base_addr = (unsigned long) ioremap(acpi_madt->lapic_address, 0);
 
 	printk(KERN_INFO PREFIX "Local APIC address 0x%lx\n", ipi_base_addr);
+
+	acpi_madt_oem_check(acpi_madt->header.oem_id,
+		acpi_madt->header.oem_table_id);
+
 	return 0;
 }
 
arch/ia64/kernel/cyclone.c new file +156 -0

156 lines not on this page · raw message

include/asm-ia64/cyclone.h new file +15 -0
diff -Nru a/include/asm-ia64/cyclone.h b/include/asm-ia64/cyclone.h
@@ -0,0 +1,15 @@
+#ifndef ASM_IA64_CYCLONE_H
+#define ASM_IA64_CYCLONE_H
+
+#ifdef	CONFIG_IA64_CYCLONE
+extern int use_cyclone;
+extern int __init cyclone_setup(char*);
+#else	/* CONFIG_IA64_CYCLONE */
+#define use_cyclone 0
+static inline void cyclone_setup(char* s)
+{
+	printk(KERN_ERR "Cyclone Counter: System not configured"
+					" w/ CONFIG_IA64_CYCLONE.\n");
+}
+#endif	/* CONFIG_IA64_CYCLONE */
+#endif	/* !ASM_IA64_CYCLONE_H */
#12 lore raw

possible time_interpolator bug?

All,
Using my ia64-cyclone patch I've been occasionally noticing time
inconsistencies near second overflows. Being as the whole purpose of the patch is to avoid time inconsistencies, I've been wearing my forehead raw trying to find the bug in my implementation of the cyclone time interpolator.

I believe I have found either a bug in the time_interpolator code, or a bug in my understanding of how it is supposed to work.

Looking in kernel/timer.c at update_wall_time_one_tick() and update_wall_time().

First in update_wall_time():

static void update_wall_time(unsigned long ticks)

{
	do {
		ticks--;
		update_wall_time_one_tick();
	} while (ticks);

	if (xtime.tv_nsec >= 1000000000) {
	    xtime.tv_nsec -= 1000000000;
	    xtime.tv_sec++;
	    time_interpolator_update(NSEC_PER_SEC);
	    second_overflow();
	}
}

So each second, we call "_update(NSEC_PER_SEC)", however for each tick we call update_wall_time_one_tick() which calls "_update(delta_nsec)".

Thus in a period of one second, we call _update() HZ times w/ ~NSEC_PER_SEC/HZ as an argument, then at the second overflow we call it again w/ NSEC_PER_SEC.

It seems that calling _update() on the second overflow is unnecessary. And because in my implementation of update_cyclone(), we then clear the offset_base variable, this causes time inconsistencies.

It would be noted that time inconsistencies are not seen using the ITC interpolator, however the ITC interpolator has an empty _update function.

Am I just missing something here?

thanks
-john

#13 lore raw

Re: possible time_interpolator bug?

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · john stultz

John> So each second, we call "_update(NSEC_PER_SEC)", however for John> each tick we call update_wall_time_one_tick() which calls John> "_update(delta_nsec)".

John> Thus in a period of one second, we call _update() HZ times w/ John> ~NSEC_PER_SEC/HZ as an argument, then at the second overflow John> we call it again w/ NSEC_PER_SEC.

John> It seems that calling _update() on the second overflow is John> unnecessary.

Not just unnecessary, but wrong!

John> It would be noted that time inconsistencies are not seen using John> the ITC interpolator, however the ITC interpolator has an John> empty _update function.

Yes.

John> Am I just missing something here?

I don't think so. Good bug hunting. Some time ago SGI reported some jumpiness but I never got a definite answer whether the problem had been solved.

You may want to run this by someone who actually understands the code in timer.c but I'm pretty sure you're right.

Thanks,

	--david
#14 lore raw

PATCH 1/1 linux-2.6.3_time-interpolator-fix_A0

[Resending to Andrew and LKML]

All,
In developing the ia64-cyclone patch, which implements a cyclone based
time interpolator, I found the following bug which could cause time inconsistencies.

In update_wall_time_one_tick(), which is called each timer interrupt, we call time_interpolator_update(delta_nsec) where delta_nsec is approximately NSEC_PER_SEC/HZ. This directly correlates with the changes to xtime which occurs in update_wall_time_one_tick().

However in update_wall_time(), on a second overflow, we again call time_interpolator_update(NSEC_PER_SEC). However while the components of xtime are being changed, the overall value of xtime does not (nsec is decremented NSEC_PER_SEC and sec is incremented). Thus this call to time_interpolator_update is incorrect.

This patch removes the incorrect call to time_interpolator_update and was found to resolve the time inconsistencies I had seen while developing the ia64-cyclone patch.

Please consider for inclusion.

kernel/timer.c +0 -1
diff -Nru a/kernel/timer.c b/kernel/timer.c
@@ -677,7 +677,6 @@
 	if (xtime.tv_nsec >= 1000000000) {
 	    xtime.tv_nsec -= 1000000000;
 	    xtime.tv_sec++;
-	    time_interpolator_update(NSEC_PER_SEC);
 	    second_overflow();
 	}
 }
#15 lore raw

Re: [PATCH] linux-2.6.3_time-interpolator-fix_A0

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · john stultz

John> This patch removes the incorrect call to
John> time_interpolator_update and was found to resolve the time John> inconsistencies I had seen while developing the ia64-cyclone John> patch.

John> Please consider for inclusion.

In case it isn't clear: this patch has my support.

	--david