From: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>,
Tony Luck <tony.luck@intel.com>
Subject: [PATCH 10/12] x86, mce: cleanup mce_read
Date: Fri, 27 May 2011 13:11:34 +0900 [thread overview]
Message-ID: <4DDF2476.1010903@jp.fujitsu.com> (raw)
In-Reply-To: <4DDF21DE.9040705@jp.fujitsu.com>
Use temporary local entry to make code simple.
No change in logic.
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
---
arch/x86/kernel/cpu/mcheck/mce.c | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 9fe9e6e..4ba4040 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -1533,18 +1533,17 @@ static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize,
do {
for (i = prev; i < next; i++) {
unsigned long start = jiffies;
+ struct mce *entry = &mcelog.entry[i];
- while (!mcelog.entry[i].finished) {
+ while (!entry->finished) {
if (time_after_eq(jiffies, start + 2)) {
- memset(mcelog.entry + i, 0,
- sizeof(struct mce));
+ memset(entry, 0, sizeof(struct mce));
goto timeout;
}
cpu_relax();
}
smp_rmb();
- err |= copy_to_user(buf, mcelog.entry + i,
- sizeof(struct mce));
+ err |= copy_to_user(buf, entry, sizeof(struct mce));
buf += sizeof(struct mce);
timeout:
;
@@ -1565,13 +1564,13 @@ timeout:
on_each_cpu(collect_tscs, cpu_tsc, 1);
for (i = next; i < MCE_LOG_LEN; i++) {
- if (mcelog.entry[i].finished &&
- mcelog.entry[i].tsc < cpu_tsc[mcelog.entry[i].cpu]) {
- err |= copy_to_user(buf, mcelog.entry+i,
- sizeof(struct mce));
+ struct mce *entry = &mcelog.entry[i];
+
+ if (entry->finished && entry->tsc < cpu_tsc[entry->cpu]) {
+ err |= copy_to_user(buf, entry, sizeof(struct mce));
smp_rmb();
buf += sizeof(struct mce);
- memset(&mcelog.entry[i], 0, sizeof(struct mce));
+ memset(entry, 0, sizeof(struct mce));
}
}
--
1.7.1
next prev parent reply other threads:[~2011-05-27 4:11 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-27 4:00 [PATCH 00/12] minor cleanups/fixes for MCE codes Hidetoshi Seto
2011-05-27 4:03 ` [PATCH 01/12] mce-severity: fixes for mce severity table Hidetoshi Seto
2011-05-27 4:04 ` [PATCH 02/12] mce-severity: cleanup severity table, prep Hidetoshi Seto
2011-05-27 4:05 ` [PATCH 03/12] mce-severity: cleanup severity table Hidetoshi Seto
2011-05-27 6:46 ` Borislav Petkov
2011-05-27 7:54 ` Ingo Molnar
2011-05-30 5:42 ` Hidetoshi Seto
2011-05-27 4:06 ` [PATCH 04/12] mce-severity: trivial cleanups Hidetoshi Seto
2011-05-27 4:07 ` [PATCH 05/12] x86, mce: replace MCE_SELF_VECTOR by irq_work Hidetoshi Seto
2011-05-27 4:08 ` [PATCH 06/12] x86, mce: replace MCM_ to MCI_MISC_ Hidetoshi Seto
2011-05-27 4:09 ` [PATCH 07/12] x86, mce: introduce mce_gather_info() Hidetoshi Seto
2011-05-27 6:27 ` Tony Luck
2011-05-27 8:00 ` Ingo Molnar
2011-05-27 16:29 ` Tony Luck
2011-05-30 5:42 ` Hidetoshi Seto
2011-05-27 4:10 ` [PATCH 08/12] x86, mce: check the result of ancient_init() Hidetoshi Seto
2011-05-27 4:10 ` [PATCH 09/12] x86, mce: cleanup mce_create/remove_device Hidetoshi Seto
2011-05-27 4:11 ` Hidetoshi Seto [this message]
2011-05-27 6:38 ` [PATCH 10/12] x86, mce: cleanup mce_read Borislav Petkov
2011-05-30 5:43 ` Hidetoshi Seto
2011-05-27 4:12 ` [PATCH 11/12] x86, mce: use prefix mce_chrdev_ to group functions Hidetoshi Seto
2011-05-27 4:13 ` [PATCH 12/12] x86, mce: use prefix mce_sysdev_ " Hidetoshi Seto
-- strict thread matches above, loose matches on Subject: below --
2011-06-08 1:48 [PATCH 00/12] x86: minor cleanups/fixes for MCE codes (v2) Hidetoshi Seto
2011-06-08 2:00 ` [PATCH 10/12] x86, mce: cleanup mce_read Hidetoshi Seto
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=4DDF2476.1010903@jp.fujitsu.com \
--to=seto.hidetoshi@jp.fujitsu.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
/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