From: "Pallipadi, Venkatesh" <venkatesh.pallipadi@intel.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: "akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"mingo@elte.hu" <mingo@elte.hu>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"hpa@zytor.com" <hpa@zytor.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] [2/4] x86: MCE: Implement dynamic machine check banks support v5
Date: Thu, 12 Feb 2009 10:03:05 -0800 [thread overview]
Message-ID: <1234461785.4286.1918.camel@localhost.localdomain> (raw)
In-Reply-To: <20090212124321.8A98B3E666D@basil.firstfloor.org>
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@intel.com>
>
> Signed-off-by: Andi Kleen <ak@linux.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
next prev parent reply other threads:[~2009-02-12 18:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-12 12:43 [PATCH] [0/4] x86: MCE: Cleanups series Andi Kleen
2009-02-12 12:43 ` [PATCH] [1/4] x86: MCE: Enable machine checks in 64bit defconfig Andi Kleen
2009-02-12 12:43 ` [PATCH] [2/4] x86: MCE: Implement dynamic machine check banks support v5 Andi Kleen
2009-02-12 18:03 ` Pallipadi, Venkatesh [this message]
2009-02-12 21:25 ` Andi Kleen
2009-02-17 22:07 ` [PATCH] x86: MCE: Implement dynamic machine check banks support v6 Andi Kleen
2009-02-12 12:43 ` [PATCH] [3/4] x86: MCE: Factor out duplicated struct mce setup code into a single function Andi Kleen
2009-02-12 12:43 ` [PATCH] [4/4] x86: MCE: Separate correct machine check poller and fatal exception handler v2 Andi Kleen
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=1234461785.4286.1918.camel@localhost.localdomain \
--to=venkatesh.pallipadi@intel.com \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
/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.