All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
To: linux-kernel@vger.kernel.org
Cc: "x86@kernel.org" <x86@kernel.org>, Ingo Molnar <mingo@elte.hu>,
	Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	"Luck, Tony" <tony.luck@intel.com>,
	Borislav Petkov <bp@amd64.org>
Subject: [PATCH 3/8] x86, mce: introduce mce_timer_add()
Date: Fri, 17 Jun 2011 17:43:09 +0900	[thread overview]
Message-ID: <4DFB139D.8060401@jp.fujitsu.com> (raw)
In-Reply-To: <4DFB1242.90404@jp.fujitsu.com>

It is too redundant to call setup_timer() every time when the timer is
going to be added.

This patch breaks __mcheck_cpu_init_timer() down, put setup part to init
code path and construct mce_timer_add() from the rests. Since there is no
strong reason to keep interval only when it back from hotplug event, this
patch also helps to kill duplicated code in hotplug notifier.

As the sideline this patch includes rename of mce_start_timer() to
mce_timer_run(), to group related functions with mce_timer_ prefix.

Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
---
 arch/x86/kernel/cpu/mcheck/mce.c |   54 ++++++++++++++++++-------------------
 1 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 205b334..c3dad64 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -1114,7 +1114,7 @@ static int check_interval = 5 * 60; /* 5 minutes */
 static DEFINE_PER_CPU(int, mce_next_interval); /* in jiffies */
 static DEFINE_PER_CPU(struct timer_list, mce_timer);
 
-static void mce_start_timer(unsigned long data)
+static void mce_timer_run(unsigned long data)
 {
 	struct timer_list *t = &per_cpu(mce_timer, data);
 	int *n;
@@ -1147,6 +1147,21 @@ static void mce_timer_delete_all(void)
 	}
 }
 
+static void mce_timer_add(unsigned long cpu)
+{
+	struct timer_list *t = &per_cpu(mce_timer, cpu);
+	int *n = &per_cpu(mce_next_interval, cpu);
+
+	if (mce_ignore_ce || !check_interval)
+		return;
+
+	/* reset next interval */
+	*n = check_interval * HZ;
+
+	t->expires = round_jiffies(jiffies + *n);
+	add_timer_on(t, cpu);
+}
+
 static void mce_do_trigger(struct work_struct *work)
 {
 	call_usermodehelper(mce_helper, mce_helper_argv, NULL, UMH_NO_WAIT);
@@ -1374,23 +1389,6 @@ static void __mcheck_cpu_init_vendor(struct cpuinfo_x86 *c)
 	}
 }
 
-static void __mcheck_cpu_init_timer(void)
-{
-	struct timer_list *t = &__get_cpu_var(mce_timer);
-	int *n = &__get_cpu_var(mce_next_interval);
-
-	setup_timer(t, mce_start_timer, smp_processor_id());
-
-	if (mce_ignore_ce)
-		return;
-
-	*n = check_interval * HZ;
-	if (!*n)
-		return;
-	t->expires = round_jiffies(jiffies + *n);
-	add_timer_on(t, smp_processor_id());
-}
-
 /* Handle unconfigured int18 (should never happen) */
 static void unexpected_machine_check(struct pt_regs *regs, long error_code)
 {
@@ -1408,6 +1406,8 @@ void (*machine_check_vector)(struct pt_regs *, long error_code) =
  */
 void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
 {
+	int cpu = smp_processor_id();
+
 	if (mce_disabled)
 		return;
 
@@ -1433,9 +1433,12 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
 
 	__mcheck_cpu_init_generic();
 	__mcheck_cpu_init_vendor(c);
-	__mcheck_cpu_init_timer();
+
+	setup_timer(&__get_cpu_var(mce_timer), mce_timer_run, cpu);
 	INIT_WORK(&__get_cpu_var(mce_work), mce_process_work);
 	init_irq_work(&__get_cpu_var(mce_irq_work), &mce_irq_work_cb);
+
+	mce_timer_add(cpu);
 }
 
 /*
@@ -1765,7 +1768,7 @@ static struct syscore_ops mce_syscore_ops = {
 static void mce_cpu_restart(void *data)
 {
 	__mcheck_cpu_init_generic();
-	__mcheck_cpu_init_timer();
+	mce_timer_add(smp_processor_id());
 }
 
 /* Reinit MCEs after user configuration changes */
@@ -1786,7 +1789,7 @@ static void mce_enable_ce(void *all)
 	cmci_reenable();
 	cmci_recheck();
 	if (all)
-		__mcheck_cpu_init_timer();
+		mce_timer_add(smp_processor_id());
 }
 
 static struct sysdev_class mce_sysdev_class = {
@@ -2030,7 +2033,6 @@ static int __cpuinit
 mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
 {
 	unsigned int cpu = (unsigned long)hcpu;
-	struct timer_list *t = &per_cpu(mce_timer, cpu);
 
 	switch (action) {
 	case CPU_ONLINE:
@@ -2047,16 +2049,12 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
 		break;
 	case CPU_DOWN_PREPARE:
 	case CPU_DOWN_PREPARE_FROZEN:
-		del_timer_sync(t);
+		del_timer_sync(&per_cpu(mce_timer, cpu));
 		smp_call_function_single(cpu, mce_disable_cpu, &action, 1);
 		break;
 	case CPU_DOWN_FAILED:
 	case CPU_DOWN_FAILED_FROZEN:
-		if (!mce_ignore_ce && check_interval) {
-			t->expires = round_jiffies(jiffies +
-					   __get_cpu_var(mce_next_interval));
-			add_timer_on(t, cpu);
-		}
+		mce_timer_add(cpu);
 		smp_call_function_single(cpu, mce_reenable_cpu, &action, 1);
 		break;
 	case CPU_POST_DEAD:
-- 
1.7.1



  parent reply	other threads:[~2011-06-17  8:43 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-17  8:37 [PATCH 0/8] x86, mce: misc fix/cleanups, cont Hidetoshi Seto
2011-06-17  8:40 ` [PATCH 1/8] x86, mce: stop calling del_timer_sync() from interrupt Hidetoshi Seto
2011-06-17 13:56   ` Borislav Petkov
2011-06-20  4:46     ` Hidetoshi Seto
2011-06-20  7:36       ` Borislav Petkov
2011-08-26 10:50   ` Borislav Petkov
2011-06-17  8:42 ` [PATCH 2/8] x86, mce: remove redundant mce_available() checks Hidetoshi Seto
2011-06-17 14:39   ` Borislav Petkov
2011-06-20  4:47     ` Hidetoshi Seto
2011-06-20  7:44       ` Borislav Petkov
2011-06-17  8:43 ` Hidetoshi Seto [this message]
2011-06-17 15:11   ` [PATCH 3/8] x86, mce: introduce mce_timer_add() Borislav Petkov
2011-06-17  8:44 ` [PATCH 4/8] x86, mce: rename bootparam parser Hidetoshi Seto
2011-06-17 15:41   ` Borislav Petkov
2011-06-17 22:25     ` Luck, Tony
2011-06-18  8:38       ` Borislav Petkov
2011-06-20  4:48         ` Hidetoshi Seto
2011-06-17  8:45 ` [PATCH 5/8] x86, mce: introduce mce_sysdev_init() Hidetoshi Seto
2011-06-17 16:32   ` Borislav Petkov
2011-06-20  4:48     ` Hidetoshi Seto
2011-06-17  8:46 ` [PATCH 6/8] x86, mce: introduce mce_memory_failure_process() Hidetoshi Seto
2011-06-17 16:59   ` Borislav Petkov
2011-06-17  8:49 ` [PATCH 7/8] x86, mce: rework use of TIF_MCE_NOTIFY Hidetoshi Seto
2011-06-17  8:50 ` [PATCH 8/8] x86, mce, edac: call edac_mce_parse() once per a record Hidetoshi Seto
2011-06-17 17:10   ` Borislav Petkov

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=4DFB139D.8060401@jp.fujitsu.com \
    --to=seto.hidetoshi@jp.fujitsu.com \
    --cc=bp@amd64.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=x86@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.