Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754198AbcCBRDR (ORCPT ); Wed, 2 Mar 2016 12:03:17 -0500 Received: from bh-25.webhostbox.net ([208.91.199.152]:32990 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751787AbcCBRDO (ORCPT ); Wed, 2 Mar 2016 12:03:14 -0500 Subject: Re: [v2 PATCH 1/3] panic: Change nmi_panic from macro to function To: Michal Hocko , Hidehiro Kawai References: <20160302103624.5058.35844.stgit@softrs> <20160302103626.5058.74361.stgit@softrs> <20160302131824.GH26686@dhcp22.suse.cz> Cc: Andrew Morton , Thomas Mingarelli , Wim Van Sebroeck , Corey Minyard , Javi Merino , linux-watchdog@vger.kernel.org, "Steven Rostedt (Red Hat)" , Rasmus Villemoes , linux-kernel@vger.kernel.org, Michal Nazarewicz , Vitaly Kuznetsov , HATAYAMA Daisuke , Borislav Petkov , Gobinda Charan Maji , Tejun Heo , Nicolas Iooss , openipmi-developer@lists.sourceforge.net, Borislav Petkov , Thomas Gleixner From: Guenter Roeck Message-ID: <56D71CCA.20809@roeck-us.net> Date: Wed, 2 Mar 2016 09:03:06 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20160302131824.GH26686@dhcp22.suse.cz> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated_sender: linux@roeck-us.net X-OutGoing-Spam-Status: No, score=0.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: linux@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: linux@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1187 Lines: 44 On 03/02/2016 05:18 AM, Michal Hocko wrote: > On Wed 02-03-16 19:36:26, Hidehiro Kawai wrote: > [...] >> +void nmi_panic(struct pt_regs *regs, const char *fmt, ...) > > Do we really need vargs? All the current users seem to be OK with a > simple string. This makes the code slightly more complicated without any > apparent reason. > >> +{ >> + static char buf[1024]; /* protected by panic_cpu */ I am also not too happy with this additional stack allocation. panic() itself takes varargs. Can those be passed on ? I understand this would need something like vpanic(), so maybe that isn't feasible. Dropping the format, at least for now, might be a simpler option. Guenter >> + va_list args; >> + int old_cpu, cpu; >> + >> + cpu = raw_smp_processor_id(); >> + old_cpu = atomic_cmpxchg(&panic_cpu, PANIC_CPU_INVALID, cpu); >> + >> + if (old_cpu == PANIC_CPU_INVALID) { >> + va_start(args, fmt); >> + vsnprintf(buf, sizeof(buf), fmt, args); >> + va_end(args); >> + >> + panic("%s", buf); >> + } else if (old_cpu != cpu) >> + nmi_panic_self_stop(regs); >> +} >> +EXPORT_SYMBOL(nmi_panic); >> + >> /** >> * panic - halt the system >> * @fmt: The text string to print >> >> >