From: linux@horizon.com
To: davej@redhat.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: discriminate single bit error hardware failure from slab corruption.
Date: 3 Feb 2006 04:25:33 -0500 [thread overview]
Message-ID: <20060203092533.13547.qmail@science.horizon.com> (raw)
Um... case values are allowed to be expressions.
Isn't
+ switch (total) {
+ case SLAB_POISON ^ 0x01:
+ case SLAB_POISON ^ 0x02:
+ case SLAB_POISON ^ 0x04:
+ case SLAB_POISON ^ 0x08:
+ case SLAB_POISON ^ 0x10:
+ case SLAB_POISON ^ 0x20:
+ case SLAB_POISON ^ 0x40:
+ case SLAB_POISON ^ 0x80:
+ printk (KERN_ERR "Single bit error detected. Possibly bad RAM\n"
Infinitely clearer, even without the comments? Or, if you want to
be cleverer:
total ^= SLAB_POISON;
if ((total & (total-1)) == 0) {
printk (KERN_ERR "Single bit error detected. Possibly bad RAM\n"
}
If you wanted to get the bit-counting exactly accurate, you'd do:
unsigned char total = 0, total2 = 0;
for (i = 0; i < limit; i++) {
unsigned char delta = data[offset+i];
printk(" %02x", delta;
delta ^= POISON_FREE;
total2 |= total & delta;
total |= delta;
}
printk("\n");
/* If total2 has 0 bits set and total1 has at most 1 bit set... */
if (!total2 && !(total1 & (total1 - 1)) {
printk (KERN_ERR "Single bit error detected. Possibly bad RAM\n"
}
next reply other threads:[~2006-02-03 9:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-03 9:25 linux [this message]
2006-02-03 14:14 ` Jan Engelhardt
-- strict thread matches above, loose matches on Subject: below --
2006-02-02 19:24 Dave Jones
2006-02-02 19:28 ` Randy.Dunlap
2006-02-02 19:38 ` Jesper Juhl
2006-02-02 19:53 ` Pekka Enberg
2006-02-03 0:44 ` Avi Kivity
2006-02-03 1:46 ` Dave Jones
2006-02-03 2:05 ` Avi Kivity
2006-02-03 4:20 ` Dave Jones
2006-02-03 4:41 ` Roland Dreier
2006-02-03 5:03 ` Dave Jones
2006-02-03 14:12 ` Jan Engelhardt
2006-02-03 11:05 ` Olivier Galibert
2006-02-06 20:19 ` Pavel Machek
2006-02-03 14:09 ` Jan Engelhardt
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=20060203092533.13547.qmail@science.horizon.com \
--to=linux@horizon.com \
--cc=davej@redhat.com \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®