From: Keith Owens <kaos@sgi.com>
To: linux-ia64@vger.kernel.org
Subject: [patch 3/5 salinfo-0.6] kernel-clear
Date: Mon, 04 Oct 2004 06:25:50 +0000 [thread overview]
Message-ID: <11369.1096871150@kao2.melbourne.sgi.com> (raw)
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;
}
reply other threads:[~2004-10-04 6:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11369.1096871150@kao2.melbourne.sgi.com \
--to=kaos@sgi.com \
--cc=linux-ia64@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox