From: Borislav Petkov <bp@alien8.de>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-kernel@vger.kernel.org, rt@linutronix.de,
Tony Luck <tony.luck@intel.com>,
linux-edac@vger.kernel.org, x86@kernel.org,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 21/25] x86/mcheck: Split threshold_cpu_callback into two callbacks
Date: Mon, 7 Nov 2016 14:20:40 +0100 [thread overview]
Message-ID: <20161107132040.w6oaoe2hu6hpdvy4@pd.tnic> (raw)
In-Reply-To: <20161103145021.28528-22-bigeasy@linutronix.de>
On Thu, Nov 03, 2016 at 03:50:17PM +0100, Sebastian Andrzej Siewior wrote:
> The threshold_cpu_callback callbacks looks like one of the notifier and
> its arguments are almost the same. Split this out and have one ONLINE
> and one DEAD callback. This will come handy later once the main code
> gets changed to use the callback mechanism.
> Also, handle threshold_cpu_callback_online() return value so we don't
> continue if the function fails.
>
> Cc: Tony Luck <tony.luck@intel.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: linux-edac@vger.kernel.org
> Cc: x86@kernel.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
> arch/x86/include/asm/mce.h | 3 ++-
> arch/x86/kernel/cpu/mcheck/mce.c | 18 +++++++++++++-----
> arch/x86/kernel/cpu/mcheck/mce_amd.c | 24 ++++--------------------
> 3 files changed, 19 insertions(+), 26 deletions(-)
...
> -void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu);
> +int (*threshold_cpu_callback_online)(unsigned int cpu);
> +int (*threshold_cpu_callback_dead)(unsigned int cpu);
Let's get rid of those pointers and pointer testing and export the
create/remove functions directly.
How's that? It builds here.
---
Index: b/arch/x86/include/asm/mce.h
===================================================================
--- a/arch/x86/include/asm/mce.h 2016-11-07 14:06:40.246518729 +0100
+++ b/arch/x86/include/asm/mce.h 2016-11-07 14:17:36.770529205 +0100
@@ -292,9 +292,9 @@ void do_machine_check(struct pt_regs *,
/*
* Threshold handler
*/
-
extern void (*mce_threshold_vector)(void);
-extern void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu);
+extern int mce_threshold_create_device(unsigned int cpu);
+extern int mce_threshold_remove_device(unsigned int cpu);
/* Deferred error interrupt handler */
extern void (*deferred_error_int_vector)(void);
Index: b/arch/x86/kernel/cpu/mcheck/mce.c
===================================================================
--- a/arch/x86/kernel/cpu/mcheck/mce.c 2016-11-07 14:06:40.246518729 +0100
+++ b/arch/x86/kernel/cpu/mcheck/mce.c 2016-11-07 14:17:06.186528717 +0100
@@ -2291,8 +2291,6 @@ static struct bus_type mce_subsys = {
DEFINE_PER_CPU(struct device *, mce_device);
-void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu);
-
static inline struct mce_bank *attr_to_bank(struct device_attribute *attr)
{
return container_of(attr, struct mce_bank, attr);
@@ -2548,13 +2546,17 @@ mce_cpu_callback(struct notifier_block *
switch (action & ~CPU_TASKS_FROZEN) {
case CPU_ONLINE:
+
mce_device_create(cpu);
- if (threshold_cpu_callback)
- threshold_cpu_callback(action, cpu);
+
+ if (mce_threshold_create_device(cpu)) {
+ mce_device_remove(cpu);
+ return NOTIFY_BAD;
+ }
+
break;
case CPU_DEAD:
- if (threshold_cpu_callback)
- threshold_cpu_callback(action, cpu);
+ mce_threshold_remove_device(cpu);
mce_device_remove(cpu);
mce_intel_hcpu_update(cpu);
Index: b/arch/x86/kernel/cpu/mcheck/mce_amd.c
===================================================================
--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c 2016-11-07 14:06:40.246518729 +0100
+++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c 2016-11-07 14:18:10.506529743 +0100
@@ -55,6 +55,8 @@
/* Threshold LVT offset is at MSR0xC0000410[15:12] */
#define SMCA_THR_LVT_OFF 0xF000
+static bool thresholding_en;
+
static const char * const th_names[] = {
"load_store",
"insn_fetch",
@@ -1097,10 +1099,13 @@ free_out:
per_cpu(threshold_banks, cpu)[bank] = NULL;
}
-static void threshold_remove_device(unsigned int cpu)
+int mce_threshold_remove_device(unsigned int cpu)
{
unsigned int bank;
+ if (!thresholding_en)
+ return 0;
+
for (bank = 0; bank < mca_cfg.banks; ++bank) {
if (!(per_cpu(bank_map, cpu) & (1 << bank)))
continue;
@@ -1108,15 +1113,19 @@ static void threshold_remove_device(unsi
}
kfree(per_cpu(threshold_banks, cpu));
per_cpu(threshold_banks, cpu) = NULL;
+ return 0;
}
/* create dir/files for all valid threshold banks */
-static int threshold_create_device(unsigned int cpu)
+int mce_threshold_create_device(unsigned int cpu)
{
unsigned int bank;
struct threshold_bank **bp;
int err = 0;
+ if (!thresholding_en)
+ return 0;
+
bp = per_cpu(threshold_banks, cpu);
if (bp)
return 0;
@@ -1136,40 +1145,23 @@ static int threshold_create_device(unsig
}
return err;
err:
- threshold_remove_device(cpu);
+ mce_threshold_remove_device(cpu);
return err;
}
-/* get notified when a cpu comes on/off */
-static void
-amd_64_threshold_cpu_callback(unsigned long action, unsigned int cpu)
-{
- switch (action) {
- case CPU_ONLINE:
- case CPU_ONLINE_FROZEN:
- threshold_create_device(cpu);
- break;
- case CPU_DEAD:
- case CPU_DEAD_FROZEN:
- threshold_remove_device(cpu);
- break;
- default:
- break;
- }
-}
-
static __init int threshold_init_device(void)
{
unsigned lcpu = 0;
/* to hit CPUs online before the notifier is up */
for_each_online_cpu(lcpu) {
- int err = threshold_create_device(lcpu);
+ int err = mce_threshold_create_device(lcpu);
if (err)
return err;
}
- threshold_cpu_callback = amd_64_threshold_cpu_callback;
+
+ thresholding_en = true;
return 0;
}
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
next prev parent reply other threads:[~2016-11-07 13:20 UTC|newest]
Thread overview: 99+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-03 14:49 cpu hotplug: convert more drivers (batch #4) Sebastian Andrzej Siewior
2016-11-03 14:49 ` [PATCH 01/25] fs/buffer: Convert to hotplug state machine Sebastian Andrzej Siewior
2016-11-09 22:52 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-11-10 16:24 ` [PATCH 01/25] " Al Viro
2016-11-10 16:31 ` Thomas Gleixner
2016-11-03 14:49 ` [PATCH 02/25] kernel/printk: " Sebastian Andrzej Siewior
2016-11-09 22:52 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-11-03 14:49 ` [PATCH 03/25] mm/memcg: " Sebastian Andrzej Siewior
2016-11-09 22:53 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-11-03 14:50 ` [PATCH 04/25] lib/percpu_counter: " Sebastian Andrzej Siewior
2016-11-09 22:53 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-11-03 14:50 ` [PATCH 05/25] lib/radix-tree: " Sebastian Andrzej Siewior
2016-11-09 22:54 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-11-03 14:50 ` [PATCH 06/25] mm/page_alloc: " Sebastian Andrzej Siewior
2016-11-09 22:54 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-11-03 14:50 ` [PATCH 07/25] mm/vmscan: " Sebastian Andrzej Siewior
2016-11-09 22:55 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-11-03 14:50 ` [PATCH 08/25] net/dev: " Sebastian Andrzej Siewior
2016-11-09 22:55 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-11-03 14:50 ` [PATCH 09/25] net/flowcache: " Sebastian Andrzej Siewior
2016-11-09 22:56 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-11-03 14:50 ` [PATCH 10/25] s390/smp: Make cpu notifier symetric Sebastian Andrzej Siewior
2016-11-04 14:22 ` Heiko Carstens
2016-11-04 14:41 ` [PATCH 10/25 v2] " Sebastian Andrzej Siewior
2016-11-09 22:56 ` [tip:smp/hotplug] " tip-bot for Thomas Gleixner
2016-11-03 14:50 ` [PATCH 11/25] s390/smp: Convert to hotplug state machine Sebastian Andrzej Siewior
2016-11-04 14:34 ` Heiko Carstens
2016-11-04 14:45 ` [PATCH 11/25 v2] " Sebastian Andrzej Siewior
2016-11-09 22:57 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-11-03 14:50 ` [PATCH 12/25] drivers base/cacheinfo: " Sebastian Andrzej Siewior
2016-11-09 22:57 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-11-03 14:50 ` [PATCH 13/25] drivers base/topology: " Sebastian Andrzej Siewior
2016-11-09 22:57 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-11-03 14:50 ` [PATCH 14/25] ia64/err-inject: " Sebastian Andrzej Siewior
2016-11-09 22:58 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-11-03 14:50 ` [PATCH 15/25] ia64/palinfo: " Sebastian Andrzej Siewior
2016-11-09 22:58 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-11-03 14:50 ` [PATCH 16/25] ia64/salinfo: " Sebastian Andrzej Siewior
2016-11-03 15:45 ` kbuild test robot
2016-11-03 17:31 ` [PATCH 16/25 v2] " Sebastian Andrzej Siewior
2016-11-09 22:59 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-11-03 16:22 ` [PATCH 16/25] " kbuild test robot
2016-11-03 14:50 ` [PATCH 17/25] ia64/topology: " Sebastian Andrzej Siewior
2016-11-03 15:53 ` kbuild test robot
2016-11-03 17:33 ` [PATCH 17/25 v2] " Sebastian Andrzej Siewior
2016-11-09 22:59 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-11-03 14:50 ` [PATCH 18/25] x86/mcheck: Move threshold_create_device() Sebastian Andrzej Siewior
2016-11-07 10:32 ` Borislav Petkov
2016-11-03 14:50 ` [PATCH 19/25] x86/mcheck: Explicit cleanup on failure in mce_amd Sebastian Andrzej Siewior
2016-11-03 14:50 ` [PATCH 20/25] x86/mcheck: Be prepared for a rollback back to the ONLINE state Sebastian Andrzej Siewior
2016-11-07 10:32 ` Borislav Petkov
2016-11-07 10:40 ` Sebastian Andrzej Siewior
2016-11-07 12:31 ` Borislav Petkov
2016-11-07 17:23 ` Sebastian Andrzej Siewior
2016-11-03 14:50 ` [PATCH 21/25] x86/mcheck: Split threshold_cpu_callback into two callbacks Sebastian Andrzej Siewior
2016-11-07 13:20 ` Borislav Petkov [this message]
2016-11-07 13:25 ` Sebastian Andrzej Siewior
2016-11-07 15:07 ` Borislav Petkov
2016-11-07 15:14 ` Sebastian Andrzej Siewior
2016-11-07 17:26 ` Sebastian Andrzej Siewior
2016-11-07 18:19 ` Borislav Petkov
2016-11-03 14:50 ` [PATCH 22/25] x86/mcheck: Do the init in one place Sebastian Andrzej Siewior
2016-11-07 18:45 ` Borislav Petkov
2016-11-07 18:55 ` Luck, Tony
2016-11-07 20:12 ` Borislav Petkov
2016-11-08 9:23 ` Borislav Petkov
2016-11-09 14:22 ` Sebastian Andrzej Siewior
2016-11-09 15:38 ` Borislav Petkov
2016-11-09 16:24 ` Sebastian Andrzej Siewior
2016-11-09 17:01 ` Borislav Petkov
2016-11-09 17:22 ` Sebastian Andrzej Siewior
2016-11-09 18:37 ` Luck, Tony
2016-11-10 9:00 ` Sebastian Andrzej Siewior
2016-11-10 9:18 ` Borislav Petkov
2016-11-10 17:44 ` x86/mcheck: convert to hotplug state engine, take #2 Sebastian Andrzej Siewior
2016-11-10 17:44 ` [PATCH 1/7] x86/mcheck: Move threshold_create_device() Sebastian Andrzej Siewior
2016-11-16 8:39 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-11-10 17:44 ` [PATCH 2/7] x86/mcheck: Explicit cleanup on failure in mce_amd Sebastian Andrzej Siewior
2016-11-16 8:40 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-11-10 17:44 ` [PATCH 3/7] x86/mcheck: Be prepared for a rollback back to the ONLINE state Sebastian Andrzej Siewior
2016-11-16 8:40 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-11-10 17:44 ` [PATCH 4/7] x86/mcheck: Split threshold_cpu_callback into two callbacks Sebastian Andrzej Siewior
2016-11-16 8:41 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-11-10 17:44 ` [PATCH 5/7] x86/mcheck: reorganize the hotplug callbacks Sebastian Andrzej Siewior
2016-11-11 18:44 ` Borislav Petkov
2016-11-11 19:36 ` Sebastian Andrzej Siewior
2016-11-11 19:57 ` Borislav Petkov
2016-11-14 10:47 ` [PATCH 5/7 v2] " Sebastian Andrzej Siewior
2016-11-16 8:41 ` [tip:smp/hotplug] x86/mcheck: Reorganize " tip-bot for Sebastian Andrzej Siewior
2016-11-10 17:44 ` [PATCH 6/7] x86/mcheck: Move CPU_ONLINE and CPU_DOWN_PREPARE to hotplug state machine Sebastian Andrzej Siewior
2016-11-16 8:42 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-11-10 17:44 ` [PATCH 7/7] x86/mcheck: Move CPU_DEAD " Sebastian Andrzej Siewior
2016-11-11 20:18 ` Borislav Petkov
2016-11-16 8:42 ` [tip:smp/hotplug] " tip-bot for Sebastian Andrzej Siewior
2016-11-10 10:22 ` [PATCH 22/25] x86/mcheck: Do the init in one place Thomas Gleixner
2016-11-10 10:27 ` Sebastian Andrzej Siewior
2016-11-03 14:50 ` [PATCH 23/25] x86/mcheck: Make CPU_DOWN_PREPARE the counter part of CPU_STARTING Sebastian Andrzej Siewior
2016-11-03 14:50 ` [PATCH 24/25] x86/mcheck: Move CPU_ONLINE to hotplug state machine Sebastian Andrzej Siewior
2016-11-03 14:50 ` [PATCH 25/25] x86/mcheck: Move CPU_DEAD " Sebastian Andrzej Siewior
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=20161107132040.w6oaoe2hu6hpdvy4@pd.tnic \
--to=bp@alien8.de \
--cc=bigeasy@linutronix.de \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rt@linutronix.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).