From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752633AbcKGKdc (ORCPT ); Mon, 7 Nov 2016 05:33:32 -0500 Received: from mail.skyhub.de ([78.46.96.112]:56269 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751991AbcKGKda (ORCPT ); Mon, 7 Nov 2016 05:33:30 -0500 Date: Mon, 7 Nov 2016 11:32:19 +0100 From: Borislav Petkov To: Sebastian Andrzej Siewior Cc: linux-kernel@vger.kernel.org, rt@linutronix.de, Tony Luck , linux-edac@vger.kernel.org, x86@kernel.org, Thomas Gleixner Subject: Re: [PATCH 20/25] x86/mcheck: Be prepared for a rollback back to the ONLINE state Message-ID: <20161107103219.sm4otwhwptzckvzh@pd.tnic> References: <20161103145021.28528-1-bigeasy@linutronix.de> <20161103145021.28528-21-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20161103145021.28528-21-bigeasy@linutronix.de> User-Agent: NeoMutt/20161014 (1.7.1) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 03, 2016 at 03:50:16PM +0100, Sebastian Andrzej Siewior wrote: > If we try a CPU down and fail in the middle then we roll back to the > online state. This means we would perform CPU_ONLINE() > without invoking CPU_DEAD() for the cleanup of what was allocated in Are CPU_ONLINE() and CPU_DEAD() functions? Those are the states, right? > CPU_ONLINE. > Be prepared for this and don't allocate the struct if we have it > already. > > Cc: Tony Luck > Cc: Borislav Petkov > Cc: linux-edac@vger.kernel.org > Cc: x86@kernel.org > Signed-off-by: Sebastian Andrzej Siewior > Signed-off-by: Thomas Gleixner > --- > arch/x86/kernel/cpu/mcheck/mce.c | 4 ++++ > arch/x86/kernel/cpu/mcheck/mce_amd.c | 3 +++ > 2 files changed, 7 insertions(+) > > diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c > index a7fdf453d895..e9ffd6d9e32d 100644 > --- a/arch/x86/kernel/cpu/mcheck/mce.c > +++ b/arch/x86/kernel/cpu/mcheck/mce.c > @@ -2409,6 +2409,10 @@ static int mce_device_create(unsigned int cpu) > if (!mce_available(&boot_cpu_data)) > return -EIO; > > + dev = per_cpu(mce_device, cpu); > + if (dev) > + return 0; > + > dev = kzalloc(sizeof *dev, GFP_KERNEL); > if (!dev) > return -ENOMEM; > diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c > index 55cd018bc1ae..3e529fd747f8 100644 > --- a/arch/x86/kernel/cpu/mcheck/mce_amd.c > +++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c > @@ -1097,6 +1097,9 @@ static int threshold_create_device(unsigned int cpu) > struct threshold_bank **bp; > int err = 0; > > + bp = per_cpu(threshold_banks, cpu); > + if (bp) > + return 0; <--- newline here. > bp = kzalloc(sizeof(struct threshold_bank *) * mca_cfg.banks, > GFP_KERNEL); > if (!bp) > -- > 2.10.2 > > -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.