[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1234461785.4286.1918.camel@localhost.localdomain>
Date: Thu, 12 Feb 2009 10:03:05 -0800
From: "Pallipadi, Venkatesh" <venkatesh.pallipadi@...el.com>
To: Andi Kleen <andi@...stfloor.org>
Cc: "akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
"mingo@...e.hu" <mingo@...e.hu>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"hpa@...or.com" <hpa@...or.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] [2/4] x86: MCE: Implement dynamic machine check banks
support v5
On Thu, 2009-02-12 at 04:43 -0800, Andi Kleen wrote:
> Impact: cleanup; making code future proof; memory saving on small systems
>
> This patch replaces the hardcoded max number of machine check banks with
> dynamic allocation depending on what the CPU reports. The sysfs
> data structures and the banks array are dynamically allocated.
>
> There is still a hard bank limit (128) because the mcelog protocol uses
> banks >= 128 as pseudo banks to escape other events. But we expect
> that 128 banks is beyond any reasonable CPU for now.
>
> This supersedes an earlier patch by Venki, but it solves the problem
> more completely by making the limit fully dynamic (upto the 128 boundary)
>
> This saves some memory on machines with less than 6 banks because
> they won't need sysdevs for unused ones and also allows to
> use sysfs to control these banks on possible future CPUs with
> more than 6 banks.
>
> v2: Fix typo in initialization
> v3: Fold fix banks message fix into this one.
> v4: Fix cap init ordering
> v5: Forward port to new patch order
>
> Cc: Venki Pallipadi <venkatesh.pallipadi@...el.com>
>
> Signed-off-by: Andi Kleen <ak@...ux.intel.com>
>
> ---
> arch/x86/kernel/cpu/mcheck/mce_64.c | 139 +++++++++++++++++++++++++++---------
> 1 file changed, 107 insertions(+), 32 deletions(-)
>
> Index: linux/arch/x86/kernel/cpu/mcheck/mce_64.c
> ===================================================================
> --- linux.orig/arch/x86/kernel/cpu/mcheck/mce_64.c 2009-02-12 11:30:51.000000000 +0100
> +++ linux/arch/x86/kernel/cpu/mcheck/mce_64.c 2009-02-12 12:10:19.000000000 +0100
> @@ -24,6 +24,8 @@
> #include <linux/ctype.h>
> #include <linux/kmod.h>
> #include <linux/kdebug.h>
> +#include <linux/kobject.h>
> +#include <linux/sysfs.h>
> #include <asm/processor.h>
> #include <asm/msr.h>
> #include <asm/mce.h>
> @@ -32,7 +34,12 @@
> #include <asm/idle.h>
>
> #define MISC_MCELOG_MINOR 227
> -#define NR_SYSFS_BANKS 6
> +
> +/*
> + * To support more than 128 would need to escape the predefined
> + * Linux defined extended banks first.
> + */
> +#define MAX_NR_BANKS (MCE_EXTENDED_BANK - 1)
>
> atomic_t mce_entry;
>
> @@ -47,7 +54,7 @@
> */
> static int tolerant = 1;
> static int banks;
> -static unsigned long bank[NR_SYSFS_BANKS] = { [0 ... NR_SYSFS_BANKS-1] = ~0UL };
> +static u64 *bank;
> static unsigned long notify_user;
> static int rip_msr;
> static int mce_bootlog = -1;
> @@ -212,7 +219,7 @@
> barrier();
>
> for (i = 0; i < banks; i++) {
> - if (i < NR_SYSFS_BANKS && !bank[i])
> + if (!bank[i])
> continue;
>
> m.misc = 0;
> @@ -446,21 +453,36 @@
> /*
> * Initialize Machine Checks for a CPU.
> */
> -static void mce_init(void *dummy)
> +static void mce_cap_init(void)
> {
> u64 cap;
> - int i;
>
> rdmsrl(MSR_IA32_MCG_CAP, cap);
> - banks = cap & 0xff;
> - if (banks > MCE_EXTENDED_BANK) {
> - banks = MCE_EXTENDED_BANK;
> - printk(KERN_INFO "MCE: warning: using only %d banks\n",
> - MCE_EXTENDED_BANK);
> + /* Handle the unlikely case of one CPU having less banks than others */
> + if (banks == 0 || banks > (cap & 0xff))
> + banks = cap & 0xff;
Do we need a per cpu count of # of banks to handle one CPU having less
banks than others case?
Specifically, I am thinking of sequence:
- CPU 0 has n banks
- CPU 0 does below
for (i = 0; i < banks; i++) {
err = sysdev_create_file(&per_cpu(device_mce, cpu),
&bank_attrs[i]);
- CPU 1, which comes online later, has say n-2 banks. So, banks now becomes n-2.
- Now whenever CPU 0 does sysdev_remove_file loop below, it will do it only for n-2 banks.
Thanks,
Venki
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists