* [patch 3/5 salinfo-0.6] kernel-clear
@ 2004-10-04 6:25 Keith Owens
0 siblings, 0 replies; only message in thread
From: Keith Owens @ 2004-10-04 6:25 UTC (permalink / raw)
To: linux-ia64
kernel-clear Handle Ben Woodward's incompatible kernel change in 2.6.9-rc3
Index: salinfo-0.6/salinfo_decode.c
=================================--- salinfo-0.6.orig/salinfo_decode.c Wed Sep 15 16:21:10 2004
+++ salinfo-0.6/salinfo_decode.c Mon Oct 4 12:17:47 2004
@@ -9,6 +9,8 @@
* 2003-11-16 Break out oem data decoder so each platform can handle the
* oem data as it likes.
* Keith Owens <kaos@sgi.com>
+ * 2004-10-04 Handle kernels that clear the bit themselves when there is no data.
+ * Keith Owens <kaos@sgi.com>
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
@@ -97,11 +99,36 @@ usage (void)
, stderr);
}
+/* Ben Woodard of RedHat changed the kernel salinfo code around 2.6.9-rc3 to
+ * clear the cpu state bit if there is no data. He did not add any indication
+ * to user space of this change, which means that user space must deduce if it
+ * is running on a kernel with or without Ben Woodward's change :(.
+ *
+ * Start off by assuming we are running on a changed kernel, and do not write
+ * 'clear' to the kernel when there is no data. When running on an old kernel,
+ * user space will then be invoked repeatedly with no data. Detect this loop
+ * for an old kernel and turn on do_clear.
+ */
+
static int
-clear_cpu(int fd_data, int cpu, const char *data_filename)
+clear_cpu(int fd_data, int cpu, const char *data_filename, int have_data)
{
char text[400];
int l;
+ static int prev_cpu = -1, loop = 0, do_clear = 0;
+
+ if (have_data)
+ loop = 0;
+ if (!do_clear) {
+ if (cpu <= prev_cpu) {
+ ++loop;
+ if (loop = 2)
+ do_clear = 1;
+ }
+ prev_cpu = cpu;
+ }
+ if (!have_data && !do_clear)
+ return 0;
snprintf(text, sizeof(text), "clear %d\n", cpu);
l = strlen(text);
@@ -226,7 +253,7 @@ talk_to_sal (const char *type, const cha
goto out;
}
if (!(buffer = salinfo_buffer(fd_data, &bufsize))) {
- if (clear_cpu(fd_data, cpu, data_filename))
+ if (clear_cpu(fd_data, cpu, data_filename, 0))
goto out;
continue; /* event but no data is normal at boot */
}
@@ -292,7 +319,7 @@ talk_to_sal (const char *type, const cha
printf("END HARDWARE ERROR STATE from %s on cpu %d\n", type, cpu);
free(buffer);
fclose(stdout);
- if (clear_cpu(fd_data, cpu, data_filename))
+ if (clear_cpu(fd_data, cpu, data_filename, 1))
goto out;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-10-04 6:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-04 6:25 [patch 3/5 salinfo-0.6] kernel-clear Keith Owens
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox